2

I have to extract two columns from this data set (Cars93 on MASS) and create a separate folder consisting only of the two columns MPG.highway and EngineSize. How do I go about doing this?

You can look at Cars93 on Mass and just get the first ten rows to see it.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Alyse W
  • 21
  • 1
  • 1
  • 2

1 Answers1

5

You can create a subset using the names directly using the subset function or alternately,

new_df <- Cars93[,c("MPG.highway","EngineSize")]
#or
new_df <- subset(Cars93, keep = c("MPG.highway","EngineSize"))
SmitM
  • 1,366
  • 1
  • 8
  • 14