Re: [R] creating possible cominations of a vector's elements

2016-12-22 Thread William Michels via R-help
; 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 >>

Re: [R] creating possible cominations of a vector's elements

2016-12-09 Thread Dimitri Liakhovitski
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) { >

Re: [R] creating possible cominations of a vector's elements

2016-12-08 Thread David L Carlson
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

Re: [R] creating possible cominations of a vector's elements

2016-12-08 Thread David L Carlson
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

Re: [R] creating possible cominations of a vector's elements

2016-12-08 Thread William Dunlap via R-help
> 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

Re: [R] creating possible cominations of a vector's elements

2016-12-08 Thread Dimitri Liakhovitski
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

Re: [R] creating possible cominations of a vector's elements

2016-12-08 Thread David L Carlson
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

[R] creating possible cominations of a vector's elements

2016-12-08 Thread Dimitri Liakhovitski
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"