[R] Error in length of vector ?

2007-03-02 Thread Sérgio Nunes
Hi,

I'm having a weird result with the length() function:

a
[... omited ...]
[9994] NA2003-12-03 16:37:00 2002-06-26 18:43:00
[9997] 2005-07-04 04:00:00 2007-02-16 22:09:00 2007-02-24 15:49:00
[1] NA

 length(LastModified)
[1] 9

 length(c(LastModified))
[1] 9

I was expecting to get 1 as an answer.
I'm trying to bind two vector, and I keep getting the error - number
of rows of result is not a multiple of vector length. Thus I tested
length and got this value.

Any hint?

Thanks in advance,
Sérgio Nunes

__
R-help@stat.math.ethz.ch 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] Error in length of vector ?

2007-03-02 Thread Petr Pikal
Hi

you stepped on a difference between POSIXct and POSIXlt

Details
There are two basic classes of date/times. Class POSIXct represents 
the (signed) number of seconds since the beginning of 1970 as a 
***numeric vector***. Class POSIXlt is a ***named list*** of 
vectors representing 

so you need to change your POSIXlt - named list to POSIXct by

as.POSIXct(your vector)

HTH
Petr

Maybe it could be useful to give some kind of warning into the help 
page of strptime e.g.

Be aware of length of an objects created by strptime as POSIXlt 
class.  It is always 9. See Details section of  DateTimeClasses.

 
On 2 Mar 2007 at 12:33, Sérgio Nunes wrote:

Date sent:  Fri, 2 Mar 2007 12:33:46 +
From:   Sérgio Nunes [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] Error in length of vector ?

 Hi,
 
 I'm having a weird result with the length() function:
 
 a
 [... omited ...]
 [9994] NA2003-12-03 16:37:00 2002-06-26
 18:43:00 [9997] 2005-07-04 04:00:00 2007-02-16 22:09:00
 2007-02-24 15:49:00 [1] NA
 
  length(LastModified)
 [1] 9
 
  length(c(LastModified))
 [1] 9
 
 I was expecting to get 1 as an answer.
 I'm trying to bind two vector, and I keep getting the error - number
 of rows of result is not a multiple of vector length. Thus I tested
 length and got this value.
 
 Any hint?
 
 Thanks in advance,
 Sérgio Nunes
 
 __
 R-help@stat.math.ethz.ch 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.

Petr Pikal
[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] Error in length of vector ?

2007-03-02 Thread Sérgio Nunes
Thanks. Using as.POSIXct() worked fine, length = 1.
Basically I cannot have a column of POSIXlt values in a matrix?

Sérgio Nunes

On 3/2/07, Petr Pikal [EMAIL PROTECTED] wrote:
 Hi

 you stepped on a difference between POSIXct and POSIXlt

 Details
 There are two basic classes of date/times. Class POSIXct represents
 the (signed) number of seconds since the beginning of 1970 as a
 ***numeric vector***. Class POSIXlt is a ***named list*** of
 vectors representing

 so you need to change your POSIXlt - named list to POSIXct by

 as.POSIXct(your vector)

 HTH
 Petr

 Maybe it could be useful to give some kind of warning into the help
 page of strptime e.g.

 Be aware of length of an objects created by strptime as POSIXlt
 class.  It is always 9. See Details section of  DateTimeClasses.


 On 2 Mar 2007 at 12:33, Sérgio Nunes wrote:

 Date sent:  Fri, 2 Mar 2007 12:33:46 +
 From:   Sérgio Nunes [EMAIL PROTECTED]
 To: r-help@stat.math.ethz.ch
 Subject:[R] Error in length of vector ?

  Hi,
 
  I'm having a weird result with the length() function:
 
  a
  [... omited ...]
  [9994] NA2003-12-03 16:37:00 2002-06-26
  18:43:00 [9997] 2005-07-04 04:00:00 2007-02-16 22:09:00
  2007-02-24 15:49:00 [1] NA
 
   length(LastModified)
  [1] 9
 
   length(c(LastModified))
  [1] 9
 
  I was expecting to get 1 as an answer.
  I'm trying to bind two vector, and I keep getting the error - number
  of rows of result is not a multiple of vector length. Thus I tested
  length and got this value.
 
  Any hint?
 
  Thanks in advance,
  Sérgio Nunes
 
  __
  R-help@stat.math.ethz.ch 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.

 Petr Pikal
 [EMAIL PROTECTED]



