[R] count data without NA in certain time intervals and plot it
arun
smartpink111 at yahoo.com
Sun Jun 17 22:35:54 CEST 2012
Hi,
Sorry, I didn't understand your question in the first post. I saw Rui's reply and your reply that it is solved.
I have another solution if it helps you.
dattrial<-data.frame(a=c(1,NA,rnorm(4,10)), Week=c(3,3,3,4,4,4))
dattrial_wk3<-subset(dattrial,Week==3)
dattrial_wk4<-subset(dattrial,Week==4)
count1<-colSums(!is.na(dattrial_wk3))
count2<-colSums(!is.na(dattrial_wk4))
dattrialnew<-data.frame(rbind(count1[1],count2[2]),Week=(rle(dattrial$Week)$values))
plot(dattrialnew$Week,dattrialnew$a,type="l",col="blue",pch=14,xlab="Week",ylab="Count")
A.K.
----- Original Message -----
From: Tagmarie <Ramgad82 at gmx.net>
To: r-help at r-project.org
Cc:
Sent: Sunday, June 17, 2012 5:40 AM
Subject: Re: [R] count data without NA in certain time intervals and plot it
Thank you Arun for your time!
Your idea is maybe only the first step to what I want but it was
nevertheless a new tool for me and interessing to learn.
I added a "week"-column to your data set:
dattrial<-data.frame(a=c(1,NA,rnorm(4,10)), Week=c(3,3,3,4,4,4))
I am looking for a way to count the number of rows for each week which do
contain data (without NA).
In the next step I want to create a graph which shows the week on the x-axis
and the counted number of data for each week on the y-axis.
Thank you!
--
View this message in context: http://r.789695.n4.nabble.com/count-data-without-NA-in-certain-time-intervals-and-plot-it-tp4633611p4633635.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list