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> >
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 dashedDid you try plotting just this line? What happened?> On Jun 9, 2015, at 5:53 PM, 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. > > > <FullSizeRender.jpg> > > Is it more clear now? > > Atenciosamente, > Rosa Oliveira > > -- > ____________________________________________________________________________ > > <smile.jpg> > 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 dashedDid 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 <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> >> >
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: rosita21 at 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 <dmck at u.washington.edu> 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 <rosita21 at gmail.com <mailto: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. >> >> >> <FullSizeRender.jpg> >> >> Is it more clear now? >> >> Atenciosamente, >> Rosa Oliveira >> >> -- >> ____________________________________________________________________________ >> >> <smile.jpg> >> 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 > > 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 <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> >>> >> > > <PastedGraphic-1.tiff> >
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.