[R] about data format in R

Rui Barradas ruipbarradas at sapo.pt
Fri Dec 30 19:23:19 CET 2016


Hello,

Have you tried

df$date <- as.POSIXct(dat$date, format = "%m/%d/%Y-%H:%M:%S")

?

Hope this helps,

Rui Barradas


Em 30-12-2016 17:40, lily li escreveu:
> Hi R users,
>
> I'm trying to read in data, and then plot time series data. However, I have
> some problems. In my dataset, the first column represents time, and in the
> format:
> mm/dd/yyyy-hr:min:sec; For example, 10/01/1995-00:00:00,
> 10/01/1995-06:00:00, etc.
>
> df:
>             date                    evap     precip    intercept
> 10/01/1995-00:00:00       1.5          2            0.2
> 10/01/1995-12:00:00       1.7          2.2         0.1
> 10/02/1995-00:00:00       1.5          1.8         0.3
> ...
>
> My code is like this
> file1 = read.table('df', head=T)
>
> When I read in data, I found that it read incorrectly. How to format when
> read in data? Thanks.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list