How to find variables in R with pattern in the current session?

This recipe helps you find variables in R with pattern in the current session

Recipe Objective

How to find variables in R with a pattern in the current session? A variable is a reserved memory space used to store a value.Variable stores a vector or group of vectors in it. The variables must start with a letter or underscore or a dot. To find all the variables currently available in an R session, we use the ls () function. The ls () function uses patterns to match the variable names of a vector. This recipe illustrates an example of finding a variable in R with patterns.

Step 1- To find variables in R

To find all variables available with pattern in the current session of R script file , ls() function is used.

print(ls())
"Output of the code is : "a"    "var"  "var1" 
print(ls(pattern='var'))
"Output of the code is :"var"  "var1" 

What Users are saying..

profile image

Abhinav Agarwal

Graduate Student at Northwestern University
linkedin profile url

I come from Northwestern University, which is ranked 9th in the US. Although the high-quality academics at school taught me all the basics I needed, obtaining practical experience was a challenge.... Read More

Relevant Projects

Digit Recognition using CNN for MNIST Dataset in Python
In this deep learning project, you will build a convolutional neural network using MNIST dataset for handwritten digit recognition.

Personalized Medicine: Redefining Cancer Treatment
In this Personalized Medicine Machine Learning Project you will learn to classify genetic mutations on the basis of medical literature into 9 classes.

Time Series Forecasting Project-Building ARIMA Model in Python
Build a time series ARIMA model in Python to forecast the use of arrival rate density to support staffing decisions at call centres.

Deep Learning Project for Time Series Forecasting in Python
Deep Learning for Time Series Forecasting in Python -A Hands-On Approach to Build Deep Learning Models (MLP, CNN, LSTM, and a Hybrid Model CNN-LSTM) on Time Series Data.

Build a Face Recognition System in Python using FaceNet
In this deep learning project, you will build your own face recognition system in Python using OpenCV and FaceNet by extracting features from an image of a person's face.

Deep Learning Project for Beginners with Source Code Part 1
Learn to implement deep neural networks in Python .

AWS MLOps Project for Gaussian Process Time Series Modeling
MLOps Project to Build and Deploy a Gaussian Process Time Series Model in Python on AWS

Build CNN Image Classification Models for Real Time Prediction
Image Classification Project to build a CNN model in Python that can classify images into social security cards, driving licenses, and other key identity information.

Build Deep Autoencoders Model for Anomaly Detection in Python
In this deep learning project , you will build and deploy a deep autoencoders model using Flask.

Detectron2 Object Detection and Segmentation Example Python
Object Detection using Detectron2 - Build a Dectectron2 model to detect the zones and inhibitions in antibiogram images.