how can I write code like this

...
leadership <- within(leadership,{
agecat <- NA
agecat[age > 75] <- "Elder"
agecat[age >= 55 & age <= 75] <- "Middle Aged"
agecat[age < 55] <- "Young" })
...
how can I write code like this,different conditions are in different lines.
When I try to inmitate the code above
leadership <- within(leadership,{agecat <- NA})
,then What can I do,I can not input space or comma(because both ways are wrong)

Hello :slight_smile:

Happy to help if you can post some example data and the expected output you want!

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.