[R] Accessing data
Dimitris Rizopoulos
dimitris.rizopoulos at med.kuleuven.ac.be
Mon May 17 10:56:27 CEST 2004
Dear Matthias,
you could try something like:
x <- matrix(rnorm(30*6), 30, 6)
colnames(x) <- c("Besch", "Ang.m", "Arb.m", "i10", "Umsatz", "arbstd")
your.choice <- "Besch"
x[,match(your.choice, colnames(x))]
x[,-match(your.choice, colnames(x))]
I hope this helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Doctoral Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/396887
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
----- Original Message -----
From: "TEMPL Matthias" <Matthias.Templ at statistik.gv.at>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, May 17, 2004 10:46 AM
Subject: [R] Accessing data
> Hello,
>
> I would like to access my data frame without one variable.
>
> E.g.:
> > colnames(x)
> [1] "Besch" "Ang.m" "Arb.m" "i10" "Umsatz" "arbstd"
>
> I can try x[,-1], but this variable must be called by it´s name.
>
> x[,-"Besch"]
> x[,!"Besch"]
> attach(x)
> x[-Besch]
> ...
> ...
> does not work.
>
>
> I could not found a solution of this little problem in any scripts
about R and in google.
>
> Should I type in x[,c("Ang.m","Arb.m","i10","Umsatz","arbstd")] to
access my data frame without variable "Besch", or is there any better
solution.
>
> Some of my data frames has ~100 variables and so is x[,c(...)] a
little bit exhausting.
>
> Thanks for any help,
>
> Matthias
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list