.davis.ca.us]
> >Sent: Tuesday, 03 July, 2018 17:48
> >To: r-help@r-project.org; Viechtbauer, Wolfgang (SP); r-help@r-
> >project.org
> >Subject: Re: [R] Combine by columns a vector with another vector that is
> >constant across rows
> >
> >Sorry trying ag
g
>-Original Message-
>From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
>Sent: Tuesday, 03 July, 2018 17:48
>To: r-help@r-project.org; Viechtbauer, Wolfgang (SP); r-help@r-
>project.org
>Subject: Re: [R] Combine by columns a vector with another vector that is
Sorry trying again...
fastWolfgang <- function( v, vec ) {
matrix( c( v, rep( vec, each = length( v ) ) )
, nrow = length( v ) )
}
On July 3, 2018 8:21:47 AM PDT, Jeff Newmiller wrote:
>Gabor's solution seems to optimize 'simpler'.
>
>More efficient is to learn that in R a vector is n
or this variation if you don't want the first column to be named init:
Reduce(cbind2, vec, 1:5)
On Tue, Jul 3, 2018 at 10:46 AM, Gabor Grothendieck
wrote:
> Try Reduce:
>
> Reduce(cbind, vec, 1:5)
>
> On Tue, Jul 3, 2018 at 9:28 AM, Viechtbauer, Wolfgang (SP)
> wrote:
>> Hi All,
>>
>> I have
Gabor's solution seems to optimize 'simpler'.
More efficient is to learn that in R a vector is not a matrix, but a matrix is
just an ornamented vector.
fastWolfgang <- function( v, vec ) {
matrix( c( v, rep( vec, length( v ) ) )
, now = length( v ) )
}
On July 3, 2018 6:28:45 AM PDT,
Try Reduce:
Reduce(cbind, vec, 1:5)
On Tue, Jul 3, 2018 at 9:28 AM, Viechtbauer, Wolfgang (SP)
wrote:
> Hi All,
>
> I have one vector that I want to combine with another vector and that other
> vector should be the same for every row in the combined matrix. This
> obviously does not work:
>
Viechtbauer,
> Wolfgang (SP)
> Sent: Tuesday, July 3, 2018 3:29 PM
> To: r-help@r-project.org
> Subject: [R] Combine by columns a vector with another vector that is constant
> across rows
>
> Hi All,
>
> I have one vector that I want to combine with another vector and
Hi All,
I have one vector that I want to combine with another vector and that other
vector should be the same for every row in the combined matrix. This obviously
does not work:
vec <- c(2,4,3)
cbind(1:5, vec)
This does, but requires me to specify the correct value for 'n' in replicate():
cbi
8 matches
Mail list logo