[R] Creating a sequence of variables in a data frame
spencer.graves at pdf.com
Mon Mar 10 16:31:34 CET 2003
> data1 <- data.frame(old=1:2)
> data1$old2 <- 3:4
1 1 3
2 2 4
Ryan T. Moore wrote:
> Two questions:
> 1. I have a data frame named "data1" that includes the variable "old". I want to create a sequence of new variables in the data frame called "old.1", "old.2", ... . I've tried a few "paste" commands, and creating a new data frame of the new variables, all to no avail. Any advice?
> 2. If I have a variable in a data frame, is there quick bit of code that creates a dummy variable for each level of that variable?
> Thank you,
> Ryan Moore
> [[alternate HTML version deleted]]
> R-help at stat.math.ethz.ch mailing list
More information about the R-help