I am fairly new to R and have tried several versions of the following statement with no avail. What I need is to create a new variable MAXVO2 and perform calculations adjusted for Age and Sex and then round it to 2 decimals.
If (18 <= ed.frame$Age && ed.frame$Age <= 99 && ed.frame$Sex == 1) {
ed.frame$MAXVO2 <- 60-(.55ed.frame$Age)
}
if(18 <= ed.frame$AgeAge && ed.frame$Age <= 99 && Sex = 2) {
ed.frame$MAXVO2 <- 48-(.37ed.frame$Age)
}
Else {ed.frame$MAXVO2 <- 999
}
ed.frame$MAXVO2 <- round(ed.frame$MAXVO2, 2)
Error I recive:
Error: unexpected '{' in "If (18 <= ed.frame$Age && ed.frame$Age <= 99 && ed.frame$Sex == 1) {"
Any help/guidance is great appreciated.