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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:55:20+00:00 2026-06-12T04:55:20+00:00

I am trying to figure out a way to loop through my data frame

  • 0

I am trying to figure out a way to loop through my data frame and replace any values greater than 200 with a decimal point.

Here is my code:

for (i in data$AGE) if (i > 199) i <- i*.01-2

Here is a head() sample of my data frame:

  AGE LOC RACE SEX WORKREL PROD1 ICD10 INJ_ST DTH_YEAR DTH_MONTH DTH_DAY ACC_YEAR ACC_MONTH ACC_DAY
1  26   5    1   1       0  1290  V865     UT     2003         1       1     2002        12      31
2  20   1    7   2       0  1899   X47     HI     2003         1       1     2003         1       1
3 202   1    2   2       0  1598   W75     FL     2003         1       1     2003         1       1
4  86   5    1   2       0  1807   W18     FL     2003         1       1     2002        12      14
5 203   1    2   1       0  1598   W75     GA     2003         1       1     2003         1       1
6  79   0    1   2       2   921   X49     MA     2003         1       1       NA        NA      NA

So basically, if the value of AGE is greater than 200, then I want to multiply that value by .01 and then subtract 2.

My reason is because any value with 200 and greater is the age in months.

I’m not a Stats or R genius so my humble thanks in advance for all advice.

  • 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-12T04:55:21+00:00Added an answer on June 12, 2026 at 4:55 am
    data$AGE[data$AGE> 200] <- data$AGE[data$AGE > 200] * 0.01 - 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out the cleanest way to loop through the first item
I am trying to figure out my way through c89 and now I ma
I am trying to figure out some way to get actual time via JavaScript,
I'm trying to figure out a way of how to be able to assign
I am trying to figure out a way to cut out a certain region
I'm trying to figure out a way to limit the dragging option of the
I am trying to figure out a way for somehow fetching the all the
I'm trying to figure out a way to re-use the validation rules of Yii's
I am trying to figure out a way to pre-process few things before my
I'm trying to figure out a way to use tar+pipes on a Ubuntu Server

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.