Displaying 20 results from an estimated 10000 matches similar to: "ggplot2 x axis question"
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
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
2011 May 18
1
Changing order of facet grid in ggplot2
Hi I am running the following code:
sym <- c(sym1,sym2,sym4)
lifedxm <- c("O-BD","O-WELL","O-UNI")
life <- c(lifedxm,lifedxm,lifedxm)
tp <- c("TP-ANY","TP-ANY", "TP-ANY", "TP-SUB", "TP-SUB", "TP-SUB", "TP-CLIN"
, "TP-CLIN", "TP-CLIN")
data <-
2011 Jul 07
1
Confidence bands in ggplot2
Hi,
I have the following data:
> est
sch190 sch107 sch290 sch256 sch287 sch130 sch139
4.16656026 2.64306071 4.22579866 6.12024789 4.49624748 11.12799127 1.17353917
sch140 sch282 sch161 sch193 sch156 sch288 sch352
3.48197696 -0.29659410 -1.99194986 10.23489859 7.77342138 6.77624539 9.66795001
sch368
2007 Nov 13
1
ggplot2: changing axis labels in ggplot()
Hi all,
For various reasons, I need to use ggplot instead of qplot for a complex
figure. Everything is working fine, except I cannot figure out how to rename
the axis labels in ggplot. I have pasted a simple example below. Any ideas
on what I am doing wrong?
Thanks for your help.
James
library(ggplot2)
##create data
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
2011 Jun 21
2
qplot/ggplot2 Questions
I took some data from an online poll about which R GUI people used most and I
am messing around with it to learn how to use qplot. Specifically I am
making a horizontal bar graph and I have two questions.
1. The categories are ordered in rather strange way at least to me. It is
not alphabetical or ascending/descending order of votes cast so i had to
manually state the order I wanted which is
2012 Jul 17
3
Finding the column with the maximum value by row
Hi,
Let's say I have the following data:
> a=matrix(c(1,2,4,4,2,1,1,2,4),nrow=3,byrow=T)
> a
[,1] [,2] [,3]
[1,] 1 2 4
[2,] 4 2 1
[3,] 1 2 4
What syntax should I use to get R to tell me the column that corresponds to
the maximum value for each row?
For my example, I would like to get a vector that says 3, 1, 3 because the
maximum value for row 1 is
2010 May 13
1
Questions about ggplot2
Hi I have two questions about using ggplot2.
First, I have multiple columns of data that I would like to combine into
one histogram where each column of data would correspond to one bar in
the histogram. Each column has 0 or 1s and I want my bars in the
histogram to correspond to the sum of the 1s in each column. Does that
make sense?
Second, is there a way to completely turn off the legend?
2012 Apr 09
3
For loops
Hi,
I am having trouble with syntax for a for loop. Here is what I am trying to
do.
class=c(rep(1,3),rep(2,3),rep(3,3))
out1=rnorm(length(class))
out2=rnorm(length(class))
out3=rnorm(length(class))
data=data.frame(class,out1,out2,out3)
dat.split=split(data,data$class)
for(i in 1:3){
sub[i]=dat.split[i]
}
However, the for loop doesn't work. I want to assign each split to a
different
2011 Mar 30
6
Quick recode of -999 to NA in R
Hi,
I am trying to write a loop to recode my data from -999 to NA in R. What's
the most efficient way to do this? Below is what I'm presently doing, which
is inefficient. Thanks,
Chris
dat0 <- read.table("time1.dat")
colnames(dat0) <- c("e1dq", "e1arcp", "e1dev", "s1prcp", "s1nrcp", "s1ints",
2010 Feb 03
2
ggplot2/qplot question regarding reducing the no. of x-axis labels
All:
I am using the command: qplot(date,MAE,data=data,facets=INTERVAL~type)
which works fine except that the dates for my date axes are crunched
together so much that they are unreadable. I can not find an option that
I can set that will automatically reduce the x-axis labels to fit the
available space.
regards to all?
--
Thomas E Adams
National Weather Service
Ohio River Forecast Center
2010 Jul 22
2
Multilevel survival model
* Please cc me if you reply as I am a digest subscriber *
Hi,
I am wondering how I can run a multilevel survival model in R? Below is
some of my data.
> head(bi0.test)
childid famid lifedxm sex age delta
1 22.02 22 CONTROL MALES 21.36893 0
2 13.02 13 MAJOR MALES 21.18001 0
3 64.02 64 CONTROL MALES 20.09377 0
4 5.02 5 CONTROL FEMALES
2007 Jul 12
1
ggplot2 / reshape / Question on manipulating data
I'm an R newbie but recently discovered the ggplot2 and reshape
packages which seem incredibly useful and much easier to use for a
beginner. Using the data from the IMDB, I'm trying to see how the
average movie rating varies by year. Here is what my data looks like:
> ratings <- read.delim("groomed.list", header = TRUE, sep = "|", comment.char = "")
2010 Jul 23
1
Survival analysis MLE gives NA or enormous standard errors
Hi,
I am trying to fit the following model:
sr.reg.s4.nore <- survreg(Surv(age_sym4,sym4), as.factor(lifedxm),
data=bip.surv)
Where age_sym4 is the age that a subject develops clinical thought
problems; sym4 is whether they develop clinical thoughts problems (0 or
1); and lifedxm is mother's diagnosis: BIPOLAR, MAJOR DEPRESSION, or
CONTROL.
I am interested in whether or not
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 =
2007 Jul 24
1
ggplot2 axis color
Hi:
Does anyone have an idea on how to color the axis and
labels using ggplot2? This is what I got:
library(ggplot2)
p <- qplot(total_bill, tip, data = tips)
NewPlot<- p + geom_abline(slope=c(0.1,0.15,0.2),
colour=c("red","blue","yellow"),size=c(2,5,2))
NewPlot + geom_smooth(colour="green",
size=3,linetype=3)
2010 Mar 24
1
GGPLOT2: Reverse order of legend to match order of x-axis
How do I reverse the order of the legend in a bar plot to match order of the
x-axis? In other words, I want the stacked colors of the legend to match the
stacked colors of the bar plot. I tried this, but it didn't work.
colors <- c("5" = "red","4" = "blue","3" = "darkgreen")
p <- qplot(factor(cyl), data=mtcars,
2010 Feb 19
1
ggplot2 X axis levels
Hi all:
I've done this before with factors but can't figure how to do it with
a continuous variable. I am trying to reorder the sequence of my weeks
along the X axis. I want to start with week 27 to 52 and then 1 to 26.
I guess I could use levels along with seq() but doesn't seem to work for me.
Thanks for your help
winter <- structure(list(week = c(27L, 28L, 29L, 30L, 31L, 32L,
2008 Aug 04
1
Sweave and ggplot2
Hi all,
I've been trying to run Sweave with R code embedded - using the ggplot2
package and in particular the qplot command. There appears to be a problem
in Sweave not picking up that qplot is a function. Has anybody else tried
to use qplot in Sweave and have you been successful? Any help would be
very much appreciated.
Kind Regards,
Sorn
Notice:
This email and any attachments may