I want to list all objects in R that start with something, like starts with character "A", I only know how to use ls(), is there a way to do so? Thanks!
+4
A:
ls()
has a pattern
argument - see ?ls
. To search with an 'a' anywhere:
> ls(pattern='a')
[1] "a" "clean" "extractRawText" "extractRSS" "extractText" "parts" "raw.data"
Or with a regular expression to get things that start with "A":
> ls(pattern='^A')
[1] "A" "Act"
If you don't know about regular expressions, but know about wildcards like '*' and such, you can use glob2rx()
:
> ls(pattern=glob2rx("A*"))
[1] "A" "Act"
Vince
2010-08-23 08:44:58