[R] Keeping the order of data set when plotting

jim holtman jholtman at gmail.com
Tue Mar 2 05:07:01 CET 2010


PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Can you provide the data and the commands that you were using.  When
providing the data, please use 'dput'.  Most likely it might be
because one of the things you are trying to plot is a factor, but
unless we can see the data and commands, it is hard to tell.

To add a line to a plot, you would do the following by making sure you
have the correct limits for y:

plot(Occupation,American.Workers, ylim=range(c(American.Workers,
Foreign.Workers)))
lines(Occupation,Foreign.Workers)

On Mon, Mar 1, 2010 at 9:53 PM, cosinenonqua <sergeygoder at gmail.com> wrote:
>
> I have a data frame with 3 columns and I want to order the entire list by one
> column and then plot. I used order() and it does order the data set but when
> I plot it is as if the set is as it was originally. I also can't figure out
> how to plot two sets of data on the same graph. I have,
>
> Occupation              American.Workers        Foreign.Workers
> Accountant              12                              2
> Engineer                45                              54
> Doctor          50                              37
>
> I want to be able to order American.Workers and then
> plot(Occupation,American.Workers) and plot(Occupation,Foreign.Workers) on
> the same graph.
> --
> View this message in context: http://n4.nabble.com/Keeping-the-order-of-data-set-when-plotting-tp1574535p1574535.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list