Displaying 20 results from an estimated 2000 matches similar to: "subset dataframe by rows using character vector?"
2008 Nov 24
3
multiple plots in R
Hi, I just try to draw multiple plots in one page using R, I used par
command. For example I have 7 plots, but instead of arranging them in
the default way
plot1 plot2 plot3
plot4 plot5 plot6
plot7
I want them in this order
plot1 plot2 plot3
plot4 plot5 plot6
plot7
Could somebody tell me how to do this, please? Thanks so many.
Suyan
2010 Aug 20
3
if-else function
Hi R people!
I am looking for some suggestions writing an if-else function.
The idea is to characterize different plots containing counts of
variables (here parasites). If a plot has a count equal or higher than
4 for any parasite the function should return a 1 else a 0. Later I
can loop the function over all plots.
Here I have a little subset of my data:
VariablePAR Plot1
2012 May 10
6
averaging two tables (rows with columns)
Hi R user,I am struggling to figure out on how I can calculate the average from the two tables in R. Any one can help me? really your help would be grateful- I am spending so much time to figure it out. It should not be so hard, I think.
I have very big data but I have created a hypothetical data for simplification.
for example
I have : table 1
table 1: species occurance data
2007 Dec 09
1
Saving lattice plot as a PDF
Hi there,
I need to save a series of lattice plots as a PDF,
this is my code so far:
windows(height=8,width=6)
plot.new()
library('grid')
lattice.options(layout.heights=list(top.padding=list(x=0.15,
units="inches")))
print(plot1, split=c(1,1,2,3), more=TRUE)
print(plot2, split=c(1,2,2,3), more=TRUE)
print(plot3, split=c(1,3,2,3), more=TRUE)
print(plot4, split=c(2,1,2,3),
2007 Dec 10
2
Viewport and grid.draw
Hi Deepayan and everyone,
I need to add a common legend to a group of latice
graphs, I have tried different ways using viewport and
grid.draw without success.
Here is what I have:
plot.new()
library(grid)
library('IDPmisc')
print(plot1, split=c(1,1,2,4), more=TRUE)
print(plot4, split=c(2,1,2,4), more=TRUE)
print(plot2, split=c(1,2,2,4), more=TRUE)
print(plot5, split=c(2,2,2,4),
2011 Jul 19
5
multiple plots in single frame: 2 upper, 1 lower
Hi,
par(mfrow = c(2,2))
will create a 2x2 window that I can use to plot 4 diferent figures in:
[plot1 plot2]
[plot3 plot4]
But how can do 3 so that the bottom spans the width of the upper two:
[plot1 plot1]
[p l o t 3]
Is this possible in R?
--
View this message in context: http://r.789695.n4.nabble.com/multiple-plots-in-single-frame-2-upper-1-lower-tp3679574p3679574.html
Sent from the R
2007 May 31
4
Aggregate to find majority level of a factor
I want to use the aggregate function to summarize data by a factor (my
field plots), but I want the summary to be the majority level of another
factor.
For example, given the dataframe:
Plot1 big
Plot1 big
Plot1 small
Plot2 big
Plot2 small
Plot2 small
Plot3 small
Plot3 small
Plot3 small
My desired result would be:
Plot1 big
Plot2 small
Plot3 small
I
2005 Dec 26
4
lme X lmer results
Hi,
this is not a new doubt, but is a doubt that I cant find a good response.
Look this output:
> m.lme <- lme(Yvar~Xvar,random=~1|Plot1/Plot2/Plot3)
> anova(m.lme)
numDF denDF F-value p-value
(Intercept) 1 860 210.2457 <.0001
Xvar 1 2 1.2352 0.3821
> summary(m.lme)
Linear mixed-effects model fit by REML
Data: NULL
AIC BIC
2009 Jul 27
1
Cross-validating two matrices
Hello,
I am trying to help a colleague with an R problem (see below) to whit
I can only generate a very inelegant solution. Any advice would be
welcome.
Thanks,
Brian
If you have two matrices, say a species by trait matrix (Matrix 1
below) and a plot by species matrix (Matrix 2 below), is there a
straightforward way to prune one matrix so that the species list
matches those in a
2012 Dec 13
3
Repeat elements of matrix based on vector counts
I have two dataframes (df) that share a column header ("plot.id"). In the
1st df, "plot.id" records are repeated a variable number of times based on
the number of trees monitored within each plot. The 2nd df only has a
single record for each "plot.id", and contains a variable named "load" that
is collected at the plot-level and is only listed once per plot
2008 Jan 12
2
Lattice equivalent of par(mfrow = )
Dear r-helpers,
Does anyone have a straightforward example of putting together three
unrelated (expect for a common y-axis) xyplot() figures in what would
be in base graphics a par(mfrow = c(1, 3)) arrangement?
_____________________________
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400 Charlottesville, VA 22904-4400
Parcels: Room 102
2009 Sep 24
1
Creating grid graphics with grid.layout
Hi,
I recently created a function which uses grid with a viewport
constructed with grid.layout() to position four plots on a plot device.
My question is what's the best way to programatically traverse each
element of the viewport?
The grid is 5x5 and the four plots occupy positions (2,2), (4,2), (2,4),
and (4,4).
Here's the viewport code:
pushViewport(
viewport(
2011 Nov 15
1
grid.arrange, grid.layout - legend, global y axis title
Hello,
I created several plot with ggplot2 dev mode.
Now I want to combine the plots in a grid
e.g. 2x2 with a fixed size of the output.
What I am doing at the moment is:
grid.newpage()
pushViewport(viewport(layout = grid.layout(nrow=2, ncol=2,
widths = unit(c(7.5,6.5), "cm"),
heights = unit(rep(5, 2), "cm"))))
print(plot1, vp = viewport(layout.pos.row = 1,
2011 Mar 08
4
beamer overlays with Sweave?
This may be asking too much, but I'm wondering if anyone has a
solution (even a hack) for creating multiple (overlay) plots in an
Sweave file and post-processing the overlays in beamer appropriately.
For example, suppose I have a series of figure blocks in my .Rnw file:
<<plot1,fig=TRUE>>=
[stuff]
@
<<plot2,fig=TRUE>>=
[stuff]
@
<<plot3,fig=TRUE>>=
2013 Jan 22
1
How to remove the vertical space between two graps
Hi,
I have created a barplot using the following code.
a<-c(11,23,15,34,42,31)
m<-matrix(a,nrow=2)
m[2,]<-(-1)*m[2,]
par(mar=c(4,4,4,0))
barplot(m[2,],horiz=T)
par(mar=c(4,0,4,2))
barplot(m[1,],horiz=T,col="black")
and the plot obtained is shown in "plot1.tiff".
I was not willing to see the gap (vertical space) between two graphs.
How can I achieve it?
Further
2012 Nov 27
1
Plot from a jpeg
Hi all,
I know that I can for instance draw to plots in one using
nf<-layout(matrix(c(1,2),1,2,byrow=FALSE))
Imagine I have 3 files:
plot1.jpeg
plot2.jpeg
plot3.jpeg
Anyone knows if I can read them and put on one colum and three rows reading
directly from the jpeg file?
Many Thanks
[[alternative HTML version deleted]]
2003 Oct 22
1
0-only-rows in correspondence analysis
Hello,
I am looking for a workaround of "species empty" plots in a correspondence
analysis.
I tried to do a community structure analysis with a ca via decorana(), ca()
and CAIV(), but none of them allow 0 only-rows.
I have species (abs./pres) in columns and sites in rows
sp1 sp1 sp3 ...
plot1 0 1 1
plot2 0 0 0
plot3 1 0 1
.....
but on some plots no
2008 Jan 25
4
Function for translation of a list into a matrix as used by ordination?
Hello.
Does anyone know of an existing function that takes a list in the form of:
Plot1 Species1 Abundance1
Plot1 Species2 Abundance2
Plot2 Species1 Abundance1
Plot2 Species3 Abundance3
.
.
.
PlotN SpeciesN AbundanceN
and translates into a matrix in the form of
Species1 Species2.... SpeciesN
Plot1 Abundance1 Abundance2... AbundanceN
Plot2 Abundance1
2010 Jun 30
5
plot focus
I am doing calculations in a loop and then plotting the results by adding a
point to each of 2 charts at the end of the loop. Its very informative as
you can see the progression through time.
My problem is, if I have 2 plots, I don't know how to get the focus back to
the first plot.
layout(matrix(c(1,2)))
plot(iris[,1],col="red",) #plot1
plot(iris[,3],col="blue") #plot2
2004 Sep 09
2
Skipping panels in Lattice
Dear all,
I wish to generate a lattice boxplot which skips an empty cell in a design.
I have trawled r-help, scruitinized xyplot(lattice) help page, and merrily
reproduced examples of using skip from a couple of previous r-help queries
and the example given in Pinheiro & Bates. But I must be missing something...
Here's an example (running R 1.9.1 on Win2k):
# generate some data
df1