Re: [R] graphs, need urgent help (deadline :( )

2015-06-11 Thread Jim Lemon
Rosa Oliveira wrote:

> Dear Jim,
>
> when I run your code (even the one you send me, not in my data), I get:
>
> Don't know how to automatically pick scale for object of type function. 
> Defaulting to continuous
> Error in data.frame(x = c(0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1,  :
>  arguments imply differing number of rows: 24, 0

Well, let's agree on the data first. Using your original dataset:

my.data<-read.table(text="region sample factora factorb factorc
 0.1  10  0.895   0.903   0.378
 0.2  10  0.811   0.865   0.688
 0.1  20  0.735   0.966   0.611
 0.2  20  0.777   0.732   0.653
 0.1  30  0.600   0.778   0.694
 0.2  30  0.466   174.592 0.461
 0.1  40  0.446   0.432   0.693
 0.2  40  0.392   0.294   0.686",header=TRUE)
library(plotrix)
par(tcl=-0.1)
gap.plot(x=rep(seq(10,45,by=5),3),
 y=unlist(my.data[,c("factora","factorb","factorc")]),
 main="A plot of factorial mystery",
 gap=c(1.1,174),ylim=c(0,175),ylab="factor score",xlab="Group",
 xticlab=c(" \n0.1\n10"," \n0.2\n10"," \n0.1\n20"," \n0.2\n20",
  " \n0.1\n30"," \n0.2\n30"," \n0.1\n40"," \n0.2\n40"),
 ytics=c(0,0.5,1,174.59),pch=rep(1:3,each=8),col=rep(c(4,2,3),each=8))
mtext(c("Region","Sample"),side=1,at=6,line=c(0,1))
lines(seq(10,45,by=5),my.data$factora,col=4)
lines(seq(10,45,by=5),my.data$factorb[c(1:5,NA,7,8)],col=2)
lines(seq(10,45,by=5),my.data$factorc,col=3)
legend(18,1.8,c("factora","factorb","factorc"),pch=1:3,col=c(4,2,3))

This produces a plot, and I realize that it is not the one you
describe. As before, if you can let us know what is wrong with it,
maybe we can fix it.

Jim

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] graphs, need urgent help (deadline :( )

2015-06-11 Thread Don McKenzie
Thanks John!  My eyes aren't good enough to see that. I actually checked (I 
thought). This was the default window on Mac console, for others who might care.

Sent from my iPad

> On Jun 10, 2015, at 6:17 PM, John Kane  wrote:
> 
> You have curly quotes rather than plain ones here : 
> col=4,type=“l”,xlab=“Region”,ylab=“factor")
> 
> 
> 
> John Kane
> Kingston ON Canada
> 
> -Original Message-
> From: d...@u.washington.edu
> Sent: Wed, 10 Jun 2015 11:32:59 -0700
> To: rosit...@gmail.com
> Subject: Re: [R] graphs, need urgent help (deadline :( )
> 
> You were caught by a mysterious issue that I don’t understand either.
> 
> plot(therapy.df$Region[therapy.df$sample==50],therapy.df$factor.a[therapy.df$sample==50],col=4,type=“l”,xlab=“Region”,ylab=“factor")
> 
> Error: unexpected input in 
> "plot(therapy.df$Region[therapy.df$sample==50],therapy.df$factor.a[therapy.df$sample==50],col=4,type=‚”
> 
> but if I change the order of arguments to plot(), it’s fine
> 
> plot(therapy.df$Region[therapy.df$sample==50],therapy.df$factor.a[therapy.df$sample==50],type="l",col=4,xlab="Region",ylab="factor”)
> 
> I don’t know what to tell you.  If someone wiser than I is still reading, 
> maybe s(he) can explain.  Possibly a bug has crept into the call to “par”, 
> but “bugs" suspected by non-experts like me usually turn out to be naive user 
> errors.  
> 
> For your purposes, use the one that works.  :-)
> 
> On Jun 10, 2015, at 11:03 AM, Rosa Oliveira  wrote:
> 
> Sorry,
> 
> I taught I attached the cvs file :)
> 
> 
> 
> Don,
> 
> I tried, but I got an error:
> 
>> my.data$Region
> 
>  [1]  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5  6  7  8  9 10  1  2  3  4  
> 5  6  7  8  9 10
> 
>> my.data$sample
> 
>  [1]   50   50   50   50   50   50   50   50   50   50  250  250  250  250  
> 250  250  250  250  250  250 1000 1000 1000 1000 1000 1000 1000 1000
> 
> [29] 1000 1000
> 
>> my.data$factor.a
> 
>  [1] 0.895 0.811 0.685 0.777 0.600 0.466 0.446 0.392 0.256 0.198 0.136 0.121 
> 0.875 0.777 0.685 0.626 0.550 0.466 0.384 0.330 0.060 0.138 0.065
> 
> [24] 0.034 0.931 0.124 0.060 0.028 0.017 0.014
> 
>> plot(my.data$Region[my.data$sample==50],my.data$factor.a[my.data$sample==50],col=4,type=“l”,xlab=“Region”,ylab=“factor")
> 
> Error: unexpected input in 
> "plot(my.data$Region[my.data$sample==50],my.data$factor.a[my.data$sample==50],col=4,type=�”
> 
> I’m really naive, right?
> 
> Best,
> 
> RO
> 
> Atenciosamente,
> Rosa Oliveira
> 
> -- 
> 
> 
> 
> 
> Rosa Celeste dos Santos Oliveira, 
> 
> E-mail: rosit...@gmail.com
> Tlm: +351 939355143 
> Linkedin: https://pt.linkedin.com/in/rosacsoliveira 
> [https://pt.linkedin.com/in/rosacsoliveira]
> 
> 
> "Many admire, few know"
> Hippocrates
> 
> On 10 Jun 2015, at 18:10, Don McKenzie  wrote:
> 
> For a legend, try (untested)
> 
> legend(0.15,0.9,c("factora","factorb","factorc"),col=c(4,2,3),lty=1)
> 
> If it overlaps data points move the first two arguments (0.15 and 0.9) 
> around, or change the “ylim” argument in the plot() to ~1.2.
> 
> to avoid clutter, put the line-types information in the figure caption (IMO)
> 
> On Jun 10, 2015, at 10:03 AM, Don McKenzie  wrote:
> 
> On Jun 10, 2015, at 9:08 AM, Rosa Oliveira  wrote:
> 
> Dear All,
> 
> I attach my data.
> 
> Dear Jim, 
> 
> when I run your code (even the one you send me, not in my data), I get: 
> 
> Don't know how to automatically pick scale for object of type function. 
> Defaulting to continuous
> 
> Error in data.frame(x = c(0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1,  : 
> 
>   arguments imply differing number of rows: 24, 0
> 
> Dear Don,
> 
> It’s meant that I will have 12 lines: 
> 
> 3 factors - lines colors
> 
> with 3 different values of “sample” for each - line types
> 
> [Three colors, one for each factor,
> and  three line types (lty=1,2,3), one for eachvalue of “sample - preferable 
> dash, thin and thick).
> 
> in the X - I should have region (because I have 10 regions)
> 
> for each region I have the outcome of 3 different treatments (factor)
> 
> for each region and each treatment I have 3 different sample size.
> 
> But in your original post you had 4 sample sizes: 10,20,30,40.
> 
> I need to “see” the the influence of the region in the treatment outcome for 
> each sample size.
> 
> So, at

Re: [R] graphs, need urgent help (deadline :( )

2015-06-11 Thread Rosa Oliveira
data$factorb[my.data$sample==20],col=2,lty=2)
>>>> lines(my.data$region[my.data$sample==20],my.data$factorc[my.data$sample==20],col=3,lty=2)
>>>> 
>>>> #  Now do two more groups of 3, changing the parameter “lty” to 3 and then 
>>>> 4
>>>> 
>>>> # Look at the syntax and note what changes and what stays constant. Do you 
>>>> see how this works?
>>>> # there will be what looks like a vertical line where sample = 30 and 
>>>> factorb = 174.592.  Do you see why?
>>>> 
>>>> # then you will need a legend
>>>> 
>>>>> Nonetheless I can’t do it :(
>>>>> 
>>>>> best,
>>>>> RO
>>>>> 
>>>>> 
>>>>> 
>>>>> Atenciosamente,
>>>>> Rosa Oliveira
>>>>> 
>>>>> -- 
>>>>> 
>>>>>  
>>>>> 
>>>>> Rosa Celeste dos Santos Oliveira, 
>>>>> 
>>>>> E-mail: rosit...@gmail.com
>>>>> Tlm: +351 939355143 
>>>>> Linkedin: https://pt.linkedin.com/in/rosacsoliveira
>>>>> 
>>>>> "Many admire, few know"
>>>>> Hippocrates
>>>>> 
>>>>>> On 10 Jun 2015, at 14:13, John Kane  wrote:
>>>>>> 
>>>>>> Hi Jim,
>>>>>> 
>>>>>> I was looking at that last night and had the same problem of visualizing 
>>>>>> what Rosa needed.  
>>>>>> 
>>>>>> Hi Rosa
>>>>>> This is nothing like what you wanted and I really don't understand your 
>>>>>> data but would something like this work as a substitute or am I 
>>>>>> completely lost?
>>>>>> 
>>>>>> 
>>>>>> dat1  <-  structure(list(region = c(0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1, 
>>>>>> 0.2), sample = c(10L, 10L, 20L, 20L, 30L, 30L, 40L, 40L), factora = 
>>>>>> c(0.895, 
>>>>>> 0.811, 0.735, 0.777, 0.6, 0.466, 0.446, 0.392), factorb = c(0.903,
>>>>>> 0.865, 0.966, 0.732, 0.778, 0.592, 0.432, 0.294), factorc = c(0.37, 
>>>>>> 0.688, 0.611, 0.653, 0.694, 0.461, 0.693, 0.686)), .Names = c("region", 
>>>>>> "sample", "factora", "factorb", "factorc"), class = "data.frame", 
>>>>>> row.names = c(NA, 
>>>>>> -8L))
>>>>>> 
>>>>>> 
>>>>>> mdat1  <-   melt(dat1, id.var = c("region", "sample"),
>>>>>>variable.name = "factor",
>>>>>>value.name = "value")
>>>>>> str(mdat1)
>>>>>> 
>>>>>> ggplot(mdat1, aes(region, value, colour = factor)) +
>>>>>>geom_line() + facet_grid(sample ~ .)
>>>>>> 
>>>>>> John Kane
>>>>>> Kingston ON Canada
>>>>>> 
>>>>>> 
>>>>>>> -Original Message-
>>>>>>> From: drjimle...@gmail.com
>>>>>>> Sent: Wed, 10 Jun 2015 20:51:52 +1000
>>>>>>> To: rosit...@gmail.com
>>>>>>> Subject: Re: [R] graphs, need urgent help (deadline :( )
>>>>>>> 
>>>>>>> Hi Rosa,
>>>>>>> Like Don, I can't work out what you want and I don't even have the
>>>>>>> picture. For example, your specification of color and line type leaves
>>>>>>> only one point for each color and line type, and the line from one
>>>>>>> point to the same point is not going to show up. Here is a possibility
>>>>>>> that may lead (eventually) to a solution.
>>>>>>> 
>>>>>>> library(plotrix)
>>>>>>> par(tcl=-0.1)
>>>>>>> gap.plot(x=rep(seq(10,45,by=5),3),
>>>>>>> y=unlist(my.data[,c("factora","factorb","factorc")]),
>>>>>>> main="A plot of factorial mystery",
>>>>>>> gap=c(1.1,174),ylim=c(0,175),ylab="factor score",xlab="Group",
>>>>>>> xticlab=c(" \n

Re: [R] graphs, need urgent help (deadline :( )

2015-06-10 Thread John Kane
You have curly quotes rather than plain ones here : 
col=4,type=“l”,xlab=“Region”,ylab=“factor")



John Kane
Kingston ON Canada

-Original Message-
From: d...@u.washington.edu
Sent: Wed, 10 Jun 2015 11:32:59 -0700
To: rosit...@gmail.com
Subject: Re: [R] graphs, need urgent help (deadline :( )

You were caught by a mysterious issue that I don’t understand either.

plot(therapy.df$Region[therapy.df$sample==50],therapy.df$factor.a[therapy.df$sample==50],col=4,type=“l”,xlab=“Region”,ylab=“factor")

Error: unexpected input in 
"plot(therapy.df$Region[therapy.df$sample==50],therapy.df$factor.a[therapy.df$sample==50],col=4,type=‚”

but if I change the order of arguments to plot(), it’s fine

plot(therapy.df$Region[therapy.df$sample==50],therapy.df$factor.a[therapy.df$sample==50],type="l",col=4,xlab="Region",ylab="factor”)

I don’t know what to tell you.  If someone wiser than I is still reading, maybe 
s(he) can explain.  Possibly a bug has crept into the call to “par”, but “bugs" 
suspected by non-experts like me usually turn out to be naive user errors.  

For your purposes, use the one that works.  :-)

On Jun 10, 2015, at 11:03 AM, Rosa Oliveira  wrote:

Sorry,

I taught I attached the cvs file :)



Don,

I tried, but I got an error:

> my.data$Region

 [1]  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5 
 6  7  8  9 10

> my.data$sample

 [1]   50   50   50   50   50   50   50   50   50   50  250  250  250  250  250 
 250  250  250  250  250 1000 1000 1000 1000 1000 1000 1000 1000

[29] 1000 1000

> my.data$factor.a

 [1] 0.895 0.811 0.685 0.777 0.600 0.466 0.446 0.392 0.256 0.198 0.136 0.121 
0.875 0.777 0.685 0.626 0.550 0.466 0.384 0.330 0.060 0.138 0.065

[24] 0.034 0.931 0.124 0.060 0.028 0.017 0.014

> plot(my.data$Region[my.data$sample==50],my.data$factor.a[my.data$sample==50],col=4,type=“l”,xlab=“Region”,ylab=“factor")

Error: unexpected input in 
"plot(my.data$Region[my.data$sample==50],my.data$factor.a[my.data$sample==50],col=4,type=�”

I’m really naive, right?

Best,

RO

 Atenciosamente,
Rosa Oliveira

-- 




Rosa Celeste dos Santos Oliveira, 

E-mail: rosit...@gmail.com
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira 
[https://pt.linkedin.com/in/rosacsoliveira]


"Many admire, few know"
Hippocrates

On 10 Jun 2015, at 18:10, Don McKenzie  wrote:

For a legend, try (untested)

legend(0.15,0.9,c("factora","factorb","factorc"),col=c(4,2,3),lty=1)

If it overlaps data points move the first two arguments (0.15 and 0.9) around, 
or change the “ylim” argument in the plot() to ~1.2.

to avoid clutter, put the line-types information in the figure caption (IMO)

On Jun 10, 2015, at 10:03 AM, Don McKenzie  wrote:

On Jun 10, 2015, at 9:08 AM, Rosa Oliveira  wrote:

Dear All,

I attach my data.

Dear Jim, 

when I run your code (even the one you send me, not in my data), I get: 

Don't know how to automatically pick scale for object of type function. 
Defaulting to continuous

Error in data.frame(x = c(0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1,  : 

  arguments imply differing number of rows: 24, 0

Dear Don,

It’s meant that I will have 12 lines: 

3 factors - lines colors

with 3 different values of “sample” for each - line types

[Three colors, one for each factor,
and  three line types (lty=1,2,3), one for eachvalue of “sample - preferable 
dash, thin and thick).

in the X - I should have region (because I have 10 regions)

for each region I have the outcome of 3 different treatments (factor)

for each region and each treatment I have 3 different sample size.

But in your original post you had 4 sample sizes: 10,20,30,40.

I need to “see” the the influence of the region in the treatment outcome for 
each sample size.

So, at the end I should have 9 lines

3 red (1 dash, 1 thin, 1 thick) - concerning factor a (dash for sample size 50, 
thin for sample size 250 and thick for sample size 1000)

3 blue (1 dash, 1 thin, 1 thick) - concerning factor b (dash for sample size 
50, thin for sample size 250 and thick for sample size 1000)

3 green (1 dash, 1 thin, 1 thick) - concerning factor c (dash for sample size 
50, thin for sample size 250 and thick for sample size 1000)

Hope this time is clear.

I also though about doing 3 different graphs, each one for 1 different sample 
size, and in that case I should have 3 graphs each one with 3 lines

1 red to factor a, 1 blue to factor b and 1 green to factor c.

Do you all think is better?

A matter of style perhaps but I would use dotplots because you have only two 
data points for each “line”.  The lines will be misleading.  You also could use 

panel plots, but given your skill set (unless someone wants to spend a fair bit 
of time with

Re: [R] graphs, need urgent help (deadline :( )

2015-06-10 Thread John Kane

Hi Don,
You got caught by the old curly quotation marks vs plain quotations problem.  
My guess is  that at one point the code went through HTML or a word processor 
that automatically changes straight quotes " to curly ”  (if that comes 
through). 

A couple of long and painful debugging sessions a few years ago make me 
sensitive to such problems.

John Kane
Kingston ON Canada

-Original Message-
From: d...@u.washington.edu
Sent: Wed, 10 Jun 2015 12:07:27 -0700
To: rosit...@gmail.com
Subject: Re: [R] graphs, need urgent help (deadline :( )

Here is code that IS tested.  I am sending Rosa the (ugly) output in a separate 
file.  Crazy problems with argument order; I never figured out
exactly what was wrong.

# therapy plot

 
plot(therapy.df$Region[therapy.df$sample==50],therapy.df$factor.a[therapy.df$sample==50],xlab="Region",ylab="factor",type="l",col=4,ylim=c(0,1.5))
lines(therapy.df$Region[therapy.df$sample==50],therapy.df$factor.b[therapy.df$sample==50],col=2)
lines(therapy.df$Region[therapy.df$sample==50],therapy.df$factor.c[therapy.df$sample==50],col=3)

lines(therapy.df$Region[therapy.df$sample==250],therapy.df$factor.a[therapy.df$sample==250],col=4,lty=2)
lines(therapy.df$Region[therapy.df$sample==250],therapy.df$factor.b[therapy.df$sample==250],col=2,lty=2)
lines(therapy.df$Region[therapy.df$sample==250],therapy.df$factor.c[therapy.df$sample==250],col=3,lty=2)

lines(therapy.df$Region[therapy.df$sample==1000],therapy.df$factor.a[therapy.df$sample==1000],col=4,lty=3)
lines(therapy.df$Region[therapy.df$sample==1000],therapy.df$factor.b[therapy.df$sample==1000],col=2,lty=3)
lines(therapy.df$Region[therapy.df$sample==1000],therapy.df$factor.c[therapy.df$sample==1000],col=3,lty=3)

legend(7,1.4,c("factor.a","factor.b","factor.c"),col=c(4,2,3),lty=1)

On Jun 10, 2015, at 11:03 AM, Rosa Oliveira  wrote:

Sorry,

I taught I attached the cvs file :)



Don,

I tried, but I got an error:

> my.data$Region
 [1]  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5 
 6  7  8  9 10
> my.data$sample
 [1]   50   50   50   50   50   50   50   50   50   50  250  250  250  250  250 
 250  250  250  250  250 1000 1000 1000 1000 1000 1000 1000 1000
[29] 1000 1000
> my.data$factor.a
 [1] 0.895 0.811 0.685 0.777 0.600 0.466 0.446 0.392 0.256 0.198 0.136 0.121 
0.875 0.777 0.685 0.626 0.550 0.466 0.384 0.330 0.060 0.138 0.065
[24] 0.034 0.931 0.124 0.060 0.028 0.017 0.014

> plot(my.data$Region[my.data$sample==50],my.data$factor.a[my.data$sample==50],col=4,type=“l”,xlab=“Region”,ylab=“factor")
Error: unexpected input in 
"plot(my.data$Region[my.data$sample==50],my.data$factor.a[my.data$sample==50],col=4,type=�”

I’m really naive, right?

Best,
RO

Atenciosamente,
Rosa Oliveira

-- 




Rosa Celeste dos Santos Oliveira, 

E-mail: rosit...@gmail.com
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira

"Many admire, few know"
Hippocrates

On 10 Jun 2015, at 18:10, Don McKenzie  wrote:

For a legend, try (untested)

legend(0.15,0.9,c("factora","factorb","factorc"),col=c(4,2,3),lty=1)

If it overlaps data points move the first two arguments (0.15 and 0.9) around, 
or change the “ylim” argument in the plot() to ~1.2.

to avoid clutter, put the line-types information in the figure caption (IMO)

On Jun 10, 2015, at 10:03 AM, Don McKenzie  
wrote:

On Jun 10, 2015, at 9:08 AM, Rosa Oliveira  wrote:

Dear All,

I attach my data.

Dear Jim, 

when I run your code (even the one you send me, not in my data), I get: 

Don't know how to automatically pick scale for object of type function. 
Defaulting to continuous
Error in data.frame(x = c(0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1,  : 
  arguments imply differing number of rows: 24, 0

Dear Don,

It’s meant that I will have 12 lines: 
3 factors - lines colors
with 3 different values of “sample” for each - line types

[Three colors, one for each factor,
and  three line types (lty=1,2,3), one for eachvalue of “sample - preferable 
dash, thin and thick).

in the X - I should have region (because I have 10 regions)
for each region I have the outcome of 3 different treatments (factor)
for each region and each treatment I have 3 different sample size.

But in your original post you had 4 sample sizes: 10,20,30,40.

I need to “see” the the influence of the region in the treatment outcome for 
each sample size.

So, at the end I should have 9 lines
3 red (1 dash, 1 thin, 1 thick) - concerning factor a (dash for sample size 50, 
thin for sample size 250 and thick for sample size 1000)
3 blue (1 dash, 1 thin, 1 thick) - concerning factor b (dash for sample size 
50, thin for sample size 250 and thick for sample size 1000)
3 gree

Re: [R] graphs, need urgent help (deadline :( )

2015-06-10 Thread Don McKenzie
10,20,30,40.
>>>> 
>>>> I need to “see” the the influence of the region in the treatment outcome 
>>>> for each sample size.
>>>> 
>>>> So, at the end I should have 9 lines
>>>> 3 red (1 dash, 1 thin, 1 thick) - concerning factor a (dash for sample 
>>>> size 50, thin for sample size 250 and thick for sample size 1000)
>>>> 3 blue (1 dash, 1 thin, 1 thick) - concerning factor b (dash for sample 
>>>> size 50, thin for sample size 250 and thick for sample size 1000)
>>>> 3 green (1 dash, 1 thin, 1 thick) - concerning factor c (dash for sample 
>>>> size 50, thin for sample size 250 and thick for sample size 1000)
>>>> 
>>>> 
>>>> 
>>>> Hope this time is clear.
>>>> 
>>>> 
>>>> I also though about doing 3 different graphs, each one for 1 different 
>>>> sample size, and in that case I should have 3 graphs each one with 3 lines
>>>> 1 red to factor a, 1 blue to factor b and 1 green to factor c.
>>>> 
>>>> Do you all think is better?
>>> 
>>> A matter of style perhaps but I would use dotplots because you have only 
>>> two data points for each “line”.  The lines will be misleading.  You also 
>>> could use 
>>> panel plots, but given your skill set (unless someone wants to spend a fair 
>>> bit of time with you), it’s probably best to stay as simple as possible.
>>> 
>>> But given your original post (cleaned up)   # untested: apologies for any 
>>> typos
>>> 
>>>>region  sample  factora  factorb
>>>> factorc
>>>>0.1 10   0.895  0.903   
>>>> 0.378
>>>>0.2 10  0.8110.865  
>>>>  0.688
>>>>0.1 20  0.735   0.966   
>>>> 0.611
>>>>0.2 20   0.777   0.732  
>>>>  0.653
>>>>0.1 30  0.600   0.778   
>>>> 0.694
>>>>0.2 30   0.466   174.592
>>>> 0.461
>>>>0.1 40   0.446  0.432   
>>>> 0.693
>>>>0.2 40   0.392  0.294   
>>>>  0.686
>>> 
>>> plot(my.data$region[my.data$sample==10],my.data$factora[my.data$sample==10],col=4,type=“l”,ylim=c(0,1),xlab=“region”,ylab=“factor")
>>> lines(my.data$region[my.data$sample==10],my.data$factorb[my.data$sample==10],col=2)
>>> lines(my.data$region[my.data$sample==10],my.data$factorc[my.data$sample==10],col=3)
>>> 
>>> lines(my.data$region[my.data$sample==20],my.data$factora[my.data$sample==20],col=4,lty=2)
>>> lines(my.data$region[my.data$sample==20],my.data$factorb[my.data$sample==20],col=2,lty=2)
>>> lines(my.data$region[my.data$sample==20],my.data$factorc[my.data$sample==20],col=3,lty=2)
>>> 
>>> #  Now do two more groups of 3, changing the parameter “lty” to 3 and then 4
>>> 
>>> # Look at the syntax and note what changes and what stays constant. Do you 
>>> see how this works?
>>> # there will be what looks like a vertical line where sample = 30 and 
>>> factorb = 174.592.  Do you see why?
>>> 
>>> # then you will need a legend
>>> 
>>>> Nonetheless I can’t do it :(
>>>> 
>>>> best,
>>>> RO
>>>> 
>>>> 
>>>> 
>>>> Atenciosamente,
>>>> Rosa Oliveira
>>>> 
>>>> -- 
>>>> 
>>>>  
>>>> 
>>>> Rosa Celeste dos Santos Oliveira, 
>>>> 
>>>> E-mail: rosit...@gmail.com
>>>> Tlm: +351 939355143 
>>>> Linkedin: https://pt.linkedin.com/in/rosacsoliveira
>>>> 
>>>> "Many admire, few know"
>>>> Hippocrates
>>>> 
>>>>> On 10 Jun 2015, at 14:13, John Kane  wrote:
>>>>> 
>>>>> Hi Jim,
>>>>> 
>>>>> I was looking at that last night and had the sa

Re: [R] graphs, need urgent help (deadline :( )

2015-06-10 Thread Don McKenzie
e end I should have 9 lines
>>>> 3 red (1 dash, 1 thin, 1 thick) - concerning factor a (dash for sample 
>>>> size 50, thin for sample size 250 and thick for sample size 1000)
>>>> 3 blue (1 dash, 1 thin, 1 thick) - concerning factor b (dash for sample 
>>>> size 50, thin for sample size 250 and thick for sample size 1000)
>>>> 3 green (1 dash, 1 thin, 1 thick) - concerning factor c (dash for sample 
>>>> size 50, thin for sample size 250 and thick for sample size 1000)
>>>> 
>>>> 
>>>> 
>>>> Hope this time is clear.
>>>> 
>>>> 
>>>> I also though about doing 3 different graphs, each one for 1 different 
>>>> sample size, and in that case I should have 3 graphs each one with 3 lines
>>>> 1 red to factor a, 1 blue to factor b and 1 green to factor c.
>>>> 
>>>> Do you all think is better?
>>> 
>>> A matter of style perhaps but I would use dotplots because you have only 
>>> two data points for each “line”.  The lines will be misleading.  You also 
>>> could use 
>>> panel plots, but given your skill set (unless someone wants to spend a fair 
>>> bit of time with you), it’s probably best to stay as simple as possible.
>>> 
>>> But given your original post (cleaned up)   # untested: apologies for any 
>>> typos
>>> 
>>>>region  sample  factora  factorb
>>>> factorc
>>>>0.1 10   0.895  0.903   
>>>> 0.378
>>>>0.2 10  0.8110.865  
>>>>  0.688
>>>>0.1 20  0.735   0.966   
>>>> 0.611
>>>>0.2 20   0.777   0.732  
>>>>  0.653
>>>>0.1 30  0.600   0.778   
>>>> 0.694
>>>>0.2 30   0.466   174.592
>>>> 0.461
>>>>0.1 40   0.446  0.432   
>>>> 0.693
>>>>0.2 40   0.392  0.294   
>>>>  0.686
>>> 
>>> 
>>> plot(my.data$region[my.data$sample==10],my.data$factora[my.data$sample==10],col=4,type=“l”,ylim=c(0,1),xlab=“region”,ylab=“factor")
>>> lines(my.data$region[my.data$sample==10],my.data$factorb[my.data$sample==10],col=2)
>>> lines(my.data$region[my.data$sample==10],my.data$factorc[my.data$sample==10],col=3)
>>> 
>>> lines(my.data$region[my.data$sample==20],my.data$factora[my.data$sample==20],col=4,lty=2)
>>> lines(my.data$region[my.data$sample==20],my.data$factorb[my.data$sample==20],col=2,lty=2)
>>> lines(my.data$region[my.data$sample==20],my.data$factorc[my.data$sample==20],col=3,lty=2)
>>> 
>>> #  Now do two more groups of 3, changing the parameter “lty” to 3 and then 4
>>> 
>>> 
>>> # Look at the syntax and note what changes and what stays constant. Do you 
>>> see how this works?
>>> # there will be what looks like a vertical line where sample = 30 and 
>>> factorb = 174.592.  Do you see why?
>>> 
>>> # then you will need a legend
>>> 
>>>> Nonetheless I can’t do it :(
>>>> 
>>>> best,
>>>> RO
>>>> 
>>>> 
>>>> 
>>>> Atenciosamente,
>>>> Rosa Oliveira
>>>> 
>>>> -- 
>>>> 
>>>>  
>>>> 
>>>> Rosa Celeste dos Santos Oliveira, 
>>>> 
>>>> E-mail: rosit...@gmail.com <mailto:rosit...@gmail.com>
>>>> Tlm: +351 939355143 
>>>> Linkedin: https://pt.linkedin.com/in/rosacsoliveira 
>>>> <https://pt.linkedin.com/in/rosacsoliveira>
>>>> 
>>>> "Many admire, few know"
>>>> Hippocrates
>>>> 
>>>>> On 10 Jun 2015, at 14:13, John Kane >>>> <mailto:jrkrid...@inbox.com>> wrote:
>>>>> 
>>>>> Hi Jim,
>>>>> 
>>>>> I was looking at that last night and had the same problem of visua

Re: [R] graphs, need urgent help (deadline :( )

2015-06-10 Thread Don McKenzie
 50, thin for sample size 250 and thick for sample size 1000)
>>>>> 3 blue (1 dash, 1 thin, 1 thick) - concerning factor b (dash for sample 
>>>>> size 50, thin for sample size 250 and thick for sample size 1000)
>>>>> 3 green (1 dash, 1 thin, 1 thick) - concerning factor c (dash for sample 
>>>>> size 50, thin for sample size 250 and thick for sample size 1000)
>>>>> 
>>>>> 
>>>>> 
>>>>> Hope this time is clear.
>>>>> 
>>>>> 
>>>>> I also though about doing 3 different graphs, each one for 1 different 
>>>>> sample size, and in that case I should have 3 graphs each one with 3 lines
>>>>> 1 red to factor a, 1 blue to factor b and 1 green to factor c.
>>>>> 
>>>>> Do you all think is better?
>>>> 
>>>> A matter of style perhaps but I would use dotplots because you have only 
>>>> two data points for each “line”.  The lines will be misleading.  You also 
>>>> could use 
>>>> panel plots, but given your skill set (unless someone wants to spend a 
>>>> fair bit of time with you), it’s probably best to stay as simple as 
>>>> possible.
>>>> 
>>>> But given your original post (cleaned up)   # untested: apologies for any 
>>>> typos
>>>> 
>>>>>region  sample  factora  factorb   
>>>>> factorc
>>>>>   0.1 10   0.895  0.903   
>>>>> 0.378
>>>>>   0.2 10  0.8110.865  
>>>>>  0.688
>>>>>   0.1 20  0.735   0.966   
>>>>> 0.611
>>>>>   0.2 20   0.777   0.732  
>>>>>  0.653
>>>>>   0.1 30  0.600   0.778   
>>>>> 0.694
>>>>>   0.2 30   0.466   174.592
>>>>> 0.461
>>>>>   0.1 40   0.446  0.432   
>>>>> 0.693
>>>>>   0.2 40   0.392  0.294   
>>>>>  0.686
>>>> 
>>>> 
>>>> plot(my.data$region[my.data$sample==10],my.data$factora[my.data$sample==10],col=4,type=“l”,ylim=c(0,1),xlab=“region”,ylab=“factor")
>>>> lines(my.data$region[my.data$sample==10],my.data$factorb[my.data$sample==10],col=2)
>>>> lines(my.data$region[my.data$sample==10],my.data$factorc[my.data$sample==10],col=3)
>>>> 
>>>> lines(my.data$region[my.data$sample==20],my.data$factora[my.data$sample==20],col=4,lty=2)
>>>> lines(my.data$region[my.data$sample==20],my.data$factorb[my.data$sample==20],col=2,lty=2)
>>>> lines(my.data$region[my.data$sample==20],my.data$factorc[my.data$sample==20],col=3,lty=2)
>>>> 
>>>> #  Now do two more groups of 3, changing the parameter “lty” to 3 and then 
>>>> 4
>>>> 
>>>> 
>>>> # Look at the syntax and note what changes and what stays constant. Do you 
>>>> see how this works?
>>>> # there will be what looks like a vertical line where sample = 30 and 
>>>> factorb = 174.592.  Do you see why?
>>>> 
>>>> # then you will need a legend
>>>> 
>>>>> Nonetheless I can’t do it :(
>>>>> 
>>>>> best,
>>>>> RO
>>>>> 
>>>>> 
>>>>> 
>>>>> Atenciosamente,
>>>>> Rosa Oliveira
>>>>> 
>>>>> -- 
>>>>> 
>>>>>  
>>>>> 
>>>>> Rosa Celeste dos Santos Oliveira, 
>>>>> 
>>>>> E-mail: rosit...@gmail.com <mailto:rosit...@gmail.com>
>>>>> Tlm: +351 939355143 
>>>>> Linkedin: https://pt.linkedin.com/in/rosacsoliveira 
>>>>> <https://pt.linkedin.com/in/rosacsoliveira>
>>>>> 
>>>>> "Many admire, few know"
>>>>> Hippocrates
>>>>> 
>>>>>> On 10 Jun 2015, at 

Re: [R] graphs, need urgent help (deadline :( )

2015-06-10 Thread Rosa Oliveira
 0.1 10   0.895  0.903   
>>> 0.378
>>> 0.2 10  0.8110.865  
>>>  0.688
>>> 0.1 20  0.735   0.966   
>>> 0.611
>>> 0.2 20   0.777   0.732  
>>>  0.653
>>> 0.1 30  0.600   0.778   
>>> 0.694
>>> 0.2 30   0.466   174.592
>>> 0.461
>>> 0.1 40   0.446  0.432   
>>> 0.693
>>> 0.2 40   0.392  0.294   
>>>  0.686
>> 
>> 
>> plot(my.data$region[my.data$sample==10],my.data$factora[my.data$sample==10],col=4,type=“l”,ylim=c(0,1),xlab=“region”,ylab=“factor")
>> lines(my.data$region[my.data$sample==10],my.data$factorb[my.data$sample==10],col=2)
>> lines(my.data$region[my.data$sample==10],my.data$factorc[my.data$sample==10],col=3)
>> 
>> lines(my.data$region[my.data$sample==20],my.data$factora[my.data$sample==20],col=4,lty=2)
>> lines(my.data$region[my.data$sample==20],my.data$factorb[my.data$sample==20],col=2,lty=2)
>> lines(my.data$region[my.data$sample==20],my.data$factorc[my.data$sample==20],col=3,lty=2)
>> 
>> #  Now do two more groups of 3, changing the parameter “lty” to 3 and then 4
>> 
>> 
>> # Look at the syntax and note what changes and what stays constant. Do you 
>> see how this works?
>> # there will be what looks like a vertical line where sample = 30 and 
>> factorb = 174.592.  Do you see why?
>> 
>> # then you will need a legend
>> 
>>> Nonetheless I can’t do it :(
>>> 
>>> best,
>>> RO
>>> 
>>> 
>>> 
>>> Atenciosamente,
>>> Rosa Oliveira
>>> 
>>> -- 
>>> 
>>>  
>>> 
>>> Rosa Celeste dos Santos Oliveira, 
>>> 
>>> E-mail: rosit...@gmail.com <mailto:rosit...@gmail.com>
>>> Tlm: +351 939355143 
>>> Linkedin: https://pt.linkedin.com/in/rosacsoliveira 
>>> <https://pt.linkedin.com/in/rosacsoliveira>
>>> 
>>> "Many admire, few know"
>>> Hippocrates
>>> 
>>>> On 10 Jun 2015, at 14:13, John Kane >>> <mailto:jrkrid...@inbox.com>> wrote:
>>>> 
>>>> Hi Jim,
>>>> 
>>>> I was looking at that last night and had the same problem of visualizing 
>>>> what Rosa needed.  
>>>> 
>>>> Hi Rosa
>>>> This is nothing like what you wanted and I really don't understand your 
>>>> data but would something like this work as a substitute or am I completely 
>>>> lost?
>>>> 
>>>> 
>>>> dat1  <-  structure(list(region = c(0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1, 
>>>> 0.2), sample = c(10L, 10L, 20L, 20L, 30L, 30L, 40L, 40L), factora = 
>>>> c(0.895, 
>>>> 0.811, 0.735, 0.777, 0.6, 0.466, 0.446, 0.392), factorb = c(0.903, 
>>>> 0.865, 0.966, 0.732, 0.778, 0.592, 0.432, 0.294), factorc = c(0.37,
>>>> 0.688, 0.611, 0.653, 0.694, 0.461, 0.693, 0.686)), .Names = c("region", 
>>>> "sample", "factora", "factorb", "factorc"), class = "data.frame", 
>>>> row.names = c(NA, 
>>>> -8L))
>>>> 
>>>> 
>>>> mdat1  <-   melt(dat1, id.var = c("region", "sample"),
>>>>variable.name = "factor",
>>>>value.name = "value")
>>>> str(mdat1)
>>>> 
>>>> ggplot(mdat1, aes(region, value, colour = factor)) +
>>>>geom_line() + facet_grid(sample ~ .)
>>>> 
>>>> John Kane
>>>> Kingston ON Canada
>>>> 
>>>> 
>>>>> -Original Message-
>>>>> From: drjimle...@gmail.com <mailto:drjimle...@gmail.com>
>>>>> Sent: Wed, 10 Jun 2015 20:51:52 +1000
>>>>> To: rosit...@gmail.com <mailto:rosit...@gmail.com>
>>>>> Subject: Re: [R] graphs, need urgent help (deadline :( )
&

Re: [R] graphs, need urgent help (deadline :( )

2015-06-10 Thread Don McKenzie
ne for 1 different 
>>>> sample size, and in that case I should have 3 graphs each one with 3 lines
>>>> 1 red to factor a, 1 blue to factor b and 1 green to factor c.
>>>> 
>>>> Do you all think is better?
>>> 
>>> A matter of style perhaps but I would use dotplots because you have only 
>>> two data points for each “line”.  The lines will be misleading.  You also 
>>> could use 
>>> panel plots, but given your skill set (unless someone wants to spend a fair 
>>> bit of time with you), it’s probably best to stay as simple as possible.
>>> 
>>> But given your original post (cleaned up)   # untested: apologies for any 
>>> typos
>>> 
>>>>region  sample  factora  factorb
>>>> factorc
>>>>0.1 10   0.895  0.903   
>>>> 0.378
>>>>0.2 10  0.8110.865  
>>>>  0.688
>>>>0.1 20  0.735   0.966   
>>>> 0.611
>>>>0.2 20   0.777   0.732  
>>>>  0.653
>>>>0.1 30  0.600   0.778   
>>>> 0.694
>>>>0.2 30   0.466   174.592
>>>> 0.461
>>>>0.1 40   0.446  0.432   
>>>> 0.693
>>>>0.2 40   0.392  0.294   
>>>>  0.686
>>> 
>>> 
>>> plot(my.data$region[my.data$sample==10],my.data$factora[my.data$sample==10],col=4,type=“l”,ylim=c(0,1),xlab=“region”,ylab=“factor")
>>> lines(my.data$region[my.data$sample==10],my.data$factorb[my.data$sample==10],col=2)
>>> lines(my.data$region[my.data$sample==10],my.data$factorc[my.data$sample==10],col=3)
>>> 
>>> lines(my.data$region[my.data$sample==20],my.data$factora[my.data$sample==20],col=4,lty=2)
>>> lines(my.data$region[my.data$sample==20],my.data$factorb[my.data$sample==20],col=2,lty=2)
>>> lines(my.data$region[my.data$sample==20],my.data$factorc[my.data$sample==20],col=3,lty=2)
>>> 
>>> #  Now do two more groups of 3, changing the parameter “lty” to 3 and then 4
>>> 
>>> 
>>> # Look at the syntax and note what changes and what stays constant. Do you 
>>> see how this works?
>>> # there will be what looks like a vertical line where sample = 30 and 
>>> factorb = 174.592.  Do you see why?
>>> 
>>> # then you will need a legend
>>> 
>>>> Nonetheless I can’t do it :(
>>>> 
>>>> best,
>>>> RO
>>>> 
>>>> 
>>>> 
>>>> Atenciosamente,
>>>> Rosa Oliveira
>>>> 
>>>> -- 
>>>> 
>>>>  
>>>> 
>>>> Rosa Celeste dos Santos Oliveira, 
>>>> 
>>>> E-mail: rosit...@gmail.com <mailto:rosit...@gmail.com>
>>>> Tlm: +351 939355143 
>>>> Linkedin: https://pt.linkedin.com/in/rosacsoliveira 
>>>> <https://pt.linkedin.com/in/rosacsoliveira>
>>>> 
>>>> "Many admire, few know"
>>>> Hippocrates
>>>> 
>>>>> On 10 Jun 2015, at 14:13, John Kane >>>> <mailto:jrkrid...@inbox.com>> wrote:
>>>>> 
>>>>> Hi Jim,
>>>>> 
>>>>> I was looking at that last night and had the same problem of visualizing 
>>>>> what Rosa needed.  
>>>>> 
>>>>> Hi Rosa
>>>>> This is nothing like what you wanted and I really don't understand your 
>>>>> data but would something like this work as a substitute or am I 
>>>>> completely lost?
>>>>> 
>>>>> 
>>>>> dat1  <-  structure(list(region = c(0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1, 
>>>>> 0.2), sample = c(10L, 10L, 20L, 20L, 30L, 30L, 40L, 40L), factora = 
>>>>> c(0.895, 
>>>>> 0.811, 0.735, 0.777, 0.6, 0.466, 0.446, 0.392), factorb = c(0.903, 
>>>>> 0.865, 0.966, 0.732, 0.778, 0.592, 0.432, 0.294), factorc 

Re: [R] graphs, need urgent help (deadline :( )

2015-06-10 Thread Don McKenzie
works?
> # there will be what looks like a vertical line where sample = 30 and factorb 
> = 174.592.  Do you see why?
> 
> # then you will need a legend
> 
>> Nonetheless I can’t do it :(
>> 
>> best,
>> RO
>> 
>> 
>> 
>> Atenciosamente,
>> Rosa Oliveira
>> 
>> -- 
>> 
>>  
>> 
>> Rosa Celeste dos Santos Oliveira, 
>> 
>> E-mail: rosit...@gmail.com <mailto:rosit...@gmail.com>
>> Tlm: +351 939355143 
>> Linkedin: https://pt.linkedin.com/in/rosacsoliveira 
>> <https://pt.linkedin.com/in/rosacsoliveira>
>> 
>> "Many admire, few know"
>> Hippocrates
>> 
>>> On 10 Jun 2015, at 14:13, John Kane >> <mailto:jrkrid...@inbox.com>> wrote:
>>> 
>>> Hi Jim,
>>> 
>>> I was looking at that last night and had the same problem of visualizing 
>>> what Rosa needed.  
>>> 
>>> Hi Rosa
>>> This is nothing like what you wanted and I really don't understand your 
>>> data but would something like this work as a substitute or am I completely 
>>> lost?
>>> 
>>> 
>>> dat1  <-  structure(list(region = c(0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1, 
>>> 0.2), sample = c(10L, 10L, 20L, 20L, 30L, 30L, 40L, 40L), factora = 
>>> c(0.895, 
>>> 0.811, 0.735, 0.777, 0.6, 0.466, 0.446, 0.392), factorb = c(0.903, 
>>> 0.865, 0.966, 0.732, 0.778, 0.592, 0.432, 0.294), factorc = c(0.37, 
>>> 0.688, 0.611, 0.653, 0.694, 0.461, 0.693, 0.686)), .Names = c("region", 
>>> "sample", "factora", "factorb", "factorc"), class = "data.frame", row.names 
>>> = c(NA, 
>>> -8L))
>>> 
>>> 
>>> mdat1  <-   melt(dat1, id.var = c("region", "sample"),
>>>variable.name = "factor",
>>>value.name = "value")
>>> str(mdat1)
>>> 
>>> ggplot(mdat1, aes(region, value, colour = factor)) +
>>>geom_line() + facet_grid(sample ~ .)
>>> 
>>> John Kane
>>> Kingston ON Canada
>>> 
>>> 
>>>> -Original Message-
>>>> From: drjimle...@gmail.com <mailto:drjimle...@gmail.com>
>>>> Sent: Wed, 10 Jun 2015 20:51:52 +1000
>>>> To: rosit...@gmail.com <mailto:rosit...@gmail.com>
>>>> Subject: Re: [R] graphs, need urgent help (deadline :( )
>>>> 
>>>> Hi Rosa,
>>>> Like Don, I can't work out what you want and I don't even have the
>>>> picture. For example, your specification of color and line type leaves
>>>> only one point for each color and line type, and the line from one
>>>> point to the same point is not going to show up. Here is a possibility
>>>> that may lead (eventually) to a solution.
>>>> 
>>>> library(plotrix)
>>>> par(tcl=-0.1)
>>>> gap.plot(x=rep(seq(10,45,by=5),3),
>>>> y=unlist(my.data[,c("factora","factorb","factorc")]),
>>>> main="A plot of factorial mystery",
>>>> gap=c(1.1,174),ylim=c(0,175),ylab="factor score",xlab="Group",
>>>> xticlab=c(" \n0.1\n10"," \n0.2\n10"," \n0.1\n20"," \n0.2\n20",
>>>>  " \n0.1\n30"," \n0.2\n30"," \n0.1\n40"," \n0.2\n40"),
>>>> ytics=c(0,0.5,1,174.59),pch=rep(1:3,each=8),col=rep(c(4,2,3),each=8))
>>>> mtext(c("Region","Sample"),side=1,at=6,line=c(0,1))
>>>> lines(seq(10,45,by=5),my.data$factora,col=4)
>>>> lines(seq(10,45,by=5),my.data$factorb[c(1:5,NA,7,8)],col=2)
>>>> lines(seq(10,45,by=5),my.data$factorc,col=3)
>>>> 
>>>> Jim
>>>> 
>>>> 
>>>> On Wed, Jun 10, 2015 at 10:53 AM, Rosa Oliveira >>> <mailto:rosit...@gmail.com>>
>>>> wrote:
>>>>> Dear Don and all,
>>>>> 
>>>>> I’ve read the tutorial and tried several codes before posting :)
>>>>> I’m really naive.
>>>>> 
>>>>> 
>>>>> 
>>>>> what I was trying to :  is something like the graph in the picture I
>>>>> drawee.
>>>>> 
>>>>> 
>>>>>

Re: [R] graphs, need urgent help (deadline :( )

2015-06-10 Thread Rosa Oliveira
Dear All,


I attach my data.

Dear Jim, 

when I run your code (even the one you send me, not in my data), I get: 

Don't know how to automatically pick scale for object of type function. 
Defaulting to continuous
Error in data.frame(x = c(0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1,  : 
  arguments imply differing number of rows: 24, 0



Dear Don,

It’s meant that I will have 12 lines: 
3 factors - lines colors
with 3 different values of “sample” for each - line types


[Three colors, one for each factor,
and  three line types (lty=1,2,3), one for eachvalue of “sample - preferable 
dash, thin and thick).


in the X - I should have region (because I have 10 regions)
for each region I have the outcome of 3 different treatments (factor)
for each region and each treatment I have 3 different sample size.

I need to “see” the the influence of the region in the treatment outcome for 
each sample size.

So, at the end I should have 9 lines
3 red (1 dash, 1 thin, 1 thick) - concerning factor a (dash for sample size 50, 
thin for sample size 250 and thick for sample size 1000)
3 blue (1 dash, 1 thin, 1 thick) - concerning factor b (dash for sample size 
50, thin for sample size 250 and thick for sample size 1000)
3 green (1 dash, 1 thin, 1 thick) - concerning factor c (dash for sample size 
50, thin for sample size 250 and thick for sample size 1000)



Hope this time is clear.


I also though about doing 3 different graphs, each one for 1 different sample 
size, and in that case I should have 3 graphs each one with 3 lines
1 red to factor a, 1 blue to factor b and 1 green to factor c.

Do you all think is better?
Nonetheless I can’t do it :(

best,
RO



Atenciosamente,
Rosa Oliveira

-- 



Rosa Celeste dos Santos Oliveira, 

E-mail: rosit...@gmail.com
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira

"Many admire, few know"
Hippocrates

> On 10 Jun 2015, at 14:13, John Kane  wrote:
> 
> Hi Jim,
> 
> I was looking at that last night and had the same problem of visualizing what 
> Rosa needed.  
> 
> Hi Rosa
> This is nothing like what you wanted and I really don't understand your data 
> but would something like this work as a substitute or am I completely lost?
> 
> 
> dat1  <-  structure(list(region = c(0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1,
> 0.2), sample = c(10L, 10L, 20L, 20L, 30L, 30L, 40L, 40L), factora = c(0.895, 
> 0.811, 0.735, 0.777, 0.6, 0.466, 0.446, 0.392), factorb = c(0.903, 
> 0.865, 0.966, 0.732, 0.778, 0.592, 0.432, 0.294), factorc = c(0.37, 
> 0.688, 0.611, 0.653, 0.694, 0.461, 0.693, 0.686)), .Names = c("region",
> "sample", "factora", "factorb", "factorc"), class = "data.frame", row.names = 
> c(NA, 
> -8L))
> 
> 
> mdat1  <-   melt(dat1, id.var = c("region", "sample"),
>variable.name = "factor",
>value.name = "value")
> str(mdat1)
> 
> ggplot(mdat1, aes(region, value, colour = factor)) +
>geom_line() + facet_grid(sample ~ .)
> 
> John Kane
> Kingston ON Canada
> 
> 
>> -Original Message-
>> From: drjimle...@gmail.com
>> Sent: Wed, 10 Jun 2015 20:51:52 +1000
>> To: rosit...@gmail.com
>> Subject: Re: [R] graphs, need urgent help (deadline :( )
>> 
>> Hi Rosa,
>> Like Don, I can't work out what you want and I don't even have the
>> picture. For example, your specification of color and line type leaves
>> only one point for each color and line type, and the line from one
>> point to the same point is not going to show up. Here is a possibility
>> that may lead (eventually) to a solution.
>> 
>> library(plotrix)
>> par(tcl=-0.1)
>> gap.plot(x=rep(seq(10,45,by=5),3),
>> y=unlist(my.data[,c("factora","factorb","factorc")]),
>> main="A plot of factorial mystery",
>> gap=c(1.1,174),ylim=c(0,175),ylab="factor score",xlab="Group",
>> xticlab=c(" \n0.1\n10"," \n0.2\n10"," \n0.1\n20"," \n0.2\n20",
>>  " \n0.1\n30"," \n0.2\n30"," \n0.1\n40"," \n0.2\n40"),
>> ytics=c(0,0.5,1,174.59),pch=rep(1:3,each=8),col=rep(c(4,2,3),each=8))
>> mtext(c("Region","Sample"),side=1,at=6,line=c(0,1))
>> lines(seq(10,45,by=5),my.data$factora,col=4)
>> lines(seq(10,45,by=5),my.data$factorb[c(1:5,NA,7,8)],col=2)
>> lines(seq(10,45,by=5),my.data$factorc,col=3)
>> 
>> Jim
>> 
>> 
>> On Wed, Jun 10, 2015 at 10:53 

Re: [R] graphs, need urgent help (deadline :( )

2015-06-10 Thread Don McKenzie
gt;> 
>> I was looking at that last night and had the same problem of visualizing 
>> what Rosa needed.  
>> 
>> Hi Rosa
>> This is nothing like what you wanted and I really don't understand your data 
>> but would something like this work as a substitute or am I completely lost?
>> 
>> 
>> dat1  <-  structure(list(region = c(0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1, 
>> 0.2), sample = c(10L, 10L, 20L, 20L, 30L, 30L, 40L, 40L), factora = c(0.895, 
>> 0.811, 0.735, 0.777, 0.6, 0.466, 0.446, 0.392), factorb = c(0.903, 
>> 0.865, 0.966, 0.732, 0.778, 0.592, 0.432, 0.294), factorc = c(0.37, 
>> 0.688, 0.611, 0.653, 0.694, 0.461, 0.693, 0.686)), .Names = c("region", 
>> "sample", "factora", "factorb", "factorc"), class = "data.frame", row.names 
>> = c(NA, 
>> -8L))
>> 
>> 
>> mdat1  <-   melt(dat1, id.var = c("region", "sample"),
>>variable.name = "factor",
>>value.name = "value")
>> str(mdat1)
>> 
>> ggplot(mdat1, aes(region, value, colour = factor)) +
>>geom_line() + facet_grid(sample ~ .)
>> 
>> John Kane
>> Kingston ON Canada
>> 
>> 
>>> -Original Message-
>>> From: drjimle...@gmail.com <mailto:drjimle...@gmail.com>
>>> Sent: Wed, 10 Jun 2015 20:51:52 +1000
>>> To: rosit...@gmail.com <mailto:rosit...@gmail.com>
>>> Subject: Re: [R] graphs, need urgent help (deadline :( )
>>> 
>>> Hi Rosa,
>>> Like Don, I can't work out what you want and I don't even have the
>>> picture. For example, your specification of color and line type leaves
>>> only one point for each color and line type, and the line from one
>>> point to the same point is not going to show up. Here is a possibility
>>> that may lead (eventually) to a solution.
>>> 
>>> library(plotrix)
>>> par(tcl=-0.1)
>>> gap.plot(x=rep(seq(10,45,by=5),3),
>>> y=unlist(my.data[,c("factora","factorb","factorc")]),
>>> main="A plot of factorial mystery",
>>> gap=c(1.1,174),ylim=c(0,175),ylab="factor score",xlab="Group",
>>> xticlab=c(" \n0.1\n10"," \n0.2\n10"," \n0.1\n20"," \n0.2\n20",
>>>  " \n0.1\n30"," \n0.2\n30"," \n0.1\n40"," \n0.2\n40"),
>>> ytics=c(0,0.5,1,174.59),pch=rep(1:3,each=8),col=rep(c(4,2,3),each=8))
>>> mtext(c("Region","Sample"),side=1,at=6,line=c(0,1))
>>> lines(seq(10,45,by=5),my.data$factora,col=4)
>>> lines(seq(10,45,by=5),my.data$factorb[c(1:5,NA,7,8)],col=2)
>>> lines(seq(10,45,by=5),my.data$factorc,col=3)
>>> 
>>> Jim
>>> 
>>> 
>>> On Wed, Jun 10, 2015 at 10:53 AM, Rosa Oliveira >> <mailto:rosit...@gmail.com>>
>>> wrote:
>>>> Dear Don and all,
>>>> 
>>>> I’ve read the tutorial and tried several codes before posting :)
>>>> I’m really naive.
>>>> 
>>>> 
>>>> 
>>>> what I was trying to :  is something like the graph in the picture I
>>>> drawee.
>>>> 
>>>> 
>>>> 
>>>> 
>>>> Is it more clear now?
>>>> 
>>>> Atenciosamente,
>>>> Rosa Oliveira
>>>> 
>>>> --
>>>> 
>>>> 
>>>> 
>>>> Rosa Celeste dos Santos Oliveira,
>>>> 
>>>> E-mail: rosit...@gmail.com <mailto:rosit...@gmail.com> 
>>>> <mailto:rosit...@gmail.com <mailto:rosit...@gmail.com>>
>>>> Tlm: +351 939355143
>>>> Linkedin: https://pt.linkedin.com/in/rosacsoliveira 
>>>> <https://pt.linkedin.com/in/rosacsoliveira>
>>>> <https://pt.linkedin.com/in/rosacsoliveira 
>>>> <https://pt.linkedin.com/in/rosacsoliveira>>
>>>> 
>>>> "Many admire, few know"
>>>> Hippocrates
>>>> 
>>>>> On 09 Jun 2015, at 19:23, Don McKenzie >>>> <mailto:d...@u.washington.edu>
>>>>> <mailto:d...@u.washington.edu <mailto:d...@u.washington.edu>>> wrote:
>>>>> 
>>>>> The answer lies in learning to use the he

Re: [R] graphs, need urgent help (deadline :( )

2015-06-10 Thread John Kane
Hi Jim,

I was looking at that last night and had the same problem of visualizing what 
Rosa needed.  

Hi Rosa
This is nothing like what you wanted and I really don't understand your data 
but would something like this work as a substitute or am I completely lost?


dat1  <-  structure(list(region = c(0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1, 
0.2), sample = c(10L, 10L, 20L, 20L, 30L, 30L, 40L, 40L), factora = c(0.895, 
0.811, 0.735, 0.777, 0.6, 0.466, 0.446, 0.392), factorb = c(0.903, 
0.865, 0.966, 0.732, 0.778, 0.592, 0.432, 0.294), factorc = c(0.37, 
0.688, 0.611, 0.653, 0.694, 0.461, 0.693, 0.686)), .Names = c("region", 
"sample", "factora", "factorb", "factorc"), class = "data.frame", row.names = 
c(NA, 
-8L))


mdat1  <-   melt(dat1, id.var = c("region", "sample"),
variable.name = "factor",
value.name = "value")
str(mdat1)
 
ggplot(mdat1, aes(region, value, colour = factor)) +
geom_line() + facet_grid(sample ~ .)

John Kane
Kingston ON Canada


> -Original Message-----
> From: drjimle...@gmail.com
> Sent: Wed, 10 Jun 2015 20:51:52 +1000
> To: rosit...@gmail.com
> Subject: Re: [R] graphs, need urgent help (deadline :( )
> 
> Hi Rosa,
> Like Don, I can't work out what you want and I don't even have the
> picture. For example, your specification of color and line type leaves
> only one point for each color and line type, and the line from one
> point to the same point is not going to show up. Here is a possibility
> that may lead (eventually) to a solution.
> 
> library(plotrix)
> par(tcl=-0.1)
> gap.plot(x=rep(seq(10,45,by=5),3),
>  y=unlist(my.data[,c("factora","factorb","factorc")]),
>  main="A plot of factorial mystery",
>  gap=c(1.1,174),ylim=c(0,175),ylab="factor score",xlab="Group",
>  xticlab=c(" \n0.1\n10"," \n0.2\n10"," \n0.1\n20"," \n0.2\n20",
>   " \n0.1\n30"," \n0.2\n30"," \n0.1\n40"," \n0.2\n40"),
>  ytics=c(0,0.5,1,174.59),pch=rep(1:3,each=8),col=rep(c(4,2,3),each=8))
> mtext(c("Region","Sample"),side=1,at=6,line=c(0,1))
> lines(seq(10,45,by=5),my.data$factora,col=4)
> lines(seq(10,45,by=5),my.data$factorb[c(1:5,NA,7,8)],col=2)
> lines(seq(10,45,by=5),my.data$factorc,col=3)
> 
> Jim
> 
> 
> On Wed, Jun 10, 2015 at 10:53 AM, Rosa Oliveira 
> wrote:
>> Dear Don and all,
>> 
>> I’ve read the tutorial and tried several codes before posting :)
>> I’m really naive.
>> 
>> 
>> 
>> what I was trying to :  is something like the graph in the picture I
>> drawee.
>> 
>> 
>> 
>> 
>> Is it more clear now?
>> 
>> Atenciosamente,
>> Rosa Oliveira
>> 
>> --
>> 
>> 
>> 
>> Rosa Celeste dos Santos Oliveira,
>> 
>> E-mail: rosit...@gmail.com <mailto:rosit...@gmail.com>
>> Tlm: +351 939355143
>> Linkedin: https://pt.linkedin.com/in/rosacsoliveira
>> <https://pt.linkedin.com/in/rosacsoliveira>
>> 
>> "Many admire, few know"
>> Hippocrates
>> 
>>> On 09 Jun 2015, at 19:23, Don McKenzie >> <mailto:d...@u.washington.edu>> wrote:
>>> 
>>> The answer lies in learning to use the help (and knowing where to
>>> start).  Did you look at the tutorial that comes with the R
>>> installation?
>>> 
>>> ?plot
>>> ?lines
>>> 
>>> ?par
>>> 
>>> In the last, look for the descriptions of “col” and “lty”.
>>> 
>>> Using plot() and lines(), and subsetting the four unique values of
>>> “sample”, you can create your lines.
>>> 
>>> Here is a crude start, assuming your columns are part of a data frame
>>> called “my.data”.   Untested...
>>> 
plot(my.data$region[my.data$sample==10],my.data$factora[my.data$sample==10],col=4)
>>> # blue line, not dashed
>>> .
>>> .
>>> .
lines(my.data$region[my.data$sample==20],my.data$factorb[my.data$sample==20],col=2,lty=2)
>>> # red dashed line
>>> 
>>> 
>>>> On Jun 9, 2015, at 10:36 AM, Rosa Oliveira >>> <mailto:rosit...@gmail.com>> wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> another naive question (i’m pretty sure :( )
>>>> 
>>>> 
>>>> I’m trying to plot a multi

Re: [R] graphs, need urgent help (deadline :( )

2015-06-10 Thread Jim Lemon
Hi Rosa,
Like Don, I can't work out what you want and I don't even have the
picture. For example, your specification of color and line type leaves
only one point for each color and line type, and the line from one
point to the same point is not going to show up. Here is a possibility
that may lead (eventually) to a solution.

library(plotrix)
par(tcl=-0.1)
gap.plot(x=rep(seq(10,45,by=5),3),
 y=unlist(my.data[,c("factora","factorb","factorc")]),
 main="A plot of factorial mystery",
 gap=c(1.1,174),ylim=c(0,175),ylab="factor score",xlab="Group",
 xticlab=c(" \n0.1\n10"," \n0.2\n10"," \n0.1\n20"," \n0.2\n20",
  " \n0.1\n30"," \n0.2\n30"," \n0.1\n40"," \n0.2\n40"),
 ytics=c(0,0.5,1,174.59),pch=rep(1:3,each=8),col=rep(c(4,2,3),each=8))
mtext(c("Region","Sample"),side=1,at=6,line=c(0,1))
lines(seq(10,45,by=5),my.data$factora,col=4)
lines(seq(10,45,by=5),my.data$factorb[c(1:5,NA,7,8)],col=2)
lines(seq(10,45,by=5),my.data$factorc,col=3)

Jim


On Wed, Jun 10, 2015 at 10:53 AM, Rosa Oliveira  wrote:
> Dear Don and all,
>
> I’ve read the tutorial and tried several codes before posting :)
> I’m really naive.
>
>
>
> what I was trying to :  is something like the graph in the picture I drawee.
>
>
>
>
> Is it more clear now?
>
> Atenciosamente,
> Rosa Oliveira
>
> --
> 
>
>
> Rosa Celeste dos Santos Oliveira,
>
> E-mail: rosit...@gmail.com 
> Tlm: +351 939355143
> Linkedin: https://pt.linkedin.com/in/rosacsoliveira 
> 
> 
> "Many admire, few know"
> Hippocrates
>
>> On 09 Jun 2015, at 19:23, Don McKenzie > > wrote:
>>
>> The answer lies in learning to use the help (and knowing where to start).  
>> Did you look at the tutorial that comes with the R installation?
>>
>> ?plot
>> ?lines
>>
>> ?par
>>
>> In the last, look for the descriptions of “col” and “lty”.
>>
>> Using plot() and lines(), and subsetting the four unique values of “sample”, 
>> you can create your lines.
>>
>> Here is a crude start, assuming your columns are part of a data frame called 
>> “my.data”.   Untested...
>>
>> plot(my.data$region[my.data$sample==10],my.data$factora[my.data$sample==10],col=4)
>>  # blue line, not dashed
>> .
>> .
>> .
>> lines(my.data$region[my.data$sample==20],my.data$factorb[my.data$sample==20],col=2,lty=2)
>># red dashed line
>>
>>
>>> On Jun 9, 2015, at 10:36 AM, Rosa Oliveira >> > wrote:
>>>
>>> Hi,
>>>
>>> another naive question (i’m pretty sure :( )
>>>
>>>
>>> I’m trying to plot a multiple line graph:
>>>
>>> region  sample  factora  factorb
>>> factorc
>>> 0.1  10  0.895   0.903   0.378
>>> 0.2  10  0.811   0.865   0.688
>>> 0.1  20  0.735   0.966   0.611
>>> 0.2  20  0.777   0.732   0.653
>>> 0.1  30  0.600   0.778   0.694
>>> 0.2  30  0.466   174.592 0.461
>>> 0.1  40  0.446   0.432   0.693
>>> 0.2  40  0.392   0.294   0.686
>>>
>>>
>>>
>>> The first column should be the independent variable, the second should 
>>> compute a bold line for sample(10) and dash line for sample 20.
>>
>> What about the other two values of “sample”?
>>
>>> The others variables are outcomes for each of the first scenarios, and so 
>>> it should: the 3rd, 4th and 5th columns should be blue, red and green 
>>> respectively.
>>>
>>>
>>> Resume :)
>>>
>>> I should have a graph, in the x-axe should have the region and in the y 
>>> axe, the factor.
>>> Lines:
>>>  1 - blue and bold for region 0.1, sample 10 and factor a
>>>  2 - blue and dash for region 0.2, sample 10 and factor a
>>>  3 - red and bold for region 0.1, sample 10 and factor b
>>>  4 - red and dash for region 0.2, sample 10 and factor b
>>>  5 - green and bold for region 0.1, sample 10 and factor c
>>>  6 - green and dash for region 0.2, sample 10 and factor c
>>
>> Not consistent with what you said above. These are no longer lines, but 
>> points.
>>>
>>> nonetheless the independent variable is nominal, I should plot a line graph.
>>>
>>> Can anyone help me please?
>>> I have my file as a cvs file, so I first read that file (that I know how to 
>>> do :)).
>>>
>>> But I have it in that format.
>>>
>>> Best,
>>> RO
>>>
>>>
>>>
>>> Atenciosamente,
>>> Rosa Oliveira
>>>
>>> --
>>> 
>>>
>>>
>>> Rosa Celeste dos Santos Oliveira,
>>>
>>> E-mail: rosit...@gmail.com 
>>> Tlm: +351 939355143
>>> Linkedin: https://pt.linkedin.com/in/rosacsoliveira 
>>> 
>>> 
>>> "Many admire, few know"
>>> Hippocrates
>>>
>>>
>>>  [[alternative HTML version deleted]]
>>>
>>> __

Re: [R] graphs, need urgent help [from Rosa Oliveira]

2015-06-09 Thread Rosa Oliveira
Dear Don,

I done the plot and the lines, and it’s  fine.
I’ll have 10 values on sample. It’s generating (on simulation), that’s why that 
huge outlier, and the other missing points.

The graph I’ve done, is just an example, just to illustrate what I have to get, 
but off course with 10 points in sample, and all the other specificityies.

Best,
RO

Atenciosamente,
Rosa Oliveira

-- 



Rosa Celeste dos Santos Oliveira, 

E-mail: rosit...@gmail.com
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira

"Many admire, few know"
Hippocrates

> On 10 Jun 2015, at 02:41, Don McKenzie  wrote:
> 
> The R function plot() will draw the first line and the two axes.  You need to 
> tell it which subsample of your data to plot, as in my example below.
> So start with those two observations for which “sample” = 10.  But if you 
> want separate lines for each unique value of “sample”, your lines will connect
> only two data points, because you have only two instances of each of those 
> unique values, unlike the lines in your hand-drawn graph.
> 
> Another issue is that you have a huge outlier (value very much larger than 
> the others) in the 6th row of “factorb”.  Is this an error?  If not, your 
> other lines will be indistinguishable when you try to plot everything.
> 
> Part of the reason no one else has responded may be that it appears that you 
> are confused about your own data in a way that makes it very difficult for 
> us to help you.  Can you get some basic advice from someone local?  I or 
> someone else on the list could give you the code line-by-line that we THINK 
> you need,
> but it could be wrong, given the inconsistencies in what you have shown us, 
> and that would make everything worse.
> 
>>> plot(my.data$region[my.data$sample==10],my.data$factora[my.data$sample==10],col=4)
>>>  # blue line, not dashed
> 
> Did you try plotting just this line?  What happened?
> 
> 
>> On Jun 9, 2015, at 5:53 PM, Rosa Oliveira > > wrote:
>> 
>> Dear Don and all,
>> 
>> I’ve read the tutorial and tried several codes before posting :)
>> I’m really naive.
>> 
>> 
>> 
>> what I was trying to :  is something like the graph in the picture I drawee.
>> 
>> 
>> 
>> 
>> Is it more clear now? 
>> 
>> Atenciosamente,
>> Rosa Oliveira
>> 
>> -- 
>> 
>>  
>> 
>> Rosa Celeste dos Santos Oliveira, 
>> 
>> E-mail: rosit...@gmail.com 
>> Tlm: +351 939355143 
>> Linkedin: https://pt.linkedin.com/in/rosacsoliveira 
>> 
>> 
>> "Many admire, few know"
>> Hippocrates
>> 
>>> On 09 Jun 2015, at 19:23, Don McKenzie >> > wrote:
>>> 
>>> The answer lies in learning to use the help (and knowing where to start).  
>>> Did you look at the tutorial that comes with the R installation?
>>> 
>>> ?plot
>>> ?lines
>>> 
>>> ?par   
>>> 
>>> In the last, look for the descriptions of “col” and “lty”.
>>> 
>>> Using plot() and lines(), and subsetting the four unique values of 
>>> “sample”, you can create your lines.
>>> 
>>> Here is a crude start, assuming your columns are part of a data frame 
>>> called “my.data”.   Untested...
>>> 
>>> plot(my.data$region[my.data$sample==10],my.data$factora[my.data$sample==10],col=4)
>>>  # blue line, not dashed
> 
> Did you try plotting just this line?  What happened?
> 
>>> .
>>> .
>>> .
>>> lines(my.data$region[my.data$sample==20],my.data$factorb[my.data$sample==20],col=2,lty=2)
>>># red dashed line
>>> 
>>> 
 On Jun 9, 2015, at 10:36 AM, Rosa Oliveira >>> > wrote:
 
 Hi,
 
 another naive question (i’m pretty sure :( )
 
 
 I’m trying to plot a multiple line graph:
 
 regionsample  factora  factorb
 factorc
 0.110  0.895   0.903   0.378
 0.210  0.811   0.865   0.688
 0.120  0.735   0.966   0.611
 0.220  0.777   0.732   0.653
 0.130  0.600   0.778   0.694
 0.230  0.466   174.592 0.461
 0.140  0.446   0.432   0.693
 0.240  0.392   0.294   0.686
 
 
 
 The first column should be the independent variable, the second should 
 compute a bold line for sample(10) and dash line for sample 20.
>>> 
>>> What about the other two values of “sample”?  
>>> 
 The others variables are outcomes for each of the first scenarios, and so 
 it should: the 3rd, 4th and 5th columns should be blue, red and green 
 respectively. 
 
 
 Resume :)
 
 I should have a graph, in the x-axe should have t

Re: [R] graphs, need urgent help [from Rosa Oliveira]

2015-06-09 Thread Don McKenzie
The R function plot() will draw the first line and the two axes.  You need to 
tell it which subsample of your data to plot, as in my example below.
So start with those two observations for which “sample” = 10.  But if you want 
separate lines for each unique value of “sample”, your lines will connect
only two data points, because you have only two instances of each of those 
unique values, unlike the lines in your hand-drawn graph.

Another issue is that you have a huge outlier (value very much larger than the 
others) in the 6th row of “factorb”.  Is this an error?  If not, your other 
lines will be indistinguishable when you try to plot everything.

Part of the reason no one else has responded may be that it appears that you 
are confused about your own data in a way that makes it very difficult for 
us to help you.  Can you get some basic advice from someone local?  I or 
someone else on the list could give you the code line-by-line that we THINK you 
need,
but it could be wrong, given the inconsistencies in what you have shown us, and 
that would make everything worse.

>> plot(my.data$region[my.data$sample==10],my.data$factora[my.data$sample==10],col=4)
>>  # blue line, not dashed

Did you try plotting just this line?  What happened?


> On Jun 9, 2015, at 5:53 PM, Rosa Oliveira  wrote:
> 
> Dear Don and all,
> 
> I’ve read the tutorial and tried several codes before posting :)
> I’m really naive.
> 
> 
> 
> what I was trying to :  is something like the graph in the picture I drawee.
> 
> 
> 
> 
> Is it more clear now? 
> 
> Atenciosamente,
> Rosa Oliveira
> 
> -- 
> 
>  
> 
> Rosa Celeste dos Santos Oliveira, 
> 
> E-mail: rosit...@gmail.com 
> Tlm: +351 939355143 
> Linkedin: https://pt.linkedin.com/in/rosacsoliveira 
> 
> 
> "Many admire, few know"
> Hippocrates
> 
>> On 09 Jun 2015, at 19:23, Don McKenzie > > wrote:
>> 
>> The answer lies in learning to use the help (and knowing where to start).  
>> Did you look at the tutorial that comes with the R installation?
>> 
>> ?plot
>> ?lines
>> 
>> ?par   
>> 
>> In the last, look for the descriptions of “col” and “lty”.
>> 
>> Using plot() and lines(), and subsetting the four unique values of “sample”, 
>> you can create your lines.
>> 
>> Here is a crude start, assuming your columns are part of a data frame called 
>> “my.data”.   Untested...
>> 
>> plot(my.data$region[my.data$sample==10],my.data$factora[my.data$sample==10],col=4)
>>  # blue line, not dashed

Did you try plotting just this line?  What happened?

>> .
>> .
>> .
>> lines(my.data$region[my.data$sample==20],my.data$factorb[my.data$sample==20],col=2,lty=2)
>># red dashed line
>> 
>> 
>>> On Jun 9, 2015, at 10:36 AM, Rosa Oliveira >> > wrote:
>>> 
>>> Hi,
>>> 
>>> another naive question (i’m pretty sure :( )
>>> 
>>> 
>>> I’m trying to plot a multiple line graph:
>>> 
>>> region sample  factora  factorb
>>> factorc
>>> 0.1 10  0.895   0.903   0.378
>>> 0.2 10  0.811   0.865   0.688
>>> 0.1 20  0.735   0.966   0.611
>>> 0.2 20  0.777   0.732   0.653
>>> 0.1 30  0.600   0.778   0.694
>>> 0.2 30  0.466   174.592 0.461
>>> 0.1 40  0.446   0.432   0.693
>>> 0.2 40  0.392   0.294   0.686
>>> 
>>> 
>>> 
>>> The first column should be the independent variable, the second should 
>>> compute a bold line for sample(10) and dash line for sample 20.
>> 
>> What about the other two values of “sample”?  
>> 
>>> The others variables are outcomes for each of the first scenarios, and so 
>>> it should: the 3rd, 4th and 5th columns should be blue, red and green 
>>> respectively. 
>>> 
>>> 
>>> Resume :)
>>> 
>>> I should have a graph, in the x-axe should have the region and in the y 
>>> axe, the factor.
>>> Lines:
>>> 1 - blue and bold for region 0.1, sample 10 and factor a
>>> 2 - blue and dash for region 0.2, sample 10 and factor a
>>> 3 - red and bold for region 0.1, sample 10 and factor b
>>> 4 - red and dash for region 0.2, sample 10 and factor b
>>> 5 - green and bold for region 0.1, sample 10 and factor c
>>> 6 - green and dash for region 0.2, sample 10 and factor c
>> 
>> Not consistent with what you said above. These are no longer lines, but 
>> points.
>>> 
>>> nonetheless the independent variable is nominal, I should plot a line graph.
>>> 
>>> Can anyone help me please?
>>> I have my file as a cvs file, so I first read that file (that I know how to 
>>> do :)).
>>> 
>>> But I have it in that format.
>>> 
>>> Best,
>>> RO
>>> 
>>> 
>>> 
>>> Atenciosamente,
>>> Rosa Oliveira
>>> 
>>> -- 
>>> 
>>> 
>>> 
>>> Rosa Celeste dos Santos Olive

Re: [R] graphs, need urgent help (deadline :( )

2015-06-09 Thread Rosa Oliveira
Dear Don and all,

I’ve read the tutorial and tried several codes before posting :)
I’m really naive.



what I was trying to :  is something like the graph in the picture I drawee.




Is it more clear now? 

Atenciosamente,
Rosa Oliveira

-- 



Rosa Celeste dos Santos Oliveira, 

E-mail: rosit...@gmail.com 
Tlm: +351 939355143 
Linkedin: https://pt.linkedin.com/in/rosacsoliveira 


"Many admire, few know"
Hippocrates

> On 09 Jun 2015, at 19:23, Don McKenzie  > wrote:
> 
> The answer lies in learning to use the help (and knowing where to start).  
> Did you look at the tutorial that comes with the R installation?
> 
> ?plot
> ?lines
> 
> ?par   
> 
> In the last, look for the descriptions of “col” and “lty”.
> 
> Using plot() and lines(), and subsetting the four unique values of “sample”, 
> you can create your lines.
> 
> Here is a crude start, assuming your columns are part of a data frame called 
> “my.data”.   Untested...
> 
> plot(my.data$region[my.data$sample==10],my.data$factora[my.data$sample==10],col=4)
>  # blue line, not dashed
> .
> .
> .
> lines(my.data$region[my.data$sample==20],my.data$factorb[my.data$sample==20],col=2,lty=2)
># red dashed line
> 
> 
>> On Jun 9, 2015, at 10:36 AM, Rosa Oliveira > > wrote:
>> 
>> Hi,
>> 
>> another naive question (i’m pretty sure :( )
>> 
>> 
>> I’m trying to plot a multiple line graph:
>> 
>> region  sample  factora  factorb
>> factorc
>> 0.1  10  0.895   0.903   0.378
>> 0.2  10  0.811   0.865   0.688
>> 0.1  20  0.735   0.966   0.611
>> 0.2  20  0.777   0.732   0.653
>> 0.1  30  0.600   0.778   0.694
>> 0.2  30  0.466   174.592 0.461
>> 0.1  40  0.446   0.432   0.693
>> 0.2  40  0.392   0.294   0.686
>> 
>> 
>> 
>> The first column should be the independent variable, the second should 
>> compute a bold line for sample(10) and dash line for sample 20.
> 
> What about the other two values of “sample”?  
> 
>> The others variables are outcomes for each of the first scenarios, and so it 
>> should: the 3rd, 4th and 5th columns should be blue, red and green 
>> respectively. 
>> 
>> 
>> Resume :)
>> 
>> I should have a graph, in the x-axe should have the region and in the y axe, 
>> the factor.
>> Lines:
>>  1 - blue and bold for region 0.1, sample 10 and factor a
>>  2 - blue and dash for region 0.2, sample 10 and factor a
>>  3 - red and bold for region 0.1, sample 10 and factor b
>>  4 - red and dash for region 0.2, sample 10 and factor b
>>  5 - green and bold for region 0.1, sample 10 and factor c
>>  6 - green and dash for region 0.2, sample 10 and factor c
> 
> Not consistent with what you said above. These are no longer lines, but 
> points.
>> 
>> nonetheless the independent variable is nominal, I should plot a line graph.
>> 
>> Can anyone help me please?
>> I have my file as a cvs file, so I first read that file (that I know how to 
>> do :)).
>> 
>> But I have it in that format.
>> 
>> Best,
>> RO
>> 
>> 
>> 
>> Atenciosamente,
>> Rosa Oliveira
>> 
>> -- 
>> 
>> 
>> 
>> Rosa Celeste dos Santos Oliveira, 
>> 
>> E-mail: rosit...@gmail.com 
>> Tlm: +351 939355143 
>> Linkedin: https://pt.linkedin.com/in/rosacsoliveira 
>> 
>> 
>> "Many admire, few know"
>> Hippocrates
>> 
>> 
>>  [[alternative HTML version deleted]]
>> 
>> __
>> R-help@r-project.org  mailing list -- To 
>> UNSUBSCRIBE and more, see
>> 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 -- To UNSUBSCRIBE and more, see
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] graphs, need urgent help (deadline :( )

2015-06-09 Thread Don McKenzie
The answer lies in learning to use the help (and knowing where to start).  Did 
you look at the tutorial that comes with the R installation?

?plot
?lines

?par   

In the last, look for the descriptions of “col” and “lty”.

Using plot() and lines(), and subsetting the four unique values of “sample”, 
you can create your lines.

Here is a crude start, assuming your columns are part of a data frame called 
“my.data”.   Untested...

plot(my.data$region[my.data$sample==10],my.data$factora[my.data$sample==10],col=4)
 # blue line, not dashed
.
.
.
lines(my.data$region[my.data$sample==20],my.data$factorb[my.data$sample==20],col=2,lty=2)
   # red dashed line


> On Jun 9, 2015, at 10:36 AM, Rosa Oliveira  wrote:
> 
> Hi,
> 
> another naive question (i’m pretty sure :( )
> 
> 
> I’m trying to plot a multiple line graph:
> 
> region   sample  factora  factorb
> factorc
> 0.1   10  0.895   0.903   0.378
> 0.2   10  0.811   0.865   0.688
> 0.1   20  0.735   0.966   0.611
> 0.2   20  0.777   0.732   0.653
> 0.1   30  0.600   0.778   0.694
> 0.2   30  0.466   174.592 0.461
> 0.1   40  0.446   0.432   0.693
> 0.2   40  0.392   0.294   0.686
> 
> 
> 
> The first column should be the independent variable, the second should 
> compute a bold line for sample(10) and dash line for sample 20.

What about the other two values of “sample”?  

> The others variables are outcomes for each of the first scenarios, and so it 
> should: the 3rd, 4th and 5th columns should be blue, red and green 
> respectively. 
> 
> 
> Resume :)
> 
> I should have a graph, in the x-axe should have the region and in the y axe, 
> the factor.
> Lines:
>   1 - blue and bold for region 0.1, sample 10 and factor a
>   2 - blue and dash for region 0.2, sample 10 and factor a
>   3 - red and bold for region 0.1, sample 10 and factor b
>   4 - red and dash for region 0.2, sample 10 and factor b
>   5 - green and bold for region 0.1, sample 10 and factor c
>   6 - green and dash for region 0.2, sample 10 and factor c

Not consistent with what you said above. These are no longer lines, but points.
> 
> nonetheless the independent variable is nominal, I should plot a line graph.
> 
> Can anyone help me please?
> I have my file as a cvs file, so I first read that file (that I know how to 
> do :)).
> 
> But I have it in that format.
> 
> Best,
> RO
> 
> 
> 
> Atenciosamente,
> Rosa Oliveira
> 
> -- 
> 
> 
> 
> Rosa Celeste dos Santos Oliveira, 
> 
> E-mail: rosit...@gmail.com
> Tlm: +351 939355143 
> Linkedin: https://pt.linkedin.com/in/rosacsoliveira
> 
> "Many admire, few know"
> Hippocrates
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Graphs for scientific publication ?

2015-06-03 Thread David Winsemius

On Jun 3, 2015, at 3:30 AM, Jeremy Clark wrote:

> The coding I've settled on to save file without clipping is:

What exactly was "clipping". You earlier complained about "jaggies". There was 
no restriction of the plotted lines to the plot area in the example you earlier 
presented. That's what I understand "clipping" to mean.

> 
> library(gridExtra)
> gt <- ggplot_gtable(ggplot_build(q3))
> gt$layout$clip[gt$layout$name=="panel"] <- "off"
> gt4 <- arrangeGrob(gt)
> ggsave <- ggplot2::ggsave; body(ggsave) <- body(ggplot2::ggsave)[-2]
> ## from Baptiste
> ggsave("gt.pdf", plot = gt4, width = 6, height = 6)
> ggsave("gt.png", plot = gt4, width = 6, height = 6)
> 
> Part of the problem with plotmath is that as soon as paste is used the
> syntax needed is different eg. substitute and substitute(paste( do not
> accept the same syntax eg. == or "=".
> 

There's not much context for this. If you are bothered that that you need "=" 
inside paste and `==` outside, then you just need to spend more time 
understanding expression syntax.  I have found that plotmath's `paste` usually 
ends up obscuring a proper understanding of expression syntax. Would be 
annotators reach for plotmath-`paste` because they missed the part about using 
"*" and "~" to separate tokens Oh wait ... now I remember there isn't 
really any section in the ?plotmath page that actually says that, is there? 
(Sorry, Not my area of responsibility. Took me years to learn this.)

Your other complaint about plotmath not supporting line-breaks is a recognized 
problem. Multi-element expression vectors are one strategy to consider.  You 
should also look at the grid.text function if you are working in the 
ggplot2-world and want fine-tuned control. You are already building a 
grid-based structure. (And to your whine that ggplot2 is not in base-R, 
consider that the grid package is.) Bert Gunter's suggestion that you purchase 
Murrell's "R Graphics" should be remembered. It is essentially the assembly 
language in which ggplot2 is written.

Learn to use bquote ... You had:

rsquaredlm = NULL
rsquaredlm[[6]] <- 3 ## false value
listr2 <- list(r2 = rsquaredlm[[6]])
eq1 <- substitute(italic(R)^2 == r2, listr2)
eqstr1 <- as.character(as.expression(eq1))
q3 <- p2 +  annotate(geom = "text", x = 20, y = 30, label = eqstr1,
parse = TRUE, vjust = 1)

The results from `bquote` appear to be handled properly within ggplot2-code. 
(Lattice functions do not like `bquote` for its expressions, since they are not 
actually in expression mode.)

rsquaredlm = NULL
rsquaredlm[[6]] <- 3 
 eq1 <- bquote(italic(R)^2 == .(rsquaredlm[[6]]))  # the value will be 
substituted in the plot
 eqstr1 <- as.character(as.expression(eq1))
q3 <- p2 +  annotate(geom = "text", x = 20, y = 30, label = eqstr1,
parse = TRUE, vjust = 1)

-- 

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Graphs for scientific publication ?

2015-06-03 Thread Jeremy Clark
The coding I've settled on to save file without clipping is:

library(gridExtra)
gt <- ggplot_gtable(ggplot_build(q3))
gt$layout$clip[gt$layout$name=="panel"] <- "off"
gt4 <- arrangeGrob(gt)
ggsave <- ggplot2::ggsave; body(ggsave) <- body(ggplot2::ggsave)[-2]
## from Baptiste
ggsave("gt.pdf", plot = gt4, width = 6, height = 6)
ggsave("gt.png", plot = gt4, width = 6, height = 6)

Part of the problem with plotmath is that as soon as paste is used the
syntax needed is different eg. substitute and substitute(paste( do not
accept the same syntax eg. == or "=".

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Graphs for scientific publication ?

2015-05-04 Thread David Winsemius

On May 4, 2015, at 3:13 AM, Jeremy Clark wrote:

> Dear All,
> 
> Many thanks for your very comprehensive replies. Here I provide some
> coding which on my system has the following effects:
> 1) The italic R is not rendered by CairoX11, but is rendered by quartz.
> 2) Both geom_smooth and geom_abline here give stepped lines (I've
> realised the angle of the line makes quite a difference to this). I
> presume that these are not "anti-aliased" - so I was hoping that Cairo
> would change this. Unfortunately the command Cairo() does not open any
> device, and the CairoX11 device gives similar lines to that from
> quartz.
> 3) As I must turn off general clipping (because I need to add some
> text which overlaps the plot edge) it would be useful to be able to
> clip particular lines to the plot edge - although this is not a
> catastrophe as I can create a new truncated dataframe and plot the
> lines from this.
> 
> My system is MacBook Air, with all Xcode recently updated including
> IOS 8.2, OS X 10.10, Xcode 6.2. I previously, and fairly recently,
> installed X11 (and Xquartz), and also updated R and R Cairo, but none
> of this has affected the above behaviour.
> 
> Any advice gratefully received.
> 
> Yours sincerely,
> 
> Jeremy Clark
> 
> library(ggplot2)
> library(grid)
> library(Cairo)
> 
> theme_jack <- function (base_size = 16, base_family = "") {
>theme_classic(base_size = base_size, base_family = base_family) %+replace%
>theme(
>plot.title = element_text(size=15, vjust=3),
>axis.text = element_text(colour = "black", family="Times",
> face=c('bold'), size = 18),
>axis.title.x = element_text(colour = "black",
> family="Times", face=c('bold'),   vjust = -1,size =
> 20),
>axis.title.y = element_text(colour = "black",
> family="Times", angle=90,  face=c('bold'), vjust= 2, size = 20),
>panel.background = element_rect(fill="white"),
>panel.grid.minor = element_blank(),
>panel.grid.major = element_blank(),
>plot.background = element_rect(fill="white"),
>panel.border = element_blank(),
>panel.background = element_blank(),
>plot.margin=unit(c(1,1.5,1.3,1.3),"cm")
>)
> }
> theme_set(theme_jack())
> 
> DataX <- seq(1, 40, by = 1)
> DataY <- seq(1, 40, by = 1)
> Datadf <- data.frame(DataX, DataY)
> 
> ## replace "quartz" with "CairoX11" or "X11" for various effects:
> 
> quartz(width = 6 , height = 6) ## quartz renders the italic R correctly
> p1 <- ggplot() + ggtitle("Title") + coord_cartesian(xlim = c(1, 40),
> ylim = c(0, 40)) + scale_y_continuous(breaks = c(0, 10, 20, 30),
> labels = c("0", "10", "20", "30"), expand = c(0, 0)) + ylab("Y-axis")
> + scale_x_continuous(breaks = c(10, 20, 30, 40), expand = c(0, 0)) +
> geom_point(data = Datadf, aes(x = DataX, y = DataY)) + xlab("X-axis")
> 

> predy <- as.integer(c(38, 25, 20, 14, 8))
> predx <- as.integer(c(20, 21, 22, 24, 25))
> datapreddf <- as.data.frame(predx, predy)
> myplm <- lm(predy ~ predx, data = datapreddf)
> lmxrange <- data.frame(predx = seq(from = 20, to = 30, by = 0.01))
> lmyrange <- predict.lm(myplm, newdata <- lmxrange)
> lmdataframe <- data.frame(lmxrange, lmyrange)
> p2 <- p1 + geom_smooth(data = lmdataframe, aes(x = predx, y =
> lmyrange), method=lm, se=FALSE, color = "black") +
> geom_abline(aes(intercept = as.vector(coefficients(myplm)[1]),
> slope=as.vector(coefficients(myplm)[2]+2)), data=lmdataframe) ## both
> give stepped lines in both quartz and CairoX11
> 
> rsquaredlm = NULL
> rsquaredlm[[6]] <- 3 ## false value
> listr2 <- list(r2 = rsquaredlm[[6]])
> eq1 <- substitute(italic(R)^2 == r2, listr2)
> eqstr1 <- as.character(as.expression(eq1))
> q3 <- p2 +  annotate(geom = "text", x = 20, y = 30, label = eqstr1,
> parse = TRUE, vjust = 1)
> gt <- ggplot_gtable(ggplot_build(q3))
> 
> gt$layout$clip[gt$layout$name=="panel"] <- "off"

> ## (necessary toallow additional text
> ## overlap - not shown) - clipping of lines can be done with other
#   coding - although it
> 
> ## would be nice to be able to do this more efficiently
> grid.draw(gt)
> 
> ## _
> 
> Cairo() ## doesn't open any device

I would not expect it to. The default for the file argument to Cairo() is "". I 
get an error when I try this on a MacPro running 0sx 10.7.5:

> Cairo(file="test.png")
Fontconfig error: 
"/Library/Frameworks/R.framework/Resources/fontconfig/fonts/conf.d/10-scale-bitmap-fonts.conf",
 line 70: non-double matrix element

At any rate one would not generally attempt to smooth out jaggies with the 
default .png setting for Cairo. One would use CairoPDF or CairoSVG depending on 
the preferences of ones publisher. (I've never used CairoPDF(), since the 
ordinary pdf() device "just works".)

This does seem to be way too much code for demonstration of difficulties with 
getting proper output from a vector graphics device. The onscreen version of 
quartz

Re: [R] Graphs for scientific publication ?

2015-05-04 Thread Ista Zahn
Hi Jeremy,

On Mon, May 4, 2015 at 6:13 AM, Jeremy Clark 
wrote:
> Dear All,
>
> Many thanks for your very comprehensive replies. Here I provide some
> coding which on my system has the following effects:
> 1) The italic R is not rendered by CairoX11, but is rendered by quartz.

I don't have a Mac available, but it works as expected here on Linux. You
may wish to ask on the r-sig-mac mailing list.

> 2) Both geom_smooth and geom_abline here give stepped lines (I've
> realised the angle of the line makes quite a difference to this). I
> presume that these are not "anti-aliased" - so I was hoping that Cairo
> would change this. Unfortunately the command Cairo() does not open any
> device,

Are you sure about that? It opens a png device by default here. See ?Cairo
especially the type argument.

and the CairoX11 device gives similar lines to that from
> quartz.

Generally graphics that you wish to publish or otherwise disseminate will
be written to a png, pdf, or similar. How does

png("tst.png", width=5, height=5, units = "in", res=300)
q3
dev.off()

look?

> 3) As I must turn off general clipping (because I need to add some
> text which overlaps the plot edge) it would be useful to be able to
> clip particular lines to the plot edge - although this is not a
> catastrophe as I can create a new truncated dataframe and plot the
> lines from this.

It would have been nice to have a reproducible example of what you are
trying to accomplish by turning off clipping. There may be an easier way,
but it's hard to say for sure without knowing what the goal is.

Best,
Ista
>
> My system is MacBook Air, with all Xcode recently updated including
> IOS 8.2, OS X 10.10, Xcode 6.2. I previously, and fairly recently,
> installed X11 (and Xquartz), and also updated R and R Cairo, but none
> of this has affected the above behaviour.
>
> Any advice gratefully received.
>
> Yours sincerely,
>
> Jeremy Clark
>
> library(ggplot2)
> library(grid)
> library(Cairo)
>
> theme_jack <- function (base_size = 16, base_family = "") {
> theme_classic(base_size = base_size, base_family = base_family) %+replace%
> theme(
> plot.title = element_text(size=15, vjust=3),
> axis.text = element_text(colour = "black", family="Times",
> face=c('bold'), size = 18),
> axis.title.x = element_text(colour = "black",
> family="Times", face=c('bold'), vjust = -1, size =
> 20),
> axis.title.y = element_text(colour = "black",
> family="Times", angle=90, face=c('bold'), vjust= 2, size = 20),
> panel.background = element_rect(fill="white"),
> panel.grid.minor = element_blank(),
> panel.grid.major = element_blank(),
> plot.background = element_rect(fill="white"),
> panel.border = element_blank(),
> panel.background = element_blank(),
> plot.margin=unit(c(1,1.5,1.3,1.3),"cm")
> )
> }
> theme_set(theme_jack())
>
> DataX <- seq(1, 40, by = 1)
> DataY <- seq(1, 40, by = 1)
> Datadf <- data.frame(DataX, DataY)
>
> ## replace "quartz" with "CairoX11" or "X11" for various effects:
>
> quartz(width = 6 , height = 6) ## quartz renders the italic R correctly
> p1 <- ggplot() + ggtitle("Title") + coord_cartesian(xlim = c(1, 40),
> ylim = c(0, 40)) + scale_y_continuous(breaks = c(0, 10, 20, 30),
> labels = c("0", "10", "20", "30"), expand = c(0, 0)) + ylab("Y-axis")
> + scale_x_continuous(breaks = c(10, 20, 30, 40), expand = c(0, 0)) +
> geom_point(data = Datadf, aes(x = DataX, y = DataY)) + xlab("X-axis")
>
> predy <- as.integer(c(38, 25, 20, 14, 8))
> predx <- as.integer(c(20, 21, 22, 24, 25))
> datapreddf <- as.data.frame(predx, predy)
> myplm <- lm(predy ~ predx, data = datapreddf)
> lmxrange <- data.frame(predx = seq(from = 20, to = 30, by = 0.01))
> lmyrange <- predict.lm(myplm, newdata <- lmxrange)
> lmdataframe <- data.frame(lmxrange, lmyrange)
> p2 <- p1 + geom_smooth(data = lmdataframe, aes(x = predx, y =
> lmyrange), method=lm, se=FALSE, color = "black") +
> geom_abline(aes(intercept = as.vector(coefficients(myplm)[1]),
> slope=as.vector(coefficients(myplm)[2]+2)), data=lmdataframe) ## both
> give stepped lines in both quartz and CairoX11
>
> rsquaredlm = NULL
> rsquaredlm[[6]] <- 3 ## false value
> listr2 <- list(r2 = rsquaredlm[[6]])
> eq1 <- substitute(italic(R)^2 == r2, listr2)
> eqstr1 <- as.character(as.expression(eq1))
> q3 <- p2 + annotate(geom = "text", x = 20, y = 30, label = eqstr1,
> parse = TRUE, vjust = 1)
> gt <- ggplot_gtable(ggplot_build(q3))
>
> gt$layout$clip[gt$layout$name=="panel"] <- "off" ## (necessary to
> allow additional text
> ## overlap - not shown) - clipping of lines can be done with other
> coding - although it
> ##would be nice to be able to do this more efficiently
> grid.draw(gt)
>
> ## _
>
> Cairo() ## doesn't open any device
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commen

Re: [R] Graphs for scientific publication ?

2015-05-04 Thread Jeremy Clark
Dear All,

Many thanks for your very comprehensive replies. Here I provide some
coding which on my system has the following effects:
1) The italic R is not rendered by CairoX11, but is rendered by quartz.
2) Both geom_smooth and geom_abline here give stepped lines (I've
realised the angle of the line makes quite a difference to this). I
presume that these are not "anti-aliased" - so I was hoping that Cairo
would change this. Unfortunately the command Cairo() does not open any
device, and the CairoX11 device gives similar lines to that from
quartz.
3) As I must turn off general clipping (because I need to add some
text which overlaps the plot edge) it would be useful to be able to
clip particular lines to the plot edge - although this is not a
catastrophe as I can create a new truncated dataframe and plot the
lines from this.

My system is MacBook Air, with all Xcode recently updated including
IOS 8.2, OS X 10.10, Xcode 6.2. I previously, and fairly recently,
installed X11 (and Xquartz), and also updated R and R Cairo, but none
of this has affected the above behaviour.

Any advice gratefully received.

Yours sincerely,

Jeremy Clark

library(ggplot2)
library(grid)
library(Cairo)

theme_jack <- function (base_size = 16, base_family = "") {
theme_classic(base_size = base_size, base_family = base_family) %+replace%
theme(
plot.title = element_text(size=15, vjust=3),
axis.text = element_text(colour = "black", family="Times",
face=c('bold'), size = 18),
axis.title.x = element_text(colour = "black",
family="Times", face=c('bold'),   vjust = -1,size =
20),
axis.title.y = element_text(colour = "black",
family="Times", angle=90,  face=c('bold'), vjust= 2, size = 20),
panel.background = element_rect(fill="white"),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
plot.background = element_rect(fill="white"),
panel.border = element_blank(),
panel.background = element_blank(),
plot.margin=unit(c(1,1.5,1.3,1.3),"cm")
)
}
theme_set(theme_jack())

DataX <- seq(1, 40, by = 1)
DataY <- seq(1, 40, by = 1)
Datadf <- data.frame(DataX, DataY)

## replace "quartz" with "CairoX11" or "X11" for various effects:

quartz(width = 6 , height = 6) ## quartz renders the italic R correctly
p1 <- ggplot() + ggtitle("Title") + coord_cartesian(xlim = c(1, 40),
ylim = c(0, 40)) + scale_y_continuous(breaks = c(0, 10, 20, 30),
labels = c("0", "10", "20", "30"), expand = c(0, 0)) + ylab("Y-axis")
+ scale_x_continuous(breaks = c(10, 20, 30, 40), expand = c(0, 0)) +
geom_point(data = Datadf, aes(x = DataX, y = DataY)) + xlab("X-axis")

predy <- as.integer(c(38, 25, 20, 14, 8))
predx <- as.integer(c(20, 21, 22, 24, 25))
datapreddf <- as.data.frame(predx, predy)
myplm <- lm(predy ~ predx, data = datapreddf)
lmxrange <- data.frame(predx = seq(from = 20, to = 30, by = 0.01))
lmyrange <- predict.lm(myplm, newdata <- lmxrange)
lmdataframe <- data.frame(lmxrange, lmyrange)
p2 <- p1 + geom_smooth(data = lmdataframe, aes(x = predx, y =
lmyrange), method=lm, se=FALSE, color = "black") +
geom_abline(aes(intercept = as.vector(coefficients(myplm)[1]),
slope=as.vector(coefficients(myplm)[2]+2)), data=lmdataframe) ## both
give stepped lines in both quartz and CairoX11

rsquaredlm = NULL
rsquaredlm[[6]] <- 3 ## false value
listr2 <- list(r2 = rsquaredlm[[6]])
eq1 <- substitute(italic(R)^2 == r2, listr2)
eqstr1 <- as.character(as.expression(eq1))
q3 <- p2 +  annotate(geom = "text", x = 20, y = 30, label = eqstr1,
parse = TRUE, vjust = 1)
gt <- ggplot_gtable(ggplot_build(q3))

gt$layout$clip[gt$layout$name=="panel"] <- "off" ## (necessary to
allow additional text
## overlap - not shown) - clipping of lines can be done with other
coding - although it
##would be nice to be able to do this more efficiently
grid.draw(gt)

## _

Cairo() ## doesn't open any device

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Graphs for scientific publication ?

2015-05-01 Thread Ista Zahn
On Thu, Apr 30, 2015 at 8:05 AM, Jeremy Clark  wrote:
> Dear All,
>
> First of all, many thanks to all R contributors for a fantastic
> program, and especially to Hadley Wickham for creating ggplot2. The
> following is intended to be a warning that, if the apparently
> superficial problems described are not sorted out, R could well find
> itself being superceded.

In my opinion that can and should happen, but my prediction is that R
has such a big lead in terms of available functionality and packages
that no one will catch up for at least a decade.

The reason is that a new user wants to draw a
> graph, and perhaps publish in a scientific journal a graph created
> using R, well before wanting to do a complex regression (and the
> latter is relatively easy). So here goes:
>
> 1) The saga of the straight line. I implemented a geom_abline - it
> looked superb. Unfortunately I had to disable clip to allow text - now
> my abline looked ridiculous. My search found plotrix: ablineclip -
> fantastic I thought - but it applies to plot and not geom_plot. I
> switched to geom_segment - the rendering looked trash. I switched to
> geom_smooth - should work but as I don't know the x values beforehand
> I'll have to clip a new dataframe - it that a hassle ? - Yes it is !

As others have mentioned we can probably help you if you give us a
reproducible example and a clear description of what you are trying to
accomplish. Absent that this just sounds like complaining for the sake
of it.

>
> So my general question is - why isn't ggplot2 already part
> of R base

I think packages are added to the base distribution relatively
infrequently these days. Is

install.packages("ggplot2")

really an issue?

- or at least if someone is to create useful packages for
> plot - perhaps a subtle hint could be made that they should also apply
> to ggplot2 (and perhaps to lattice ??

I'm not understanding what you are trying to say here.

- also personally I would scrap
> qplot as an unnecessary distraction which is not easier to implement
> than ggplot).

ggplot2 is in maintenance mode, so it is unlikely that major changes
like that will be introduced.

 In general duplication of packages for plot and ggplot
> doesn't seem like a good idea.

I'm not sure what kind of duplication you are referring to here,
though in general I also wish there was less duplicated functionality
spread across various R packages.

>
>
> 2) The saga of the italic letter. I found, to my dismay, that to
> insert an italic letter into my plot I had to learn a whole new
> language called plotmath - which wouldn't accept normal R coding, and
> didn't even have normal control functions such as /n for a new line.
> This is ridiculous (and I'm not sure how plotmath managed to get into
> R base).

library(ggplot2)

d1 <- data.frame(x = 1, y = 1, t = "some text")
d2 <- d1
d2$x <- 2

ggplot(d1, aes(x = x, y = y, label = t)) +
  geom_text(hjust = 0, size = 10) +
  geom_text(data=d2, fontface="italic", hjust=1, size = 10)

Works for me.

>
> So my question is, when is plotmath going to have a
> complete overhaul to allow eg. "," instead of, or as well as, ~,~, and
> normal control functions such as \n ?

Probably never (though you could do it yourself if you think it is
worth spending the time to improve it).

>
> 3) A related question to (2) is: where is geom_textbox ?

I don't think there is one. You could make one following the
documentation at
https://github.com/hadley/ggplot2/wiki/Creating-a-new-geom

>
> 4) Where are examples with scientific graph defaults ?  (meaning a
> two-axis graph which is publishable - I will post my own after this is
> published in a years time, but as suggested above, while the graph
> looks good the implementation of this is not pretty).

Lot's of people publish ggplot2 graphs, standards differ from field to
field and from journal to journal.
http://scholar.google.com/scholar?cites=14238124760782644329&as_sdt=4005&sciodt=0,22&hl=en
will give you some examples. Beyond that I think you'll have to be
more specific about what exactly you want the graphs to look like.

>
> Having said that - good luck with implementation - and many thanks for
> all your hard work !
>
> Yours sincerely,
>
> Abiologist
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Graphs for scientific publication ?

2015-04-30 Thread David L Carlson
More useful to the r-help list would be a reproducible example of the data you 
are using and a clear statement of what you are trying to accomplish. It is 
likely that all of your requirements can be easily met, but you spent most of 
your message talking about what you have tried without telling us where you 
want to end up. People on the list are familiar with base graphics, lattice 
graphics, and ggplot2. If you list your requirements clearly, you might end up 
with three solutions.

-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter
Sent: Thursday, April 30, 2015 1:41 PM
To: Jeremy Clark
Cc: r-help@r-project.org
Subject: Re: [R] Graphs for scientific publication ?

Jeremy:

I suggest you have a look at the latest edition of Paul Murrell's
book, "R Graphics", as you seem to be unaware that ggplot2 (as well as
a 3rd graphics paradigm, the lattice package) and base graphics are
built on 2 different and incompatible graphics engines.

Obviously, you are entitled to your opinions and graphical
predilections vary, but I do not think R-Help is a good venue for
these sorts of discussions. The R-devel list might be a better place
to discuss such matters.

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll




On Thu, Apr 30, 2015 at 5:05 AM, Jeremy Clark  wrote:
> Dear All,
>
> First of all, many thanks to all R contributors for a fantastic
> program, and especially to Hadley Wickham for creating ggplot2. The
> following is intended to be a warning that, if the apparently
> superficial problems described are not sorted out, R could well find
> itself being superceded. The reason is that a new user wants to draw a
> graph, and perhaps publish in a scientific journal a graph created
> using R, well before wanting to do a complex regression (and the
> latter is relatively easy). So here goes:
>
> 1) The saga of the straight line. I implemented a geom_abline - it
> looked superb. Unfortunately I had to disable clip to allow text - now
> my abline looked ridiculous. My search found plotrix: ablineclip -
> fantastic I thought - but it applies to plot and not geom_plot. I
> switched to geom_segment - the rendering looked trash. I switched to
> geom_smooth - should work but as I don't know the x values beforehand
> I'll have to clip a new dataframe - it that a hassle ? - Yes it is !
>
> So my general question is - why isn't ggplot2 already part
> of R base - or at least if someone is to create useful packages for
> plot - perhaps a subtle hint could be made that they should also apply
> to ggplot2 (and perhaps to lattice ?? - also personally I would scrap
> qplot as an unnecessary distraction which is not easier to implement
> than ggplot). In general duplication of packages for plot and ggplot
> doesn't seem like a good idea.
>
>
> 2) The saga of the italic letter. I found, to my dismay, that to
> insert an italic letter into my plot I had to learn a whole new
> language called plotmath - which wouldn't accept normal R coding, and
> didn't even have normal control functions such as /n for a new line.
> This is ridiculous (and I'm not sure how plotmath managed to get into
> R base).
>
> So my question is, when is plotmath going to have a
> complete overhaul to allow eg. "," instead of, or as well as, ~,~, and
> normal control functions such as \n ?
>
> 3) A related question to (2) is: where is geom_textbox ?
>
> 4) Where are examples with scientific graph defaults ?  (meaning a
> two-axis graph which is publishable - I will post my own after this is
> published in a years time, but as suggested above, while the graph
> looks good the implementation of this is not pretty).
>
> Having said that - good luck with implementation - and many thanks for
> all your hard work !
>
> Yours sincerely,
>
> Abiologist
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Graphs for scientific publication ?

2015-04-30 Thread Bert Gunter
Jeremy:

I suggest you have a look at the latest edition of Paul Murrell's
book, "R Graphics", as you seem to be unaware that ggplot2 (as well as
a 3rd graphics paradigm, the lattice package) and base graphics are
built on 2 different and incompatible graphics engines.

Obviously, you are entitled to your opinions and graphical
predilections vary, but I do not think R-Help is a good venue for
these sorts of discussions. The R-devel list might be a better place
to discuss such matters.

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll




On Thu, Apr 30, 2015 at 5:05 AM, Jeremy Clark  wrote:
> Dear All,
>
> First of all, many thanks to all R contributors for a fantastic
> program, and especially to Hadley Wickham for creating ggplot2. The
> following is intended to be a warning that, if the apparently
> superficial problems described are not sorted out, R could well find
> itself being superceded. The reason is that a new user wants to draw a
> graph, and perhaps publish in a scientific journal a graph created
> using R, well before wanting to do a complex regression (and the
> latter is relatively easy). So here goes:
>
> 1) The saga of the straight line. I implemented a geom_abline - it
> looked superb. Unfortunately I had to disable clip to allow text - now
> my abline looked ridiculous. My search found plotrix: ablineclip -
> fantastic I thought - but it applies to plot and not geom_plot. I
> switched to geom_segment - the rendering looked trash. I switched to
> geom_smooth - should work but as I don't know the x values beforehand
> I'll have to clip a new dataframe - it that a hassle ? - Yes it is !
>
> So my general question is - why isn't ggplot2 already part
> of R base - or at least if someone is to create useful packages for
> plot - perhaps a subtle hint could be made that they should also apply
> to ggplot2 (and perhaps to lattice ?? - also personally I would scrap
> qplot as an unnecessary distraction which is not easier to implement
> than ggplot). In general duplication of packages for plot and ggplot
> doesn't seem like a good idea.
>
>
> 2) The saga of the italic letter. I found, to my dismay, that to
> insert an italic letter into my plot I had to learn a whole new
> language called plotmath - which wouldn't accept normal R coding, and
> didn't even have normal control functions such as /n for a new line.
> This is ridiculous (and I'm not sure how plotmath managed to get into
> R base).
>
> So my question is, when is plotmath going to have a
> complete overhaul to allow eg. "," instead of, or as well as, ~,~, and
> normal control functions such as \n ?
>
> 3) A related question to (2) is: where is geom_textbox ?
>
> 4) Where are examples with scientific graph defaults ?  (meaning a
> two-axis graph which is publishable - I will post my own after this is
> published in a years time, but as suggested above, while the graph
> looks good the implementation of this is not pretty).
>
> Having said that - good luck with implementation - and many thanks for
> all your hard work !
>
> Yours sincerely,
>
> Abiologist
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] graphs

2015-03-14 Thread John Kane
I suspect that this does look a bit easier to interpret. It certainly beats 68 
lines on one graph. Still it's a lot of individual subplots.

What I was suggesting was grouping all NASS, HASS, etc. together and graphing 
each so that you get several lines per subplot. I don't know if this makes 
sense in your context but it should reduce the size of the overall plot.

Ugly simple-minded example of what I meant below.

library(ggplot2)
names   <-  c('hass', "ham", 'nacs', 'nass')
line  <-  c('alpha', "beta")
xval  <-  1:4

dat1  <-  data.frame(group= rep(names, each = 3, 4),
tt  =  rep(line, each =12 , 2),
xx  =  rep(xval, 12 ),
yy  =  rnorm(48))

p  <-  ggplot(dat1, aes(xx, yy, colour = tt)) + geom_line() +
  facet_grid(. ~ group)
p

John Kane
Kingston ON Canada


> -Original Message-
> From: mir.sa...@uef.fi
> Sent: Fri, 13 Mar 2015 16:27:06 +0000
> To: jrkrid...@inbox.com, petr.pi...@precheza.cz, r-help@r-project.org
> Subject: RE: [R] graphs
> 
> 
> __Dear all,
> 
> You can see the plot specif curves in the enclosed document. Inclusion of
> all plot specif curves in one plot may not be look  good and finally it
> will be unreadable. I am agree with Petrr and John. This graph is more
> readable.
> 
> 
> Best regards
> Salam
> 
> 
> 
> 
> 
> 
> 
> 
> ______
> From: John Kane 
> Sent: Friday, March 13, 2015 4:12 PM
> To: PIKAL Petr; Mir Salam; r-help@r-project.org
> Subject: Re: [R] graphs
> 
> @Petr
> 
> I agree. I think Mir would get a totally unreadable graph. I occasionally
> look at some spagetti graphs from climate research, and I find 8 - 12
> lines are incomprehensible (I'm not a subject matter expert)'
> 
> @Mir
> 
> Is there any logical way to break down the data ? I think Petr is correct
> in that ggplot2 should be able to do it but I'd suggest thinking about,
> perhaps, facetting the data to produce some reasonable number of panels.
> 
> Here is a simple three-panel plot to illustrate what I mean but I have
> easily produced a 9 or 10 panel plot which reduces visual clutter
> immensely.
> 
> library(plyr) library(ggplot2)
> 
> df1 = data.frame(basel_asset_class =
c("bank","bank","bank","bank","bank","bank","bank","corporate","corporate","corporate","corporate","corporate","corporate","corporate","sovereign","sovereign","sovereign","sovereign","sovereign","sovereign","sovereign"),
> ratings =
c("AAA","AA","A","BBB","BB","B","CCC","AAA","AA","A","BBB","BB","B","CCC","AAA","AA","A","BBB","BB","B","CCC"),
> default_probability =
> c(0.0027,0.0029,0.0031,0.0034,0.0037,0.004,0.0043,0.0025,0.0024,0.0024,0.0023,0.0022,0.0021,0.0021,0.003,0.0031,0.0032,0.0033,0.0034,0.0035,0.0036))
> 
> names(df1) <- c("class", "rate", "default")
> 
> p <- ggplot(df1, aes(rate, default,colour=class)) + geom_point() +
> facet_grid(class ~.) + theme(legend.position="none")
> p
> 
> John Kane
> Kingston ON Canada
> 
> 
>> -Original Message-
>> From: petr.pi...@precheza.cz
>> Sent: Fri, 13 Mar 2015 11:34:42 +
>> To: mir.sa...@uef.fi, r-help@r-project.org
>> Subject: Re: [R] graphs
>> 
>> Hi
>> 
>> Your example is not reproducible, but I presume you could use ggplot
>> together with predict. However, I wonder how do you want to distinguish
>> 68 curves in one picture.
>> I would
>> 
>> Cheers
>> Petr
>> 
>> 
>>> -Original Message-
>>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Mir
>>> Salam
>>> Sent: Sunday, March 08, 2015 10:57 PM
>>> To: r-help@r-project.org
>>> Subject: [R] graphs
>>> 
>>> Dear all,
>>> 
>>>  I need help to get different 68  plots specifc fitted curves in one
>>> plot with respective field data observations (age vs dominant height).
>>> 
>>> 
>>> 
>>> aspdomH2<-groupedData(domH2~age|plotno,data=aspdomH2)
>>> 
>>> 
>>> 
>>> names(aspdomH2)
>>> 
>>> plotno, age, origin, soilcharacter, domH2,
>>> 
>>> 
>>> 
>>> pl

Re: [R] graphs

2015-03-13 Thread David Winsemius

On Mar 13, 2015, at 9:27 AM, Mir Salam wrote:

> 
> __Dear all,
> 
> You can see the plot specif curves in the enclosed document. Inclusion of all 
> plot specif curves in one plot may not be look  good and finally it will be 
> unreadable. I am agree with Petrr and John. This graph is more readable.
> 

You should remember that both lattice (and, I seem to vaguely remember, 
ggplot2) allow specification of three "dimensions" for plot layout, the third 
being for pages. For xyplot which I think is the underlying mechanism for 
nmle-plot methods, the parameter is `layout` which can be a vector of length 2 
or 3. This would only apply to multipage graphics devices but you seem to ahve 
figured out how to make PDFs so that should apply.

> 
> Best regards
> Salam
> 
> 
> 
> __
> From: John Kane 
> Sent: Friday, March 13, 2015 4:12 PM
> To: PIKAL Petr; Mir Salam; r-help@r-project.org
> Subject: Re: [R] graphs
> 
> @Petr
> 
> I agree. I think Mir would get a totally unreadable graph. I occasionally 
> look at some spagetti graphs from climate research, and I find 8 - 12 lines 
> are incomprehensible (I'm not a subject matter expert)'
> 
> @Mir
> 
> Is there any logical way to break down the data ? I think Petr is correct in 
> that ggplot2 should be able to do it but I'd suggest thinking about, perhaps, 
> facetting the data to produce some reasonable number of panels.
> 
> Here is a simple three-panel plot to illustrate what I mean but I have easily 
> produced a 9 or 10 panel plot which reduces visual clutter immensely.
> 
> library(plyr) library(ggplot2)
> 
> df1 = data.frame(basel_asset_class = 
> c("bank","bank","bank","bank","bank","bank","bank","corporate","corporate","corporate","corporate","corporate","corporate","corporate","sovereign","sovereign","sovereign","sovereign","sovereign","sovereign","sovereign"),
>  ratings = 
> c("AAA","AA","A","BBB","BB","B","CCC","AAA","AA","A","BBB","BB","B","CCC","AAA","AA","A","BBB","BB","B","CCC"),
>  default_probability = 
> c(0.0027,0.0029,0.0031,0.0034,0.0037,0.004,0.0043,0.0025,0.0024,0.0024,0.0023,0.0022,0.0021,0.0021,0.003,0.0031,0.0032,0.0033,0.0034,0.0035,0.0036))
> 
> names(df1) <- c("class", "rate", "default")
> 
> p <- ggplot(df1, aes(rate, default,colour=class)) + geom_point() + 
> facet_grid(class ~.) + theme(legend.position="none")
> p
> 
> John Kane
> Kingston ON Canada
> 
> 
>> -Original Message-
>> From: petr.pi...@precheza.cz
>> Sent: Fri, 13 Mar 2015 11:34:42 +
>> To: mir.sa...@uef.fi, r-help@r-project.org
>> Subject: Re: [R] graphs
>> 
>> Hi
>> 
>> Your example is not reproducible, but I presume you could use ggplot
>> together with predict. However, I wonder how do you want to distinguish
>> 68 curves in one picture.
>> I would
>> 
>> Cheers
>> Petr
>> 
>> 
>>> -Original Message-
>>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Mir
>>> Salam
>>> Sent: Sunday, March 08, 2015 10:57 PM
>>> To: r-help@r-project.org
>>> Subject: [R] graphs
>>> 
>>> Dear all,
>>> 
>>> I need help to get different 68  plots specifc fitted curves in one
>>> plot with respective field data observations (age vs dominant height).
>>> 
>>> 
>>> 
>>> aspdomH2<-groupedData(domH2~age|plotno,data=aspdomH2)
>>> 
>>> 
>>> 
>>> names(aspdomH2)
>>> 
>>> plotno, age, origin, soilcharacter, domH2,
>>> 
>>> 
>>> 
>>> plotno-different plot no. I have 68 plots
>>> 
>>> age- every plot have from age 5 to 30 years
>>> 
>>> origin- two, native aspen and hybrid aspen
>>> 
>>> domH2<-dominant height
>>> 
>>> soilcharacter-3, clay, silt and mold. both origin have different soil
>>> charcter
>>> 
>>> 
>>> 
>>>  then I fit model
>>> 
>>> fm2cham.nlme<-nlme(domH2~cham(age,b0,b1,b2),
>>>   data=aspdomH2,
>>>   fixed = list(b0~1+origin+soilcharacter,b1~ 1,b2 ~
>>&g

Re: [R] graphs

2015-03-13 Thread Mir Salam

__Dear all,

You can see the plot specif curves in the enclosed document. Inclusion of all 
plot specif curves in one plot may not be look  good and finally it will be 
unreadable. I am agree with Petrr and John. This graph is more readable.


Best regards
Salam








__
From: John Kane 
Sent: Friday, March 13, 2015 4:12 PM
To: PIKAL Petr; Mir Salam; r-help@r-project.org
Subject: Re: [R] graphs

@Petr

I agree. I think Mir would get a totally unreadable graph. I occasionally look 
at some spagetti graphs from climate research, and I find 8 - 12 lines are 
incomprehensible (I'm not a subject matter expert)'

@Mir

Is there any logical way to break down the data ? I think Petr is correct in 
that ggplot2 should be able to do it but I'd suggest thinking about, perhaps, 
facetting the data to produce some reasonable number of panels.

Here is a simple three-panel plot to illustrate what I mean but I have easily 
produced a 9 or 10 panel plot which reduces visual clutter immensely.

library(plyr) library(ggplot2)

df1 = data.frame(basel_asset_class = 
c("bank","bank","bank","bank","bank","bank","bank","corporate","corporate","corporate","corporate","corporate","corporate","corporate","sovereign","sovereign","sovereign","sovereign","sovereign","sovereign","sovereign"),
 ratings = 
c("AAA","AA","A","BBB","BB","B","CCC","AAA","AA","A","BBB","BB","B","CCC","AAA","AA","A","BBB","BB","B","CCC"),
 default_probability = 
c(0.0027,0.0029,0.0031,0.0034,0.0037,0.004,0.0043,0.0025,0.0024,0.0024,0.0023,0.0022,0.0021,0.0021,0.003,0.0031,0.0032,0.0033,0.0034,0.0035,0.0036))

names(df1) <- c("class", "rate", "default")

p <- ggplot(df1, aes(rate, default,colour=class)) + geom_point() + 
facet_grid(class ~.) + theme(legend.position="none")
p

John Kane
Kingston ON Canada


> -Original Message-
> From: petr.pi...@precheza.cz
> Sent: Fri, 13 Mar 2015 11:34:42 +
> To: mir.sa...@uef.fi, r-help@r-project.org
> Subject: Re: [R] graphs
>
> Hi
>
> Your example is not reproducible, but I presume you could use ggplot
> together with predict. However, I wonder how do you want to distinguish
> 68 curves in one picture.
> I would
>
> Cheers
> Petr
>
>
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Mir
>> Salam
>> Sent: Sunday, March 08, 2015 10:57 PM
>> To: r-help@r-project.org
>> Subject: [R] graphs
>>
>> Dear all,
>>
>>  I need help to get different 68  plots specifc fitted curves in one
>> plot with respective field data observations (age vs dominant height).
>>
>>
>>
>> aspdomH2<-groupedData(domH2~age|plotno,data=aspdomH2)
>>
>>
>>
>> names(aspdomH2)
>>
>> plotno, age, origin, soilcharacter, domH2,
>>
>>
>>
>> plotno-different plot no. I have 68 plots
>>
>> age- every plot have from age 5 to 30 years
>>
>> origin- two, native aspen and hybrid aspen
>>
>> domH2<-dominant height
>>
>> soilcharacter-3, clay, silt and mold. both origin have different soil
>> charcter
>>
>>
>>
>>  then I fit model
>>
>> fm2cham.nlme<-nlme(domH2~cham(age,b0,b1,b2),
>>data=aspdomH2,
>>fixed = list(b0~1+origin+soilcharacter,b1~ 1,b2 ~
>> 1+origin+soilcharacter),
>>random = b0+b2~1|plotno,
>>start=c(b0=26.3387,0,0,0,b1=0.1065,b2=1.9453,0,0,0),
>>weights=varPower(form = ~age, 0.5),
>>correlation=corAR1())
>>
>>
>>
>>  parameter values
>>
>> Fixed effects: list(b0 ~ 1 + origin + soil character, b1 ~ 1, b2 ~ 1 +
>> origin + soil character)
>>
>> Value
>> b0.(Intercept) 21.081124
>> b0.origin17.735064
>> b0.soilcharactermold   10.689051
>> b0.soilcharactersilt   3.906585
>> b1  0.079035
>> b2.(Intercept)  1.616360
>> b2.origin1-0.384421
>> b2.soilcharactermold  0.612285
>> b2.soilcharactersilt  0.527462
>>
>>
>>
>> # I can easily get the augmented plot. 

Re: [R] graphs

2015-03-13 Thread John Kane
@Petr 

I agree. I think Mir would get a totally unreadable graph. I occasionally look 
at some spagetti graphs from climate research, and I find 8 - 12 lines are 
incomprehensible (I'm not a subject matter expert)'

@Mir

Is there any logical way to break down the data ? I think Petr is correct in 
that ggplot2 should be able to do it but I'd suggest thinking about, perhaps, 
facetting the data to produce some reasonable number of panels.

Here is a simple three-panel plot to illustrate what I mean but I have easily 
produced a 9 or 10 panel plot which reduces visual clutter immensely.

library(plyr) library(ggplot2)

df1 = data.frame(basel_asset_class = 
c("bank","bank","bank","bank","bank","bank","bank","corporate","corporate","corporate","corporate","corporate","corporate","corporate","sovereign","sovereign","sovereign","sovereign","sovereign","sovereign","sovereign"),
 ratings = 
c("AAA","AA","A","BBB","BB","B","CCC","AAA","AA","A","BBB","BB","B","CCC","AAA","AA","A","BBB","BB","B","CCC"),
 default_probability = 
c(0.0027,0.0029,0.0031,0.0034,0.0037,0.004,0.0043,0.0025,0.0024,0.0024,0.0023,0.0022,0.0021,0.0021,0.003,0.0031,0.0032,0.0033,0.0034,0.0035,0.0036))

names(df1) <- c("class", "rate", "default")

p <- ggplot(df1, aes(rate, default,colour=class)) + geom_point() + 
facet_grid(class ~.) + theme(legend.position="none") 
p

John Kane
Kingston ON Canada


> -Original Message-
> From: petr.pi...@precheza.cz
> Sent: Fri, 13 Mar 2015 11:34:42 +
> To: mir.sa...@uef.fi, r-help@r-project.org
> Subject: Re: [R] graphs
> 
> Hi
> 
> Your example is not reproducible, but I presume you could use ggplot
> together with predict. However, I wonder how do you want to distinguish
> 68 curves in one picture.
> I would
> 
> Cheers
> Petr
> 
> 
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Mir
>> Salam
>> Sent: Sunday, March 08, 2015 10:57 PM
>> To: r-help@r-project.org
>> Subject: [R] graphs
>> 
>> Dear all,
>> 
>>  I need help to get different 68  plots specifc fitted curves in one
>> plot with respective field data observations (age vs dominant height).
>> 
>> 
>> 
>> aspdomH2<-groupedData(domH2~age|plotno,data=aspdomH2)
>> 
>> 
>> 
>> names(aspdomH2)
>> 
>> plotno, age, origin, soilcharacter, domH2,
>> 
>> 
>> 
>> plotno-different plot no. I have 68 plots
>> 
>> age- every plot have from age 5 to 30 years
>> 
>> origin- two, native aspen and hybrid aspen
>> 
>> domH2<-dominant height
>> 
>> soilcharacter-3, clay, silt and mold. both origin have different soil
>> charcter
>> 
>> 
>> 
>>  then I fit model
>> 
>> fm2cham.nlme<-nlme(domH2~cham(age,b0,b1,b2),
>>data=aspdomH2,
>>fixed = list(b0~1+origin+soilcharacter,b1~ 1,b2 ~
>> 1+origin+soilcharacter),
>>random = b0+b2~1|plotno,
>>start=c(b0=26.3387,0,0,0,b1=0.1065,b2=1.9453,0,0,0),
>>weights=varPower(form = ~age, 0.5),
>>correlation=corAR1())
>> 
>> 
>> 
>>  parameter values
>> 
>> Fixed effects: list(b0 ~ 1 + origin + soil character, b1 ~ 1, b2 ~ 1 +
>> origin + soil character)
>> 
>> Value
>> b0.(Intercept) 21.081124
>> b0.origin17.735064
>> b0.soilcharactermold   10.689051
>> b0.soilcharactersilt   3.906585
>> b1  0.079035
>> b2.(Intercept)  1.616360
>> b2.origin1-0.384421
>> b2.soilcharactermold  0.612285
>> b2.soilcharactersilt  0.527462
>> 
>> 
>> 
>> # I can easily get the augmented plot.  I got  different 68 plots
>> specific curves.
>> 
>> ###
>> 
>> Any body can help me how can I will get all 68 plots specific fitted
>> curves in one plot with respective plot specific age and dominant
>> height obervations? (x axis will represent age, y axis will represent
>> dominant height and fitted curves of all 68 plots)
>> 
>&g

Re: [R] graphs

2015-03-13 Thread PIKAL Petr
Hi

Your example is not reproducible, but I presume you could use ggplot together 
with predict. However, I wonder how do you want to distinguish 68 curves in one 
picture.
I would

Cheers
Petr


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Mir
> Salam
> Sent: Sunday, March 08, 2015 10:57 PM
> To: r-help@r-project.org
> Subject: [R] graphs
>
> Dear all,
>
>  I need help to get different 68  plots specifc fitted curves in one
> plot with respective field data observations (age vs dominant height).
>
>
>
> aspdomH2<-groupedData(domH2~age|plotno,data=aspdomH2)
>
>
>
> names(aspdomH2)
>
> plotno, age, origin, soilcharacter, domH2,
>
>
>
> plotno-different plot no. I have 68 plots
>
> age- every plot have from age 5 to 30 years
>
> origin- two, native aspen and hybrid aspen
>
> domH2<-dominant height
>
> soilcharacter-3, clay, silt and mold. both origin have different soil
> charcter
>
>
>
>  then I fit model
>
> fm2cham.nlme<-nlme(domH2~cham(age,b0,b1,b2),
>data=aspdomH2,
>fixed = list(b0~1+origin+soilcharacter,b1~ 1,b2 ~
> 1+origin+soilcharacter),
>random = b0+b2~1|plotno,
>start=c(b0=26.3387,0,0,0,b1=0.1065,b2=1.9453,0,0,0),
>weights=varPower(form = ~age, 0.5),
>correlation=corAR1())
>
>
>
>  parameter values
>
> Fixed effects: list(b0 ~ 1 + origin + soil character, b1 ~ 1, b2 ~ 1 +
> origin + soil character)
>
> Value
> b0.(Intercept) 21.081124
> b0.origin17.735064
> b0.soilcharactermold   10.689051
> b0.soilcharactersilt   3.906585
> b1  0.079035
> b2.(Intercept)  1.616360
> b2.origin1-0.384421
> b2.soilcharactermold  0.612285
> b2.soilcharactersilt  0.527462
>
>
>
> # I can easily get the augmented plot.  I got  different 68 plots
> specific curves.
>
> ###
>
> Any body can help me how can I will get all 68 plots specific fitted
> curves in one plot with respective plot specific age and dominant
> height obervations? (x axis will represent age, y axis will represent
> dominant height and fitted curves of all 68 plots)
>
>
>
>
>
>
>
>
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the o

Re: [R] Graphs using R

2012-10-08 Thread PIKAL Petr
Hi

homework? No homewok policy here.

You can check e.g. ggplot2 package

Regards
Petr

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Nethal Jajo
> Sent: Monday, October 08, 2012 10:27 AM
> To: r-help@R-project.org
> Subject: [R] Graphs using R
> 
> Dear,
> 
> I have a table with four columns similar to the following:
> 
> Factory Name  Production typeMonthsFreq
> 
> Factory 1   Car type 1   Jan.
> 0
> 
> Factory 1   Car type 2   Feb.
> 1
> 
> Factory 2Car type 3  May
> 3
> 
> 
> 
> I need help in producing graphs;
> 
> 1. I need to graph the production of the factories per month in
> "Stacked columns"
> 
> 2. I need to graph the each of the production type by factory and
> month.
> 
> 
> 
> Regards
> 
> N.Jajo
> 
>   [[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-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] Graphs using R

2012-10-08 Thread FJ M




To start:
pdf("Auto_Analysis.pdf)
from the R console type:
? hist

For the histogram help page. 
If you show the R code for your data, I'll generate the actual code for the 
histogram. Thanks.
> From: nethal.j...@sydney.edu.au
> To: r-help@r-project.org
> Date: Mon, 8 Oct 2012 08:26:59 +
> Subject: [R] Graphs using R
> 
> Dear,
> 
> I have a table with four columns similar to the following:
> 
> Factory Name  Production typeMonthsFreq
> 
> Factory 1   Car type 1   Jan.0
> 
> Factory 1   Car type 2   Feb.  1
> 
> Factory 2Car type 3  May 3
> 
> 
> 
> I need help in producing graphs;
> 
> 1. I need to graph the production of the factories per month in "Stacked 
> columns"
> 
> 2. I need to graph the each of the production type by factory and month.
> 
> 
> 
> Regards
> 
> N.Jajo
> 
>   [[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.

  
[[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] graphs of gamma, normal fit to a histogram are about half as large as they should be

2011-05-17 Thread Benjamin Caldwell
Rolf,

Taking out the scalar multiples did it. Thanks for that.


*Ben Caldwell*

PhD Candidate
University of California, Berkeley




On Sun, May 15, 2011 at 10:30 PM, Rolf Turner wrote:

>
> In your example it appears that you are plotting a histogram (on the
> frequency
> scale) and then superimposing scalar multiples of gamma and Gaussian
> densities.
>
> You should just plot a histogram (with frequency=FALSE) and then
> superimpose the
> densities --- without any scalar multipliers.
>
> If that doesn't work, please provide a minimal *reproducible* (no one but
> you
> has the ``rwb'' data object) example of the problem that you are having
> (as the posting guide requests).
>
> cheers,
>
> Rolf Turner
>
>
>
> On 16/05/11 17:01, Benjamin Caldwell wrote:
>
> Hmm; still missing something - hist defaults to frequencies, not prob.
> densities; and, I thought I'd scaled the fitted lines to the values in the
> data frame. Just going with it, I specified freq=FALSE, and the prob density
> was of course at a different order of magnitude than the lines.
>
>  What are you trying to hint at?
>
>
> On Fri, May 13, 2011 at 6:05 PM, Rolf Turner wrote:
>
>>  On 14/05/11 10:00, Benjamin Caldwell wrote:
>>
>>> Hello,
>>>
>>> I'm trying to compare the fit of two distributions, normal and gamma, to
>>> a
>>> histogram of my response variable.
>>>
>>>
>>> rate<-mean(na.omit(rwb$post.f.crwn.length))/var(na.omit(rwb$post.f.crwn.length))
>>> shape<-rate*mean(na.omit(rwb$post.f.crwn.length))
>>> hist((rwb$post.f.crwn.length), main="rwb$post.f.crwn.length")
>>>
>>> lines(seq(0.01,70,0.01),length(rwb$post.f.crwn.length)*dgamma(seq(0.01,70,0.01),shape,rate))
>>>
>>> lines(seq(0,70,0.1),length(na.omit(rwb$post.f.crwn.length))*dnorm(seq(0,70,.1),mean(na.omit(rwb$post.f.crwn.length)),sqrt(var(na.omit(rwb$post.f.crwn.length
>>>
>>> However, the height of the two curves are about 1/3 to 1/4 the height
>>> that
>>> they should be compared to the histogram. Any ideas?
>>>
>>
>>  Yes.  Read the help on "hist"!  (Hint:  Pay particular attention to the
>> "freq" and/or "probability" arguments.)
>>
>>cheers,
>>
>>Rolf Turner
>>
>
>
>
<>__
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] graphs and arrays

2011-05-17 Thread Bogdan Tanasa
Dear all,

it might not be a R-related question, however, I would appreciate if anyone
could suggest a mathematical/statistical framework that integrates graphs
and arrays, and potentially has a R implementation.

to give an example : given a graph of interactions (gene1 --- gene2, gene3
--- gene5, etc), where each gene has set of features (eg expression,
activity), to classify the subgraphs based on the features of its nodes.

thanks very much,

bogdan

[[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] graphs of gamma, normal fit to a histogram are about half as large as they should be

2011-05-15 Thread Rolf Turner

In your example it appears that you are plotting a histogram (on the 
frequency
scale) and then superimposing scalar multiples of gamma and Gaussian 
densities.

You should just plot a histogram (with frequency=FALSE) and then 
superimpose the
densities --- without any scalar multipliers.

If that doesn't work, please provide a minimal *reproducible* (no one 
but you
has the ``rwb'' data object) example of the problem that you are having
(as the posting guide requests).

 cheers,

 Rolf Turner


On 16/05/11 17:01, Benjamin Caldwell wrote:
> Hmm; still missing something - hist defaults to frequencies, not prob. 
> densities; and, I thought I'd scaled the fitted lines to the values in 
> the data frame. Just going with it, I specified freq=FALSE, and the 
> prob density was of course at a different order of magnitude than the 
> lines.
>
> What are you trying to hint at?
>
>
> On Fri, May 13, 2011 at 6:05 PM, Rolf Turner  > wrote:
>
> On 14/05/11 10:00, Benjamin Caldwell wrote:
>
> Hello,
>
> I'm trying to compare the fit of two distributions, normal and
> gamma, to a
> histogram of my response variable.
>
> 
> rate<-mean(na.omit(rwb$post.f.crwn.length))/var(na.omit(rwb$post.f.crwn.length))
> shape<-rate*mean(na.omit(rwb$post.f.crwn.length))
> hist((rwb$post.f.crwn.length), main="rwb$post.f.crwn.length")
> 
> lines(seq(0.01,70,0.01),length(rwb$post.f.crwn.length)*dgamma(seq(0.01,70,0.01),shape,rate))
> 
> lines(seq(0,70,0.1),length(na.omit(rwb$post.f.crwn.length))*dnorm(seq(0,70,.1),mean(na.omit(rwb$post.f.crwn.length)),sqrt(var(na.omit(rwb$post.f.crwn.length
>
> However, the height of the two curves are about 1/3 to 1/4 the
> height that
> they should be compared to the histogram. Any ideas?
>
>
> Yes.  Read the help on "hist"!  (Hint:  Pay particular attention
> to the
> "freq" and/or "probability" arguments.)
>
>cheers,
>
>Rolf Turner
>
>


[[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] graphs of gamma, normal fit to a histogram are about half as large as they should be

2011-05-15 Thread Benjamin Caldwell
Hmm; still missing something - hist defaults to frequencies, not prob.
densities; and, I thought I'd scaled the fitted lines to the values in the
data frame. Just going with it, I specified freq=FALSE, and the prob density
was of course at a different order of magnitude than the lines.

What are you trying to hint at?


On Fri, May 13, 2011 at 6:05 PM, Rolf Turner  wrote:

> On 14/05/11 10:00, Benjamin Caldwell wrote:
>
>> Hello,
>>
>> I'm trying to compare the fit of two distributions, normal and gamma, to a
>> histogram of my response variable.
>>
>>
>> rate<-mean(na.omit(rwb$post.f.crwn.length))/var(na.omit(rwb$post.f.crwn.length))
>> shape<-rate*mean(na.omit(rwb$post.f.crwn.length))
>> hist((rwb$post.f.crwn.length), main="rwb$post.f.crwn.length")
>>
>> lines(seq(0.01,70,0.01),length(rwb$post.f.crwn.length)*dgamma(seq(0.01,70,0.01),shape,rate))
>>
>> lines(seq(0,70,0.1),length(na.omit(rwb$post.f.crwn.length))*dnorm(seq(0,70,.1),mean(na.omit(rwb$post.f.crwn.length)),sqrt(var(na.omit(rwb$post.f.crwn.length
>>
>> However, the height of the two curves are about 1/3 to 1/4 the height that
>> they should be compared to the histogram. Any ideas?
>>
>
> Yes.  Read the help on "hist"!  (Hint:  Pay particular attention to the
> "freq" and/or "probability" arguments.)
>
>cheers,
>
>Rolf Turner
>

[[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] graphs of gamma, normal fit to a histogram are about half as large as they should be

2011-05-13 Thread Rolf Turner

On 14/05/11 10:00, Benjamin Caldwell wrote:

Hello,

I'm trying to compare the fit of two distributions, normal and gamma, to a
histogram of my response variable.

rate<-mean(na.omit(rwb$post.f.crwn.length))/var(na.omit(rwb$post.f.crwn.length))
shape<-rate*mean(na.omit(rwb$post.f.crwn.length))
hist((rwb$post.f.crwn.length), main="rwb$post.f.crwn.length")
lines(seq(0.01,70,0.01),length(rwb$post.f.crwn.length)*dgamma(seq(0.01,70,0.01),shape,rate))
lines(seq(0,70,0.1),length(na.omit(rwb$post.f.crwn.length))*dnorm(seq(0,70,.1),mean(na.omit(rwb$post.f.crwn.length)),sqrt(var(na.omit(rwb$post.f.crwn.length

However, the height of the two curves are about 1/3 to 1/4 the height that
they should be compared to the histogram. Any ideas?


Yes.  Read the help on "hist"!  (Hint:  Pay particular attention to the
"freq" and/or "probability" arguments.)

cheers,

Rolf Turner

__
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] graphs

2009-07-25 Thread Radha Krishna
Hi Mary,

One can use arrows too...

Here is the code :

x<-seq(75,225,0.1)
plot(x,dnorm(x,mean=140, sd=15), type='l', col='navy')
*arrows(149,0,149,dnorm(149,140,15),length=0)
*par(new=T)
plot(x,dnorm(x,mean=150, sd=15), type='l', col='orange',axes=F)


Regards
Radha


On Sun, Jul 26, 2009 at 5:09 AM, Mary A. Marion  wrote:

> Hello,
>
> I am plotting two distributions and want to draw a vertical line at the
> critical point 149.
> How can I stop it from going further up than the norm(140,15) curve?
>
> x<-seq(75,225,0.1)
> plot(x,dnorm(x,mean=140, sd=15), type='l', col='navy')
> abline(v = 149, col = "black")
> curve(dnorm(x,mean=150, sd=15),from=75, to=225, col='orange', add=TRUE)
>
> Thank you.
>
> 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.
>

[[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] graphs

2009-07-25 Thread Poersching
Mary A. Marion schrieb:
> Hello,
>
> I am plotting two distributions and want to draw a vertical line at
> the critical point 149.
> How can I stop it from going further up than the norm(140,15) curve?
>
> x<-seq(75,225,0.1)
> plot(x,dnorm(x,mean=140, sd=15), type='l', col='navy')
> abline(v = 149, col = "black")
> curve(dnorm(x,mean=150, sd=15),from=75, to=225, col='orange', add=TRUE)
>
> Thank you.
>
> 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.
>
Hey,
in your case you shouldn't use the abline command. Instead try segment like:
segments(149, 0, 149, dnorm(149,mean=140, sd=15))

Regards,
Christian Porsche



signature.asc
Description: OpenPGP digital signature
__
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] graphs

2009-07-25 Thread Steve Lianoglou

Hi Mary,

On Jul 25, 2009, at 7:39 PM, Mary A. Marion wrote:


Hello,

I am plotting two distributions and want to draw a vertical line at  
the critical point 149.

How can I stop it from going further up than the norm(140,15) curve?

x<-seq(75,225,0.1)
plot(x,dnorm(x,mean=140, sd=15), type='l', col='navy')
abline(v = 149, col = "black")
curve(dnorm(x,mean=150, sd=15),from=75, to=225, col='orange',  
add=TRUE)



Check ?segments

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
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] graphs

2009-07-25 Thread baptiste auguie
Try with ?segments,

x<-seq(75,225,0.1)
plot(x,dnorm(x,mean=140, sd=15), type='l', col='navy')
#abline(v = 149, col = "black")
segments(149, 0, 149, dnorm(149,140,15))
curve(dnorm(x,mean=150, sd=15),from=75, to=225, col='orange', add=TRUE)


HTH,

baptiste



2009/7/26 Mary A. Marion 

> Hello,
>
> I am plotting two distributions and want to draw a vertical line at the
> critical point 149.
> How can I stop it from going further up than the norm(140,15) curve?
>
> x<-seq(75,225,0.1)
> plot(x,dnorm(x,mean=140, sd=15), type='l', col='navy')
> abline(v = 149, col = "black")
> curve(dnorm(x,mean=150, sd=15),from=75, to=225, col='orange', add=TRUE)
>
> Thank you.
>
> 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.
>



-- 

_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
__

[[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] graphs in R

2008-10-13 Thread stephen sefick
Do you have an example.  I am not sure what you mean.

On Mon, Oct 13, 2008 at 9:48 AM, guria <[EMAIL PROTECTED]> wrote:
>
> How Graphs in R with leveling of point can be done?
> Please help.
> --
> View this message in context: 
> http://www.nabble.com/graphs-in-R-tp19955281p19955281.html
> Sent from the R help mailing list archive at Nabble.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.
>



-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
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] graphs for pretest data

2008-08-24 Thread Jim Lemon
On Sat, 2008-08-23 at 12:04 -0400, Juliet Hannah wrote:
> Is there an easy way to make graphs for the following data. I have
> pretest and posttest scores for men and
> women. I would like to form a 'titlted segment' plot for the data.
> That is, make segments joining the scores,
> with different types of segments for men and women.
> 
> Example data:
> 
> menpre <- c(43,42,26,39,60,60,46)
> menpost <- c(40,41,36,42,54,58,43)
> 
> womenpre <- c(46,56,81,56,70,70)
> womenpost <- c(44,52,81,59,69,68)
> 
Hi Juliet,
This looks like spread.labels in the plotrix package might do the job.
Check the second example.

Jim

__
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] graphs for pretest data

2008-08-23 Thread hadley wickham
On Sat, Aug 23, 2008 at 1:10 PM, Michael Kubovy <[EMAIL PROTECTED]> wrote:
> Dear Juliet,
>
> Perhaps start here:
>
> require(lattice)
> mwpp <- data.frame(y = c(43,42,26,39,60,60,46,40,41,36,42,54,
>58,43,46,56,81,56,70,70,44,52,81,59,69,68),
>sex = rep(c(rep('men', 14), rep('women', 12))),
>pp = c(rep(c('pre', 'post'), each = 7), rep(c('pre', 'post'), each =
> 6)),
>sub = c(1:7, 1:7, 8:13, 8:13))

Or in ggplot2:

library(ggplot2)
qplot(pp, y, data=mwpp, geom=c("point","line"), group = sub, colour=sex)
qplot(pp, y, data=mwpp, geom=c("point","line"), group = sub, facets = .  ~ sex)

The key is to get your data into a data frame with variables that
explicitly label the experimental units, as Michael did for you.

Hadley


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

__
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] graphs for pretest data

2008-08-23 Thread Michael Kubovy
Dear Juliet,

Perhaps start here:

require(lattice)
mwpp <- data.frame(y = c(43,42,26,39,60,60,46,40,41,36,42,54,
58,43,46,56,81,56,70,70,44,52,81,59,69,68),
sex = rep(c(rep('men', 14), rep('women', 12))),
pp = c(rep(c('pre', 'post'), each = 7), rep(c('pre', 'post'), each =  
6)),
sub = c(1:7, 1:7, 8:13, 8:13))
xyplot(y ~ pp | sex, groups = sub, type = 'b', mwpp)

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

On Aug 23, 2008, at 12:04 PM, Juliet Hannah wrote:

> Is there an easy way to make graphs for the following data. I have
> pretest and posttest scores for men and
> women. I would like to form a 'titlted segment' plot for the data.
> That is, make segments joining the scores,
> with different types of segments for men and women.
>
> Example data:
>
> menpre <- c(43,42,26,39,60,60,46)
> menpost <- c(40,41,36,42,54,58,43)
>
> womenpre <- c(46,56,81,56,70,70)
> womenpost <- c(44,52,81,59,69,68)
>
> Thanks!
>
> Juliet

[[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] graphs for pretest data

2008-08-23 Thread John Kane
?plot ?lines

Something like this perhaps

plot( menpre, type="l", col="red")
lines(menpost, col="blue")
lines(womenpre,col="green"
lines(womenpost, col= "orange")

also have a look at ?par for various options




--- On Sat, 8/23/08, Juliet Hannah <[EMAIL PROTECTED]> wrote:

> From: Juliet Hannah <[EMAIL PROTECTED]>
> Subject: [R] graphs for pretest data
> To: r-help@r-project.org
> Received: Saturday, August 23, 2008, 12:04 PM
> Is there an easy way to make graphs for the following data.
> I have
> pretest and posttest scores for men and
> women. I would like to form a 'titlted segment'
> plot for the data.
> That is, make segments joining the scores,
> with different types of segments for men and women.
> 
> Example data:
> 
> menpre <- c(43,42,26,39,60,60,46)
> menpost <- c(40,41,36,42,54,58,43)
> 
> womenpre <- c(46,56,81,56,70,70)
> womenpost <- c(44,52,81,59,69,68)
> 
> Thanks!
> 
> Juliet
> 
> __
> 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.


  __
[[elided Yahoo spam]]

__
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] Graphs in R

2008-06-30 Thread Henrique Dallazuanna
Try:

for(i in 1:10){
jpeg(sprintf("Rplots%02d.jpg", i))
   plot(rnorm(20))
   dev.off()
}

On Mon, Jun 30, 2008 at 11:58 AM, Leandro Marino <[EMAIL PROTECTED]>
wrote:

> Hi list,
>
> I want to make a lot of graphics to my end course project. So, i was using
> this sintax:
>
>
> jpeg(filename = "graf01.jpg", width = 1024, height = 1024,
> units = "px", pointsize = 25, quality = 100, bg = "grey95",
> res = NA, restoreConsole = TRUE)
> i=1
> par(mfrow=c(4,1),col="grey90",font.lab=2)
> hist(sul[,i+2],nclass=75,xlab="Região
> Sul",ylab="Freqüência",col="antiquewhite4",main="")
>
> hist(PR[,i+2],nclass=75,xlab="Paraná",ylab="Freqüência",col="antiquewhite4",
> main="")
> hist(SC[,i+2],nclass=75,xlab="Santa
> Catarina",ylab="Freqüência",col="antiquewhite4",main="")
> hist(RS[,i+2],nclass=75,xlab="Rio Grande do
> Sul",ylab="Freqüência",col="antiquewhite4",main="")
> dev.off()
>
> But, I want to know how can I create an for to do that. Like that:
>
> for(i in 1:250){
> jpeg(filename = "graf01.jpg", width = 1024, height = 1024,
> units = "px", pointsize = 25, quality = 100, bg = "grey95",
> res = NA, restoreConsole = TRUE)
> par(mfrow=c(4,1),col="grey90",font.lab=2)
> hist(sul[,i+2],nclass=75,xlab="Região
> Sul",ylab="Freqüência",col="antiquewhite4",main="")
>
> hist(PR[,i+2],nclass=75,xlab="Paraná",ylab="Freqüência",col="antiquewhite4",
> main="")
> hist(SC[,i+2],nclass=75,xlab="Santa
> Catarina",ylab="Freqüência",col="antiquewhite4",main="")
> hist(RS[,i+2],nclass=75,xlab="Rio Grande do
> Sul",ylab="Freqüência",col="antiquewhite4",main="")
> dev.off()
> }
>
> The problem is the name of the file, I want to do something like grafi.jpg
> where i goes from 1 to 250.
>
> Thanks a lot for the help.
>
>
> Best Regards,
> Leandro Marino
>
> __
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[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] Graphs in R

2008-06-30 Thread Gabor Csardi
paste(sep="", "graf", 1:250, ".jpg")

See ?paste,
G.

On Mon, Jun 30, 2008 at 11:58:51AM -0300, Leandro Marino wrote:
> Hi list,
> 
> I want to make a lot of graphics to my end course project. So, i was using
> this sintax:
> 
> 
> jpeg(filename = "graf01.jpg", width = 1024, height = 1024,
>  units = "px", pointsize = 25, quality = 100, bg = "grey95",
>  res = NA, restoreConsole = TRUE)
> i=1
> par(mfrow=c(4,1),col="grey90",font.lab=2)
> hist(sul[,i+2],nclass=75,xlab="Região
> Sul",ylab="Freqüência",col="antiquewhite4",main="")
> hist(PR[,i+2],nclass=75,xlab="Paraná",ylab="Freqüência",col="antiquewhite4",
> main="")
> hist(SC[,i+2],nclass=75,xlab="Santa
> Catarina",ylab="Freqüência",col="antiquewhite4",main="")
> hist(RS[,i+2],nclass=75,xlab="Rio Grande do
> Sul",ylab="Freqüência",col="antiquewhite4",main="")
> dev.off()
> 
> But, I want to know how can I create an for to do that. Like that:
> 
> for(i in 1:250){
> jpeg(filename = "graf01.jpg", width = 1024, height = 1024,
>  units = "px", pointsize = 25, quality = 100, bg = "grey95",
>  res = NA, restoreConsole = TRUE)
> par(mfrow=c(4,1),col="grey90",font.lab=2)
> hist(sul[,i+2],nclass=75,xlab="Região
> Sul",ylab="Freqüência",col="antiquewhite4",main="")
> hist(PR[,i+2],nclass=75,xlab="Paraná",ylab="Freqüência",col="antiquewhite4",
> main="")
> hist(SC[,i+2],nclass=75,xlab="Santa
> Catarina",ylab="Freqüência",col="antiquewhite4",main="")
> hist(RS[,i+2],nclass=75,xlab="Rio Grande do
> Sul",ylab="Freqüência",col="antiquewhite4",main="")
> dev.off()
> }
> 
> The problem is the name of the file, I want to do something like grafi.jpg
> where i goes from 1 to 250.
> 
> Thanks a lot for the help.
> 
> 
> Best Regards,
> Leandro Marino
> 
> __
> 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.

-- 
Csardi Gabor <[EMAIL PROTECTED]>UNIL DGM

__
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] graphs with gradients of colors

2007-09-18 Thread Greg Snow
The first question you should ask is "why do you want to do this?".
Adding gradients and other things like that can make a graph look neat,
but can also distort the information in the graph.  You should carefully
consider whether doing things like this really help the graph, or
distract from it.

If you do create a graph with the gradient, you should also create one
without the gradient and compare them to see which conveys the important
information better.

If you decide to go ahead with this, there was a discussion a while ago
on including pictures as the background of bar charts, you could use
something similar to that but with a gradient instead of a picture.  For
some cases it may be easier to create your graph, then use another tool
like imagemagick or gimp to replace a color with the gradient.

If you want to do it in R, then here are a couple of options to get you
started (your specifics will vary depending on the curve you want to
use, how smooth you want things to look, etc.

xx <- seq( -3,3, length=250 )
yy <- dnorm(xx, 0, 1)

plot(xx,yy, type='l')
tmp <- par('usr')

par(new=TRUE)

image( tmp[1:2], seq( tmp[3], tmp[4], len=101 ), 
  matrix( 1:100, ncol=100, nrow=1), add=TRUE,
  col=heat.colors(100))

polygon( c(tmp[1],xx,tmp[2],tmp[2],tmp[1] ), 
  c(yy[1], yy, yy[ length(yy) ], tmp[4], tmp[4] ), 
  col='white', border='white')
polygon( c(tmp[1], tmp[2], tmp[2], tmp[1] ),
  c(yy[1],yy[1], tmp[3], tmp[3]), col='white', border='white')

lines(xx,yy)
box()

# this one may be a bit of overkill for most cases, but does give more
# flexibility

library(TeachingDemos)

xx <- seq(0, 2*pi, length=100)
yy <- sin(xx)

plot(xx,yy, type='l', ylim=c(-1.1, 1.1))

tmpfun <- function(...){
   image( c(0,2*pi), seq(-1.1,1.1,length=101), matrix( 1:100, nrow=1 ),
col=terrain.colors(100), add=TRUE )
}

xxx <- embed(xx,2)
for( i in 1:99 ){
clipplot( tmpfun(), c(xxx[i,2],xxx[i,1]), c(-1.1,
(yy[i]+yy[i+1])/2 ) )
}

lines(xx,yy)

# shade from 0

plot(xx,yy, type='l', ylim=c(-1.1, 1.1))

tmpfun <- function(...){
   image( c(0,2*pi), seq(-1.1,1.1,length=101), matrix( 1:100, nrow=1 ),
col=terrain.colors(100), add=TRUE )
}

xxx <- embed(xx,2)
for( i in 1:99 ){
clipplot( tmpfun(), c(xxx[i,2],xxx[i,1]), c(0, (yy[i]+yy[i+1])/2
) )
}

lines(xx,yy)


Use at your own risk and definitly compare them to simple plots for
clarity.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Van Dongen Stefan
> Sent: Monday, September 17, 2007 7:37 AM
> To: [EMAIL PROTECTED]
> Subject: [R] graphs with gradients of colors
> 
> Hi All,
>  
> I would like to fill the area under a curve with a gradient 
> of colors. Are there any packages or trick I could use
>  
> Thanks
>  
> Stefan
>  
>  
> Stefan Van Dongen
> Antwerp
> 
>   [[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-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] graphs with gradients of colors

2007-09-18 Thread Jim Lemon
Van Dongen Stefan wrote:
> Hi All,
>  
> I would like to fill the area under a curve with a gradient of colors. Are 
> there any packages or trick I could use
>  
> 
Hi Stefan,

Chris has answered the question of how to define the polygons, so I'll 
have a shot at the gradient. The plotrix package has three functions 
that produce color gradients, smoothColors, color.gradient and color.scale.

smoothColors allows you to specify the extreme, and optionally 
intervening, colors and interpolates colors between the ones you have 
specified.

color.gradient is quite similar, except that the user can specify the 
red, green and blue components separately.

color.scale turns numeric values into colors using the same method of 
color specification as color.gradient. It will also work with just the 
extreme colors.

The RColorBrewer package also has the capability to produce color 
gradients. There may be other packages that will do what you want as well.

Jim

__
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] graphs with gradients of colors

2007-09-17 Thread Chris Stubben

You could use a loop and fill small polygons with colors.

x<-seq(-3, 3, .01)
y<-eval(expression(x^3-3*x))
plot(x,y, type="n", las=1)   
n<-length(x)

# vertical bars
for(i in 1:n)
{
polygon(c(x[i], x[i], x[i+1], x[i+1]), c(min(y), y[i], y[i+1], min(y)),
border=0, col = rainbow(n)[i]) 
}

## or split each vertical bars into 100 smaller blocks
plot(x,y, type="n", las=1)
for(i in 1:n)
{
  y1<-seq(y[i], min(y), length.out=101)
  y2<-seq(y[i+1], min(y), length.out=101)
  for(j in 1:100)
  { 
polygon(c(x[i], x[i], x[i+1], x[i+1]), c(y1[j+1], y1[j], y2[j],
y2[j+1]), border=0, col = rev(heat.colors(100))[j]) 
  }
}

Chris Stubben




Van Dongen Stefan wrote:
> 
> Hi All,
>  
> I would like to fill the area under a curve with a gradient of colors. Are
> there any packages or trick I could use
>  
> Thanks
>  
> Stefan
>  
>  
> Stefan Van Dongen
> Antwerp
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/graphs-with-gradients-of-colors-tf4466780.html#a12743725
Sent from the R help mailing list archive at Nabble.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.


Re: [R] graphs with gradients of colors

2007-09-17 Thread Vladimir Eremeev

Maybe this information (from the R's father) can be of some help.
http://www.stat.auckland.ac.nz/~ihaka/Graphics/index.html


Van Dongen Stefan wrote:
> 
> Hi All,
>  
> I would like to fill the area under a curve with a gradient of colors. Are
> there any packages or trick I could use
>  
> Thanks
>  
> Stefan
>  
> 

-- 
View this message in context: 
http://www.nabble.com/graphs-with-gradients-of-colors-tf4466780.html#a12741808
Sent from the R help mailing list archive at Nabble.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.