[R] Length of data.frame column
rkevinburton at charter.net
rkevinburton at charter.net
Fri Aug 8 23:18:38 CEST 2008
I have a beginner question. After I finally get the data to a data.frame that I can work with I have the following a data frame that is fairly long:
> length(r2007)
[1] 17409
If I look at the first element:
> r2007[1]
$`100009`
DayOfYear Quantity
1 66 1
2 128 1
3 137 1
4 193 1
Now how do I get the length of this list (actually it is another data.frame)?
I have tried:
> length(r2007[1])
[1] 1
Not right. And:
> length(r2007[1]$DayOfYear)
[1] 0
Also not right the length returned should be 4 from the output above. I want to use this to iterate through the object. So in the outer loop I would have:
for(i in 1:length(r2007))
{
. . . .
}
I need to form an inner loop and an expression that returns each row (as above).
Any ideas?
Thank you.
Kevin
More information about the R-help
mailing list