[R] How to generate a particular sequence ?
    Jim Lemon 
    jim at bitwrit.com.au
       
    Mon Sep 13 11:32:56 CEST 2010
    
    
  
On 09/13/2010 07:19 PM, Feng Li wrote:
> Dear R,
>
> I have a vector, say a = c(1,2,4,5,6,8). Can I generate a vector or array
> (2-by-3-by-3) of this form c(1,2,1,2,1,2,4,5,4,5,4,5,6,8,6,8,6,8), in which
> every two elements in "a" have been repeated twice?
>
> I am to stupid today and could not figure this simple question out...  Many
> many thanks!
>
Hi Feng,
I would take a quick look at the help for "rep" and "c", but I would 
first suggest that you count the number of times that the elements are 
to be repeated. While you have made the definition of the problem 
reasonably clear with your example, there are an awful lot of 
combinations of "every two elements" of a, whether you want to repeat 
them two or three times.
Jim
    
    
More information about the R-help
mailing list