Displaying 20 results from an estimated 3000 matches similar to: "Doing operations by grouping variable"
2011 Mar 01
2
Does POSIXlt extract date components properly?
I would like to use POSIX classes to store dates and extract components of
dates. Following the example in Spector ("Data Manipulation in R"), I
create a date
> mydate = as. POSIXlt('2005-4-19 7:01:00')
I then successfully extract the day with the command
> mydate$day
[1] 19
But when I try to extract the month
> mydate$mon
[1] 3
it returns the wrong month. And
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
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 <-
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 =
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
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) =
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
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))
2018 Jan 02
1
httr::content without message
Thanks to all that replied. I had just looked through the httr code and sure enough for a .csv mime time it calls readr::read_csv(). The httr::content docs suggest not using automatic parsing in a package, rather to determine mime type and parse yourself and Ben's suggestion also works if I do:
junk <- readr::read_csv(r1$content, col_types = cols())
Perfect. Using httr rather than
2018 Jan 02
0
httr::content without message
Ahoy!
That's a message generated by the readr::read_table() function (or it's friends). You can suppress it a number of ways, but this should work as httr::content() will pass through arguments, like col_types = cols(), to the file reader.
junk <- httr::content(r1, col_types = cols())
See more here...
https://blog.rstudio.com/2016/08/05/readr-1-0-0/
2007 May 09
1
How to remove outer box from Wireframe plots?
I would like to remove the outermost box from my wireframe plots -- this is
the box that is automatically generated, and is not the inner cube that
frames the data. There was a thread on this 4 yrs ago but none of the fixes
work (e.g., grid.newpage(), grid.lines(gp = gpar(col = NA)) or
par.box=list(col=1),col=NA. These just make the data or the cube disappear.
Has anyone solved this issue?
2008 Dec 03
1
how do I eliminate excess levels in lattice contourplot key / legend?
I'm working on a contourplot( ) graph, the subject of several previous
posts to this list. The contours express probabilities from 0 - 1, but the
key that is automatically generated by contourplot pads the probability
scale with values that are impossible (i.e, range goes from -0.2 to 1.2),
which will be confusing to those who view the plot. How can I get the
scale to just run from 0 - 1?
2018 Mar 22
0
how to add a child to a child in XML
Hi,
It's a reasonable question. The answer is that it actually is included, but there are many instances across packages where multiple functions are documented on a single help page. The following brings up such a page... (for XML_3.98-1.9)
> library(XML)
> ?newXMLNode
You can see the same on line...
https://www.rdocumentation.org/packages/XML/versions/3.98-1.9/topics/newXMLDoc
2018 Mar 22
1
how to add a child to a child in XML
Just to clarify and hopefully catch the attention of the maintainer:
The newXMLNode function is not mentioned in:
https://cran.r-project.org/web/packages/XML/XML.pdf
which supposedly describes all functions in the package.
Stephen
From: Ben Tupper [mailto:btupper at bigelow.org]
Sent: Thursday, March 22, 2018 10:40 AM
To: Bond, Stephen
Cc: r-help
Subject: Re: [R] how to add a child to a
2017 Dec 16
0
Generating help files for a function
Hi,
If you are using roxygen-style function documentation then why not use devtools::document()?
Ben
> On Dec 16, 2017, at 9:00 AM, Erin Hodgess <erinm.hodgess at gmail.com> wrote:
>
> Hello everyone!
>
> I'm in the process of writing a package, and I'm using the lovely "R
> Package" book as a guideline.
>
> However, in the midst of my
2018 Mar 22
2
how to add a child to a child in XML
Big thanks. newXMLNode works great. Wonder why it is not included in the documentation.
There is newXMLDoc and newXMLNamespace, but no mention of newXMLNode.
Stephen
From: Ben Tupper [mailto:btupper at bigelow.org]
Sent: Wednesday, March 21, 2018 6:18 PM
To: Bond, Stephen
Cc: r-help
Subject: Re: [R] how to add a child to a child in XML
Hi,
XML doesn't use the `$` to access child nodes.
2017 Sep 06
1
rgdal error when trying to import raster
Indeed, Ben, but the question was something more like it is not a Dependency, just Suggested, so why the error...
John:
If you read the Introduction to the 'raster' package vignette, it indicates that some input formats are supported within the raster package and some rely on other packages. Clearly the attempt to read a TIFF was an example of the latter. Had you used a different input
2009 Jan 12
2
problems with download.file() from ftp?
Dear list,
I am trying to download a text file from an ftp site using download.file().
I used the following code:
url <- "ftp://ftp.wcc.nrcs.usda.gov/data/snow/snow_course/table/history/idaho/13e19.txt"
dest <- "c:/test/downloadtest.txt"
download.file(url, dest)
I get this error message, indicating that R is unable to open the connection:
trying URL