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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:26:10+00:00 2026-06-08T12:26:10+00:00

I have a dataframe in R looking like this: … vals cat … 1.2

  • 0

I have a dataframe in R looking like this:

 ...    vals         cat  ...
        1.2          TRUE
        1.6          FALSE
        5            TRUE

I like to modify the values in the “vals” column depending on if the factor in the cat
column is TRUE or false. Lets say I want to multiply the value in the vals column
with a factor (e.g 9) when the category of the same row says TRUE.

As result I would like to
have a copy of the original dataframe but with the modified values instead. Or a dataframe with one more column containing the original values if unmodified (FALSE) and the modified if cat
was TRUE.

Hope somebody could
give me a hand with this.

Best Regards Sab.

  • 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-08T12:26:12+00:00Added an answer on June 8, 2026 at 12:26 pm
    x <- data.frame(vals=c(11.2,9.1,2.1),cat=c(TRUE,FALSE,TRUE))
    
    x
      vals   cat
    1 11.2  TRUE
    2  9.1 FALSE
    3  2.1  TRUE
    
    y <- x
    
    y[y$cat,] <- x[x$cat,]*9
    
    y
       vals cat
    1 100.8   9
    2   9.1   0
    3  18.9   9
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dataframe foo looking like this Date Return 1998-01-01 0.02 1998-01-02 0.04
I have a dataframe x with this values: x1 x2 x3 1 NA 4
I have a dataframe with numeric entries like this one test <- data.frame(x =
I have a dataframe with a column of integers that I would like to
I have a dataframe and would like to add a new column where the
I have a dataframe called data where I would like to rescale the values
Say I have a dataframe source <- data.frame(ID=c(1,2), COUNT=c(3,4)) that looks like this: ID
Let's say I have a data frame looking like this: Value1 Value2 1 543
I have a dataframe called ants detailing multiple entries per site, looks like this:
I have a dataframe with distances df<-data.frame(site.x=c(A,A,A,B,B,C), site.y=c(B,C,D,C,D,D),Distance=c(67,57,64,60,67,60)) I need to convert this to

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.