Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103
I am trying to generate a list of length 4n which consists of the integers 1
to n repeated in groups of four, i.e.
1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n
(The spaces in the list are added only for clarity.)
I can generate the list as
Look more at help(rep) and help(seq):
n - 7
rep(seq_len(n), each=4)
[1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Sun, Apr 19, 2015 at 6:44 AM, John Sorkin jsor...@grecc.umaryland.edu
wrote:
Windows 7 64-bit
R 3.1.3
rep(1:n, each=4)
Sent from my iPhone
On Apr 19, 2015, at 09:44, John Sorkin jsor...@grecc.umaryland.edu wrote:
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103
I am trying to generate a list of length 4n which consists of the integers 1
to n repeated in groups of four, i.e.
1,1,1,1,
In '?rep' find out about the 'each' argument.
Also there is the function 'gl' which creates a factor and offers a shorter
syntax for your problem.
If n equals 5 use one of:
rep(seq(5), each = 4)
gl(5,4)
On 19 April 2015 at 15:44, John Sorkin jsor...@grecc.umaryland.edu wrote:
Windows 7 64-bit
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103
I am trying to generate a list of length 4n which consists of the integers 1
to n repeated in groups of four, i.e.
1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n
(The spaces in the list are added only for clarity.)
I can generate the list as
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103
I am trying to generate a list of length 4n which consists of the integers 1
to n repeated in groups of four, i.e.
1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n
(The spaces in the list are added only for clarity.)
I can generate the list as
You are not generating lists, you are generating vectors.
Try
rep( seq.int( n ), each= 4 )
---
Jeff NewmillerThe . . Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.
On Apr 19, 2015, at 9:44 AM, John Sorkin jsor...@grecc.umaryland.edu wrote:
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103
I am trying to generate a list of length 4n which consists of the integers 1
to n repeated in groups of four, i.e.
1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n
Hi, John,
doesn't
n - your number
lapply( 1:n, rep, each = 4)
do what you need?
Hth -- Gerrit
On Sat, 18 Apr 2015, John Sorkin wrote:
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103
I am trying to generate a list of length 4n which consists of the integers 1
to n repeated in groups of
That would be the each argument to rep()...
n - 5
rep(1:n, each=4)
[1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5
Cheers,
B.
On Apr 19, 2015, at 9:44 AM, John Sorkin jsor...@grecc.umaryland.edu wrote:
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103
I am trying to generate a list of length 4n
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 jsor...@grecc.umaryland.edu
wrote:
Windows 7 64-bit
R 3.1.3
RStudio
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103
I am trying to generate a list of length 4n which consists of the integers 1
to n repeated in groups of four, i.e.
1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n
(The spaces in the list are added only for clarity.)
I can generate the list as
On 19/04/2015 15:34, John Sorkin wrote:
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103
I am trying to generate a list of length 4n which consists of the integers 1
to n repeated in groups of four, i.e.
1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n
(The spaces in the list are added only for
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103
I am trying to generate a list of length 4n which consists of the integers 1
to n repeated in groups of four, i.e.
1,1,1,1, 2,2,2,2, 3,3,3,3, . . . . , n,n,n,n
(The spaces in the list are added only for clarity.)
I can generate the list as
14 matches
Mail list logo