__
R-help@stat.math.ethz.ch 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] Error in length of vector ?

2007-03-02 Thread Petr Pikal


On 2 Mar 2007 at 13:22, Sérgio Nunes wrote:

Date sent:  Fri, 2 Mar 2007 13:22:43 +
From:   Sérgio Nunes [EMAIL PROTECTED]
To: Petr Pikal [EMAIL PROTECTED]
Copies to:  r-help@stat.math.ethz.ch
Subject:Re: [R] Error in length of vector ?

 Thanks. Using as.POSIXct() worked fine, length = 1.
 Basically I cannot have a column of POSIXlt values in a matrix?

No, it has different length as it is a ***named list*** see e.g. 
Last.Modified[[1]] if it is POSIXlt class.

Petr

 
 Sérgio Nunes
 
 On 3/2/07, Petr Pikal [EMAIL PROTECTED] wrote:
  Hi
 
  you stepped on a difference between POSIXct and POSIXlt
 
  Details
  There are two basic classes of date/times. Class POSIXct
  represents the (signed) number of seconds since the beginning of
  1970 as a ***numeric vector***. Class POSIXlt is a ***named
  list*** of vectors representing
 
  so you need to change your POSIXlt - named list to POSIXct by
 
  as.POSIXct(your vector)
 
  HTH
  Petr
 
  Maybe it could be useful to give some kind of warning into the help
  page of strptime e.g.
 
  Be aware of length of an objects created by strptime as POSIXlt
  class.  It is always 9. See Details section of  DateTimeClasses.
 
 
  On 2 Mar 2007 at 12:33, Sérgio Nunes wrote:
 
  Date sent:  Fri, 2 Mar 2007 12:33:46 +
  From:   Sérgio Nunes [EMAIL PROTECTED]
  To: r-help@stat.math.ethz.ch
  Subject:[R] Error in length of vector ?
 
   Hi,
  
   I'm having a weird result with the length() function:
  
   a
   [... omited ...]
   [9994] NA2003-12-03 16:37:00 2002-06-26
   18:43:00 [9997] 2005-07-04 04:00:00 2007-02-16 22:09:00
   2007-02-24 15:49:00 [1] NA
  
length(LastModified)
   [1] 9
  
length(c(LastModified))
   [1] 9
  
   I was expecting to get 1 as an answer.
   I'm trying to bind two vector, and I keep getting the error -
   number of rows of result is not a multiple of vector length.
   Thus I tested length and got this value.
  
   Any hint?
  
   Thanks in advance,
   Sérgio Nunes
  
   __
   R-help@stat.math.ethz.ch 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.
 
  Petr Pikal
  [EMAIL PROTECTED]
 
 
 
 __
 R-help@stat.math.ethz.ch 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.

Petr Pikal
[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] Error in length of vector ?

2007-03-02 Thread Gabor Grothendieck
Suggest you review the help desk article on dates in
R News 4/1.   It mentions that POSIXlt objects are
lists with 9 components and other facts about date
objects in R.

On 3/2/07, Sérgio Nunes [EMAIL PROTECTED] wrote:
 Hi,

 I'm having a weird result with the length() function:

 a
 [... omited ...]
 [9994] NA2003-12-03 16:37:00 2002-06-26 18:43:00
 [9997] 2005-07-04 04:00:00 2007-02-16 22:09:00 2007-02-24 15:49:00
 [1] NA

  length(LastModified)
 [1] 9

  length(c(LastModified))
 [1] 9

 I was expecting to get 1 as an answer.
 I'm trying to bind two vector, and I keep getting the error - number
 of rows of result is not a multiple of vector length. Thus I tested
 length and got this value.

 Any hint?

 Thanks in advance,
 Sérgio Nunes

 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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.