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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:30:33+00:00 2026-06-09T20:30:33+00:00

I am looking for a convenient way to convert positive values (proportions) into negative

  • 0

I am looking for a convenient way to convert positive values (proportions) into negative values of the same variable, depending on the value of another variable.

This is how the data structure looks like:

id Item Var1  Freq 
1  P1   0    0.043
2  P2   1    0.078
3  P3   2    0.454
4  P4   3    0.543
5  T1   0    0.001
6  T2   1    0
7  T3   2    0.045
8  T4   3    0.321
9  A1   0    0.671
...

More precisely, I would like to put the numbers for Freq into the negative if Var1 <= 1 (e.g. -0.043).

This is what I tried:

for(i in 1: 180) {
if (mydata$Var1 <= "1") (mydata$Freq*(-1))}

OR

mydata$Freq[mydata$Var1 <= "1"] = -abs(mydata$Freq)}

In both cases, the negative sign is rightly set but the numbers are altered as well.

Any help is highly appreciated. 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-09T20:30:35+00:00Added an answer on June 9, 2026 at 8:30 pm
    new.Freq <- with(mydata, ifelse(Var1 <= 1, -Freq, Freq))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Express and I am looking for a convenient way to convert
I am looking for a convenient way to create a list of lists for
I am looking for a convenient way to export every images found in an
I'm looking for a fast and possibly convenient way in Python 3 to translate
this may seem a little odd, but it would make for a convenient way
I have been looking for a convenient way of making and maintaining translations of
i'm looking for a convenient way to create a map of all articles within
I'm looking for a convenient way to use jQuery to remove all classes from
I am looking for the most practical and convenient way of laying out my
Looking to do a bit of refactoring... Using NHibernate I have this query currently

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.