R import changes binary factors to intervals

80 views Asked by At

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?

1

There are 1 answers

1
Akos On BEST ANSWER

Saving as an R object solved my problem. Thanks, user20650.