I have a dataframe which contains several binary variables, labelled as "0" and "1". I converted these to factors in R after initial import, saved the variables as factors using as.factor()
, and saved the dataframe using write.csv()
. The next time I imported the saved dataframe, R imported these variables as intervals again.
Is there any way to ensure that these metadata are saved and applied on each import, so that I don't have to apply as.factor()
to every one of these variables every time I work on the data and for each subset of the data I create?
Saving as an R object solved my problem. Thanks, user20650.