I have two data frames I merged:
df1 <- read_csv("df1.csv", col_types = cols(Date = col_date(format = "%d/%m/%Y")))
df2 <- read_csv("df2.csv", col_types = cols(Date = col_date(format = "%d/%m/%Y")))
df3 <-left_join(df1, df2, by = 'Date', df1 = TRUE)
write.table(df3, file = "df3.csv", sep = "," )
before I export the df3, all my columns are numerical but after exporting they are transformed into logical so I do the following:
df3 <- read_csv("df3.csv", col_types = cols(Date = col_date(format = "%d/%m/%Y")))
cols <- c(sapply(df3, is.logical))
Q[cols] <- lapply(df3[cols], as.numeric)
But once I export it one more time, the data frame goes back to logical and that affects my following functions.
My doubt is:
- How can I preserve the numerical class of my columns when exporting a data frame.
