Date
Then you are looking at a different file... check your filenames. You have imported the column as character, and R has not yet recognized that it is supposed to be a date, so it can only show what it found. You will almost certainly find your error if you make a reproducible example.
On November 4, 2021 5:30:22 PM PDT, Val <valkremk at gmail.com> wrote:
Jeff, The date from y data file looks like as follow in the Linux environment, My_date 2019-09-16 2021-02-21 2021-02-22 2017-10-11 2017-10-10 2018-11-11 2017-10-27 2017-10-30 2019-05-20 On Thu, Nov 4, 2021 at 5:00 PM Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:
You are claiming behavior that is not something R does, but is something Excel does constantly. Compare what your data file looks like using a text editor with what R has imported. Absolutely do not use a spreadsheet program to do this. On November 4, 2021 2:43:25 PM PDT, Val <valkremk at gmail.com> wrote:
IHi All, l,
I am reading a csv file and one of the columns is named as "mydate"
with this form, 2019-09-16.
I am reading this file as
dat=read.csv("myfile.csv")
the structure of the data looks like as follow
str(dat)
mydate : chr "09/16/2019" "02/21/2021" "02/22/2021" "10/11/2017" ...
Please note the format has changed from YYYY-mm-dd to mm/dd/YYYY
When I tried to change this as a Date using
as.Date(as.Date(mydate, format="%m/%d/%Y" )
I am getting this error message
Error in charToDate(x) :
characte string is not in a standard unambiguous format
My question is,
1. how can I read the file as it is (i.e., without changing the date format) ?
2. why does R change the date format?
Thank you,
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
-- Sent from my phone. Please excuse my brevity.
Sent from my phone. Please excuse my brevity.