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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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
>
> ______________________________________________
> [EMAIL PROTECTED] 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

______________________________________________
[EMAIL PROTECTED] 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

Reply via email to