Sheri Conner Gausepohl
2005-Jul-12 21:46 UTC
[R] using its to import time series data with uneven dates
Good day: I am trying to use readcsvIts("nwr_data_qc.txt",informat=its.format("%Y%m%d%h%M %Y"),header=TRUE,sep="",skip=0,row.names=NULL,as.is=TRUE,dec=".") to read in a file (nwr_data_qc.txt) that looks like this: Time Y M D H Min CO2 2000.18790 2000. 3. 9. 18. 30. 373.60 2000.20156 2000. 3. 14. 18. 30. 373.34 2000.22609 2000. 3. 23. 18. 0. 373.01 and R returns this: Y M D H Min CO2 <NA> 2000 3 9 18 30 373.60 <NA> 2000 3 14 18 30 373.34 <NA> 2000 3 23 18 0 373.01 I have tried every format option on the help page. How can I read in my decimal dates (e.g., 2000.18790)? Note that these data (CO2) are irregularly spaced in time (Time). Ultimately I would like to fit a trigonometric polynomial (first harmonic) to these data in order to smooth them and obtain values between measurements. Any suggestions you can provide on how to do this would be much appreciated. Thank you for your help. Sheri Sheri L. Conner Gausepohl Graduate Research Assistant Department of Atmospheric Science Colorado State University
Whit Armstrong
2005-Jul-12 22:01 UTC
[R] using its to import time series data with uneven dates
You would probably do better to read in your data and reformat the dates. What date format is 2000.18790? The Its package uses POSIXct dates and readcsvIts expects the formats to be "%Y-%m-%d" unless you've changed the default format. -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Sheri Conner Gausepohl Sent: Tuesday, July 12, 2005 5:47 PM To: r-help at stat.math.ethz.ch Subject: [R] using its to import time series data with uneven dates Good day: I am trying to use readcsvIts("nwr_data_qc.txt",informat=its.format("%Y%m%d%h%M %Y"),header=TRUE,sep="",skip=0,row.names=NULL,as.is=TRUE,dec=".") to read in a file (nwr_data_qc.txt) that looks like this: Time Y M D H Min CO2 2000.18790 2000. 3. 9. 18. 30. 373.60 2000.20156 2000. 3. 14. 18. 30. 373.34 2000.22609 2000. 3. 23. 18. 0. 373.01 and R returns this: Y M D H Min CO2 <NA> 2000 3 9 18 30 373.60 <NA> 2000 3 14 18 30 373.34 <NA> 2000 3 23 18 0 373.01 I have tried every format option on the help page. How can I read in my decimal dates (e.g., 2000.18790)? Note that these data (CO2) are irregularly spaced in time (Time). Ultimately I would like to fit a trigonometric polynomial (first harmonic) to these data in order to smooth them and obtain values between measurements. Any suggestions you can provide on how to do this would be much appreciated. Thank you for your help. Sheri Sheri L. Conner Gausepohl Graduate Research Assistant Department of Atmospheric Science Colorado State University ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Gabor Grothendieck
2005-Jul-12 23:02 UTC
[R] using its to import time series data with uneven dates
On 7/12/05, Sheri Conner Gausepohl <sheri at atmos.colostate.edu> wrote:> Good day: > > I am trying to use > readcsvIts("nwr_data_qc.txt",informat=its.format("%Y%m%d%h%M > %Y"),header=TRUE,sep="",skip=0,row.names=NULL,as.is=TRUE,dec=".") > > to read in a file (nwr_data_qc.txt) that looks like this: > > Time Y M D H Min CO2 > 2000.18790 2000. 3. 9. 18. 30. 373.60 > 2000.20156 2000. 3. 14. 18. 30. 373.34 > 2000.22609 2000. 3. 23. 18. 0. 373.01 > > and R returns this: > > Y M D H Min CO2 > <NA> 2000 3 9 18 30 373.60 > <NA> 2000 3 14 18 30 373.34 > <NA> 2000 3 23 18 0 373.01 > > I have tried every format option on the help page. How can I read in > my decimal dates (e.g., 2000.18790)? > > Note that these data (CO2) are irregularly spaced in time (Time). > > Ultimately I would like to fit a trigonometric polynomial (first > harmonic) to these data in order to smooth them and obtain values > between measurements. Any suggestions you can provide on how to do > this would be much appreciated. > > Thank you for your help. > > Sheri > > Sheri L. Conner Gausepohl > Graduate Research Assistant > Department of Atmospheric Science > Colorado State UniversityTry this: library(its) dd <- read.table(myfile, header = TRUE) tt <- paste(dd$Y, "-", dd$M, "-", dd$D, " ", dd$H, ":", dd$Min, sep = "") co2 <- its(dd$CO2, as.POSIXct(tt)) co2 # display co2
Gabor Grothendieck
2005-Jul-12 23:13 UTC
[R] using its to import time series data with uneven dates
On 7/12/05, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:> On 7/12/05, Sheri Conner Gausepohl <sheri at atmos.colostate.edu> wrote: > > Good day: > > > > I am trying to use > > readcsvIts("nwr_data_qc.txt",informat=its.format("%Y%m%d%h%M > > %Y"),header=TRUE,sep="",skip=0,row.names=NULL,as.is=TRUE,dec=".") > > > > to read in a file (nwr_data_qc.txt) that looks like this: > > > > Time Y M D H Min CO2 > > 2000.18790 2000. 3. 9. 18. 30. 373.60 > > 2000.20156 2000. 3. 14. 18. 30. 373.34 > > 2000.22609 2000. 3. 23. 18. 0. 373.01 > > > > and R returns this: > > > > Y M D H Min CO2 > > <NA> 2000 3 9 18 30 373.60 > > <NA> 2000 3 14 18 30 373.34 > > <NA> 2000 3 23 18 0 373.01 > > > > I have tried every format option on the help page. How can I read in > > my decimal dates (e.g., 2000.18790)? > > > > Note that these data (CO2) are irregularly spaced in time (Time). > > > > Ultimately I would like to fit a trigonometric polynomial (first > > harmonic) to these data in order to smooth them and obtain values > > between measurements. Any suggestions you can provide on how to do > > this would be much appreciated. > > > > Thank you for your help. > > > > Sheri > > > > Sheri L. Conner Gausepohl > > Graduate Research Assistant > > Department of Atmospheric Science > > Colorado State University > > Try this: > > library(its) > dd <- read.table(myfile, header = TRUE) > tt <- paste(dd$Y, "-", dd$M, "-", dd$D, " ", dd$H, ":", dd$Min, sep = "") > co2 <- its(dd$CO2, as.POSIXct(tt)) > co2 # display co2 >or even easier use ISOdatetime: library(its) dd <- read.table(myfile, header = TRUE) co2 <- with(dd, its(CO2, ISOdatetime(Y, M, D, H, Min, 0)))