Re: [R] Problems Dating....

2011-06-01 Thread Struckmeier, Nathanael
I'll give this a try and mess with what format to convert it to. Thanks
again!




-Original Message-
From: Stephan Kolassa [mailto:stephan.kola...@gmx.de] 
Sent: Wednesday, June 01, 2011 2:10 PM
To: Struckmeier, Nathanael
Cc: R-help@r-project.org
Subject: Re: [R] Problems Dating

Hi Nat,

I guess something like
as.Date(as.character("3/4/2007"),format="%d/%m/%Y")
should work - as.character() coerces the factors to characters, which 
the as.Date() function can work with, given the right format argument.

HTH
Stephan


Am 01.06.2011 22:59, schrieb Struckmeier, Nathanael:
> I'm trying to convert a column in a data frame with dates from a
> "Factor" type to a "Date Object" but I am encountering and error. (I
am
> having trouble plotting an x,y scatter and I suspect it's something
with
> my data format). I have a table with two columns and 8,000 rows.
>
>> dsort=read.delim("C:\\Documents and Settings\\E066582\\My
> Documents\\R\\R-2.13.0\\bin\\dsort.txt")
>
>
>
> "dsort"#name of
> data.frame
>
>> colnames(dsort)[1] #name of column 1
>
> [1] "Date"
>
>> colnames(dsort)[2] #name of column 2
>
> [1] "Qty"
>
>> class(dsort$Date) #checked data type of
column
> "Date" and it came back as a factor
>
> [1] "factor"
>
>> Date2=as.Date(dsort$Date)#attempt at changing the data type from
a
> factor to a date object (see error below).
>
> Error in charToDate(x) :
>
>character string is not in a standard unambiguous format
>
>
>
> Dates in my table are listed in "3/4/2007" format.
>
> StatBat2
>
>
>
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@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@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] Problems Dating....

2011-06-01 Thread Struckmeier, Nathanael
I'm trying to convert a column in a data frame with dates from a
"Factor" type to a "Date Object" but I am encountering and error. (I am
having trouble plotting an x,y scatter and I suspect it's something with
my data format). I have a table with two columns and 8,000 rows. 

> dsort=read.delim("C:\\Documents and Settings\\E066582\\My
Documents\\R\\R-2.13.0\\bin\\dsort.txt")

 

"dsort"#name of
data.frame

> colnames(dsort)[1] #name of column 1

[1] "Date"

> colnames(dsort)[2] #name of column 2

[1] "Qty"

> class(dsort$Date) #checked data type of column
"Date" and it came back as a factor

[1] "factor"

> Date2=as.Date(dsort$Date)#attempt at changing the data type from a
factor to a date object (see error below).

Error in charToDate(x) : 

  character string is not in a standard unambiguous format

 

Dates in my table are listed in "3/4/2007" format. 

StatBat2

 


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] FW: FW: Unable to Plot using headers (converting to Numeric)

2011-05-27 Thread Struckmeier, Nathanael
I'll take your advise and go through the intro. Thanks

Thank You
Nathan Struckmeier 
Supply Chain Planning
Office 541-864-5029
nstruckme...@harryanddavid.com
2500 S. Pacific Hwy, Medford OR, 97501
Daily Humor:  Chuck Norris can slam a revolving door



-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Friday, May 27, 2011 2:14 PM
To: Struckmeier, Nathanael
Cc: R-help@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-boun...@r-project.org
[mailto:r-help-boun...@r-project.org 
> ]
> On Behalf Of Struckmeier, Nathanael
> Sent: Friday, May 27, 2011 1:57 PM
> To: Bert Gunter
> Cc: R-help@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
> nstruckme...@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.ber...@gene.com]
> Sent: Friday, May 27, 2011 1:47 PM
> To: Struckmeier, Nathanael
> Cc: R-help@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
>  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-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org]
>> On Behalf Of stephen's mailinglist account
>> Sent: Friday, May 27, 2011 12:39 PM
>> To: Jonathan Daily
>> Cc: R-help@r-project.org
>> Subject: Re: [R] Unable to Plot using headers.
>>
>> On 27 May 2011 20:25, Jonathan Daily  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(&qu

[R] FW: FW: Unable to Plot using headers (converting to Numeric)

2011-05-27 Thread Struckmeier, Nathanael
I tried command
as.numeric(Qty)#converting column"Qty" in object "demand" to
numeric. However it remains a non-numeric value. 

What is the best way to convert a column of data to a numeric value in
R?
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? 


StatBat2


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Struckmeier, Nathanael
Sent: Friday, May 27, 2011 1:57 PM
To: Bert Gunter
Cc: R-help@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
nstruckme...@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.ber...@gene.com] 
Sent: Friday, May 27, 2011 1:47 PM
To: Struckmeier, Nathanael
Cc: R-help@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
 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-boun...@r-project.org
[mailto:r-help-boun...@r-project.org]
> On Behalf Of stephen's mailinglist account
> Sent: Friday, May 27, 2011 12:39 PM
> To: Jonathan Daily
> Cc: R-help@r-project.org
> Subject: Re: [R] Unable to Plot using headers.
>
> On 27 May 2011 20:25, Jonathan Daily  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@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@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@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@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.


Re: [R] FW: Unable to Plot using headers.

2011-05-27 Thread Struckmeier, Nathanael
> 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
nstruckme...@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.ber...@gene.com] 
Sent: Friday, May 27, 2011 1:47 PM
To: Struckmeier, Nathanael
Cc: R-help@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
 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-boun...@r-project.org
