I am new to R but a bit familiar with Stata and SPSS and a software dev. As I understand it right, there is no possibility to give variables or values a lable. Is that right? Just for example. "x" need a name. And the four values (1, 2, 3, 4) need it to. [code]> table(x)1 2 3 4 17 6 6 2 [/code] I understand that R itself is powerful and well developed. So I try to understand why it doesn't support labels. And in the next step I try to understand how do you work with your data and publish (e.g. with *TeX) it without using labels? R can put out *TeX-code, right? I don't want to modify the outputted code manually. It would waste my time and decreases my efficiency.
It looks like a terminology issue. R has names for elements of a vector and for rows and columns of a matrix or data.frame, and more generally for all dimensions of multi-dimensional array. I think your next step is to read the introductory document. Start with either of these (they are the same content) system.file("../../doc/manual/R-intro.html") system.file("../../doc/manual/R-intro.pdf") For the specific situations you described, here are examples. aa <- 1:5 names(aa) <- letters[1:5] aa names(aa) <- c("ABC","DEF","GHI","LMN","OPQ") aa bb <- matrix(1:12, 3, 4, dimnames=list(letters[1:3], LETTERS[1:4])) bb ## install.packages("Hmisc") ## if you don't have it yet library(Hmisc) latex(bb) Rich On Sat, Oct 11, 2014 at 1:17 PM, <moonkid at posteo.org> wrote:> I am new to R but a bit familiar with Stata and SPSS and a software dev. > > As I understand it right, there is no possibility to give variables or > values a lable. Is that right? > > Just for example. "x" need a name. And the four values (1, 2, 3, 4) > need it to. > > [code] >> table(x) > > 1 2 3 4 > 17 6 6 2 > [/code] > > I understand that R itself is powerful and well developed. So I try to > understand why it doesn't support labels. > > And in the next step I try to understand how do you work with your data > and publish (e.g. with *TeX) it without using labels? R can put out > *TeX-code, right? I don't want to modify the outputted code manually. It > would waste my time and decreases my efficiency. > > ______________________________________________ > 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.
No, you are wrong. Read the docs! -- start with "An Introduction to R" which ships with R. Please do not post further until after you have done your homework. x <- c(a=1,b=2,c=3) See also ?names. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." Clifford Stoll On Sat, Oct 11, 2014 at 10:17 AM, <moonkid at posteo.org> wrote:> I am new to R but a bit familiar with Stata and SPSS and a software dev. > > As I understand it right, there is no possibility to give variables or > values a lable. Is that right? > > Just for example. "x" need a name. And the four values (1, 2, 3, 4) > need it to. > > [code] >> table(x) > > 1 2 3 4 > 17 6 6 2 > [/code] > > I understand that R itself is powerful and well developed. So I try to > understand why it doesn't support labels. > > And in the next step I try to understand how do you work with your data > and publish (e.g. with *TeX) it without using labels? R can put out > *TeX-code, right? I don't want to modify the outputted code manually. It > would waste my time and decreases my efficiency. > > ______________________________________________ > 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.
You can use 'factors' to assign labels to small integer values. E.g., > x <- c(1,2,3,4,3) > fx <- factor(x, levels=1:5, labels=c("One","Two","Three","Four","Five")) > table(fx) fx One Two Three Four Five 1 1 2 1 0 Bill Dunlap TIBCO Software wdunlap tibco.com On Sat, Oct 11, 2014 at 10:17 AM, <moonkid at posteo.org> wrote:> I am new to R but a bit familiar with Stata and SPSS and a software dev. > > As I understand it right, there is no possibility to give variables or > values a lable. Is that right? > > Just for example. "x" need a name. And the four values (1, 2, 3, 4) > need it to. > > [code] >> table(x) > > 1 2 3 4 > 17 6 6 2 > [/code] > > I understand that R itself is powerful and well developed. So I try to > understand why it doesn't support labels. > > And in the next step I try to understand how do you work with your data > and publish (e.g. with *TeX) it without using labels? R can put out > *TeX-code, right? I don't want to modify the outputted code manually. It > would waste my time and decreases my efficiency. > > ______________________________________________ > 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.