Re: [R] plot pdf

2010-10-30 Thread Uwe Ligges



On 30.10.2010 17:23, mms...@comcast.net wrote:



Subject: plot

Your recent reply has got me underway.  However the savePlot command is not 
working.
I am following refman example. Any thoughts?

I am on a new windows 7 os.  I am not sure how to open a new device (output 
graphic
  window).  I wonder if that could be the problem?

R Code
xcrit=135.9
cord.x<- c(80,seq(80,xcrit,.1),xcrit)
  cord.y<- c(0, dnorm(seq(80, xcrit, .1), 140, 15), 0)
  curve(dnorm(x,140,15),xlim=c(80,200),main='Normal PDF',ylab="Probability")
  polygon(cord.x,cord.y,col='orange')
  savePlot(filename="c:\\lower.emf",type=c("emf"), device = 
dev.cur(),restoreConsole = TRUE)


Probably you do not have administrator permissions when running R and 
hence you cannot write to c:\ directly.


Uwe Ligges



Warning messages:
1: In savePlot(filename = "c:\\lower.emf", type = c("emf"), device = dev.cur(), 
 :
   Unable to open metafile 'c:\lower.emf' for writing
2: In savePlot(filename = "c:\\lower.emf", type = c("emf"), device = dev.cur(), 
 :
   opening device failed

Sincerely,
Mary A. Marion




__
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-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] plot pdf

2010-10-30 Thread mmstat


Subject: plot 

Your recent reply has got me underway.  However the savePlot command is not 
working.   
I am following refman example. Any thoughts?  

I am on a new windows 7 os.  I am not sure how to open a new device (output 
graphic
 window).  I wonder if that could be the problem? 

R Code
xcrit=135.9 
cord.x <- c(80,seq(80,xcrit,.1),xcrit) 
 cord.y <- c(0, dnorm(seq(80, xcrit, .1), 140, 15), 0) 
 curve(dnorm(x,140,15),xlim=c(80,200),main='Normal PDF',ylab="Probability") 
 polygon(cord.x,cord.y,col='orange') 
 savePlot(filename="c:\\lower.emf",type=c("emf"), device = 
dev.cur(),restoreConsole = TRUE) 
Warning messages: 
1: In savePlot(filename = "c:\\lower.emf", type = c("emf"), device = 
dev.cur(),  : 
  Unable to open metafile 'c:\lower.emf' for writing 
2: In savePlot(filename = "c:\\lower.emf", type = c("emf"), device = 
dev.cur(),  : 
  opening device failed 

Sincerely, 
Mary A. Marion 


 

__
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] plot pdf

2010-10-29 Thread Joshua Wiley
Hi Mary,

I am not sure off hand why savePlot() is not doing what you expect,
but hopefully my inline comments answer your other questions and at
least get you the graphs you want.

Cheers,

Josh

On Fri, Oct 29, 2010 at 3:18 PM,   wrote:
>
>
> I want to plot the unstadardized version of a normal plot.  Can you explain 
> why that is not working?
> Dev.set(1)
> xcrit=-1.645
> cord.x <- c(-3,seq(-3,xcrit,0.01),xcrit)
> cord.y <- c(0,dnorm(seq(-3,xcrit,0.01)),0)   # what does final 0 do here?

You are creating *coordinates* to draw a polygon.  That is, (x, y).
The 0s just match with -3 and xcrit and serve to define the perimeter
of the polygon.  Please read the documentation for ?polygon for more
details.

> curve(dnorm(x,0,1),xlim=c(-3,3),main='Normal PDF')

This makes your nice curve based on the density function for the
normal distribution with a range from -3 to +3.  This part works fine
for me.

> polygon(cord.x,cord.y,col='orange')

This does the coloring, the coordinates define the polygon, which is
closed by connecting the first and last points.  This also seems to
work.  I end up with the lower region of the graph filled orange.

> savePlot(filename="c:\\ssl_z.emf",type="emf")  #unable to create 
> metafile?  why?

hard for me to say right now (I'm on a linux box).  It might help
though if you reported sessionInfo()

> x=seq(80,200,1)
> plot(x,dnorm(x,140,15),type="l",ylab="Probability")

This seems fine to me also.

> dev.set(4)

> xcrit=135.9
> cord.x <- c(80,seq(80,xcrit,.1),xcrit)
> cord.y <- c(0,dnorm(seq(80,xcrit,.1)),0)  #final 0 needs to be 
> changed but to what?

Why does the final zero need to be changed?  What do you want it to
be?  I suspect you do need to change dnorm() though.  You are creating
y coordinates based on a normal distribution with mean 0 and sd = 1,
but then you plot a curve for a mean of 140 and sd = 15.  I would
adjust your code to:

cord.y <- c(0, dnorm(seq(80, xcrit, .1), 140, 15), 0)

which gives the results I *think* you are after.


> curve(dnorm(x,140,15),xlim=c(80,200),main='Normal PDF',ylab="Probability")
> polygon(cord.x,cord.y,col='orange')

Using the adjustment I showed above, I now get a graph that is filled
orange from 80 to xcrit (under the normal curve).

> savePlot(filename="c:\\ssl_z.emf",type="emf") #unable to create 
> metafile?  why?
>
>
> Sincerely,
>
> Mary A. Marion
>
>
>        [[alternative HTML version deleted]]

I manually removed spaces in my reply.  In the future it nice if you
could send plain text emails (since the html ones are scrubbed).

>
>
> __
> 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.



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

__
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.