similar to: ggplot2: legend

Displaying 20 results from an estimated 1000 matches similar to: "ggplot2: legend"

2012 Jul 02
5
ggplot: dodge positions
Dear all, I want to get a series of boxplots (grouped by two factors) and I want to overlay the original observations and the following code does almost what I want: library(ggplot) ddf <- data.frame(x=factor(rep(LETTERS[1:4], each=30)), y = runif(120,0,10), grp = factor(rep(rep(1:3, 10), 4))) ggplot(ddf, aes(x, y, colour=grp)) + geom_boxplot() + geom_point() Yet the position of the points
2012 Oct 31
1
aggregate.formula: formula from string
Dear all, I want to use aggregate.formula to conveniently summarize a data.frame. I have quiet some variables in the data.frame and thus I don't want to write all these names by hand, but instead create them on the fly. This approach has the advantage that if there will be even more columns in the data.frame I don't have to change the code. I've hence tried to construct a formula
2012 Dec 10
1
Sweep out control
Dear all, Assume that I have the following data structure: d <- expand.grid(subj=1:5, time=1:3, treatment=LETTERS[1:3]) d$value <- 10 ^ (as.numeric(d$treatment) + 1) + 10 * d$subj + d$time d$value2 <- 100000 + d$value where d$treatment == "C" stands for my control group. What I want to achieve now is to subtract the values corresponding to d$treatment == "C" from
2010 Jun 21
2
list() assigning the same value to two items
Hi everybody, I'd like to have a list with two elements, where both elements have the same value: z <- list(a=1, b=1) If it happens, that I've to change the value, I've to assure that I change both. This is error prone. Hence, a better way to achieve this is to define: tmp <- 1 z <- list(a=tmp, b=tmp) Now, I'm wondering if it is possible to make this more compact: z
2016 Apr 09
1
Run script R
hi all ,? i have an problem in script R . But when I execute the script R I face this error . can you help me please ???error:----------------------------------------- Error in FUN(X[[i]], ...) :?? Theme element 'text' has NULL property: margin, debugIn addition: Warning messages:1: Removed 361 rows containing non-finite values (stat_smooth).?2: Removed 361 rows containing missing values
2010 Jul 20
1
apply: return list of matrices
Hi everybody, Suppose we have the following data structure: ddf <-data.frame(a=rep(1:4,3), b=rep(paste("p", 1:3, sep=""), each=4), c=c(1,0,0,1,1,1,0,1,1,1,1,1)) I want now to make a contingency table for each pair of values of p, i.e. a contingency table for each of the pairs (p1,p2), (p1,p3) and (p2,p3). The result should be given as a list of matrices: # [[1]]
2013 May 14
1
Tamaño plots y calidad en grafico ggplot
Hola a tod en s, bueno, un poco al hilo de un mensaje anterior, reformulo la pregunta y pongo código completamente reproducible, a ver si hay más suerte. Estoy con un informe y hay que hacer algunos gráficos con datos diferentes con ggplot2, y hay que poner el mismo tamaño para todos ellos. El problema es que R cambia automáticamente el tamaño del área de trazado y el margen en función de
2017 Sep 26
2
Adding non-data line to legend ggplot2 Maximum Contaminant Level
Hello everyone, I have a plot showing chloride concentrations for various point over time. I also have a dotted line that show the Secondary Maximum Contaminant Level (my screening limit) on the graphs at 250 mg/L. But I can not figure out how to include the dotted line / Secondary Maximum Contaminant Level in the legend. Any thoughts? My code is as following and is linked to my data on the
2010 Dec 13
1
predict.lm[e] with formula passed as a variable
Dear all, In a function I paste a string and convert it to a formula which I pass to lm[e]. The idea is to write a function which takes the name of the response variable and the explanatory variable and the data frame as an argument and calculates an lm[e]. (see example below) This works fine, but if I want to make a prediction on this model, R complains that the object holding the formula
2011 Jan 05
1
Minimum of an ordered factor
Hi everybody, Is there a particular reason, why this code does not work as intended: z <- factor(LETTERS[1:3], ordered = TRUE) u <- 4:6 min(z[u > 4]) Error in Summary.factor(2:3, na.rm = FALSE) : min not meaningful for factors I agree that min is indeed not meaningful for not ordered factors, but it makes sense for ordered factors. Especially since z[3] <
2002 Sep 23
2
R crash with internet2.dll
Hi, I'm using: platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 5.1 year 2002 month 06 day 17 language R and I would like to apply: > update.packages() trying URL
2010 Aug 30
1
lattice: limits in reversed order with relation="same"
Hi everybody, I want an x-axis which has xlim=c(max, min) rather than xlim=c(min, max) in order to reflect the type of the process (cooling): library(lattice) myprepanel <- function(x,y,...) list(xlim=rev(range(x))) x <- rep(1:10, 100) z <- factor(sample(10, 1000, T)) y <- rnorm(1000, x, as.numeric(z)) xyplot(y~x|z, scales=list(x="free"), prepanel=myprepanel) This works
2011 Oct 21
1
droplevels: drops contrasts as well
Dear all, Today I figured out that there is a neat function called droplevels, which, well, drops unused levels in a data frame. I tried the function with some of my data sets and it turned out that not only the unused levels were dropped but also the contrasts I set via "C". I had a look into the code, and this behaviour arises from the fact that droplevels uses simply factor to drop
2010 Aug 23
2
Sum a list of tables
Hi all, In R it is possible to sum tables: > (a <- table(rep(1:3, sample(10,3)))) 1 2 3 2 5 7 > a+a 1 2 3 4 10 14 Now suppose that I have a list of tables, where each table counts the same things > k <- list(a,a,a) How can I sum all tables in k? > do.call(sum, k) [1] 42 does not work since it sums over each table. > do.call(`+`, list(a,a)) 1 2 3 4 10
2013 Feb 15
1
Why no line? (ex. from Andy Filed book)
The following script is written by the author of a book on R--Andy Field: You can also download the small datafile, hiccups.dat, from this address: http://www.sagepub.com/dsur/study/articles.htm The script: hiccupsData <- read.delim("Hiccups.dat", header = TRUE) hiccups<-stack(hiccupsData) names(hiccups)<-c("Hiccups","Intervention")
2010 May 04
1
Lazy evaluation in function call
Hi everybody, how is it possible to refer to an argument passed to a function in the function call? What I like to do, is something like f <- function(x,y) x+y f(2, x) # should give 4 The problem is of course that x is only known inside the function. Of course I could specify something like f(z<-2,z) but I'm just curious whether it is possible to use a fancy combination of eval,
2013 Sep 18
1
ggplot2: changing strip text in facet_grid and a legend text problem
Hi, Dummy data script and scripts are attached below. I would like to change the plot to look like this:
2013 Nov 04
1
ggplot2: Add '+' operator for aes (uneval) objects
Dear all, Is there a reason, why there is no +-operator for aes (i.e. uneval) objects (as there is for themes and gg objects)? I had a couple of cases where such an operator would be useful, for instance to combine the result of aes and aes_string in functions. Any flaws with the following proposition: `+.uneval` <- function(e1, e2) { dup <- names(e1) %in% names(e2) if (any(dup)) {
2009 Jul 06
3
Speed up code, profiling, optimization, lapply vs. loops
High everybody, currently I'm writinig a package that, for a given family of variance functions depending on a parameter theta, say, computes the extended quasi likelihood (eql) function for different values of theta. The computation involves a couple of calls of the 'glm' routine. What I'm doing now is to call 'lapply' for a list of theta values and a function, that
2020 Oct 23
0
How to shade area between lines in ggplot2
Hi Did you try google? I got several answers using your question e.g. https://stackoverflow.com/questions/54687321/fill-area-between-lines-using-g gplot-in-r Cheers Petr > -----Original Message----- > From: R-help <r-help-bounces at r-project.org> On Behalf Of Luigi Marongiu > Sent: Friday, October 23, 2020 9:59 AM > To: r-help <r-help at r-project.org> > Subject: