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.
By using bracket notation on R DataFrame (data.name) we can select rows by column value, by index, by name, by condition e.t.c. You can also use the R base function subset() to get the same results. Besides these, R also provides another function dplyr::filter() to get the rows from the DataFrame.
To pick out single or multiple columns use the select() function. The select() function expects a dataframe as it's first input ('argument', in R language), followed by the names of the columns you want to extract with a comma between each name.
Rotating or transposing R objects frame so that the rows become the columns and the columns become the rows. That is, you transpose the rows and columns. You simply use the t() command. The result of the t() command is always a matrix object.
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)])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With