missbre
September 3, 2022, 11:03am
1
Suppose that num is a single numeric value. Provide code that will add 1 to num if it is less than 0; subtract 1 from num if it is greater than 0; and leaves num unchanged if it is exactly 0.
nedallo
September 3, 2022, 11:46am
2
please look at the below example :
dff <- data.frame(x=-5:7)
dff %>% mutate(var1=ifelse(x<0,x+1,ifelse(x>0,x-1,x)))
var1 is the new defined variable which you want ..
hope this clear .
Kind Regards
Please have a look at our homework policy, homework inspired questions are welcome but they should not include verbatim instructions from your course.
Can I ask questions from a course I am taking here?
General questions are always welcome!
Please do ask general questions about things like:
How to use R
How to use the RStudio IDE or RStudio Cloud
How to work with tidyverse packages
Where to find resources to help you learn or solve problems
Specific questions can be OK, if you follow these rules:
Never copy-paste instructions from an assignment (even for online courses).
Explicitly mention the course you are taking and use the #homework tag.
Ask your question as a reproducible example (reprex) , preferably prepared for posting using the reprex package .
Want to maximize your chances of getting the help you need? Keep readin…
system
Closed
October 15, 2022, 12:44pm
4
This topic was automatically closed 42 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.