I have the following dataframe:
myd <- data.frame(a = c(3.0, "2.0 (1.8, 2.2)"))
myd$a[1] <- format(round(as.numeric(myd$a[1]), 1), nsmall = 1)
My data looks like below:
myd
a
1 3.0
2 2.0 (1.8, 2.2)
I want to export myd to csv (or excel). So I tried
write_csv(myd, "myd.csv")
However, row 1 and column 1 of the resultant csv file gives me a number 3 rather than 3.0. A screen shot of the csv is found as follows:
How can I create a .csv or .xlsx file that preserves the digits for the integers (output 3.0 rather than 3)? Hopefully this could be solved within the tidyverse ecosystem, but other solutions are also welcome.