You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
df <- data.frame(Sample = c("S1","S2","S3"), Date = c("2020-01-01","2023-05","2015"))
When I want to import this data frame into R using readxl, I seem to have two options: either import the Date column as text, in this case "2020-01-01" will become 43831, or import it as date, in this case "2023-05" will become NA and "2015" will become "1905-07-07" without any warnings.
One way to solve this is to import the column as text and then use a custom function to convert back to the original, using a function like this (though it is strange that origin required for accurate conversion is not 1970-01-01):
However, it would be even better if col_types = "text" would just read in the Date column as is, without any conversions.
(You might wonder how I can use these truncated dates in any analysis: I usually simulate a valid date within the boundaries of the information I have, but for this, I need to read in the values as is.)
EDIT: if I manually export a sheet of an xlsx as csv I can then import it using read.csv() and it works as intended.
The text was updated successfully, but these errors were encountered:
Related to #462, #716, #737.
In my data set the dates are sometimes truncated:
When I want to import this data frame into R using
readxl
, I seem to have two options: either import theDate
column astext
, in this case "2020-01-01" will become 43831, or import it asdate
, in this case "2023-05" will become NA and "2015" will become "1905-07-07" without any warnings.One way to solve this is to import the column as
text
and then use a custom function to convert back to the original, using a function like this (though it is strange that origin required for accurate conversion is not 1970-01-01):However, it would be even better if
col_types = "text"
would just read in the Date column as is, without any conversions.(You might wonder how I can use these truncated dates in any analysis: I usually simulate a valid date within the boundaries of the information I have, but for this, I need to read in the values as is.)
EDIT: if I manually export a sheet of an xlsx as csv I can then import it using
read.csv()
and it works as intended.The text was updated successfully, but these errors were encountered: