Lab0 question 3

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Lab0 question 3

Axel
Is there a way to plot multiple variables into the same graph, like plotting both the present birth counts of the boys and girls into the same variable without R adding them together or reducing the amount of data into a single line?
Reply | Threaded
Open this post in threaded view
|

Re: Lab0 question 3

Axel
This is how I was able to plot multiple lines:

plot(present$year, present$boys,type="l")
lines(present$year,present$girls,type="l")
Reply | Threaded
Open this post in threaded view
|

Re: Lab0 question 3

Darth Knight
That looks good. This would work as well:

matplot(present$year,cbind(present$boys,present$girls),type="l")
Reply | Threaded
Open this post in threaded view
|

Re: Lab0 question 3

brice
I did plot(present$boys/present$girls, present$year)
use the boy to girl ratio as one variable
Reply | Threaded
Open this post in threaded view
|

Re: Lab0 question 3

Darth Knight
I think OP wanted to explore a little bit of "Graphics in R" independently.

But, brice's idea looks similar to the one required in the question.
Maybe it would be beneficial to flip the arguments.