Thanks,
I feel like I was so close!!!
KW
--
On Nov 9, 2012, at 4:48 AM, Rui Barradas wrote:
> Hello,
>
> Something like this?
>
>
> fun <- function(years, periods){
>res <- lapply(splitIt(1:12, periods), function(x) groupingStrings(years,
> x))
>names(res) <- as.integer(names(re
Hello,
Something like this?
fun <- function(years, periods){
res <- lapply(splitIt(1:12, periods), function(x)
groupingStrings(years, x))
names(res) <- as.integer(names(res)) + 1L
res
}
fun(2010:2011, 1)
fun(2010:2011, 2)
fun(2010:2011, 4)
fun(2010:2011, 12)
Hope this helps,
R
406"
$`2004`$`2`
[1] "200407" "200408" "200409"
$`2004`$`3`
[1] "200410" "200411" "200412"
.
......
A.K.
----- Original Message -----
From: Keith Weint
Folks,
This question is somewhat related to a previous posting of mine.
I just can't seem to create a generic solution.
Here is a function that I found searching around the internet:
splitIt <- function(x, n) {split(x, sort(rank(x) %% n))}
I use it like so:
> splitIt(1:12, 2)
$`0`
[1] 1 2 3 4
4 matches
Mail list logo