[R] Problems producing a simple plot

David Freedman 3.14david at gmail.com
Sat May 2 18:50:19 CEST 2009


you might also look at matplot

d=data.frame(x=1:10,y1=sort(rnorm(10)),y2=sort(rnorm(10)))
matplot(d[,1],d[,2:3],type='l',lty=1:2)

David Freedman


Steve Murray-3 wrote:
> 
> 
> Dear R Users,
>  
> I have a data frame of the nature:
>  
>> head(aggregate_1986)
>   Latitude Mean Annual Simulated Runoff per 1° Latitudinal Band
> 1      -55                                            574.09287
> 2      -54                                            247.23078
> 3      -53                                            103.40756
> 4      -52                                             86.99991
> 5      -51                                             45.21980
> 6      -50                                             55.92928
>   Mean Annual Observed Runoff per 1° Latitudinal Band
> 1                                            491.9525
> 2                                            319.6592
> 3                                            237.8222
> 4                                            179.5391
> 5                                            105.2968
> 6                                            136.6124
>  
>  
> I am hoping to plot columns 2 and 3 against Latitude. I understand that
> you have to do this by plotting one column at a time, so I have been
> starting by attempting the following, but receiving errors:
>  
>> plot(aggregate_1986[1] ~ aggregate_1986[2], type="l")
> Error in model.frame.default(formula = aggregate_1986[1] ~
> aggregate_1986[2],  : 
>   invalid type (list) for variable 'aggregate_1986[1]'
>  
>  
> Or...
>  
>  
>>  plot(aggregate_1986[1],aggregate_1986[2], type="l")
> Error in stripchart.default(x1, ...) : invalid plotting method
>  
>  
> I'm obviously doing something fundamentally wrong (!). I'd be grateful for
> any suggestions as to how I should go about this.
>  
> Many thanks,
>  
> Steve
>  
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/Problems-producing-a-simple-plot-tp23347296p23348181.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list