expand.grid returning list

18 views
Skip to first unread message

Jonathan Rosenblatt

unread,
Jan 8, 2015, 3:15:17 AM1/8/15
to israel-r-user-group
Anyone familiar with an equivalent of expand.grid, that returns a list?
I want it so that it can take lists of functions as arguments.



--
Jonathan Rosenblatt
www.john-ros.com

amit gal

unread,
Jan 8, 2015, 3:42:56 AM1/8/15
to israel-r-...@googlegroups.com
do you mean a list of lists? that is a list whose elements are lists each specifying the combination in a form of a list?

e.g
list(list(1,1,1),list(1,1,2),list(1,2,1),list(1,2,2),...)



--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yizhar Toren

unread,
Jan 26, 2015, 7:27:12 AM1/26/15
to israel-r-...@googlegroups.com
קרה לי בהקשרים אחרים כש .../by/apply/sapply לא מצליחים "לשזור" את הווקטורים שהפונקציה מחזירה ל data.frame, אז במקום לכתוב loop שיחבר שורה שורה אפשר לנסות שני דברים:

list1 <- sapply(x, fun, ...)

## Option 1 - works faster
df1 <- do.call(rbind(list1))

## Option 2 - slower but might work with extension of the "apply-type" functions that are also parallelizable
apply(list1, I)
Reply all
Reply to author
Forward
0 new messages