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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:58:50+00:00 2026-06-09T06:58:50+00:00

I have a data frame with a numeric column called store that has some

  • 0

I have a data frame with a numeric column called store that has some negative values. I’d like to add 1440 to the negative , but am having trouble. My data looks like this:

   score
  1  816
  2 -200
  3  976
  4 -376
  5    1
  6  121
  7 -331

I can replace the values using temp[temp$score< 0] <-8888.

But, I when I try to add value to the variable using: temp[temp$score < 0] <- temp$score + 1440, I get an warning that says:

Warning message: In temp$score[temp$score < 0] <- temp$score + 1440 
:number of items to replace is not a multiple of replacement length

And then I get some odd values returned:

  score
1   816
2  2256
3   976
4  1240
5     1
6   121
7  2416

Am I calling the function wrong or am I selecting the cases wrong?

  • 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-09T06:58:52+00:00Added an answer on June 9, 2026 at 6:58 am

    From your warning message, it seems like you were trying to do the following:

    temp$score[temp$score < 0] <- temp$score + 1440 
    

    The problem here is that you are replacing a vector with one that is a different length, as the warning message suggests. You shortened the left-hand side of the assignment, but not the right-hand side – the solution would be to shorten the right-hand side too, as follows:

    score <- c(816,-200,976,-376,1,121,-331)
    temp <- data.frame(score)
    temp$score[temp$score < 0] <- temp$score[temp$score < 0] + 1440 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data.frame, d1, that has 7 columns, the 5th through 7th column
I have a data.frame with numeric values. How can I replace the each row
I have a dataframe with numeric entries like this one test <- data.frame(x =
I have a data frame that is some 35,000 rows, by 7 columns. it
Suppose I have a data frame, df, that looks like: f t1 t2 t3
I have a data frame with several columns; some numeric and some character. How
I have a data frame with two columns: an ID and some numeric value
I have the following data frame (info) that looks like this: > info[1:5,] field
I have data frame that looks like the following models cores time 1 4
I have a data frame that looks like this: site date var dil 1

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.