How to get list of User defined Variables in R

Variables are containers to for storing data in any programming language. We get the list of variables defined in R Programming Language using ls(), objects() functions. R Variables starting with dot(.) are hidden, they can be listed using ls(all:names=TRUE).

Examples:

We can get list of variables using ls(), objects(), print(ls()), print(objects()),cat(ls()), cat(objects())
To get hidden variables use ls(all.names=TRUE)

 > print(ls())
 [1] "a"            "acno"         "b"            "c"            "d"            "e"           
 [7] "f.12"         "k1"           "list1"        "name"         "p"            "result"      
[13] "t"            "this_finance" "v"            "v1"           "v2"           "v3"          
[19] "var_10"       "var1"         "var2"         "var39"        "var5"        
> cat(ls())
a acno b c d e f.12 k1 list1 name p result t this_finance v v1 v2 v3 var_10 var1 var2 var39 var5
> print(objects())
 [1] "a"            "acno"         "b"            "c"            "d"            "e"           
 [7] "f.12"         "k1"           "list1"        "name"         "p"            "result"      
[13] "t"            "this_finance" "v"            "v1"           "v2"           "v3"          
[19] "var_10"       "var1"         "var2"         "var39"        "var5"        
> cat(objects())
a acno b c d e f.12 k1 list1 name p result t this_finance v v1 v2 v3 var_10 var1 var2 var39 var5
> ls()
 [1] "a"            "acno"         "b"            "c"            "d"            "e"           
 [7] "f.12"         "k1"           "list1"        "name"         "p"            "result"      
[13] "t"            "this_finance" "v"            "v1"           "v2"           "v3"          
[19] "var_10"       "var1"         "var2"         "var39"        "var5"        
> objects()
 [1] "a"            "acno"         "b"            "c"            "d"            "e"           
 [7] "f.12"         "k1"           "list1"        "name"         "p"            "result"      
[13] "t"            "this_finance" "v"            "v1"           "v2"           "v3"          
[19] "var_10"       "var1"         "var2"         "var39"        "var5"        
> ls(all.names=TRUE)
 [1] ".f"           ".Random.seed" "a"            "acno"         "b"            "c"           
 [7] "d"            "e"            "f.12"         "k1"           "list1"        "name"        
[13] "p"            "result"       "t"            "this_finance" "v"            "v1"          
[19] "v2"           "v3"           "var_10"       "var1"         "var2"         "var39"       
[25] "var5"

How to get list of User defined Variables in R

For more information about R Variables

Related Posts

CheapSexCams
Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by k2schools