Hi all, I have this (non-working) script:
dataTest <- data.frame(col1=c(1,2,3)) new.data <- c(1,2) name <- "test" n.row <- dim(dataTest)[1] length(new.data) <- n.row names(new.data) <- name cbind(dataTest, name=new.data) print(dataTest) and would like to bind the new column 'new.data' to 'dataTest' by using the value of the variable 'name' as the column name. The end result should look like this: col1 test 1 1 1 2 2 2 3 3 NA The best I got was that 'name' became the column name but never the actual value of 'name'. How can i do that? (This is actually a function that runs many time -- this means a manual workaround is not feasible). Ralf ______________________________________________ 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.