mercredi 19 février 2020

Data frames in R and if statements

Can somebody please explain something about data frames to me in R, please?

For example, I have the following SPSS code:

if (age=33 or age=34 or age=35) agegrp3335=1
EXECUTE.

if (age=33) age33=1.
EXECUTE.

if (age=34) age34=1.
EXECUTE.

if (age=35) age353=1.
EXECUTE.

Hadley Wickham's advice, is the following:

x <- if (y < 20) "Too low" else "Too high"

But isn't this creating a new dataframe 'x'?

Any suggestions on creating a new variable on an existing R dataframe, please?

Many thanks.

Aucun commentaire:

Enregistrer un commentaire