Displaying 20 results from an estimated 7000 matches similar to: "Time Series in R with ggplot2"
2009 Sep 12
1
ggplot2: deterministic position_jitter & geom_line with position_jitter
Dear guRus,
I am starting to work with the ggplot2 package and have two very dumb
questions:
1) deterministic position_jitter - the jittering is stochastic; is there
any way to get a deterministic jittering? For instance:
example.data <-
data.frame(group=c("foo","bar","foo","bar","foo","bar"),x=c(1,1,2,2,3,3),y=c(1,1,0,2,1,1))
2011 Jan 05
3
Adding lines in ggplot2
Hello,
this is probably a recurrent question, but I couldn't find any answers that
didn't involve the expression "data frame"... so perhaps I'm looking for
something new here.
I wanted to find a code equivalent to
> x=sqrt(1:10)
> y=log(1:10)
> plot(1:10, x, type="lines", col="darkgreen")
> lines(1:10, y, col="red")
to use with
2009 Mar 02
3
ways to put multiple graphs on single page (using ggplot2)
Hi, Here are three plots:
library(ggplot2)
data(diamonds)
randind <- sample(nrow(diamonds),1000,replace=FALSE)
dsmall <- diamonds[randind,]
qplot(carat, data=dsmall, geom="histogram",binwidth=1)
qplot(carat, data=dsmall, geom="histogram",binwidth=.1)
qplot(carat, data=dsmall, geom="histogram",binwidth=.01)
What are ways to put these three plots on a single
2008 Sep 17
1
ggplot2 - deprecated guide= argument in
In the help for scale_fill_identity, it is written
## Not run:
colour <- c("red","green","blue","yellow")
qplot(1:4, 1:4, fill=colour, geom="tile")
qplot(1:4, 1:4, fill=colour, geom="tile") + scale_fill_identity()
# To get a legend, you also need to supply the labels to
# be used
2011 Jan 14
2
bug in qplot (library ggplot2)
Hello,
this following code give a nice png:
/library(ggplot2)
i <- 1
png(file=paste('test ',i,'.png',sep=''))
qplot(carat, data=diamonds,
fill=color,geom='histogram')+scale_y_continuous(i)
dev.off()
/
I would like to get more files, but the following code doesn't make any
file:
/library(ggplot2)
for (i in 1:2) {
png(file=paste('test
2009 Apr 21
3
ggplot2 - boxplot of variables / columns
Hi,
ggplot/qplot is great - it has really helped me do some nice things.
However, simple boxplot of different columns/variables is a bit
tricky, because of (i think) qplot's generic Y conditional on X input
form. Se below.
# Some data:
a <- rnorm(100)
b <- rnorm(100,1,2)
c <- rnorm(100,2,0.5)
# normal boxplot of a,b,c
boxplot(a,b,c) # Looks good
library(ggplot2) # loads qqplot2
#
2009 Oct 21
1
ggplot2: Histogram with negative values on x-axis doesn't work
I have a dataset that contains numbers between -10 and 0. E.g. x =
c(-9.23, -9.56, -1.40, ...)
If I no do a
> qplot(x, geom="histogram")
I get the error:
Error: position_stack requires non-overlapping x intervals
Strangely, the following both work:
> qplot(x * -1, geom="histogram")
> qplot(x+100, geom="histogram")
Has anyone else encountered this? Is this a
2009 Feb 18
1
lineplot in ggplot2 with different colour and linetype
Hi list,
I would like to use ggplot2 in creating a line plot with 4 lines (groups), 2
of which I want in colour and the remaining two as dotted lines.
### R code ###
library(ggplot2)
### create data ####
vals <- rnorm(400)
div<- c(rep("A",100),rep("B",100),rep("C",100),rep("D",100))
n<- rep(1:100,4)
df<- data.frame(div=
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 =
2011 May 26
1
Question about ggplot2
Hi all,
Is there any way for me to to string in the argument of qplot or ggplot? for
example
qplot(x='carat',y='price',data=diamonds,geom=c('point','smooth'))
instead of
qplot(x=carat,y=price,data=diamonds,geom=c('point','smooth'))
Thanks!!
Regards,
TszKin Julian
[[alternative HTML version deleted]]
2010 Feb 14
2
Problems with boxplot in ggplot2:qplot
Dataframe closed contains balances of closed accounts: each row has month of
closure (Date-type column month) and latest balance. I would like to plot
by-month distributions of balances. A qplot call below produces several
warnings and no output.
Can anyone help?
Thank you.
PS. A really basic task, very similar to the examples on p. 71 of the
ggplot2 book, apart from a Date grouping column; I
2008 Mar 20
2
I need help integrating ggplot2 into Excel
Dear all
I use ggplot2 extensively for my plotting routines and rexcel to have the
best of two worlds. (RExcel v 1.75 and R (D)Com v. 2.5)
I can run my ggplot functions, such as qplot(...), in scratchpad mode, but
not in Macro nor Worksheet functions mode.
I have tried the following in Macro mode:
Call RInterface.RRun("library(ggplot2)")
...
Call
2010 Apr 07
1
ggplot2, density barplot and geom_point layer
Hi,
Please consider the example below. How can I manage to overlay the points
the way I want in the second case?
Thanks, Joh
library(ggplot2)
# Modify data to match "real" case
myDiamonds <- diamonds
myDiamonds[["clarity"]] <- as.character(myDiamonds[["clarity"]])
myDiamonds[myDiamonds[["clarity"]]=="I1","clarity"] <- 1
2011 Jun 07
1
ggplot2 Histogram with density curve
I am learning ggplot2 commands and I have figured out how to create
histograms and density curves but I am not sure how to add a density curve
on top of a histogram.
Here are the two graphs that I created.
## Histogram
t<-rnorm(500)
w<-qplot(t, main="Normal Random Sample", fill=I("blue"), colour=I("black"),
geom="histogram")
w
##Density Curve
2009 May 05
2
problem with ggplot2 boxplot, groups and facets
I have a following problem:
The call
qplot(wg, v.realtime, data=df.best.medians$gv1, colour=sp, geom="boxplot")
works nice: for each value of the wg factor I get two box-plots (two levels in
the sp factor) in different colours, side-by-side, centered at the wg x-axis.
However, I want to separate the data belonging to different levels of the n
factor, so I add the facets option:
2011 Aug 04
1
Plotting just a portion of a smoother graph in ggplot2
Hi,
I am using ggplot2 to with the following code:
gmathk2 <-
qplot(time,math,colour=Kids,data=kids.ach.lm.k5,geom="smooth",method="lm",formula=y~ns(x,1))
+ opts(title="Smoother Plot: Math K-5") + xlab("Time") + ylab("Math") +
scale_colour_brewer(pal="Set1"); gmathk2
This plots all the smoother for all the x values. What I'd like
2008 Nov 22
2
ggplot2 - facet_grid and facet_wrap
Hello R users (and Hadley)
I have another question about ggplot2 :-)
(version 0.8)
`dat` <-
structure(list(D = c("a", "b", "c", "d"), G = c(1.51520888871520,
1.88812208268440, -6.60521862, 0.55968739), E = c(1.38888592256404,
1.39366168665589, 1.22509259382058, 1.36617701059296), I =
c(6.92634958902857,
6.94416045215158, 13.2179488828556,
2012 Jan 16
2
ggplot2 stacked bar - sum of values rather than count
Hi,
I'm trying to create a stacked bar plot using ggplot2. Rather than
plotting the count of each of the 13 "Bar" factors on the Y axis, I
would like to represent the sum of the Values associated with each of
the 13 "Bar" factors. Is there a way to do that? Given the following
data, that would obviously mean that there would be some negative sums
represented. Here's
2011 Dec 07
2
plotting and coloring longitudinal data with three time points (ggplot2)
Dear list,
I have been struggling with this for some time now, and for the last hour I have been struggling to make a working example for the list. I hope someone out there have some experience with plotting longitudinal data that they will share.
My data is some patient data with three different time stamps. First the patients are identified at different times (first time stamp). Second, they
2009 Sep 29
2
ggplot2 box plot notches
Dear List,
I just googled to find out if notched box plots are possible with
ggplot2, but couldn't find a answer to it.
boxplot() has the option: notch = TRUE, e.g.: boxplot(mpg$hwy, notch=TRUE)
My example code (taken from the net) is:
require(ggplot2)
qplot(class, hwy, fill=factor(year), data=mpg, geom="boxplot",
position="dodge")+theme_bw()
Thank you for you help!