I am trying to compute the occurrence of a line in a dataframe, but I don’t get the result expected.
ps: generaldf is a data.frame, and userid is a column of integer
y<-0
for(i in seq_len(nrow(generaldf)))
{
if (generaldf$userid==1)
y <-y+1
}
return(y)
useridis equal to 1?sum(generaldf$userid == 1)will do that without aforloop