Dear list,

I have to problems that are connected:

PROBLEM 1
I wonder if it is somehow possible to patch the function
'unlist(use.names=TRUE)' such that you can specify an arbitrary name
delimiter, e.g. "/" or "_". As I often name my variables "var.x.y", the
default delimiter makes it hard to distinguish the distinct layers of a
nested list after unlisting. 
As 'unlist()' it is called by '.Internal()', I didn't have a clue of how to
find the section where the names are pasted.

I'd like to use such a patched version in order to create a customized index
(class: data.frame) of nested lists which should look like this

name             index      is.top      is.bottom       degree
a            1          TRUE            FALSE           1
a/a.1        1-1        FALSE           FALSE           2
a/a.1/a.1.1  1-1-1      FALSE           TRUE            3
a/a.2        1-2        FALSE      FALSE       2
a/a.2/a.2.1  1-2-1      FALSE      TRUE        3
b            2          TRUE       FALSE       1
...

Of course I could get such an index by recursively traversing the list
layers, but this takes much too long. Maybe you also have another idea on
how to create such an index.

PROBLEM 2
I'd also like to retrieve such an index for nested environment structures.
Therefore, I would either need something similar to 'unlist()' that works on
environments or find something that coerces nested environments to nested
lists. Again, I solved this by recursively looping over the respective
environment layers, but it's too inefficient. Is there something out there
that does the job via a C routine somehow?
Thanks for any suggestions,
Janko

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to