[R] error type

David L Carlson dcarlson at tamu.edu
Mon Aug 27 00:50:06 CEST 2012


You are still using html - you need to tell hotmail to use plain text only.

I can't replicate your error with the following:

dados <- c(44, 40, 39, 38, 0, 7, 7, 1030, 57, 37, 5146, 40, 41, 4737, 34,
36, 
  2636, 28, 33, 3738, 26, 28, 2742, 38, 36, 3636, 27, 22, 2853, 43, 33, 40)

plot(dados[1],type="o",pch=21,axes=FALSE,xlab="year",ylab="cases")
lines(dados[2], type="o", pch=22)
lines(dados[3], type="o",pch=23)
lines(dados[4], type="o",pch=24)
legend(1,8.5, legend=c("Pel","RG","SM","SV"),pch=21:24)
axis(1,at=1:10,lab=c("2000","2001","2002","2003","2004","2005","2006",
     "2007","2008","2009"))
axis(2,0:60)

But I'm sure the result is not what you are looking for since you are using
lines() to plot a single symbol (points() is normally used for this). You
have 32 values in dados (or 40 if the 4-digit values should really be two
2-digit values). You are trying to plot 10 years on the x axis and you
specify a range for the y-axis of 0 to 60, but the range in values is much
greater. Use dput(dados) and paste that into your email and tell us what the
plot should look like. 

As a wild guess let's say you really want

dados <- matrix(c(44, 40, 39, 38, 0, 7, 7, 10, 30, 57, 37, 51, 46, 40, 41,
47,
 37, 34, 36, 26, 36, 28, 33, 37, 38, 26, 28, 27, 42, 38, 36, 36, 36, 27,
 22, 28, 53, 43, 33, 40), ncol=4)
group <- c(rep("Pel", 10), rep("RG", 10), rep("SM", 10), rep("SV", 10))
year <- 2000:2009
matplot(year, dados, col=1, pch=21:24)
legend("bottomleft", legend=c("Pel","RG","SM","SV"), pch=21:24)

Is this closer to what you are looking for?

-------
David

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of aprendiz programa
> Sent: Sunday, August 26, 2012 4:42 PM
> To: r-help at r-project.org
> Subject: Re: [R] error type
> 
> 
> 
> 
> From: aprendizprogram at hotmail.com
> To: r-help at r-project.org
> Date: Mon, 27 Aug 2012 00:01:52 +0300
> Subject: [R] error type
> 
> 
> Hi,
> I am trying plot a grafic but generates an error:
> Erro em plot.default(xlim, ylim, type = "n", ann = FALSE, axes = FALSE,
> :   argumento formal "type" corresponde a mzltiplos argumentos
> especificado
> >>plot(dados[1],type="o",pch=21,
> axes=FALSE,xlab="year",ylab="cases")>>lines(dados[2], type="o",
> pch=22)>>lines(dados[3], type="o",pch=23)>>lines(dados[4],
> type="o",pch=24)>>legend(1,8.5,
> legend=c("Pel","RG","SM","SV"),pch=21:24)axis(1,at=1:10,
> lab=c("2000","2001","2002","2003","2004","2005","2006","2007","2008","2
> 009"))>>axis(2,0:60)
> 	[[alternative HTML version deleted]]
> 
> 
> ______________________________________________
> R-help at 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]]




More information about the R-help mailing list