thanks in advance for your time on reading and answering this. I have a data frame (15264*3) the head of which is:
head(actData)
steps date interval
289 0 2012-10-02 0
290 0 2012-10-02 5
291 0 2012-10-02 10
292 0 2012-10-02 15
293 0 2012-10-02 20
294 0 2012-10-02 25
There are 53 of the "date" variable (factor); I want to split the data based on date, calculate the mean of the steps/date and then create a plot for interval vs. steps' mean; What I have done:
mn<- ddply(actData, c("date"), function (x) apply(x[1], 2, mean)) # to calculate mean of steps per day (with the length of 53)
splt<- split(actData, actData$date) # split the data based on date (it should divide the data into 53 parts)
Now I have two variables with the same length (53); but when I try plotting them, I get an error for the difference in their length:
plot(splt$interval, mn[,2], type="l")
Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ
when I check the length of splt$interval, it gives me "0"! I've also visited here "How to split a data frame by rows, and then process the blocks?", "Split data based on column values and create scatter plot." and so on... with a lot of good suggestions but none of them addresses my questions! Sorry if my question is a little stupid, I am not an expert in R :)
I am using windows 7, Rstudio 3.0.1. Thanks.
EDIT:
head(splt, 2)
$`2012-10-01`
[1] steps date interval
<0 rows> (or 0-length row.names)
$`2012-10-02`
steps date interval
289 0 2012-10-02 0
290 0 2012-10-02 5
291 0 2012-10-02 10
292 0 2012-10-02 15
head(mn)
date steps
1 2012-10-02 0.43750
2 2012-10-03 39.41667
3 2012-10-04 42.06944
4 2012-10-05 46.15972
5 2012-10-06 53.54167
6 2012-10-07 38.24653