Skipping specific rows and columns in R
Andrew Mclaughlin
I skipped second row of the data using this command:
Df=(read.csv(“IMDB_data.csv”, header=T, sep=",")[-2,])What is the explanation behind this? Can it be used for skipping more than 1 specific row? Can it used for skipping columns? Please help.
21 Answer
You can "skip" as many rows using negative values, i.e.
Df=(read.csv(“IMDB_data.csv”, header=T, sep=",")[-c(2,3,5:9),])Similar for columns:
Df=(read.csv(“IMDB_data.csv”, header=T, sep=",")[, -c(2,4)])To skip rows and columns
Df=(read.csv(“IMDB_data.csv”, header=T, sep=",")[-c(2,3,5:9), -c(2,4)]) 0