[R] Yearly hourly mean and NA
g||ted|||e2014 @end|ng |rom gm@||@com
Thu Jun 4 03:15:11 CEST 2020
Thank you so much for your time.
I tried your code. It successfully assigned NA to the zeros.
But the main code seems not to work with the NAs. The mean, for example,
resulted in NA. I am attaching the data for a period of one year and the
code which I use in plotting the data. Maybe it might be easier for you to
spot where I run into error (my plot was just empty).
On Wed, Jun 3, 2020 at 8:47 PM Jeff Newmiller <jdnewmil using dcn.davis.ca.us>
> df[[ 5 ]][ 0 == df[[ 5 ]] ] <- NA
> On June 3, 2020 1:59:06 AM PDT, Ogbos Okike <giftedlife2014 using gmail.com>
> >Dear R-Experts,
> >I have a cosmic ray data that span several years. The data frame is of
> >03 01 01 00 3809
> >03 01 01 01 3771
> >03 01 01 02 3743
> >03 01 01 03 3747
> >03 01 01 04 3737
> >03 01 01 05 3751
> >03 01 01 06 3733
> >03 01 01 07 3732.
> >where the columns 1 to 5 stand for year, month, day, hour and counts.
> >Some hours when the station does not have data are assigned zero,
> >there could be several zeros in column 5. Since my aim is to plot the
> >hourly mean for all the years, I started learning with one year - year
> >I carefully went through the data, removing any day that contains zero
> >any of the hours. Instead of the 365 days in the year 2003, I ended up
> >with 362 days.
> >I saved that as CLMX1C (now stored in Ogbos2 with dput function, see
> >attached please).
> >If I run the data with my script, it gives me what I am expecting. My
> >script is:
> > oodf<-data.frame(A,B)
> > oodf<-data.frame(A,B)
> >std.error<-function(x) return(sd(x)/(sum(!is.na(x))))
> > xlab="Hours",ylab="CR count",main="CR daily variation for 2004")
> >Now, instead of foraging through the big data removing the day for
> >there is a missing data for any hour, I wish to try to replace the
> >data with NA and hoping that it will do the job for me.
> >I added just three lines in the script above:
> >df<-data.frame(y)#line 1
> >library('dplyr') # line 2
> >y<-na_if(df, 0) #line 3
> >Then I started getting error messages:
> >Error in is.data.frame(x) :
> > (list) object cannot be coerced to type 'double'
> >In addition: There were 26 warnings (use warnings() to see them).
> >I hope you will assist me to deal with the issues of replacing zeros
> >NA in column 5 in such a way that my code will run.
> >Iam ever indebted!!
> >Best regards
> >R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >PLEASE do read the posting guide
> >and provide commented, minimal, self-contained, reproducible code.
> Sent from my phone. Please excuse my brevity.
More information about the R-help