I wanted to assign consecutive numbers to segments of my data.frame. I tried like so:
library(plyr)
ex1 <- mtcars
ehh <- ddply(.data=ex1, .variables=c("cyl"), transform, brx_j = c(1:nrow(cyl)))
But it's an "Error in data.frame(list(mpg = c(22.8, 24.4, 22.8, 32.4, 30.4, 33.9, 21.5, : arguments imply differing number of rows: 11, 0".
What's my mistake here?