An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20080709/b1313a14/attachment.pl>
use variable value as vector name
2 messages · Qian R, Erik Iverson
a <- "apple" b <- "pear" c <- "banana" result <- c(2, 3, 5) names(result) <- c(a, b, c)
Qian R wrote:
Here is my problem
a <- data$name[1]
b <- data$name[2]
c <- data$name[3]
a
"apple"
b
"pear"
c
"banana"
result <- c( a = 2 , b=3, c=5)
output:
a b c
2 3 5
But I want my output
apple pear banana
2 3 5
[[alternative HTML version deleted]]
------------------------------------------------------------------------
______________________________________________ R-help at 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.