Displaying 19 results from an estimated 19 matches similar to: "Efficient selection and alteration of dataframe records"
2007 Oct 17
1
passing arguments to functions within functions
Dear R Users,
I am trying to write a wrapper around summarize and xYplot from Hmisc
and am having trouble understanding how to pass arguments from the
function I am writing to the nested functions.
There must be a way, but I have not been able to figure it out.
An example is below.
Any advice would be greatly appreciated.
Thanks, Dan
# some example data
df=expand.grid(rep=1:4,
2018 Jan 19
2
Split charts with ggplot2, tidyquant
So the general strategy for getting these into separate panels in ggplot
is to have a single variable that will be your response and a factor
variable that indexes which original variable it came from. This can be
accomplished in many ways, but the way I use is with the melt() function
in the reshape2 package.
For example,
library(reshape2)
plotDF <- melt(SPYdf,
??? ??? ??? ??? ??? ???
2013 Apr 11
1
Adding time series to time graphs
Hello: I have done this before but cannot figure out how to do it again.
I would like to graph campaign evolution of news stories on certain topics. The campaign time period is as follows:
campaign<-seq.Date(from=as.Date('2011-09-06'), to=as.Date('2011-10-5'), by=1)
I have a table of newspaper story frequencies containing a certain word that can be turned into a data.frame
2018 Jan 19
0
Split charts with ggplot2, tidyquant
Hi Charlie,
Thanks. This is helpful. As mentioned in my original question, I want to be
able to plot a few such charts on the same page,
say a 2 x 2 grid with such a chart for each of 4 different stocks. Using
your solution I accomplished this by making
a list pLst of your ggplots and then calling cowplot::plot_grid(
plotlist=pLst, nrow=2, ncol=2 ) That worked fine.
The one issue I have is that
2018 Jan 20
2
Split charts with ggplot2, tidyquant
For this kind of control you will probably need to move to base graphics
and utilize the `fig` argument in par(), in which case you would want to
run the plot() command twice: once with your first outcome and once with
your second, changing the par() settings before each one to control the
size.
On 01/19/2018 01:39 PM, Eric Berger wrote:
> Hi Charlie,
> Thanks. This is helpful. As
2018 Jan 20
0
Split charts with ggplot2, tidyquant
That (the need for base graphics) is false. It certainly **can** be done in
base graphics -- see ?layout for a perhaps more straightforward way to do
it along the lines you suggest.
However both lattice and ggplot are based on grid graphics, which has a
similar but slightly more flexible ?grid.layout function which would allow
one to size and place subsequent ggplot or lattice graphs in an
2018 Jan 21
1
Split charts with ggplot2, tidyquant
Thanks for the reminder about lattice! I did some searching and there's
a good example of manipulating the size of subplots using the `position`
argument (see pp. 202-203 in the Trellis Users Guide:
http://ml.stat.purdue.edu/stat695t/writings/Trellis.User.pdf). This is
not within the paneling environment with the headers like in other
trellis plots though, so you'll have to do a bit
2018 Jan 18
0
Split charts with ggplot2, tidyquant
Hi Charlie,
I am comfortable to put the data in any way that works best. Here are two
possibilities: an xts and a data frame.
library(quantmod)
quantmod::getSymbols("SPY") # creates xts variable SPY
SPYxts <- SPY[,c("SPY.Close","SPY.Volume")]
SPYdf <- data.frame(Date=index(SPYxts),close=as.numeric(SPYxts$SPY.Close),
2018 Jan 18
3
Split charts with ggplot2, tidyquant
Could you provide some information on your data structure (e.g., are the
two time series in separate columns in the data)? The solution is fairly
straightforward once you have the data in the right structure. And I do
not think tidyquant is necessary for what you want.
Best,
Charlie
--
Charles Redmon
GRA, Center for Research Methods and Data Analysis
PhD Student, Department of Linguistics
2011 Apr 15
1
how to add two data.frame with the same column but different row numbers
Hi all,
Suppose I have 2 data.frame , a and b, how can I add them together to get c?
Thanks
> a
A
a 1
b 2
c 3
> b
A
a 6
c 1
> c
A
a 7
b 2
c 4
--
Best,
Zhenjiang
[[alternative HTML version deleted]]
2012 Sep 03
1
combing list objects
Hi,
I am trying to combine a long list but I can't work out how to do it, for
example:
abun<-list(rep(0,5),rep(0,7),rep(0,4),rep(0,10))
nb<-c(5,5,1,8)
fill.abun <- function(x, y) {
set <- sample(1:length(x), size = y)
x[set] <- rlnorm(length(set))
return(x)
}
abun <- mapply(fill.abun, abun, nb)
abun
## I want all the data in one
2012 Sep 28
1
Anova and tukey-grouping
Hello,
I am really new to R and it's still a challenge to me.
Currently I'm working on my Master's Thesis. My supervisor works with SAS
and is not familiar with R at all.
I want to run an Anova, a tukey-test and as a result I want to have the
tukey-grouping ( something like A - AB - B)
I came across the HSD.test in the agricolae-package, but... unfortunately I
do not get an output
2009 May 01
3
adding zeros to dataframe
Greetings,
I am new to R and am hoping to get some tips from experienced R-programmers.
I have a dataset that I've read into R as a dataframe. There are 5 columns: Plot location,species name, a species number code (unique to each species name), abundance, and treatment. There are 272 plots in each treatment, but only the plots in which the species was recorded have an abundance value. For
2009 Jun 26
1
50993 point distance matrix, too big to as.matrix, looking for another way to calculate point-level summary
Hello, Im working on a 50933 point count bird abundance dataset. I've
succeeded in calculating a distance matrix for this entire set, but I don't
have sufficient memory to convert this to a matrix, as below...
abun.dist <- dist(abun.mat[1:50993,1:235)
test <- rowMeans(as.matrix(abun.dist))
Error in matrix(0, size, size) : too many elements specified
ive been able to run a hclust()
2005 Nov 12
0
Error message in polr
Dear members of the list,
I'm fitting ordinal regressions using polr, and in some models I
get the error copied below. Dependent variable is an ordered factor
of bird abundance categories, and predictors are continuous habitat
variables.
> ro6 <- polr(formula = abun ~ InOmbrot + Oliva.OC + ToCultAr +
DivCulArb + AltitMax + COORXY)
> summary(ro6)
Re-fitting to get Hessian
2011 Nov 07
2
ordination in vegan: what does downweight() do?
Can anyone point me in the right direction of figuring out what downweight()
is doing?
I am using vegan to perform CCA on diatom assemblage data. I have a lot of
rare species, so I want to reduce the influence of rare species in my CCA. I
have read that some authors reduce rare species by only including species
with an abundance of at least 1% in at least one sample (other authors use
5% as a
2010 Apr 13
0
dbFD computing distinct species wrong?
Hi everyone,
I am working with the dbFD function of the FD package, and there's something
funny happening with the value of sing.sp in the output. Basically, I have
a species-function matrix and a community matrix. One site in particular
has 6 species, 4 of which have identical functional coding. I thus expect
nbsp = 6 and sing.sp = 2 for this site. However, nbsp = sing.sp = 6. This
2016 Apr 11
1
Correlation between package output
Hello
I'm currently using the dbFD function of the FD package and i'm having some
things that I can't do.
Is there any way to check the relations between dbFD indexes?
Function cor for example? I can't manage to put the informations correctly
dbFD function gives a lot of output (indexes - nbsp, sing.sp, FRic, FEve,
FDiv, FDis and RaoQ). I want to see the relationships between
2018 Jan 10
0
Problem with dbFD function in FD library
Dear all,
I have a question about FD package. I?m trying to calculate functional
diversity indices using insect data. My trait data includes dispersal
ability (0, 0.5, 1), body size (continuous) and five feeding guilds coded
as in percentages (for example; 0,0,0.5,0.5,0) since some of the species
can have two different feeding guilds. However, the package only calculates
when I run ?calc.Frich=