[R] Changing gird marks in ggplot2
Hi, When I zoom into a graph created in ggplot2 with the coord_cartesian(ylim=c(0,5)) option, I have no values labelled on my y-axis. For this graph ggplot2 only puts labels the y-axis at intervals of 10 (i.e. 0, 10, 20, ...). However, the major portion of the graph I am interested in is located between the values of 0 and 5 on the y-axis (thus why I am zoooming). How can I coerce ggplot2 into making the major gird marks so that 0, 1, 2, 3, 4, and 5 are shown as it is currently showing no label? Thanks. Also please cc me directly as I'm a digest subscriber. Chris [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot2 x axis question
Hi, I have 45 models that I have named: 1, 2, 3, ... , 45 and I am trying to plot them in order of ascending BIC values. I am however unclear as to how I can get the models to line up on the x-axis by BIC and not by numeric order. For example, if model 5 has a lower BIC than 1, I want it to be the first point on the left hand side of the curve. This seems to work in plot: plot(1:45, growthm.bic$delta, type="b", xaxt = "n", xlab="Model", ylab=expression(Delta[k])) # where growthm.bic$delta is my BIC value axis(1, at=1:45, labels=growthm.bic$Model) #where model is the name of the 45 models examined, i.e 1:45 Currently using qplot I have this which doesn't not work as it arranges the BIC values in order from 1:45. qplot(model,delta,data=growthm.bic) Thanks. Also please cc me as I am a digest subscriber. Chris __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 x axis question
Hi Hadley, Thanks for the reply and the great graphing package. That code is giving me the following error: > qplot(reorder(model,delta),delta,data=growthm.bic) Error in UseMethod("reorder") : no applicable method for "reorder" Cheers, Chris On 6/28/09 8:21 PM, hadley wickham wrote: > Hi Chris, > > Try this: > > qplot(reorder(model, delta), delta, data = growthm.bic) > > Hadley > > On Sun, Jun 28, 2009 at 9:53 AM, Christopher > Desjardins wrote: > >> Hi, >> I have 45 models that I have named: 1, 2, 3, ... , 45 and I am trying to >> plot them in order of ascending BIC values. I am however unclear as to how I >> can get the models to line up on the x-axis by BIC and not by numeric order. >> For example, if model 5 has a lower BIC than 1, I want it to be the first >> point on the left hand side of the curve. This seems to work in plot: >> >> plot(1:45, growthm.bic$delta, type="b", xaxt = "n", xlab="Model", >> ylab=expression(Delta[k])) # where growthm.bic$delta is my BIC value >> axis(1, at=1:45, labels=growthm.bic$Model) #where model is the name of the >> 45 models examined, i.e 1:45 >> >> Currently using qplot I have this which doesn't not work as it arranges the >> BIC values in order from 1:45. >> >> qplot(model,delta,data=growthm.bic) >> >> Thanks. Also please cc me as I am a digest subscriber. >> Chris >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >> > > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 x axis question
Thanks Hadley that worked. Chris On 6/29/09 11:05 AM, hadley wickham wrote: > In that case, try: > > qplot(reorder(factor(model),delta),delta,data=growthm.bic) > > Deepayan: do you think there should also be a numeric method for reorder? > > Hadley > > On Mon, Jun 29, 2009 at 10:39 AM, Christopher > Desjardins wrote: > >> Hi Hadley, >> Thanks for the reply and the great graphing package. That code is giving me >> the following error: >> >> >>> qplot(reorder(model,delta),delta,data=growthm.bic) >>> >> Error in UseMethod("reorder") : no applicable method for "reorder" >> >> Cheers, >> Chris >> >> On 6/28/09 8:21 PM, hadley wickham wrote: >> >> Hi Chris, >> >> Try this: >> >> qplot(reorder(model, delta), delta, data = growthm.bic) >> >> Hadley >> >> On Sun, Jun 28, 2009 at 9:53 AM, Christopher >> Desjardins wrote: >> >> >> Hi, >> I have 45 models that I have named: 1, 2, 3, ... , 45 and I am trying to >> plot them in order of ascending BIC values. I am however unclear as to how I >> can get the models to line up on the x-axis by BIC and not by numeric order. >> For example, if model 5 has a lower BIC than 1, I want it to be the first >> point on the left hand side of the curve. This seems to work in plot: >> >> plot(1:45, growthm.bic$delta, type="b", xaxt = "n", xlab="Model", >> ylab=expression(Delta[k])) # where growthm.bic$delta is my BIC value >> axis(1, at=1:45, labels=growthm.bic$Model) #where model is the name of the >> 45 models examined, i.e 1:45 >> >> Currently using qplot I have this which doesn't not work as it arranges the >> BIC values in order from 1:45. >> >> qplot(model,delta,data=growthm.bic) >> >> Thanks. Also please cc me as I am a digest subscriber. >> Chris >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >> >> >> >> >> > > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to combine two data frames by ID
Hi, I am trying to combine two data frames by ID. The first data frame is the whole data set and the second data frame is a subset of the first. What I would like to do is take the values from variable, p1, from the second data frame and merge them back into that variable in the first data frame. I have ID variables that match for both data frames and the data frames obviously have differing number of rows where the first data frame > second data frame. I want to keep the pre existing data for this variable that is present in the first data frame and only write over the data that I edited in the second. Thanks and please cc me as I am a digest subscriber, Chris __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error with r2winbugs
Hi, I am trying to do run the following model saved in "C:/bugs/sus.bug" model { for (i in 1:n){ y[i] ~ dpois(lamdba[i]) log(lambda[i]) <- mu+bmale[male[i]]+bschn[schn[i]]+epsilon[i] # epsilon[i] ~ dnorm(0,tau.epsilon) } mu ~ dnorm(0,.0001) bmale ~ dnorm(0,.0001) tau.epsilon <- pow(sigma.epsilon, -2) sigma.epsilon ~ dunif(0,100) for (j in 1:n.schn){ bschn[j] ~ dnorm(0,tau.schn) } tau.schn <- pow(sigma.schn, -2) sigma.schn ~ dunif(0,100) } I am running the following syntax: enroll.wide.m <- na.omit(enroll.wide) n <- nrow(enroll.wide.m) y <- enroll.wide.m$sus.5 sch <- as.vector(enroll.wide.m$schno.5) uniq <- unique(sch) n.schn <- length(uniq) male <- enroll.wide.m$male schn <- enroll.wide.m$schno.5 data <- list ("n","n.schn","y","male","schn") inits <- function() {list (bschn=rnorm(n.schn), mu=rnorm(1,0,100), bmale=rnorm(1,0,100), sigma.epsilon=runif(1,0,100),sigma.schn=runif(1,0,100))} parameters <- c("bschn","mu","bmale","sigma.epsilon","sigma.schn") sus.sim <- bugs(data,inits,parameters,"C:/bugs/susc.bug",n.chains=3,n.iter=10,debug=TRUE) And get the following error: display(log) check(C:\DOCUME~1\CHRIST~1\LOCALS~1\Temp\Rtmpyg7eDj/susc.bug.txt) empty slot not allowed in variable name data(C:/DOCUME~1/CHRIST~1/LOCALS~1/Temp/Rtmpyg7eDj/data.txt) command #Bugs:data cannot be executed (is greyed out) compile(3) inits(1,C:/DOCUME~1/CHRIST~1/LOCALS~1/Temp/Rtmpyg7eDj/inits1.txt) command #Bugs:inits cannot be executed (is greyed out) inits(2,C:/DOCUME~1/CHRIST~1/LOCALS~1/Temp/Rtmpyg7eDj/inits2.txt) command #Bugs:inits cannot be executed (is greyed out) inits(3,C:/DOCUME~1/CHRIST~1/LOCALS~1/Temp/Rtmpyg7eDj/inits3.txt) command #Bugs:inits cannot be executed (is greyed out) gen.inits() command #Bugs:gen.inits cannot be executed (is greyed out) thin.updater(1) update(5) command #Bugs:update cannot be executed (is greyed out) set(bschn) command #Bugs:set cannot be executed (is greyed out) set(mu) command #Bugs:set cannot be executed (is greyed out) set(bmale) command #Bugs:set cannot be executed (is greyed out) set(sigma.epsilon) command #Bugs:set cannot be executed (is greyed out) set(sigma.schn) command #Bugs:set cannot be executed (is greyed out) set(deviance) command #Bugs:set cannot be executed (is greyed out) dic.set() command #Bugs:dic.set cannot be executed (is greyed out) update(5) command #Bugs:update cannot be executed (is greyed out) coda(*,C:/DOCUME~1/CHRIST~1/LOCALS~1/Temp/Rtmpyg7eDj/coda) command #Bugs:coda cannot be executed (is greyed out) stats(*) command #Bugs:stats cannot be executed (is greyed out) dic.stats() DIC history(*,C:/DOCUME~1/CHRIST~1/LOCALS~1/Temp/Rtmpyg7eDj/history.odc) command #Bugs:history cannot be executed (is greyed out) save(C:/DOCUME~1/CHRIST~1/LOCALS~1/Temp/Rtmpyg7eDj/log.odc) save(C:/DOCUME~1/CHRIST~1/LOCALS~1/Temp/Rtmpyg7eDj/log.txt) Any help would be greatly appreciate. Also please cc me as I am digest subscriber. Chris __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] combining 4 vectors into one
Hi, How can I perform the following y1y2y3y4 1 0 3 2 0 1 2 1 3 2 0 1 0 5 1 0 into ... > y 1 0 3 2 0 1 2 1 3 2 0 1 0 5 1 0 Please cc me on reply as I subscribe to the digest. Thanks! Chris __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] combining 4 vectors into one
Thanks. That worked. Chris On 7/19/09 6:41 PM, jim holtman wrote: > Try this: > > >> x >> >y1 y2 y3 y4 > 1 1 0 3 2 > 2 0 1 2 1 > 3 3 2 0 1 > 4 0 5 1 0 > >> as.vector(t(x)) >> > [1] 1 0 3 2 0 1 2 1 3 2 0 1 0 5 1 0 > > > > > On Sun, Jul 19, 2009 at 7:25 PM, Christopher > Desjardins wrote: > >> Hi, >> How can I perform the following >> >> y1y2y3y4 >> 1 0 3 2 >> 0 1 2 1 >> 3 2 0 1 >> 0 5 1 0 >> >> into ... >> >> >>> y >>> >> 1 0 3 2 0 1 2 1 3 2 0 1 0 5 1 0 >> >> >> Please cc me on reply as I subscribe to the digest. >> Thanks! >> Chris >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >> > > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.