I have glad to hear that there is an updated version for reshape2 package.
I installed the package, but discovered that ggplot2 package still insist to have the reshape package, rather than the reshape2 package, as I manually removed the reshape package and then ggplot2 cannot run.
Anything I can do to fix it? Thanks!
...
Stacked bar charts use a hue-based colour scale by default, in order to distinguish the different sections of bar. Since the factor levels corresponding to my stacks are ordered, I would like to use a gradient scale.
Here's some made-up questionnaire data
dfr <- data.frame(
question = c("Do you like R?", "How about Stack Overflow?")...
Is it possible to plot a matrix of scatter plots with ggplot2, using ggplot's nice features like mapping additional factors to color, shape etc. and adding smoother?
I am thinking about something similar to pairs().
...
I'm having trouble passing a POSIXct stored in a variable as the xmin/xmax for geom_rect. I've tried to construct a free-standing example without trivializing what I'm trying to do...
The idea is to take a ggplot2 plot object, whose x is a POSIXt, and "zoom in" on a particular range in time. The zoom is in the top 80% and the entire ser...
I have a data.frame, that is sorted from highest to lowest. For example:
x <- structure(list(variable = structure(c(10L, 6L, 3L, 4L, 2L, 8L,
9L, 5L, 1L, 7L), .Label = c("a", "b", "c", "d", "e", "f", "g",
"h", "i", "j"), class = c("ordered", "factor")), value = c(0.990683229813665,
0.975155279503106, 0.928571428571429, 0.807453416149...
I am just starting out with R, and beginning to start producing charts. I am aware that there are at least three different plotting packages, the standard one, ggplot2 and lattice.
Are these packages complementary, or do they cover much the same ground? If they are complementary, when do I use each? If they cover the same ground, whi...
I have a fairly simple data.frame dput(x), below:
x <- structure(list(variable = c("a", "b", "c", "d", "e", "f", "g",
"h", "i", "j", "k", "l", "m", "n", "o", "p"), top2 = c(0.51,
0.24, 0.55, 0.36, 0.56, 0.67, 0.36, 0.22, 0.48, 0.6, 0.59, 0.06,
0.04, 0.2, 0.26, 0.25), bottom = c(0.03, 0.05, 0.03, 0.01, 0.02,
0.03, 0.01, 0.05, 0.03, ...
Hi all,
A very newbish question, but say I have data like this:
test_data <- data.frame(
var0 = 100 + c(0, cumsum(runif(49, -20, 20))),
var1 = 150 + c(0, cumsum(runif(49, -10, 10))),
date = seq.Date(as.Date("2002-01-01"), by="1 month", length.out=100))
How can I plot both time series var0 and var1 on the same graph, with date on the ...
I'd like to include the glyph used in a scatter plot directly in a text annotation.
E.g., Suppose I have:
g <- g + geom_text(aes(x=14, y = 17, label="GOOD"))
where g is a scatter plot w/ a linear trend line, labeled by "GOOD" at (14,17). Instead of
"GOOD", I'd like to have "X = GOOD" where X is a plotting glyph (e.g., a hollow t...
I have a melted data.frame, dput(x), below:
## dput(x)
x <- structure(list(variable = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L,
4L, 4L), .Label = c("a", "b", "c", "d"), class = "factor"),
value = structure(c(1L,
2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, ...
Hello,
Sorry for not included any example data for my problem. I couldn’t find a way to easily produce an example shape file. Hopefully, experienced users of ggplot can see what I’d like to do from the description below.
I’ve got:
A data frame X with information about sample plots (plotid, var1, var2, var3, var4,…)
A polygon shapefil...
What I'd like to do is label both of the geom_bar() 's in the following example with their respective data labels. So far, I can only get one or the other to show up:
dput():
x <- structure(list(variable = c("a", "b", "c"), f = c(0.98, 0.66,
0.34), m = c(0.75760989010989, 0.24890977443609, 0.175125)), .Names = c("variable",
"f", "m...
Hi,
is there a way in ggplot2 to get the plot type "b"? See example:
x <- c(1:5)
y <- x
plot(x,y,type="b")
Ideally, I want to replace the points by their values to have something similar to this famous example:
EDIT:
Here some sample data (I want to plot each "cat" in a facet with plot type "b"):
`df <- data.frame(x=rep(1:5,9),...
I would like to create 10 plots that have different data, but the same optical appearance. As an example, I’d like to change the colour of the gridline for each plot. This could be done by adding
+ opts(panel.grid.major = theme_line(colour = "white")
to each plot definition. However, when I now decide to change background colour to l...
I saw http://stackoverflow.com/questions/2492947/boxplot-in-r-showing-the-mean
I'm interested in the ggplot solution. But what I am plotting are averages already so I don't want to do an average of an average. I do have the true mean stored in TrueAvgCPC.
Here is what I tried, but it's not working:
p <- qplot(Mydf$Network,Mydf$Avg.CPC...
I'm using the plotmatrix function in ggplot2 (ggplot2_0.8.8) and would like to override the column names displayed from my dataframe, e.g.
plotmatrix(mtcars) + opts(strip.text.x = theme_text(size=20))
I can alter the properties of strip.text.x and strip.text.y with opts, but where can I change the text itself e.g. I would like "mpg" r...
Right now, the legend by default looks something like this:
Legend Title
x-1
y-2
z-3
But is it possible to make it look something like this?
Legend Title
x-1 y-2 z-3
...
Frequently, I use functions to shape or numerically alter data that I'm passing to ggplot, so that I don't have to alter my data before putting it in.
If I've saved a plot to a variable. Is there a way to see the actual data that I'm plotting? It's a sanity check.
For example:
c <- ggplot(mtcars, aes(factor(cyl))) + geom_bar()
If ...
I am plotting a simple histogram of data sampled at, say, 10%. I want counts on the y-axis, but since the data are sampled, I want them to be scaled appropriately. If I were using base graphics, I'd do something like
foo <- rnorm(50)
foo.hist <- hist(foo,plot=F)
foo.hist$counts <- foo.hist$counts * 10
plot(foo.hist)
Is there an eas...
So far I have this:
hist <- ggplot(Mydf, aes(x=Mydf$Avg.CPC))
breaks <- c(min(Mydf$Avg.CPC), median(Mydf$Avg.CPC), max(Mydf$Avg.CPC))
h <- hist + geom_bar(binwidth = 0.025, colour = "black", breaks = breaks)
print(h)
I get an error. It doesn't like having different widths. I would also like to have the Q1 and Q3 quartiles as breaks wh...