# read data as
#
# create
# append POSIX time stamp.
bp.xts <- xts(bp[,c(-1,-2)],as.POSIXct(paste(bp$Date,bp$Time,sep=" ")))
# calculate weekly mean except the
#
#
plot(merge(bp.xts,cbind(rep(85,length(bp.xts[,1])),rep(130,length(bp.xts[,1])))),col = c("red", "blue","green","green"),lwd=c(3,3,2,2),major.ticks='days',grid.ticks.on='days')
# or exclude the data $High is <= 100
plot(merge(bp.xts[,-3][bp.xts$High > 101],cbind(rep(85,length(bp.xts[,1][bp.xts$High > 101])),rep(130,length(bp.xts[,1][bp.xts$High > 101])))),col = c("red", "blue","green","green"),lwd=c(3,3,2,2),major.ticks='days',grid.ticks.on='days')
plot(xts(bp[,c(-1,-2,-5)],as.POSIXct(paste(bp$Date,bp$Time,sep=" "))))
# calculate 4 days moving average
plot(last(index(xts(bp[,c(-1,-2,-5)],as.POSIXct(paste(bp$Date,bp$Time,sep=" ")))),n=length(na.omit(filter(bp$High,rep(1,4))/4))),na.omit(filter(bp$High,rep(1,4))/4),type='l')
#
plot(last(index(xts(bp[,c(-1,-2,-5)],as.POSIXct(paste(bp$Date,bp$Time,sep=" ")))),n=length(na.omit(filter(bp$High,rep(1,7))/7))),na.omit(filter(bp$High,rep(1,7))/7),type='l')
# exclude the data whose High is more than 150 and less than 101 and calculate
# mean value.
# 1) draw High and Low by red and blue each
# 2) define
# 3) draw an additional line at 130
# 4) set x
# 6) and add grid frequency to "days"
plot(merge(bp.xts,cbind(rep(85,length(bp.xts[,1])),rep(130,length(bp.xts[,1])))),col = c("red", "blue","green","green"),lwd=c(3,3,2,2),major.ticks='days',grid.ticks.on='days')
0 件のコメント:
コメントを投稿