Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread SOUVIK BANDYOPADHYAY
Hi, You can use the apply group of functions n<-5 k<-4 unlist(lapply(1:n,rep, each=k)) # For vector output: sapply(1:n,rep, each=k) # For a matrix output Hope this helps Souvik On Sun, Apr 19, 2015 at 7:14 PM, John Sorkin wrote: > Windows 7 64-bit > R 3.1.3 > RStudio 0.98.1103 > > > I am tryi

[R] stuck with repeated values

2008-12-03 Thread SOUVIK BANDYOPADHYAY
index where the values are repeated i.e (1,2,3,4,5). I have been able to isolate out the values that are repeated from the unique list of characters in x (i.e. y<-c("a","b")). One method can be to use a loop on the which function but that would be too time consuming. Any hint