I have a csv file with daily streamflow. I need to combine the daily values into monthly. I am trying to use the "daily2monthly" function of "hydroTSM" package. sample data from the BRPT2.csv:
_date,_time,_value,_flag
10/2/1959,0:00:00,0,2
10/3/1959,0:00:00,0,2
10/4/1959,0:00:00,1540,2
10/5/1959,0:00:00,16100,2
10/6/1959,0:00:00,6680,2
10/7/1959,0:00:00,3100,2
10/8/1959,0:00:00,2060,2
I used the following commands:
qme<- read.csv(file = "BRPT2.csv",header = T,sep = ",") #read in csv file
date<- as.Date(qme$X_date,format("%Y-%m-%d")) #convert date column to date format from factor
flow<- qme[,3]
flow_2<-replace(flow,flow==-999,0) #replace the missing values (-999) with 0
df<- data.frame()
df<- rbind(df,data.frame(date,flow_2,stringsAsFactors = FALSE))
daily2monthly(df,FUN=sum,dates=1)
And it gives the following error message:
Error in
rownames<-
(*tmp*
, value = c("Oct-1959", "Nov-1959", "Dec-1959", : attempt to set 'rownames' on an object with no dimensions
Could someone help me regarding this. Thanks in advance.
Try converting your
df
into azoo
object first:The
data.frame
method fordaily2monthly
only works if you have more than one column of data; in your case, you only have one, which is why the function returns that error message. Let's say we had one more column of data: