It seems that an vector or other non elemental data type can not be assigned to an element in the data.frame. I'm wondering what is the walk around.
> li=data.frame(a=c(0,1), b=c('x','y')) > li$b[[1]]= 'x' > li$b[[2]]<- c('y','z') Error in li$b[[2]] <- c("y", "z") : more elements supplied than there are to replace Execution halted In the following example, I want the number 1 maps to 'x', but I want the number 2 maps to 'y' and 'z'. I could use the following code. But there is a redundancy in the data.frame (the number 1 appears twice). I'm wondering what is the best solution to this problem. li=data.frame(a=c(0,1,1), b=c('x','y','z')) ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.