Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Skipping specific rows and columns in R

Writer 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.

2

1 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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy