Re: [R] plotEst

From: hadley wickham <h.wickham_at_gmail.com>
Date: Sat, 16 Feb 2008 09:22:50 -0600

On Feb 16, 2008 9:11 AM, sigalit mangut-leiba <smangut_at_gmail.com> wrote:
> Hello,
> This is the first time i'm trying to plot in R. I want to plot estimates of
> OR and their confidence limits, like a scatter plot:
> the vertical axis should be the estimated OR (with upper and lower conf.
> limits),
> and the horizontal exis should be fixed values: (1,0.8,0.7,0.6,0.5,0.4)
>
> Here is a part of my code:
>
> ...ests=matrix(ncol=3,nrow=6)
>
> ests[,1]<-c(mean(or1),mean(or14),mean(or15),mean(or16),mean(or17),mean(or18))
>
> ests[,2]<-c(cl1,cl14,cl15,cl16,cl17,cl18)
>
> ests[,3]<-c(cu1,cu14,cu15,cu16,cu17,cu18)
>
> x1<-c(1,0.8,0.7,0.6,0.5,0.4)...
>
> Now I have a matrix with three columns: estimate, lower limit of the
> confidende interval, and upper limit of the confidence interval:
>
> [,1] [,2] [,3]
> [1,] 1.011794 0.6400744 1.383514
> [2,] 1.646535 1.0421947 2.250875
> [3,] 2.118518 1.3364878 2.900549
> [4,] 2.709806 1.6899134 3.729698
> [5,] 3.570759 2.2510895 4.890428
> [6,] 4.874569 2.9081958 6.840942
>
>
> The first value in x1 fit the first row in the matrix, etc..
>
> I tried the function plotEst like this:
>
> plotEst(ests,y = dim(ests)[1]:1, xlab="sensitivity", xtic=x1,
> xlim=range(xtic))
>
> and got the Error:
>
> Error in strsplit(x, as.character(split), as.logical(extended),
> as.logical(fixed),
> :
> non-character argument in strsplit()
>
> What am I missing?

If you had a data.frame with columns, x, estimate, lcl and ucl, then you could use ggplot2 as follows:

library(ggplot2)
qplot(x, estimate, min=lcl, max=ucl, data=df, geom="pointrange")

It's generally a good idea to store data in a data frame.

Hadley

-- 
http://had.co.nz/

______________________________________________
R-help_at_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.
Received on Sat 16 Feb 2008 - 15:26:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 19 Feb 2008 - 11:30:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive