[R] FW: Unable to Plot using headers.

From: Struckmeier, Nathanael <NStruckmeier_at_harryanddavid.com>
Date: Fri, 27 May 2011 13:43:57 -0700

-----Original Message-----
From: Struckmeier, Nathanael
Sent: Friday, May 27, 2011 1:39 PM
To: 'stephen's mailinglist account'
Subject: RE: [R] Unable to Plot using headers.

Thanks for the input. Despite both graphing directly and with "attach" I am still getting a screwed up graphical output as well as an error.

My table is object "demand" w/ columns Date and Qty Plot(demand$Qty, demand$Date)

Attach(demand)
Plot(Qty, Date)

Both of these commands produce something completely different (and quite odd) from a simple xy scatter. X-axis should be "date" and Y-axis should be "Qty". The table "demand" was imported into R sorted by date. Upon graphing, the X-axis displays dates but they are out of order and the graph is a black box...

-----Original Message-----
From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of stephen's mailinglist account Sent: Friday, May 27, 2011 12:39 PM
To: Jonathan Daily
Cc: R-help_at_r-project.org
Subject: Re: [R] Unable to Plot using headers.

On 27 May 2011 20:25, Jonathan Daily <biomathjdaily_at_gmail.com> wrote:
> I would caution against using attach(), however, if you are not in an
> interactive session. In functions and scripts, errors can often cause
> the interpreter to exit before the detach(), leaving your data on the
> search path. 99% of all attach/detach cases can be handled by ?with
> and ?within. The issue with attach can be seen in this example:
>
> dat <- data.frame(a = 1, b = 2)
>
> test <- function(x){
> attach(dat)
> if(x) stop("STOP")
> print(a)
> print(b)
> detach(dat)
> }
>
> a
> test(F)
> a
>
> a
> test(T)
> a
>
>
fair point
I tend to opt for the dat$a or dat$b form personally anyway, but was defaulting back to some of the instructional texts I read early on.

-- 
Stephen

______________________________________________
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.

______________________________________________
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.
Received on Fri 27 May 2011 - 20:46:16 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 27 May 2011 - 21:20:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive