similar to: Does POSIXlt extract date components properly?

Displaying 20 results from an estimated 5000 matches similar to: "Does POSIXlt extract date components properly?"

2010 Mar 15
1
Eliminate border in wireframe plot
How can I eliminate the border drawn by default around a wireframe plot? I've tried using border=NA and box=FALSE to no avail. Scott Waichler Pacific Northwest National Laboratory scott.waichler at pnl.gov
2011 May 25
3
Accessing elements of a list
I have a list that is made of lists of varying length. I wish to create a new vector that contains the last element of each list. So far I have used sapply to determine the length of each list, but I'm stymied at the part where I index the list to make a new vector containing only the last item of each list mylist =
2009 Dec 29
4
subsetting by groups, with conditions
I have a data set similar to this: P1id Veg1 Veg2 AreaPoly2 P2ID 1 p p 1 1 1 p p 1.5 2 2 p p 2 3 2 p h 3.5 4 For each group of "Poly1id" records, I wish to output (subset) the record which has largest "AreaPoly2" value, but only if
2010 Mar 05
4
conditioning variable in panel.xyplot?
I wish to create a multipanel plot (map) from several datasets ("d" and "q" in the example below). I can condition the main xyplot statement on the "site" variable, but I don't know how to pass a conditioning variable to panel.xyplot plot so that the x-y coordinates from dataset q are only plotted at the appropriate site. library(lattice) d <-
2010 Jun 22
2
Lattice legend
I have a moderately complex graph with three panels. There are data points plotted, and fitted lines are added using a panel function, which includes "with(alt.data[[which.packet()[1]]]" statements. It all graphs out beautifully, but none of the usual tricks to get the proper legend to plot are working, i.e., using auto.key, key, etc. One message I keep getting is Error in
2007 Dec 13
2
Overlaying trellis xyplot on contourplot
Friends: I wish to overlay data points on a contour graph. The following example produces a nice contour plot, but I have not mastered the concept of using panel functions to modify plots. Can someone show me how to overlay the data points (given after contour plot statement) on the contourplot? --Seth model <- function(a,b,c,X1,X2) # provide model function for contour
2009 Sep 18
1
xyplot: Can I identify groups but not use them for regression?
I wish to identify groups representing different treatments, but to plot them and do a regression using a continuous variable ("cover") ignoring the groupings. d$year <- NA d$year <-c(rep(2007,12), rep(2008,12)) d$treatment <- c(rep("A",4),rep("B",4),rep("C",4), rep("A",4), rep("B",4), rep("C",4)) d$cover <-
2010 Sep 21
1
Doing operations by grouping variable
I'm writing an expression that requires searching a vector according to group. As an example, I want to find the maximum value in each of 5 groups. group=rep(1:5, each=5) # create grouping variable variable=rnorm(25) # generate data d <- data.frame(group,variable) # make data frame
2012 Mar 23
1
Remove wireframe outer box but keep ticks
I would like to eliminate the outer box around a lattice wireframe graph, but the usual recommended solution, which is to assign a color of 'transparent' to the axis.line parameter, eliminates ticks if the 'arrows=F' command is used, as shown in the following example: test = data.frame(expand.grid(c(1:10), c(1:10))) z = test[,1] + test[,2] test = cbind(test, z) names(test) =
2009 Oct 06
2
Extracting year from a date object
Hi all, this one left me a bit puzzled, as I don't seem to find a function to perform this easily. I must have overlooked the obvious, so sorry in advance. I have a list of dates in numerical format (i.e. 34576), defined as the number of days that passed since january 1st 1900. So I apply the function : > MyDate <-as.Date(34576,origin="1900-01-01") > MyDate [1]
2011 Sep 09
1
Adding groups to regression line panel function in Lattice
I wish to display a single-panel Lattice figure with grouped data and fitted regression lines. I don't seem to be able to get the individual regression lines to display, e.g.; d <- data.frame(q = rep(1:6, each=10), cc = rep(seq(10,100, 10),6)) # create data frame with group identifier 'q', independent variable cc d$ba = d$q*0.1*d$cc + 5*rnorm(nrow(d))
2007 Jun 13
5
Confusion with sapply
Hi, I have some confusion in applying a function over a column. Here's my function. I just need to shift non-March month-ends to March month-ends. Initially I tried seq.dates, but one cannot give a negative increment (decrement) here. return(as.Date(seq.dates(format(xdate,"%m/%d/%Y"),by="months",len=4)[4]) ) Hence this simple function: > mydate <-
2017 Apr 05
2
as.POSIXct character string is not in a standard unambiguous format
Hi I have lots of issues when I try to install R 3.3.3 during the "make check" step. Every time a call to as.POSIXct is done in test scripts, I got the same error message: e.g. x <- as.POSIXct("2002-02-02 02:02") Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format It looks to be linked to localtime but when I compiled
2008 Jun 20
1
Some help with dates.
Hey, I'm new to R but familiar with other programming languages. Basically, I want to store an array of dates. For each of these dates I want to store only the day of the week and the hour. So for example: "Monday 12" would be Monday at 12 o'clock and "Tuesday 20" would be Tuesday at 8 p.m. Alternatively it could be stored as 0-6 for Sunday to Saturday. So Tuesday
2011 Jul 14
2
cbind in aggregate formula - based on an existing object (vector)
Hello! I am aggregating using a formula in aggregate - of the type: aggregate(cbind(var1,var2,var3)~factor1+factor2,sum,data=mydata) However, I actually have an object (vector of my variables to be aggregated): myvars<-c("var1","var2","var3") I'd like my aggregate formula (its "cbind" part) to be able to use my "myvars" object. Is it
2006 May 21
1
POSIX, time zone and Windows
Dear Listers, Apologize to pile up on the 'tz' issue in POSIX objects. I have a 'simple' thing on which I must make up my mind but cannot do it from the existing R-help threads. I am currently working on dog telemetry in China, and download time information from GPS collars. I would like to set up the corresponding POSIXxx variables in R to a given time zone. Eg Pekin
2011 Apr 18
1
using "aggregate" when variable names contain spaces
Hello! my data set has many variables. Unfortuantely, many of those variables contain spaces in their names. I need advice on: how to refer to variable names in the formula for "aggregate". See example below: ### Generating example data set: mydate = rep(seq(as.Date("2008-12-01"), length = 3, by = "month"),4) value1=c(1,10,100,2,20,200,3,30,300,4,40,400)
2008 Jul 24
1
time zone - best way to shift hours
I frequently work with hourly data in GMT format, and ensure that any data I read into R are expressed in GMT through as.POSIXct(mydate, tz = "GMT"). I am interested in processing air pollution data in GMT where where peaks in emissions (say from road traffic sources) tend to occur at the same LOCAL time each day. I am interested in calculating mean concentrations by hour of day i.e.
2011 Jan 30
4
Extract time only from POSIXlt object
How can I extract only the time component from an POSIXlt object? For example if I try the following it still returns both the date and time... >as.POSIXlt(tr.date[1]) [1] "2010-10-18 21:46:53" >as.POSIXlt(tr.date[1],"%H:%M:%S") [1] "2010-10-18 21:46:53" round and trunc don't help... is there an "as.Time" equivalent to as.Date ? Thanks,
2011 Apr 04
2
merging 2 frames while keeping all the entries from the "reference" frame
Hello! I have my data frame "mydata" (below) and data frame "reference" - that contains all the dates I would like to be present in the final data frame. I am trying to merge them so that the the result data frame contains all 8 dates in both subgroups (i.e., Group1 should have 8 rows and Group2 too). But when I merge it it's not coming out this way. Any hint would be