Removing columns from data frame referenced by column index

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Removing columns from data frame referenced by column index

suman dhara
Can you suggest me any way to remove a column of a data frame by the column
number,not by the column name.

Thanks,
Suman Dhara

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Removing columns from data frame referenced by column index

sayan dasgupta
data(airquality)
head(airquality)
Suppose you want to remove the 1st and the 3rd column this will do
 airquality[,-c(1,3)]


suman dhara wrote
Can you suggest me any way to remove a column of a data frame by the column
number,not by the column name.

Thanks,
Suman Dhara

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.