Hello! I just started with Rstudio and I have to create a variable which shows if the BMI is between 18.5< and <25 (as true or false) . I tried to figure out the solution for ours but could not come up with one, please help me.
Please consider our Homework policy FAQ: Homework Policy
In light of this, I wont directly answer your query, but ask you some questions to get you along.
What part(s) are you stuggling with?.
Can you create a variable that shows anything at all ?
can you check whether a variable meets a single condition?
Whats the closest you believe that you came towards answering the question for yourself... what did you try ?
I don't know I am trying to put value to a letter like y <- <2 but I does not work. I have no idea at all how this works. Due to the Corona virus we did not get a manual and currently I am struggling doing the task.
lets break this down
y is indeed a letter, and a suitable name for an object that we can assign values to. So off to a good start.
<- is the assignment operator that will attach the value on the right with the name on the left. also good
<2 this is a problem. it is not a value. it is a partial condition. In english it would be 'strictly less than 2', there are an infinitude of values that would meet such a condition. assignment with <- should be used on concrete values , or expressions that evaluate to concrete values.
You could assign 2 to a variable
y <- 2
you could assign the text string "<2" to a variable
y <- "<2"
but you cant assign a partial condition
y<- <2 #error
Thank you for your deep explanation.
I am sorry I would not ask usually I do everything myself but I don't have a manual this time, for example I learned how to make pie charts pie() or boxplot().... But can you relate to my situation? Expect someone wants the task done by sou and you don't know how at all? With no manual in a program you started with a month ago?
I don't know how to create a variable that shows if the value is in a certain interval. I would high appreciate your help, I couldn't find a solution on YouTube or Google so I created an account. All I want to do is to do my studies...
Here is a simple tutorial for you to follow.
You need to use a combination of
R Relational Operators and
R Logical Operators
Is this correct for example: y <- y<2&y>1 is everything between 1 and 2?
Thank you a lot ^^
yes well done. although its nice to spread out your code, and also not reuse variable names, so you can keep track of what's what
b <- (a>1) & (a<2)
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.