formatting if statements

This may be a trivial issue (but not to me!), nonetheless:
I'm beginning with R/Rstudio, coding this example from murach's "R for Data Analysis", pg 53:
size <- 200
if (size > 100) {

Your example didn't complete. See the FAQ: How to do a minimal reproducible example reprex for beginners to get help with specific code examples.

The syntax for if() is simple.

For short statements, they can be inline. For code requiring line breaks, enclose in curly brackets. ifelse() works similarly.

size <- 100
if(size >= 100) "big"
#> [1] "big"
if(size >= 100){
  foo = "really"
  bar = "big"
#> [1] "really big"
ifelse(size >= 100,"big","small")
#> [1] "big"

Created on 2022-12-22 by the reprex package (v2.0.1)

This topic was automatically closed 21 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.