; mapply(function(x, y) paste(vec[x:y], collapse=" "),
>> x=idx[, 1], y=idx[, 2])
>> }
>>
>> David C
>>
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David L
>> Carlson
>>
gt; Carlson
> Sent: Thursday, December 8, 2016 7:12 PM
> To: Dimitri Liakhovitski ; r-help
>
> Subject: Re: [R] creating possible cominations of a vector's elements
>
> This corrects an error in my earlier function definition:
>
> makestrings <- function(vec) {
>
x=idx[, 1], y=idx[, 2])
}
David C
-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David L Carlson
Sent: Thursday, December 8, 2016 7:12 PM
To: Dimitri Liakhovitski ; r-help
Subject: Re: [R] creating possible cominations of a vector's eleme
collapse=" "),
x=idx[, 1], y=idx[, 2])
}
David C
-Original Message-
From: David L Carlson
Sent: Thursday, December 8, 2016 5:51 PM
To: 'Dimitri Liakhovitski' ; r-help
Subject: RE: [R] creating possible cominations of a vector's elements
You can use
> ij <- combn(length(x)+1, 2)
> lapply(seq_len(ncol(ij)), function(k) x[ij[1,k]:(ij[2,k]-1)])
[[1]]
[1] "this"
[[2]]
[1] "this" "is"
...
[[9]]
[1] "my" "vector"
[[10]]
[1] "vector"
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Dec 8, 2016 at 3:02 PM, Dimitri Liakhovitski <
dimitri.l
vector"
> [10] "vector"
>
> This makes a vector of strings but if you want a list use as.list(mapply())
>
> David L. Carlson
> Department of Anthropology
> Texas A&M University
>
>
>
> -Original Message-
> From: R-help [mailto:r-help-bo
ent of Anthropology
Texas A&M University
-----Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Dimitri
Liakhovitski
Sent: Thursday, December 8, 2016 5:03 PM
To: r-help
Subject: [R] creating possible cominations of a vector's elements
Hello!
I have a vecto
Hello!
I have a vector of strings 'x' that was based on a longer string
'mystring' (the actual length of x is unknown).
mystring <- "this is my vector"
x <- strsplit(mystr, " ")[[1]]
I am looking for an elegant way of creating an object (e.g., a list)
that contains the following strings:
"this"
8 matches
Mail list logo