Skip to content

Creating a simple line graph

3 messages · PDXRugger, Liviu Andronic, PIKAL Petr

#
Hey everyone, 
   Sorry for yet another simple question but hopefully it makes whoever
comes up with the answer feel good about helping others.  I would like to
simply plot the following two sets of data in a line graph.  The one set is
an observed set of points and the latter is the predicted.  I have looked
through the documentation (which makes any graphing very complicated to me)
but i havent found what i need. So for:


Sz= c("h1","h2","h3","h4")
Pred=c(34790.0 ,47559.8, 21197.8, 28198.6)
Obs=c(34740 ,48615 ,20420, 26840)

MeanEst2000.Sz=cbind(Sz,Pred)
LaneCo2000HH.Sz =cbind(Sz,Obs)


 I would like the x-axis to display the labels(Sz) and the y-axis to be the
vlaues

I am currently using the below (wont work with sample data) which gives me
the proportions of the observed versus the predicted in four different
graphs in histogram format.

 panelHist(DataMatrix=t(apply(Hh2000.SnSz, 1, 4)),
               ObsMeans=proportion(rowSums(LaneCo2000HH.SzWk),4),
               Bounds=c(0.95, 1.05)
               )



Also, if there is additional documentation for these operations i would
appreciate any insights./  Thanks
#
Hello
I couldn't quite understand exactly what graph you are looking for, so
I'd be unable to provide code. Couple of pointers, though.
- Put your data into a data frame and look at Rcmdr "Graphs" menu. It
can do many types of them, and it should give you enough examples to
get started with.
- Try plot(x, y) and see if it satisfies your needs
- Once you get working the command, try say playwith(plot(x, y))
- Quick-R [1] contains many good examples for beginners.
Best
Liviu

[1] http://www.statmethods.net/graphs/index.html
On 8/24/09, PDXRugger <J_R_36 at hotmail.com> wrote:

  
    
#
Hi

Do not use cbind as it results in matrix and it can have only data of one 
type, in your case character. Use 

MeanEst2000.Sz=data.frame(Sz,Pred) 

instead. And you probably could go step further to put everything into one 
data frame

DF <- data.frame(Sz,Pred, Obs)
then 

with(DF, plot(Pred, Obs, axes=F))
axis(2)
axis(1, at=DF$Pred, DF$Sz)
box()

Regards
Petr

r-help-bounces at r-project.org napsal dne 25.08.2009 10:51:16:
whoever
like to
set is
looked
to me)
be the
gives me
different
would
http://www.nabble.com/Creating-a-simple-line-
http://www.R-project.org/posting-guide.html
http://www.R-project.org/posting-guide.html