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

Don McKenzie dmck at u.washington.edu
Tue Jun 9 20:23:53 CEST 2015


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> 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
> Tlm: +351 939355143 
> Linkedin: https://pt.linkedin.com/in/rosacsoliveira
> ____________________________________________________________________________
> "Many admire, few know"
> Hippocrates
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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