I’m having a difficulty properly shrinking down the row numbers in a data frame.
I have a data set named “mydata” which I imported from a text file using R. The data frame has about 200 rows with 10 columns.
I removed the row number 3, 7, 9, 199 by using:
mydata <- mydata[-c(3, 7, 9, 199),]
When I run this command, the row 3,7,9,199 are gone from the list but the row number doesn’t automatically shrink down to 196, but stays at 200. I feel like somehow these row numbers are attached to each “row” as part of the dataframe?
How do I fix this problem?
What puzzles me even more is that when I import the textfile using R Studio, I don’t have any problem. (I see 196 when I run the above command). But when using R, I can’t change the row number in a dataframe that matches the actual number of rows in the list.
Can anyone please tell me how to fix this??
You can simply do:
after performing the subsetting.
For example: