Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8522585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:09:52+00:00 2026-06-11T07:09:52+00:00

I’m having a difficulty properly shrinking down the row numbers in a data frame.

  • 0

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??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:09:54+00:00Added an answer on June 11, 2026 at 7:09 am

    You can simply do:

    rownames(mydata) <- NULL
    

    after performing the subsetting.

    For example:

    > mydata = data.frame(a=1:10, b=11:20)
    > mydata = mydata[-c(6, 8), ]
    > mydata
        a  b
    1   1 11
    2   2 12
    3   3 13
    4   4 14
    5   5 15
    7   7 17
    9   9 19
    10 10 20
    > rownames(mydata) <- NULL
    > mydata
       a  b
    1  1 11
    2  2 12
    3  3 13
    4  4 14
    5  5 15
    6  7 17
    7  9 19
    8 10 20
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have an autohotkey script which looks up a word in a bilingual dictionary
I have a text area in my form which accepts all possible characters from
I want to construct a data frame in an Rcpp function, but when I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.