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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:10:30+00:00 2026-06-07T20:10:30+00:00

I know that this is a very silly question but I cannot work out

  • 0

I know that this is a very silly question but I cannot work out how to do it.
I want to subtract 300 from the values on each row on the trial1 column if they are larger than 299.

I tried:

sums[sums$trial1 > 299, ][,"trial1"] -= 300

but didn’t work. SO far the only way I managed to get it to work is by splitting the data.frame using subset and then modifying it with :

sums$trial1 = sums$trial1 - 300

and then using rbind(). I am pretty sure that using subset and rbind is overkill, but I haven’t been able to find a direct way yet…

I used dput to get a sample of my data.frame.

structure(list(part_no = c(10L, 10L, 10L, 10L, 10L, 10L), trial1 = c(294L, 
296L, 298L, 300L, 302L, 304L), trial2 = c(295L, 297L, 299L, 301L, 
303L, 305L), id1 = c(1.5, 1.5, 1.5, 2, 2, 2), id2 = c(1.5, 1.5, 
1.5, 2, 2, 2), dist1 = c(141L, 141L, 115L, 126L, 177L, 141L), 
    width1 = c(77L, 77L, 63L, 42L, 59L, 47L), dist2 = c(143L, 
    135L, 146L, 255L, 327L, 369L), width2 = c(78L, 74L, 80L, 
    85L, 109L, 123L), ttime1 = c(1752L, 1681L, 1664L, 1798L, 
    1664L, 1697L), ttime2 = c(2563L, 1849L, 2067L, 1933L, 2118L, 
    2245L), no_clicks1 = c(8L, 8L, 8L, 8L, 8L, 8L), no_clicks2 = c(8L, 
    8L, 8L, 8L, 8L, 8L), no_ontarget1 = c(7L, 8L, 8L, 8L, 8L, 
    8L), no_ontarget2 = c(8L, 8L, 8L, 4L, 7L, 8L), e1 = c(1L, 
    0L, 0L, 0L, 0L, 0L), e2 = c(0L, 0L, 0L, 4L, 1L, 0L), rating = c(252, 
    252, 252, 252, 252, 252), prat = c(0.8, 0.8, 0.8, 0.8, 0.8, 
    0.8), ptim = c(-46.2899543378995, -9.9940511600238, -24.21875, 
    -7.5083426028921, -27.2836538461538, -32.2922804949912), 
    ptdiff = c(-47.0899543378995, -10.7940511600238, -25.01875, 
    -8.3083426028921, -28.0836538461538, -33.0922804949912), 
    pdist = c(-1.41843971631206, 4.25531914893617, -26.9565217391304, 
    -102.380952380952, -84.7457627118644, -161.702127659574), 
    pddiff = c(-2.21843971631206, 3.45531914893617, -27.7565217391304, 
    -103.180952380952, -85.5457627118644, -162.502127659574), 
    perr = c(100, NaN, NaN, -Inf, -Inf, NaN), pediff = c(99.2, 
    NaN, NaN, -Inf, -Inf, NaN)), .Names = c("part_no", "trial1", 
"trial2", "id1", "id2", "dist1", "width1", "dist2", "width2", 
"ttime1", "ttime2", "no_clicks1", "no_clicks2", "no_ontarget1", 
"no_ontarget2", "e1", "e2", "rating", "prat", "ptim", "ptdiff", 
"pdist", "pddiff", "perr", "pediff"), row.names = 148:153, class = "data.frame")

Thanks!

  • 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-07T20:10:33+00:00Added an answer on June 7, 2026 at 8:10 pm

    Your first attempt was close but there is no -= operator in base R, so you need to supply the subset on the right hand side as well.

    sums[sums$trial1 > 299,"trial1"] <- sums[sums$trial1 > 299,"trial1"]-300
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this is very basic and silly question, but as I am
I know that this question is very similar to the question posted here .
I know that this is a repeated question. I have found very similar questions
I know that this may be an amateur question but for some reason I
Okay, this is (probably) a very simple question, but I am afraid I know
This may sound silly but I didn't want to hijack a question. I recently
Okay, this might be a very silly beginner question, but: I've got an ClassA,
I know that this question has been asked loads of times, but I have
I know this is very easy question, but I couldn't find the answer anywhere.
This is probably a very obvious question but I can't quite figure it out.

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.