mydata = read.csv("table.csv"); datanames = names(mydata); print(datanames); print("Number of data rows"); print(length(mydata$Date)) print("High price was .., on:"); print(max(mydata$High)) ind = which.max(mydata$High) print(mydata$Date[ind]) print("Low price was .., on:"); print(min(mydata$Low)) ind = which.min(mydata$Low) print(mydata$Date[ind]) daily_spread = mydata$High - mydata$Low; print("Highest spread was .., on:"); print(max(daily_spread)) ind = which.max(daily_spread) print(mydata$Date[ind]) print("Lowest spread was .., on:"); print(min(daily_spread)) ind = which.min(daily_spread) print(mydata$Date[ind]) # the reason there is less than 365 is because stock market # doesn't open weekends and holidays plot(mydata$High,xlab="date index",ylab="price in dollars") title(main="Daily high prices of SCTY", col.main="red") dev.copy(jpeg,'highs1.jpg') dev.off() plot(mydata$Low,xlab="date index",ylab="price in dollars") title(main="Daily low prices of SCTY", col.main="red") dev.copy(jpeg,'lows1.jpg') dev.off() barplot(mydata$High,xlab="date index",ylab="price in dollars") title(main="Daily high prices of SCTY", col.main="red") dev.copy(jpeg,'highs2.jpg') dev.off() barplot(mydata$Low,xlab="date index",ylab="price in dollars") title(main="Daily low prices of SCTY", col.main="red") dev.copy(jpeg,'lows2.jpg') dev.off() hist(mydata$High,xlab="price in dollars",ylab="frequency", main="Distribution of high prices of SCTY", col.main="red") dev.copy(jpeg,'highs3.jpg') dev.off() hist(mydata$Low,xlab="price in dollars",ylab="frequency", main="Distribution of low prices of SCTY", col.main="red") dev.copy(jpeg,'lows3.jpg') dev.off() barplot(daily_spread,xlab="date index",ylab="spread in dollars") title(main="Daily price spread of SCTY", col.main="red") dev.copy(jpeg,'spread1.jpg') dev.off() # Stacked Bar Plot #counts <- table(mydata$Low, mydata$High) #barplot(counts, main="High and Low daily prices", # xlab="Date index", col=c("darkblue","red"), beside=TRUE);