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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:21:39+00:00 2026-05-19T11:21:39+00:00

I am new to R and am getting unexpected results while using the ifelse()

  • 0

I am new to R and am getting unexpected results while using the ifelse() function. Here is an example. Below is a subset of the data frame I am working with. After the last command, why does the example$Points column contain 12 instead of 2? I have tried this for many different values of example$Value and the result is always 10 more than what I expect.

Example:

example
     Question StudentID SchoolID Value Worth Answer Points
2926       18    101290    84386     2     2     Co      0
2927       18    100878    84386     2     2     Co      0
2928       18    100895    84386     1     5     Co      0
2929       18    100913    84386     2     2     Co      0
2930       18    100884    84386     2     2     Co      0
example$Points <- ifelse(example$Answer == "Co", example$Value, example$Points)
example
     Question StudentID SchoolID Value Worth Answer Points
2926       18    101290    84386     2     2     Co     12
2927       18    100878    84386     2     2     Co     12
2928       18    100895    84386     1     5     Co     11
2929       18    100913    84386     2     2     Co     12
2930       18    100884    84386     2     2     Co     12

I’ve been using the work-around of just then subtracting 10 from the column, but I would like to avoid this and get to the bottom of what is going on here.

Any help would be greatly appreciated. Thank you!

  • 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-19T11:21:40+00:00Added an answer on May 19, 2026 at 11:21 am

    My guess is that example$Value is a factor and you’re getting the underlying codes instead of the labels. I recommend taking a look at your data as soon as it’s read into R to see what’s causing your input method to treat those values as factors instead of integer / numeric.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting unexpected results with this code: 'foo'.match(new RegExp('\bfoo\b')); // Returns null Why is
So I'm getting a new job working with databases (Microsoft SQL Server to be
I was changing the vc++ include directory with new paths suddenly getting below error
Anyone getting this error when using the new free chart controls MS bought from
We are getting new dev machines and moving up to Vista 64 Ultimate to
We're getting new servers. Trying to figure out the AMD vs Intel holy war.
When designing a new system or getting your head around someone else's code, what
I'm looking at getting a new LCD monitor, but I'm concerned that a glossy
We were running Tarantino in a Nant build script but we're getting some new
I'm getting ready to start a new project and I've been researching the entity

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.