Re: [R] A solution for question about formatting Dates

2012-06-28 Thread Patrick Connolly
On Tue, 26-Jun-2012 at 11:57PM -0500, Erin Hodgess wrote:

| Hello again:
| 
| Here is a solution to the dates without leading zeros:
| 
| pou1 - function(x) {
|  #Note:  x is a data frame
|  #Assume that Column 1 has the date
|  #Column 2 has station
|  #Column 3 has min   
|  #Column 4 has max
|  library(stringr)
|  w - character(length=nrow(x))
|  z - str_split(x[,1],/)
|  for(i in 1:nrow(x)) {
| u -  str_pad(z[[i]][1:3],width=2,pad=0)
| w[i] - paste(u,sep=,collapse=/)
|  
| }
|  a - as.Date(w,%m/%d/%Y)
| 
| This is not particularly elegant, but it does the trick.

It's also solving a problem which doesn't arise with any of my
installations.  I'm curious to know what it is about your data that
produces such a difference.

Curious.


| 
| 
| Thanks,
| Erin
| 
| 
| -- 
| Erin Hodgess
| Associate Professor
| Department of Computer and Mathematical Sciences
| University of Houston - Downtown
| mailto: erinm.hodg...@gmail.com
| 
| __
| 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.

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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] A solution for question about formatting Dates

2012-06-28 Thread Patrick Connolly
On Thu, 28-Jun-2012 at 06:27PM +1200, Patrick Connolly wrote:

| On Tue, 26-Jun-2012 at 11:57PM -0500, Erin Hodgess wrote:
| 
| | Hello again:
| | 
| | Here is a solution to the dates without leading zeros:
| | 

[...]

| 
| | This is not particularly elegant, but it does the trick.
| 
| It's also solving a problem which doesn't arise with any of my
| installations.  I'm curious to know what it is about your data that
| produces such a difference.

Forget that.  A.K. spotted why it's happening.  It's the $Y instead of
%Y




-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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] A solution for question about formatting Dates

2012-06-26 Thread Erin Hodgess
Hello again:

Here is a solution to the dates without leading zeros:

pou1 - function(x) {
 #Note:  x is a data frame
 #Assume that Column 1 has the date
 #Column 2 has station
 #Column 3 has min  
 #Column 4 has max
 library(stringr)
 w - character(length=nrow(x))
 z - str_split(x[,1],/)
 for(i in 1:nrow(x)) {
   u -  str_pad(z[[i]][1:3],width=2,pad=0)
   w[i] - paste(u,sep=,collapse=/)

   }
 a - as.Date(w,%m/%d/%Y)

This is not particularly elegant, but it does the trick.


Thanks,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

__
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] A solution for question about formatting Dates

2012-06-26 Thread R. Michael Weylandt
Please don't change subject lines for follow-on comments. It messes up
threading in most readers: e.g.,
https://stat.ethz.ch/pipermail/r-help/2012-June/thread.html


Michael

On Tue, Jun 26, 2012 at 11:57 PM, Erin Hodgess erinm.hodg...@gmail.com wrote:
 Hello again:

 Here is a solution to the dates without leading zeros:

 pou1 - function(x) {
     #Note:  x is a data frame
     #Assume that Column 1 has the date
     #Column 2 has station
     #Column 3 has min
     #Column 4 has max
     library(stringr)
     w - character(length=nrow(x))
     z - str_split(x[,1],/)
     for(i in 1:nrow(x)) {
           u -  str_pad(z[[i]][1:3],width=2,pad=0)
           w[i] - paste(u,sep=,collapse=/)

           }
     a - as.Date(w,%m/%d/%Y)

 This is not particularly elegant, but it does the trick.


 Thanks,
 Erin


 --
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: erinm.hodg...@gmail.com

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