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

  • Home
  • SEARCH
  • 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 6379787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:10:59+00:00 2026-05-25T02:10:59+00:00

I’m having a dataframe as like below. `> am_me Group.1 Group.2 x.x x.y 2

  • 0

I’m having a dataframe as like below.

    `> am_me
      Group.1         Group.2 x.x       x.y
    2      AM  clearterminate   3  21.00000
    3      AM display.cryptic  86  30.12791
    4      AM           price  71 898.00000`

I would like to get result as like below.

    `> am_me_t
               Group.2 x.x              x.y
    2   clearterminate   3               21
    3  display.cryptic  86 30.1279069767442
    4            price  71              898
    41            AM 160 316.375968992248`

I have taken out the first column and got the result like below

    `> am_res
              Group.2 x.x       x.y
    2  clearterminate   3  21.00000
    3 display.cryptic  86  30.12791
    4           price  71 898.00000`

When I try rbind to Add “AM” to new row, as like below, I’m getting a warning message and getting NA.

     `> am_me_t <- rbind(am_res, c("AM", colSums(am_res[2]), colMeans(am_res[3])))
    Warning message:
    invalid factor level, NAs generated in: "[<-.factor"(`*tmp*`, ri, value = "AM")

               Group.2 x.x              x.y
    2   clearterminate   3               21
    3  display.cryptic  86 30.1279069767442
    4            price  71              898
    41            <NA> 160 316.375968992248`

For your information, Output of edit(am_me)

    `> edit(am_me)
    structure(list(Group.1 = structure(as.integer(c(2, 2, 2)), .Label = c("1Y",
    "AM", "BE", "CM", "CO", "LX", "SN", "US", "VK", "VS"), class = "factor"),
        Group.2 = structure(as.integer(c(2, 5, 9)), .Label = c("bestbuy",
        "clearterminate", "currency.display", "display", "display.cryptic",
        "fqa", "mileage.display", "ping", "price", "reissue", "reissuedisplay",
        "shortaccess.followon"), class = "factor"), x.x = as.integer(c(3,
        86, 71)), x.y = c(21, 30.1279069767442, 898)), .Names = c("Group.1",
    "Group.2", "x.x", "x.y"), row.names = c("2", "3", "4"), class = "data.frame")`

Also

    `> edit(me)
    structure(list(Group.1 = structure(as.integer(c(1, 2, 2, 2, 3,
    4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 8, 8,
    8, 8, 9, 9, 10, 10, 10, 10, 10, 10)), .Label = c("1Y", "AM",
    "BE", "CM", "CO", "LX", "SN", "US", "VK", "VS"), class = "factor"),
        Group.2 = structure(as.integer(c(8, 2, 5, 9, 10, 1, 2, 5,
        9, 1, 2, 5, 9, 1, 2, 3, 4, 7, 9, 11, 12, 2, 4, 6, 1, 2, 5,
        9, 2, 5, 1, 2, 3, 5, 9, 10)), .Label = c("bestbuy", "clearterminate",
        "currency.display", "display", "display.cryptic", "fqa",
        "mileage.display", "ping", "price", "reissue", "reissuedisplay",
        "shortaccess.followon"), class = "factor"), x.x = as.integer(c(1,
        3, 86, 71, 1, 2, 5, 1, 52, 10, 7, 27, 15, 5, 267, 14, 4,
        1, 256, 1, 1, 80, 1, 78, 2, 10, 23, 6, 1, 2, 4, 3, 3, 11,
        1, 1)), x.y = c(5, 21, 30.1279069767442, 898, 12280, 800,
        56.4, 104, 490.442307692308, 1759.1, 18.1428571428571, 1244.81481481481,
        518.533333333333, 3033.2, 18.5468164794007, 20, 3788.5, 23,
        2053.49609375, 3863, 6376, 17.825, 240, 1752.21794871795,
        1114.5, 34, 1369.60869565217, 1062.16666666667, 23, 245,
        5681.5, 11.3333333333333, 13.3333333333333, 1273.81818181818,
        2076, 5724)), .Names = c("Group.1", "Group.2", "x.x", "x.y"
    ), row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
    "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
    "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31",
    "32", "33", "34", "35", "36"), class = "data.frame")

       Group.1              Group.2 x.x         x.y
    1       1Y                 ping   1     5.00000
    2       AM       clearterminate   3    21.00000
    3       AM      display.cryptic  86    30.12791
    4       AM                price  71   898.00000
    5       BE              reissue   1 12280.00000
    6       CM              bestbuy   2   800.00000
    7       CM       clearterminate   5    56.40000
    8       CM      display.cryptic   1   104.00000
    9       CM                price  52   490.44231
    10      CO              bestbuy  10  1759.10000
    11      CO       clearterminate   7    18.14286
    12      CO      display.cryptic  27  1244.81481
    13      CO                price  15   518.53333
    14      LX              bestbuy   5  3033.20000
    15      LX       clearterminate 267    18.54682
    16      LX     currency.display  14    20.00000
    17      LX              display   4  3788.50000
    18      LX      mileage.display   1    23.00000
    19      LX                price 256  2053.49609
    20      LX       reissuedisplay   1  3863.00000
    21      LX shortaccess.followon   1  6376.00000
    22      SN       clearterminate  80    17.82500
    23      SN              display   1   240.00000
    24      SN                  fqa  78  1752.21795
    25      US              bestbuy   2  1114.50000
    26      US       clearterminate  10    34.00000
    27      US      display.cryptic  23  1369.60870
    28      US                price   6  1062.16667
    29      VK       clearterminate   1    23.00000
    30      VK      display.cryptic   2   245.00000
    31      VS              bestbuy   4  5681.50000
    32      VS       clearterminate   3    11.33333
    33      VS     currency.display   3    13.33333
    34      VS      display.cryptic  11  1273.81818
    35      VS                price   1  2076.00000
    36      VS              reissue   1  5724.00000`
  • 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-25T02:11:00+00:00Added an answer on May 25, 2026 at 2:11 am

    The type of the Group.2 column is factor, and that limits the possible values. You can transform it to character with am_me$Group.2 <- as.character(am_me$Group.2), after that the AM value will be added without errors.

    Note that you can also use sum() and mean() for single column operations.

    • 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 would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.