Skipping Specific Rows and Columns in R

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

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

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest