Subset a data set by Age but with issue

Hello, everyone,

I am the R studio new user. I am happening an issue and can not figure it out.
My question is: I have a data set called "result", and I want to use subset function to subset the data set by one of variables "Age" (Age =old and new). Here I just want all information but Age of new.
So my code is here:
bynew<result[result$Age==new, ]
Then the error shows:
Error in result$Age == new :
comparison (1) is possible only for atomic and list types

Please help and any help is appreciated! Thanks so much!

If result$Age is a string or factor you will need result$Age == "new"

Thanks so much! I think I get it!

I should be extra careful about this!

Yes you need to be aware of what "type" your objects are. For example, vectors, lists, dataframe, string, numeric, logical etc. R often requires objects to be a certain type.

1 Like

Thanks for reminding! Appreciate it!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.