How to list variables in R

+2 votes
HI, i have a lot of variables in my R Script. Each time i need to check in the environment variables. Is there any way to show or search variables in R with any pattern or string?
Jun 27, 2019 in Data Analytics by swathi
105,381 views

1 answer to this question.

+2 votes
Best answer

Hi Swathi,

You can use ls() to list all variables that are created in the environment.

ls() can be used to fetch variables in different ways

  • List all Variables 

             Use ls() to display all variables.

             

  • Using a character pattern

            pat = " " is used for pattern matching such as ^, $, ., etc.

            

Hope it helps!

Transform data into actionable insights with our Data Analytics Course – Enroll today!

answered Jun 27, 2019 by Cherukuri
• 33,050 points

selected Dec 15, 2020 by MD
Thanks. It worked.
I noticed that using ls() prints variables alphabetically.  How can I get it to print in the order of their column position in the data?

Thanks in advance!

Related Questions In Data Analytics

0 votes
1 answer

How to join two tables (tibbles) by *list* columns in R

You can use the hash from digest ...READ MORE

answered Apr 6, 2018 in Data Analytics by kappa3010
• 2,090 points
2,507 views
0 votes
1 answer

How to convert a list to data frame in R?

Let's assume your list of lists is ...READ MORE

answered Apr 12, 2018 in Data Analytics by nirvana
• 3,090 points

edited Apr 12, 2018 by nirvana 22,821 views
0 votes
1 answer

How to find out the sum/mean for multiple variables per group in R?

You can use the reshape2 package for ...READ MORE

answered Apr 12, 2018 in Data Analytics by DataKing99
• 8,250 points
4,699 views
0 votes
1 answer

How to create dummy variables based on a categorical variable of lists in R?

You can use mtabulate in the following way: library(qdapTools) cbind(data[1], ...READ MORE

answered Apr 13, 2018 in Data Analytics by CodingByHeart77
• 3,750 points
3,413 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points