Tuesday, February 23, 2016

In R quickly remove column from data matrix

In R if you want to remove quickly one column you can assign NULL to it.




> data
                                 V2       V3                   V4
Alzheimers_disease          1.92308 36.03875                Other
Asthma                      5.08475 56.58559                Other
Bipolar_disorder            1.91693 48.52667                Brain
Blood_pressure              6.25000 63.01744                Other
BMI                         1.06383 11.44664                Other
Body_mass_index             4.34783 66.66428                Other

data$V4 <- NULL
> data
                                 V2       V3
Alzheimers_disease          1.92308 36.03875
Asthma                      5.08475 56.58559
Bipolar_disorder            1.91693 48.52667
Blood_pressure              6.25000 63.01744
BMI                         1.06383 11.44664
Body_mass_index             4.34783 66.66428

No comments:

Post a Comment