Can somebody remember me which is the command to erase columns from a data frame? Thanks Michele ___________________________________ http://it.seriea.fantasysports.yahoo.com/
Hi,
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of michele lux
Sent: Dienstag, 14. September 2004 10:44
To: r-help at r-project.org
Subject: [R] erase columns
Can somebody remember me which is the command to erase
columns from a data frame?
Thanks Michele
I hope the following code-piece helps what you are looking for:
mydf <- as.data.frame(matrix(runif(100),ncol=5))
### if you want to erase the third column, do:
mydf <- mydf[,-3]
mydf2 <- as.data.frame(matrix(runif(100),ncol=20))
### if you want to erase the first, third and twentieth column, do:
mydf2 <- mydf2[,-c(1,5,20)]
Ciao,
Roland
+++++
This mail has been sent through the MPI for Demographic Rese...{{dropped}}
?subset /E *********** REPLY SEPARATOR *********** On 9/14/2004 at 10:44 AM michele lux wrote:>>>Can somebody remember me which is the command to erase >>>columns from a data frame? >>>Thanks Michele >>> >>> >>> >>>___________________________________ >>> >>>http://it.seriea.fantasysports.yahoo.com/ >>> >>>______________________________________________ >>>R-help at stat.math.ethz.ch mailing list >>>https://stat.ethz.ch/mailman/listinfo/r-help >>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlDipl. bio-chem. Witold Eryk Wolski @ MPI-Moleculare Genetic Ihnestrasse 63-73 14195 Berlin 'v' tel: 0049-30-83875219 / \ mail: witek96 at users.sourceforge.net ---W-W---- http://www.molgen.mpg.de/~wolski wolski at molgen.mpg.de
michele lux <nedluk <at> yahoo.it> writes:> Can somebody remember me which is the command to erase > columns from a data frame?To delete a single column assign NULL to it. That works because a data frame is a list and that works for lists. Here are three examples of deleting column 5, the Species column, from the iris data set: data(iris) iris[,5] <- NULL data(iris) iris$Species <- NULL data(iris) iris[,"Species"] <- NULL
Possibly Parallel Threads
- "diff"^-1
- Density Estimation
- Populate one data frame with values from another dataframe for rows that match
- Populate one data frame with values from another dataframe for rows that match
- Populate one data frame with values from another dataframe for rows that match