The ls(pattern=\"\")
function is very useful for me, since my list of objects seem to keep growing and growing. I am curious if this feature can be more useful.
A couple of issues:
1) The .
in ".c"
gets ignored, you need to "escape" it:
ls(pattern="\\.c")
Otherwise it will return all objects with c
regardless of having a period.
2) ls
returns names of objects as character. To get the value of an object based on its name you need the function get
:
lapply(ls(pattern="\\.c"), get)
3) As joran mentioned in the comments, it's much better to keep objects associated with each other in lists:
List.c = list(a.c=1, b.c=2, c.c=3, d.c=4)