Displaying 20 results from an estimated 4000 matches similar to: "ggplot, qplot: alpha channel for colors corresponding to factor"
2009 Mar 31
1
ggplot: order of numeric factor levels?
Hi,
I'm having problems with qplot and the order of numeric factor levels.
Factors with numeric levels show up in the order in which they appear
in the data, not in the order of the levels (as far as I understand
factors!)
Here is a minimal example:
library(ggplot2)
y <- c(-1,2,0,0,-2,-1)
z <- factor(y,levels=c(-2,-1,0,1,2))
qplot(z)
For me, the resulting plot is ordered: -1,2,0,-2
2008 Oct 05
1
barchart for aggregated (sum) data in lattice?
Hi list,
I have data in a dataframe t1, with a column for different amounts
spent, a column what it was spent on, and a column with dates, from
which I create a new column with months.
Example:
amount <- rep(c(10,20,30),3)
what <- rep(c("food","books","cycling"),3)
when <- c(rep("2008-09-05",5),rep("2008-10-07",4))
t1 <-
2010 Aug 23
2
change order of plot panels in faceted ggplot/qplot
Hi,
I have a 5-paneled figure that i made using the facet function in
qplot (ggplot). I've managed to arrange the panels into two rows/
three columns, but for the sake of easy visual comparisons between
panels in my particular dataset, I want to have the two plots on the
bottom align on the right hand side of the figure instead of the left.
Here's an example:
m <-
2009 Sep 02
1
get function to return object "name"?
Dear list,
I've written a function that plots subjects. Something like:
myplot <- function(subject) { plot(subject) }
Subjects are vectors, e.g. ...
s1 <- c(200,200,190,180)
... and plotting them works fine, e.g. ...
myplot(s1)
Now I want to have "s1" etc appear in the plot title, but I don't know
how to refer to this generically (the object "name"? I tried
2012 Jun 27
3
qplot and colors (Please Help)
Please help:
I am using qplot as below and want to specify a different color scheme for race but dont know how, can someone show me.
Thanks in advance
Code and input file below:
library(ggplot2)
library(gridExtra)
d<-read.table("results", header=TRUE, fill=TRUE)
plot2<-qplot(X,Y,data=d,color=race,facets=TYPE~., xlab="X", ylab="Y") + theme_bw()
2009 Feb 26
1
ggplot2: labels points with different colors or idnumbers
Dear list,
Using ggplot2 I could produce both boxplot and points in the same plot but instead of points I would like to label the different
subjects with different colors or their idnumbers. Is there away to do it? Also how can I put three plots on the same graph with ggplot2?
mfrow=c(3,1) did not do the job.
> dat
group time id freq
1 1 00 0018 5.21
2 1 00 3026 3.13
2009 Mar 12
3
Unable to run smoother in qplot() or ggplot() - complains about knots
I get the following error when I run qplot()
qplot(grade, read,data = hhm.long.m, geom = c("point", "smooth"))
Error in smooth.construct.cr.smooth.spec(object, data, knots) :
x has insufficient unique values to support 10 knots: reduce k.
I am not sure how to tackle this problem. When I take a subsample (<
1000) than I am able to run that function but with my sample
2008 Mar 04
1
qplot (ggplot2) faceting histogram with missing values
Hi,
I've run into a difficulty with qplot function (in the ggplot2
package). I can facet histograms even when the faceting variable
contains missing values, but only so long as the faceting variable is
not a factor.
Example:
y1 <- rnorm(10)
x1 <- c(rep(1,5), rep(2,4), NA)
x2 <- factor(c(rep(1,5), rep(2,4), NA))
library(ggplot2)
qplot(y1, geom = "histogram", facets =
2006 Oct 27
2
qplot of ggplot package how to plot different size according to the values and not to the weights?
I have the following Data structure
$ step45 : Factor w/ 2 levels
$ obserror : num 6.2 6.2 5.6 6.6 6.6 ...
$ Mon : num 2.2 2.0 1.0 3.2 2.0 ...
$ inc.comp : num 4 5 2 5 5 5 5 5 4 4 ...
all I wanted to do is plotting Mon against obserror, the colors should
be by step45 and the size of the symbol should be according to inc.comp
so I did this:
2008 Jul 10
1
layout is to xyplot as ??? is to qplot
Playing with ggplot, something I'd promised myself I'd get around to. I've
the following scenario:
library(lattice)
library(ggplot2)
myData <- data.frame(
x = rnorm(100),
y = rnorm(100),
group = 1:4
)
xyplot(y ~ x | factor(group), data = myData, layout = c(2, 2))
qplot(x, y, facets = ~ group, data = myData)
In this code the lattice example gives me a 2x2 layout, whereas
2010 Feb 22
3
gsub patterns from vector elements w/out loop?
Dear list,
I have two vectors:
x <- c("one","two")
y <- paste(rep(x,2),"blah")
I want to replace all occurrences of each element of x in y with
something else, so that y looks like this:
y
[1] "something else blah" "something else blah" "something else blah"
[4] "something else blah"
I can do this using a loop:
for (
2010 Nov 29
1
cross tabulate variables by subject id
Dear list,
I have data like this:
dat1 <- data.frame(subject=rep(1:10,2),
cond1=rep(c("A","B"),each=5),
cond2=rep(c("C","D"),each=10),
choice=sample(0:1,10,replace=TRUE))
I would like to compare subjects' "choice" for (cond1=="A" &
cond2=="C") vs
2008 Sep 25
2
ggplot, qplot in loop
Dear List,
yes, me again trying to work with qplot ;-)
I would like to make several single plots within a loop, like this
(simplified and so on...):
trials <- c("A","B","C")
mycolours <- ("wheat","darkolivegreen","lightgreen",
2010 Aug 24
1
Index list by other list (w/ logical elements)?
I have two lists of the same shape, like this:
x <- list()
x[[1]] <- c("one","two")
x[[2]] <- c("three","four","five")
y <- list()
y[[1]] <- c(TRUE,FALSE)
y[[2]] <- c(FALSE,TRUE,TRUE)
I would like to index x "by" y, that is, the result in this case
should be:
z
[[1]]
[1] "one"
[[2]]
[1] "four"
2011 Feb 02
1
pass nrow(x) to dots in function(x){plot(x,...)}
Dear Rers,
I have a function to barplot() a matrix, eg
myfun <- function(x, ...) { barplot(x , ... )}
(The real function is more complicated, it does things to the matrix first.)
So I can do:
m1 <- matrix(1:20,4)
myfun(m1)
myfun(m1, main="My title")
I'd like to be able to add the number of rows of the matrix passed to
the function to the "..." argument, eg
2008 Oct 21
1
GGPLOT/QPLOT Boxplot with summary
I'd like to generate a boxplot that has BOTH the overall distribution of a
continuous variable (say age), and then a boxplot for each level of a
stratifying variable (e.g. site). Does anyone have prototype code for this?
Thanks,
--
View this message in context: http://www.nabble.com/GGPLOT-QPLOT-Boxplot-with-summary-tp20095591p20095591.html
Sent from the R help mailing list archive at
2009 Dec 12
1
read.csv to read output of system()?
Dear list,
I have a file that is comma delimited but contains some erroneous
non-delimiter commas. I would like to replace these commas with
semicolons and then read the correct file into R as a data frame.
I want to do this from within R, without changing the original data
file.
My current idea of how to do this would be to use system("sed ...")
and feed the result to read.csv(), but
2009 Oct 03
2
add lines() to 1st plot in layout() after calling 2nd plot()?
Dear R users,
I create a graphic with two plots side by side using layout(), like this:
layout(matrix(c(1,2),1))
plot(1:10,main="left plot")
lines(c(3:7,7:3),col="red")
plot(10:1,main="right plot")
The lines() obivously get added to the "left plot" plot.
Now, I'm trying to write a function that builds up a plot bit by bit to
then include it in a
2009 Oct 09
3
"Use R" -- term and logo copyright?
Dear list,
I would like to start some R workshops at King's College London, and
to do so, I would like to use the "Use R!" logo at
http://www.agrocampus-ouest.fr/math/useR-2009//useR%21%202008_fichiers/useR-middle.png
Since it seems to be difficult to get a shell account at KCL, I also went
ahead and registered use-r.org.uk and am starting to put together a
website at
2010 Jun 30
2
ggplot qplot bar removing bars when truncating scale
I'm having problems with this example, it is posted with reproduceable code
below, both with the normal 0-6 scale and the desired 3-6 scale (with bars
removed). How can I get the graph to have the desired 3-6 scale without
removing the bars. Thanks!
#Data