0

I am beginner in R programming. i am trying to read and CSV file for data analysis. I have 20 columns of data and i only need first 6 column for a chart. how to i select only first 11 columns and the the data in first row to plot in the chart? so the name of the data frame is data I tried this

sdata<-subset(data,STATE_OR_REGION & 1910_POPULATION & 1920_POPULATION & 1930_POPULATION & 1940_POPULATION & 1950_POPULATION & 1960_POPULATION & 1970_POPULATION & 1980_POPULATION & 1990_POPULATION & 2000_POPULATION & 2010_POPULATION)

these are the columns i want to include in the subset of the dataframe to plot in the graph

Bill Chen
  • 1,699
  • 14
  • 24

1 Answers1

0

I think this answer will show you what you want. The whole post shows a few different ways to do it but the linked response shows how to use the column names to subset.

So in your case if you want to use the column names:

sdata <- data[, c("STATE_OR_REGION","1910_POPULATION", . . . )]
mechengjoe
  • 23
  • 8