[R] Count of rows while looping through data
Jeanna
stroutj at uw.edu
Tue May 24 21:08:07 CEST 2011
I have a data table with one column that indicates families, and subsequent
columns with other characteristics. I want to randomize one member of the
family to a separate table. My approach is to count the number of members,
set up a random number generator, and assign the family member based on
where they fall within the random number spectrum.
Is there a way to count the number of family members as I loop through the
whole table?
Something like this:
for (j in 1:15){
if (x$family[j] == x$family[j+1]){
count = count +1
(which doesn't work)
as I do the larger:
for (i in 2:nrow(x.tab)){
--
View this message in context: http://r.789695.n4.nabble.com/Count-of-rows-while-looping-through-data-tp3547949p3547949.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list