similar to: lattice: add vertical lines in xyplot

Displaying 20 results from an estimated 9000 matches similar to: "lattice: add vertical lines in xyplot"

2008 Jul 03
1
ggplot2 legend for vertical lines
Dear all, The following example code produces a graph with ggplot2, to which I add several vertical lines of arbitrary colors. I am not satisfied with the legend: it automatically adds some vertical lines which I'd rather not see (they confuse the reader rather than add information in this case). > library(ggplot2) > dfr <- data.frame(values = sin(1:50/10), > fact =
2008 Oct 07
2
panel.groups: use group.number to define colors
Dear list, I've been trying this for a few hours and I just don't understand how lattice works with groups and subscripts. Consider the following example, > xx <- seq(1, 10, length=100) > x <- rep(xx, 4) > y <- c(cos(xx), sin(xx), xx, xx^2/10) > fact <- factor(rep(c("cos", "sin", "id", "square"), each=100)) > fact2
2010 Nov 09
1
ggplot2: facet_grid with different vertical lines on each facet
Hello, I am plotting many histograms together using facet_grid in ggplot2. However, I want to then add a vertical line to each histogram, or facet, each of which vertical lines are at different x-values. The following example adds all vertical lines to each facet: ggplot(data,aes(values)) + geom_histogram() + facet_grid(.~variable) + geom_vline(xintercept=c(5,10,15)) How can I add a vertical
2008 Jan 17
2
Converting plots to ggplot2
Hello Hadley, I am trying to reproduce the following with ggplot: a <- seq(0, 360, 5)*pi/180 ; a ac <- sin(a + (45*pi/180)) + 1 ; ac plot(a, ac, type='b', xaxt = "n") axis(1, at=seq(0,6,1), labels=round(seq(0,6,1)*180/pi),1) abline(v=c(45*pi/180, 225*pi/180)) I can get the basic plot: p <- qplot(a, ac, geom=c('point', 'line')) ;
2008 Dec 02
1
legend idea for latticeExtra
Dear list, I've written a small utility function to add arbitrary legend(s) to a lattice graph (or a combination of them), much like the legend function of base graphics. I though perhaps it could be useful to someone else, or improved by suggestions. I understand this goes against the lattice paradigm somewhat, in that you short-cut the link between group variables and the
2008 Dec 01
2
align two lattice plots with grid
Dear list, I need to align two plots on top of each other for comparison (they only have the x-axis in common). When the y-labels have a different extent, I cannot find a way to align the x-axes, as illustrated below, > library(grid) > library(lattice) > x <- seq(0, 10, length=100) > y <- sin(x) > y2 <- 10*sin(x) > f <- rep(c("1", "2"),
2009 Nov 12
1
Rearranging long tables, Sweave, xtable, LaTeX
Dear R-users, consider the two following outputs, ## 1 and ## 2 \begin{Scode}{Setup, echo = FALSE, print = FALSE, eval = TRUE} with(expand.grid(Fact1 = 1:3, Fact2 = 1:40), table(Fact1, Fact2)) ## 1 xtable(with(expand.grid(Fact1 = 1:3, Fact2 = 1:40), table(Fact1, Fact2))) ## 2 \end{Scode} The first line with(expand.grid(Fact1 = 1:3, Fact2 = 1:40), table(Fact1, Fact2))
2009 Jan 23
3
Table Modification
I am trying to construct a two-way table where, instead of printing the two-way frequencies in the table, I would like to print the values of a third variable that correspond to the frequencies. For example, the following is easily constructed in R > fact1 <- factor(sample(LETTERS[1:3],10,replace=TRUE)) > fact2 <- factor(sample(LETTERS[25:26],10,replace=TRUE)) > fact3
2008 Dec 10
4
tapply within a data.frame: a simpler alternative?
Dear list, I have a data.frame with x, y values and a 3-level factor "group", say. I want to create a new column in this data.frame with the values of y scaled to 1 by group. Perhaps the example below describes it best: > x <- seq(0, 10, len=100) > my.df <- data.frame(x = rep(x, 3), y=c(3*sin(x), 2*cos(x), > cos(2*x)), # note how the y values have a different
2004 Aug 11
1
Fwd: Enduring LME confusion… or Psychologists and Mixed-Effects
In my undertstanding of the problem, the model lme1 <- lme(resp~fact1*fact2, random=~1|subj) should be ok, providing that variances are homogenous both between & within subjects. The function will sort out which factors & interactions are to be compared within subjects, & which between subjects. The problem with df's arises (for lme() in nlme, but not in lme4), when
2007 May 15
3
aov problem
I am using R to make two-way ANOVA on a number of variables using g <- aov(var ~ fact1*fact2) where var is a matrix containing the variables. However the outcome seem to be dependent on the order of fact1 and fact2 (i.e. fact2*fact1) gives a slightly (factor of 1.5) different result. Any ideas why this is? Thanks for any help Anders
2008 Jul 25
3
melting a list: basic question
Dear list, I'm trying to use the reshape package to perform a merging operation on a list of data.frames as illustrated below, > a <- 1:10 > example <- list( data.frame(a=a, b=sin(a)), data.frame(a=a, > b=cos(a)) ) > > melt(example, id = a) this produces the desired result, where the data.frames have been coerced into one with a common identifier variable
2004 Aug 10
4
Enduring LME confusion… or Psychologists and Mixed-Effects
Dear ExpeRts, Suppose I have a typical psychological experiment that is a within-subjects design with multiple crossed variables and a continuous response variable. Subjects are considered a random effect. So I could model > aov1 <- aov(resp~fact1*fact2+Error(subj/(fact1*fact2)) However, this only holds for orthogonal designs with equal numbers of observation and no missing values.
2008 Apr 12
1
lm() of one matrix against another
Hello R list, I have two matrices of identical dimensions, and I want to fit a straight line for each pair of columns and plot the resulting lines. I got it to work with a for loop, but there must be a better way, > n<-5 > N<-10 > > data.x<-matrix(1:(n*N),ncol=n) > data.y<-matrix(1:(n*N) + rnorm(n*N,sd=1),ncol=n) > >
2008 Aug 25
1
lattice : using both strip and strip.left
Dear all, I'm routinely using lattice and ggplot2, I wish to create a lattice theme that looks not too dissimilar to ggplot's defaults so I can include both graphs in a document with a consistent look. To illustrate my questions, consider the following example: > library(ggplot2) > library(lattice) > > # example data > x <- seq(0, 10, len = 100) > y1 <-
2007 Dec 30
1
adding a function after package.skeleton()
Dear R helpers, I've successfully created a package 'constants' using package.skeleton () with one dataframe and a few functions. However, now that I want to add some functions and data to the package, I run into a problem. I ran prompt(...) and moved + edited the resulting .Rd files as appropriate (I believe). The log file from RCMD check constants does indicate a few
2008 May 23
2
[slightly off topic] Sweave with markdown
DeaR list, Has anyone tried to mix the Sweave paradigm with the Markdown[*] (and co.) syntax? Would this be hard to implement? My tiny understanding of Sweave is that one can define new drivers for the text part, while some functions that deal with the R code would not require any modification. Here's the reason I'm interested in Mardown for a driver. I've been orbiting
2008 Aug 09
2
levels values of cut()
Dear list, I have the following example, from which I am hoping to retrieve numeric values of the factor levels (that is, without the brackets): > > x <- seq(1, 15, length=100) > y <- sin(x) > > my.cuts <- cut(which(abs(y) < 1e-1), 3) > levels(my.cuts) hist() does not suit me for this, as it does not necessarily respect the number of breaks. getAnywhere
2008 Feb 14
1
write output in a custom format
Hi, I need to create a text file in the following format, > 1 100.0 0 > 0 0 > 1 1 > 0 0 > 1 1 > # > 1 100.0 0 > 0 0 > 0 1 > 1 0 > 1 1 ... where # is part of the format and not a R comment. Each block (delimited by #) consists of a first line with three values, call it dose, and a list of (x,y) coordinates which are a matrix or data.frame, >
2007 Dec 28
1
unit attribute to list elements
Hi, I've started my own (first) package, part of which consists in listing common physical constants (Planck's constant, the speed of light in vacuum, etc). I'm wondering what would be a good way of dealing with pairs of value/unit. > constants <- list( cel = 2.99792458e8 , #m/s > Z0 = 376.730313461, #ohm > eps0 = 8.854187817e-12,#F/m > mu0 = 4*pi*1e-7,#N/A^2