How to find datatype of a variable in R?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

How to find datatype of a variable in R?

How to find datatype of a variable in R?

This recipe helps you find datatype of a variable in R

Recipe Objective**

How to find the data type of a variable in R? Variables are reserved memory locations used to store values. Variables can be of different types known as data types such as numeric, integer, character, boolean, etc. Variables are assigned to R-objects and the data type of R-objects are the data types of a variable. class () , typeof () , mode () some of the functions which help determine the data type of vector. This recipe demonstrates how to find the data type of any vector input value using different functions.

Step 1 -Create input vectors

x <- "Hello World" y <- 3 z <- 53L

Stpe 2 - Use class() function

print(paste("class of x is : ",class(x)))
 "Output is" : character 
print(paste("class of y is : ",class(y)))
 "Output is" : numeric
print(paste("class of z is : ",class(z)))
 "Output is ": integer

Step 3 - Use typeof() function

print(paste("type of x is : ",typeof(x)))
 "Output is" : character

Step 4 - Use mode() function

print(paste("mode of x is : ",mode(x)))
 "Output is" : character

Relevant Projects

Machine Learning project for Retail Price Optimization
In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

Census Income Data Set Project - Predict Adult Census Income
Use the Adult Income dataset to predict whether income exceeds 50K yr based on census data.

Data Science Project on Wine Quality Prediction in R
In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.

Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

NLP and Deep Learning For Fake News Classification in Python
In this project you will use Python to implement various machine learning methods( RNN, LSTM, GRU) for fake news classification.

Human Activity Recognition Using Multiclass Classification in Python
In this human activity recognition project, we use multiclass classification machine learning techniques to analyse fitness dataset from a smartphone tracker.

Loan Eligibility Prediction in Python using H2O.ai
In this loan prediction project you will build predictive models in Python using H2O.ai to predict if an applicant is able to repay the loan or not.

Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

Machine learning for Retail Price Recommendation with Python
Use the Mercari Dataset with dynamic pricing to build a price recommendation algorithm using machine learning in Python to automatically suggest the right product prices.