[R] Indexing dataframe
I am sorry to ask such question, but I can't find a solution... I have a dataframe 'd2004' and I want to remove two columns: 'd2004$concentration' and 'd2004$stade. I could do it just as follows: names(d2004) [1] Localite Date parcelle maille presence.plant concentration stade.culture [8] stade Trou HorizonProfondeur d2004 - d2004[, -c(6, 8)] but I'd like to use column names (to avoid finding column numbers each time). I cannot find an easy way to operate... I wonder why that works: d2004[, concentration] and this don't: d2004 - d2004[, -c(concentration, stade)] Thanks... Jacques VESLOT / CIRAD __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Indexing dataframe
Jacques VESLOT wrote: I am sorry to ask such question, but I can't find a solution... I have a dataframe 'd2004' and I want to remove two columns: 'd2004$concentration' and 'd2004$stade. d2004$concentration - NULL d2004$stade - NULL Hope it helps! Thomas P. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
AW: [R] Indexing dataframe
Hi, Use Newdata - subset(d2004, select=-c(concentration,stade)) See ?subset for details Best, Matthias -Ursprüngliche Nachricht- Von: Jacques VESLOT [mailto:[EMAIL PROTECTED] Gesendet: Donnerstag, 09. September 2004 12:38 An: [EMAIL PROTECTED] Betreff: [R] Indexing dataframe I am sorry to ask such question, but I can't find a solution... I have a dataframe 'd2004' and I want to remove two columns: 'd2004$concentration' and 'd2004$stade. I could do it just as follows: names(d2004) [1] Localite Date parcelle maille presence.plant concentration stade.culture [8] stade Trou HorizonProfondeur d2004 - d2004[, -c(6, 8)] but I'd like to use column names (to avoid finding column numbers each time). I cannot find an easy way to operate... I wonder why that works: d2004[, concentration] and this don't: d2004 - d2004[, -c(concentration, stade)] Thanks... Jacques VESLOT / CIRAD __ [EMAIL PROTECTED] mailing list https://stat.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://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html