Hello,

I've seen your reply to arun's reply and gave it a try.
Since arun's code included more than one column, I've added another in one of the examples.

# Example 1
dattrial1 <- data.frame(a=c(1,NA,rnorm(4,10)), Week=c(3,3,3,4,4,4))

d1 <- split(dattrial1, dattrial1$Week)
count <- sapply(d1, function(x) sum(!is.na(x$a)))
count


# Example 2
dattrial2 <- data.frame(a=c(1,NA,rnorm(4,10)), b=c(1,2,NA,3,4,6), Week=c(3,3,3,4,4,4))

d2 <- split(dattrial2, dattrial2$Week)
count <- sapply(d2, function(x){
                yes <- apply(x, 1, function(y) all(!is.na(y)))
                sum(yes)
        })
count


# Works for both examples
plot(names(count), count, type="b", col="red", pch=16)


Hope this helps,

Rui Barradas

Em 16-06-2012 21:11, Tagmarie escreveu:
Hello,
I'm quite new to R and still spend hours trying to figure out single things
so I hope nobody rolls his eyes over my question.

I have a data set over time and converted it to the POSTIXct format. I added
a column in the data set for the week and the month.

I try to get a plot which shows the weeks on the x-axis and the number of
datasets without NAs on the y-axis. That doesn't sound too difficult but I
can't figure it out.

Does anybody have an idea?

--
View this message in context: 
http://r.789695.n4.nabble.com/count-data-without-NA-in-certain-time-intervals-and-plot-it-tp4633611.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.


______________________________________________
R-help@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.

Reply via email to