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

Jim Lemon drjimlemon at gmail.com
Wed Jun 10 12:51:52 CEST 2015


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 <rosita21 at 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: rosita21 at gmail.com <mailto:rosita21 at 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 <dmck at u.washington.edu <mailto:dmck at 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 <rosita21 at gmail.com <mailto:rosita21 at gmail.com>> 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: rosita21 at gmail.com <mailto:rosita21 at gmail.com>
>>> Tlm: +351 939355143
>>> Linkedin: https://pt.linkedin.com/in/rosacsoliveira <https://pt.linkedin.com/in/rosacsoliveira>
>>> ____________________________________________________________________________
>>> "Many admire, few know"
>>> Hippocrates
>>>
>>>
>>>      [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help at r-project.org <mailto:R-help at r-project.org> mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help <https://stat.ethz.ch/mailman/listinfo/r-help>
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html <http://www.r-project.org/posting-guide.html>
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>> <PastedGraphic-1.tiff>
>>
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list