[R] datetime and date

2014-02-02 Thread Yolande Tra
Hi, I have the following issue. The dataframe df has a column (Date1) supposed to be a date but read as a factor. There are two types of values in the same column Date1 Type 1 are datetime like 5/23/2008 0:00:00 Type 2 have no time like 1/10/13. When I apply the following to the date column

Re: [R] datetime and date

2014-02-02 Thread Yolande Tra
:53 PM, Yolande Tra wrote: Hi, I have the following issue. The dataframe df has a column (Date1) supposed to be a date but read as a factor. There are two types of values in the same column Date1 Type 1 are datetime like 5/23/2008 0:00:00 Type 2 have no time like 1/10/13. When I apply

Re: [R] datetime and date

2014-02-02 Thread Yolande Tra
Thank you Jeff. I had to go back to excel and format the column from there. Thank you everyone, Yolande On Sun, Feb 2, 2014 at 9:51 PM, Yolande Tra yolande@gmail.com wrote: Hi Jim, I got an error df$Date2- + as.POSIXct(as.character(df$Date1, format = %m/%d/%Y %H:%M:%S)) Error

[R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Yolande Tra
Hi, Here is my data, the first 10 rows u=regCond_all[1:10,] dput(u) structure(c(999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 1.9, 2, 1.97, 1.99, 1.83, 1.78, 1.6, 1.52, 1.52, 1.36, 10.53, 9.88, 9.88, 10.53,

Re: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Yolande Tra
in place of regCond_all for the loop. A.K. - Original Message - From: Yolande Tra yolande@gmail.com To: R help r-help@r-project.org Cc: Sent: Friday, August 3, 2012 3:49 PM Subject: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing

Re: [R] replacement has length zero. In addition: Warning message: In max(i) : no non-missing arguments to max; returning -Inf

2012-08-03 Thread Yolande Tra
(diveCond$timestamp[i], %Y-%m-%d %H:%M:%S)) thisStamp ind - which.min( abs(index(regCond_all) - thisStamp )) ind diveCond$r_wvht[i] regCond_all$WVHT[ind] On Fri, Aug 3, 2012 at 5:02 PM, Yolande Tra yolande@gmail.com wrote: dput(head(diveCond, 10)) structure(list(dive_id = c(1, 2, 3, 4, 5

[R] add text to a plot, create character labels

2012-08-01 Thread Yolande Tra
Hi, I was trying to run the following, where the labels on the x axis are dates and need to be converted to characters. It did not work. Any help would be appreciated. Thanks. text(axTicks(1),par(usr)[3]-2,srt=45,adj=1,labels=as.character(c(2008-01-08,2008-08-10,2008-08-22,2008-09-03,

Re: [R] add text to a plot, create character labels

2012-08-01 Thread Yolande Tra
Thanks for the tip for future typos. Yolande On Wed, Aug 1, 2012 at 1:38 PM, David Winsemius dwinsem...@comcast.netwrote: On Aug 1, 2012, at 9:04 AM, Yolande Tra wrote: Hi, I was trying to run the following, where the labels on the x axis are dates and need to be converted to characters

[R] time series line plot: Error in plot.window(...) : invalid 'xlim' value

2012-07-31 Thread Yolande Tra
Hello, This should be pretty simple but I cannot get it right. Please point to the right code. Thanks. last - read.csv(file.path(dataDir,plot1.csv), as.is=T,stringsAsFactors = FALSE) last dater_wvht 18/6/2008 0.977 28/8/2008 0.773 3 8/11/2008 1.483 4

Re: [R] time series line plot: Error in plot.window(...) : invalid 'xlim' value

2012-07-31 Thread Yolande Tra
:02, Yolande Tra escreveu: Hello, This should be pretty simple but I cannot get it right. Please point to the right code. Thanks. last - read.csv(file.path(dataDir,**plot1.csv), as.is =T,stringsAsFactors = FALSE) last dater_wvht 18/6/2008 0.977 28/8/2008

Re: [R] time series line plot: Error in plot.window(...) : invalid 'xlim' value

2012-07-31 Thread Yolande Tra
, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, It only gives that error if you don't last$date - as.Date(last$date, format=%m/%d/%Y) You must have dates, not character values. Try it, then make a zoo object, then plot it. Rui Barradas Em 31-07-2012 18:54, Yolande Tra escreveu: Thank

Re: [R] time series line plot: Error in plot.window(...) : invalid 'xlim' value

2012-07-31 Thread Yolande Tra
=8) axis(side = 1, at = tt[ix], labels = FALSE) labs - format(tt, %Y-%b-%d) axis(side = 1, at = tt[ix], labels = labs[ix], tcl = -0.7, cex.axis = 0.7, las=2) It looks better, but I wouldn't risk good. Rui Barradas Em 31-07-2012 19:10, Yolande Tra escreveu: Thanks. This is an irregular

Re: [R] time series line plot: Error in plot.window(...) : invalid 'xlim' value

2012-07-31 Thread Yolande Tra
=) And now there was no warning. Thanks, Yolande On Tue, Jul 31, 2012 at 5:06 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, Inline. Em 31-07-2012 21:45, Yolande Tra escreveu: I am sorry but I still got some errors. May be it is because of the package zoo. Please be patient with me. Thanks

Re: [R] readRDS, In as.double.xts(fishReport$count) : NAs introduced by coercion

2012-07-29 Thread Yolande Tra
w/ 2 levels 1,15: 2 1 #$ size : Factor w/ 2 levels 23, 6: 2 1 dat6$count-as.numeric(dat6$count) is.numeric(dat6$count) #[1] TRUE I hope this helps. A.K. - Original Message - From: Yolande Tra yolande@gmail.com To: R help r-help@r-project.org Cc: Sent: Saturday

[R] readRDS, In as.double.xts(fishReport$count) : NAs introduced by coercion

2012-07-28 Thread Yolande Tra
Hello, I looked in the R-help but could not find an archive addressing the following. I would like to convert a character to numeric after reading a file with RDS extension. After using as.numeric, I checked if it is numeric. It was not converted. Please help. Here is my code Report -

[R] convert date to a factor

2012-07-20 Thread Yolande Tra
Hello, I would like to convert date as a factor to represent time in a repeated measure situation in the following code. How would I do that? d - read.csv(file.path(dataDir,data.csv), as.is=T,stringsAsFactors = FALSE) d[1:2,] id date ab c y 1 1

Re: [R] convert date to a factor

2012-07-20 Thread Yolande Tra
Thanks, Y On Fri, Jul 20, 2012 at 11:47 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: d$date - factor(d$date) Best, Michael On Fri, Jul 20, 2012 at 9:44 AM, Yolande Tra yolande@gmail.com wrote: Hello, I would like to convert date as a factor to represent time

Re: [R] convert date to a factor

2012-07-20 Thread Yolande Tra
$date-with(dat1,as.factor(date)) dat1 id date a b c y 1 1 8/6/2008 Red 15 B 22 2 1 8/6/2008 Green 15 B 22 is.factor(dat1$date) [1] TRUE A.K. - Original Message - From: Yolande Tra yolande@gmail.com To: r-help@r-project.org Cc: Sent: Friday, July 20, 2012 10

[R] expert opinion on lmer

2012-07-19 Thread Yolande Tra
Hello, I have the following design, counts were collected at different transects, different depths and different sites at different times. Time is continuous and assumed to be random, all the others are categorical fixed where transect is nested within depth which is nested within site. I would

[R] loop searching the id corresponding to the given index (timestamp)

2012-07-18 Thread Yolande Tra
Hello, I have the following loop for two data sets: diveData_2008 and diveData_2009. It uses two other data: diveCond_all and fishTable. The problem is at the point to identify the dive_id for the given index (index is timestamp). It keeps on saying for the1st loop Error in fishReport$dive_id[i]

Re: [R] loop searching the id corresponding to the given index (timestamp)

2012-07-18 Thread Yolande Tra
to run the code you submitted, but I don't have a function called index(). Jean Yolande Tra yolande@gmail.com wrote on 07/18/2012 08:47:04 AM: Hello, I have the following loop for two data sets: diveData_2008 and diveData_2009. It uses two other data: diveCond_all and fishTable

Re: [R] loop searching the id corresponding to the given index (timestamp)

2012-07-18 Thread Yolande Tra
,])) thisIndex - as.POSIXct(thisIndex) dive_id - diveCond_all$dive_id[diveCond_**all$timestamp == thisIndex] # [... etc ...] And the same in the 2009 loop. I think this is it. Good luck, Rui Barradas Em 18-07-2012 14:47, Yolande Tra escreveu: Hello, I have

[R] NA instead of time stamp

2012-07-17 Thread Yolande Tra
I was wondering why I get NA instead of the timestamp in the following. Thanks. dataDir - file.path(wd) localRaw - read.csv(file.path(dataDir,LOCAL.csv), as.is=T,stringsAsFactors = FALSE) localRaw[1:2,] Year Month Day hour minute second Temp1mab Temp7mab Temp14mab Salinity1mab 1 200910

[R] as.xts

2012-07-16 Thread Yolande Tra
Hello, Attached is the file created from as.xts. After submitting the following code, I got an error. Please help. Thanks. diveCond - data.frame(matrix(0, nrow=61, ncol=17)) names(diveCond) - c(dive_id, timestamp, visability, r_wvht, r_dpd, r_apt, r_mwd, r_wtmp, l_salinity, l_o2, l_hs, l_tp,

[R] Error in as.xts

2012-07-15 Thread Yolande Tra
Hi I got the following error using as.xts Error in xts(x, order.by = order.by, frequency = frequency, ...) : NROW(x) must match length(order.by) Here is how the data looks like d1 - read.csv(file.path(dataDir,AppendixA-FishCountsTable-2009.csv), as.is=T) d1[1:3,] dive_id date time