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 4246866
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:01:54+00:00 2026-05-21T04:01:54+00:00

I would like to convert the values in a column of an existing data

  • 0

I would like to convert the values in a column of an existing data frame into row names. Is is possible to do this without exporting the data frame and then reimporting it with a row.names = call?

For example I would like to convert:

 > samp 
     names Var.1 Var.2 Var.3
 1     A     1     5     0
 2     B     2     4     1
 3     C     3     3     2
 4     D     4     2     3
 5     E     5     1     4

Into:

> samp.with.rownames 
     Var.1 Var.2 Var.3
A     1     5     0
B     2     4     1
C     3     3     2
D     4     2     3
E     5     1     4
  • 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-05-21T04:01:55+00:00Added an answer on May 21, 2026 at 4:01 am

    This should do:

    samp2 <- samp[,-1]
    rownames(samp2) <- samp[,1]
    

    So in short, no there is no alternative to reassigning.

    Edit: Correcting myself, one can also do it in place: assign rowname attributes, then remove column:

    R> df<-data.frame(a=letters[1:10], b=1:10, c=LETTERS[1:10])
    R> rownames(df) <- df[,1]
    R> df[,1] <- NULL
    R> df
       b c
    a  1 A
    b  2 B
    c  3 C
    d  4 D
    e  5 E
    f  6 F
    g  7 G
    h  8 H
    i  9 I
    j 10 J
    R> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have double values which I would like to convert to String values with
I would like to convert some value from a XML attribute into valid HTML
I would like to convert a yyyy-mm-dd to something like this: Saturday, 2 October
I would like to convert this string foo_utf = u'nästy chäräctörs with å and
I would like to convert this fluent approach to xml: container.Register( AllTypes.FromAssemblyNamed(Company.DataAccess) .BasedOn(typeof(IReadDao<>)).WithService.FromInterface(), AllTypes.FromAssemblyNamed(Framework.DataAccess.NHibernateProvider)
I have an R data frame that looks like this: z = as.data.frame(list(Col1=c(a,c,e,g),Col2=c(b,d,f,h),Col3=c(1,2,5,3,5,7,9,8,1))) >
I would like to convert a column in mysql from varchar to enum. If
I would like to convert something like: <property name='aoeu' value='a,o,e,u'/> to: <path id='ueoa'> <pathelement
I would like to convert from an image (like jpg or png) to PDF.
I would like to convert BufferedImage to an image that will display on JSP

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.