[R] FW: FW: Unable to Plot using headers (converting to Numeric)
Struckmeier, Nathanael
NStruckmeier at HarryandDavid.com
Fri May 27 23:22:39 CEST 2011
I'll take your advise and go through the intro. Thanks
Thank You
Nathan Struckmeier
Supply Chain Planning
Office 541-864-5029
NStruckmeier at HarryandDavid.com
2500 S. Pacific Hwy, Medford OR, 97501
Daily Humor: Chuck Norris can slam a revolving door....
-----Original Message-----
From: David Winsemius [mailto:dwinsemius at comcast.net]
Sent: Friday, May 27, 2011 2:14 PM
To: Struckmeier, Nathanael
Cc: R-help at r-project.org
Subject: Re: [R] FW: FW: Unable to Plot using headers (converting to
Numeric)
On May 27, 2011, at 5:06 PM, Struckmeier, Nathanael wrote:
> I tried command
> as.numeric(Qty) #converting column"Qty" in object "demand" to
> numeric. However it remains a non-numeric value.
Right. You didn't assign it to anything. AND since you are apparently
following the IMO misguided advice to use these as attach()-ed
variables, even if you did make a change ,,,, it would be lost as soon
as you detached it. You really do need to read the "Introduction to R"
and work through the examples. Asking question like this on r-help is
slowing your progress.
>
> What is the best way to convert a column of data to a numeric value in
> R?
It depends on what it might be. Pay attention to the use of str() as
you do your reading and "homework".
> What is the best way to convert dates into a numeric format (or some
> format able to be used in an x,y scatter) while still maintaining its
> inherent "date" property?
It depends on what they really are. Are they just characters or are
they one of hte several DateTime classes? Again... back to the books.
>
>
> StatBat2
>
>
> -----Original Message-----
> From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org
> ]
> On Behalf Of Struckmeier, Nathanael
> Sent: Friday, May 27, 2011 1:57 PM
> To: Bert Gunter
> Cc: R-help at r-project.org
> Subject: Re: [R] FW: Unable to Plot using headers.
>
>> is.numeric(demand)
> [1] FALSE
>> is.numeric(Qty)
> [1] FALSE
>> is.numeric(Date)
> [1] FALSE
>
> Doesn't look like they are numeric. I'll try and convert them and
> check
> back if I have problems. Thanks Gunter!
>
> Thank You
> Nathan Struckmeier
> Supply Chain Planning
> Office 541-864-5029
> NStruckmeier at HarryandDavid.com
> 2500 S. Pacific Hwy, Medford OR, 97501
> Daily Humor: Chuck Norris can slam a revolving door....
>
>
>
> -----Original Message-----
> From: Bert Gunter [mailto:gunter.berton at gene.com]
> Sent: Friday, May 27, 2011 1:47 PM
> To: Struckmeier, Nathanael
> Cc: R-help at r-project.org
> Subject: Re: [R] FW: Unable to Plot using headers.
>
> Are Date and Qty numeric? Check.
>
> -- Bert
>
> On Fri, May 27, 2011 at 1:43 PM, Struckmeier, Nathanael
> <NStruckmeier at harryanddavid.com> wrote:
>>
>> -----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.
>>
>
>
>
> --
> "Men by nature long to get on to the ultimate truths, and will often
> be impatient with elementary studies or fight shy of them. If it were
> possible to reach the ultimate truths without the elementary studies
> usually prefixed to them, these would not be preparatory studies but
> superfluous diversions."
>
> -- Maimonides (1135-1204)
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> ______________________________________________
> 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list