-1

Here i need to make a chart using R-Script and i am using a Data frame called DF.

a<-c("01-01-2013 12:00:00 AM","01-02-2013 12:00:00 AM",
     "01-03-2013 12:00:00 AM","01-04-2013 12:00:00 AM",
     "01-05-2013 12:00:00 AM")
b<-c(1,2,3,4,5)
c<-c(11,12,13,14,15)
d<-c(101,102,103,104,105)
e<-c(50,55,34,30,45)
DF<-data.frame(DATETIME=a,DWATT=b,TNH=c,CSGV=d,CIV=e)

Requirement is, need a bar-chart using R-SCRIPT to indicate the counting for a particular DATETIME for all the four tags (DWATT,TNH,CSGV,CIV). And it should repeat for each DATETIME.

Here, x-axis should come as DATETIME and Y-axis should be for count. Chart should show the counting of each tags (DWATT,TNH,CSGV,CIV) for each timing.

4

2 回答 2

1

你可以从这个开始:

barplot(t(as.matrix(DF[,2:5])), beside=F, names.arg=as.Date(DF[,1], "%d-%m-%Y"))

或这个:

barplot(t(as.matrix(DF[,2:5])), beside=T, names.arg=as.Date(DF[,1], "%d-%m-%Y"))
于 2013-09-08T22:12:43.383 回答
0
install.packages("plotly")
library(plotly)
plot_ly(data = DF,x  = as.Date(DF$DATETIME,"%d-%m-%Y"),y = ~DWATT,type = "bar",name = "DWatt")%>%
add_trace(data = DF,x  = as.Date(DF$DATETIME,"%d-%m-%Y"),y = ~TNH,type = "bar",name = "TNH")%>%
 add_trace(data = DF,x  = as.Date(DF$DATETIME,"%d-%m-%Y"),y = ~CSGV,type = "bar",name = "CSGV")%>%
add_trace(data = DF,x  = as.Date(DF$DATETIME,"%d-%m-%Y"),y = ~CIV,type = "bar",name = "CIV")

如果您想要互动,请使用它:)

于 2018-12-20T13:26:28.977 回答