[mailto:r-help-boun...@r-project.org]
> On Behalf Of stephen's mailinglist account
> Sent: Friday, May 27, 2011 12:39 PM
> To: Jonathan Daily
> Cc: R-help@r-project.org
> Subject: Re: [R] Unable to Plot using headers.
>
> On 27 May 2011 20:25, Jonathan Daily  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@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@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@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] FW: Unable to Plot using headers.

2011-05-27 Thread Struckmeier, Nathanael

-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-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of stephen's mailinglist account
Sent: Friday, May 27, 2011 12:39 PM
To: Jonathan Daily
Cc: R-help@r-project.org
Subject: Re: [R] Unable to Plot using headers.

On 27 May 2011 20:25, Jonathan Daily  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@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@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] Unable to Plot using headers.

2011-05-27 Thread Struckmeier, Nathanael
Hello List!

 

Thank you for your input so far. I have successfully imported my data
into R but have hit a snag in plotting. Simple plot commands are unable
to find my headers when I try and plot my data on an x/y scatter. 

 

My data is a 2 column 8000 row table (saved as .txt file) imported into
R.

>demand=read.delim("C:\\Documents and Settings\\E066582\\My
Documents\\R\\R-2.13.0\\bin\\demand.txt")

 

First rows with headers are as shown: 

> demand[1,]

Date Qty

1 12/31/2006   1

With two columns Date/Qty.

 

I attempted to plot and received an error. My headers were not found as
an object in R...maybe I'm missing something, but I was under the
impression I didn't need to create each header as an object...

> plot(Qty, Date)

Error in plot(Qty, Date) : object 'Qty' not found

> plot(Date, Qty)

Error in plot(Date, Qty) : object 'Date' not found

 

What step in plotting am I missing? 

 

 

 


[[alternative HTML version deleted]]

__
R-help@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] R-Size Limit (Confused)

2011-05-26 Thread Struckmeier, Nathanael
Hello, 

 

I've been banging my head against my monitor for some time now trying to
import data into R. The problem is either in my use of syntax, my data
format, or my memory. I have described what I have tried below. Please
help. 

 

=My GOAL==

>import a 4 column, 8,000 row table into R including headers.

 

=WHAT I'VE ATTEMPTED==

Original data was in Excel format.

Converted data to both a .txt and .csv (to see which worked better) 

 Imported data into R via commands as object "demand" (see below)

 

Please excuse the long file path.

demand=read.delim("C:\\Documents and Settings\\E066582\\My

Documents\\R\\R-2.13.0\\bin\\demand.txt", header=T)

 

demand=read.csv(("C:\\Documents and Settings\\E066582\\My 

Documents\\R\\R-2.13.0\\bin\\demand.csv")

 

==PROBLEMS==

In both cases, about half to three fourths of my data shows up as 

 object "demand" with about 4000 lines. My headers also fail to appear.
When my data is imported into R and I type the object name to bring it
up I receive a memory usage error. 

 

==SOLUTIONS

I've gone in and cleaned up my data, making sure there are no (') or (#)
but it could still a formatting issue

My computer has 1.9GB RAM.  I have looked but I can't figure out how to
increase R memory usage. 

 

Any ideas would be appreciated. If someone needs more information to
help me I'll supply it. 

 

StatBat2


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] R import glitch "missing data"

2011-05-26 Thread Struckmeier, Nathanael
That is the strange thing... I DON'T get a warning message. R behaves as
if all data is being imported successfully. I don't receive a memory
warning, or warning of any kind. I've scanned my data for potential
problems and I do not have any ('). However...

The .txt version of my file does use (") around some of my dollar
values...here are all ways in which values on my .txt file are
expressed. 
900
-900
$900
"900"
"(900)"

The .csv version of my file uses:
900
-900
$900




StatBat2

-Original Message-
From: Peter Langfelder [mailto:peter.langfel...@gmail.com] 
Sent: Thursday, May 26, 2011 10:59 AM
To: Struckmeier, Nathanael
Cc: r-help@r-project.org
Subject: Re: [R] R import glitch "missing data"

On Thu, May 26, 2011 at 10:03 AM, StatBat2
 wrote:
> Hello!
>
> I am trying import data into R and im running into a snag.
>
> GOAL:
> Import a 4 column, 8,000 row table into R including headers.
>
> WHAT I'VE ATTEMPTED:
> Original data was in Excel format.
> Converted data to both a .txt and .csv (to see which worked better)
> Imported data into R via commands as object "demand" (see below)
>
> Please excuse the long file path.
> demand=read.delim("C:\\Documents and Settings\\E066582\\My
> Documents\\R\\R-2.13.0\\bin\\demand.txt")
>
> demand=read.csv(("C:\\Documents and Settings\\E066582\\My
> Documents\\R\\R-2.13.0\\bin\\demand.csv", header=True)
>
> In both cases, about half to three fourths of my data shows up as
object
> "demand". My headers also fail to appear. I get about 4000 lines of my
table
> as well as missing headers. I've tried different variations on the
synatx of
> how i go about importing, with or without headers designated, with or
> without .csv ',' designation, but nothing changes. I'm at a loss as to
what
> is incorrect.

Do you  get any error or warning messages?

Are there any apostrophes (') in your data? These can cause mayhem. If
you have any, use the argument
quote = "\"".

HTH,

Peter

__
R-help@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.