[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
Hi Jim, I got an error > df$Date2<- + as.POSIXct(as.character(df$Date1, format = "%m/%d/%Y %H:%M:%S")) Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format On Sun, Feb 2, 2014 at 9:08 PM, Jim Lemon wrote: > On 02/03/201

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 wrote: > Hi Jim, > > I got an error > > df$Date2<- > + as.POSIXct(as.character(df$Date1, format = "%m/%d

[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

[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_

[R] NA instead of time stamp

2012-07-17 Thread Yolande Tra
I was wondering why I get 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 2009

[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
x27;m trying to run the code you submitted, but I don't have a function > called index(). > > Jean > > > Yolande Tra wrote on 07/18/2012 08:47:04 AM: > > > > Hello, > > > > I have the following loop for two data sets: diveData_2008 and > > diveDa

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

2012-07-18 Thread Yolande Tra
ta_**2008[i,])) > 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 Barr

[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] 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

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 > wrote: > > Hello, > > > > I would like to

Re: [R] convert date to a factor

2012-07-20 Thread Yolande Tra
ep="",header=TRUE) > dat1$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 - > F

[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 <- readRDS(

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

2012-07-29 Thread Yolande Tra
or w/ 1 level "08/06/2008": 1 1 > #$ time : Factor w/ 1 level "8:49:00": 1 1 > #$ species: Factor w/ 2 levels "S.atrovirens",..: 2 1 > #$ count : Factor w/ 2 levels " 1","15": 2 1 > #$ size : Factor w/ 2 levels "23"," 6&

[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 8/

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

2012-07-31 Thread Yolande Tra
, 1.577, 1.39, >> 0.78, 0.838, 1.77, 1.295, 2.41, 1.317, 1.3075, 1.39, >> 1.633, 1.2416667, 1.395, 0.863, 2.79, 1.0325, 1.965, >> 1.78, 1.567, 1.05, 1.463, 1.24, 1.0075, 1.605, 1.8475 >> )), .Names = c("date", "r_wvht"), cl

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

2012-07-31 Thread Yolande Tra
, Rui Barradas 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 > &

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

2012-07-31 Thread Yolande Tra
> ix <- seq(1, length(tt), length.out=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 "go

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

2012-07-31 Thread Yolande Tra
08-08-27", "2008-08-28", "2008-08-31","2008-09-02", "2008-09-03","2008-09-04","2008-09-05","2008-09-08","2008-09-11"))) plot(z, xaxt="n") > plot(z, xaxt="n",xlab="",ylab="&qu

[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 wrote: > > 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 t

[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, 10

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
' not found > > u=regCond_all[1:10,] > Error: object 'regCond_all' not found > > > From a glance, I guess you should have posted with "u" in place of > regCond_all for the loop. > > A.K. > > - Original Message - > From: Yolande

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
99 99 > Thanks, Y On Fri, Aug 3, 2012 at 4:35 PM, Sarah Goslee wrote: > Yolande, > > Please send your message to the R-help email list too, not just to me. > > On Fri, Aug 3, 2012 at 4:28 PM, Yolande Tra wrote: > > Here is the description > > I am trying t

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
"GST", "WVHT", "DPD", "APD", "MWD", "PRES", "ATMP", "WTMP", "DEWP", "VIS", "TIDE"))) Thank you for your patience. Y On Fri, Aug 3, 2012 at 4:56 PM, Sarah Goslee wrote: > Whe

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
<- regCond_all$DPD[ind] > diveCond$r_apt[i] <- regCond_all$APD[ind] > diveCond$r_mwd[i] <- regCond_all$MWD[ind] > diveCond$r_wtmp[i] <- regCond_all$WTMP[ind] > } > > # this also runs > i <- 10 > thisStamp <- as.POSIXct(strptime(diveCond$timestamp[i],