n
Behalf Of hadley wickham
Sent: Thursday, April 16, 2009 10:50 AM
To: Raubertas, Richard
Cc: r-help
Subject: Re: [R] Extending a vector to length n
Great idea - that's a little faster than my previous approach of
setting length() and then re-adding the attributes. Thanks!
Hadley
On Thu,
> Levels: a
>>
>
> R. Raubertas
> Merck & Co
>
>
>> -Original Message-
>> From: r-help-boun...@r-project.org
>> [mailto:r-help-boun...@r-project.org] On Behalf Of hadley wickham
>> Sent: Wednesday, April 15, 2009 10:55 AM
>> To: r-help
&g
h(b)+1):n] <- NA
> bb
[1] a
Levels: a
>
R. Raubertas
Merck & Co
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of hadley wickham
> Sent: Wednesday, April 15, 2009 10:55 AM
> To: r-help
> Subj
This may not be everything you would like but perhaps its sufficient:
> structure("length<-"(a, 2), class = class(a))
[1] "2008-01-01" NA
Your second example looks ok as is. Can't tell what you don't
like about it.
On Wed, Apr 15, 2009 at 10:55 AM, hadley wickham wrote:
> In general, how can I
> In general, how can I increase a vector of length m (< n) to length n
> by padding it with m - n missing values, without losing attributes?
> The two approaches I've tried, using length<- and adding missings with
> c, do not work in general:
>
> > a <- as.Date("2008-01-01")
> > c(a, NA)
> [1] "2
In general, how can I increase a vector of length m (< n) to length n
by padding it with m - n missing values, without losing attributes?
The two approaches I've tried, using length<- and adding missings with
c, do not work in general:
> a <- as.Date("2008-01-01")
> c(a, NA)
[1] "2008-01-01" NA
>
6 matches
Mail list logo