How to define raw vectors in R?

This recipe helps you define raw vectors in R

Recipe Objective:

Vector is a type of object or data structure in R-language. They are designed to store multiple values of same data-type. For example: if you want to store different 50 food items for each cuisine, you don't need to create 50 variables for each cuisine but just a vector of length 50 of datatype character.

Note: It can not have a combination of any two datatype. It has to be homogeneous in nature.

This recipe demonstrates how to create a raw vector

German Credit Card Dataset Analysis

Step 1: Creating a vector

We use combine function "c()" to create a vector

Case 1: Vector food_items with data of 3 different cuisine of character datatype

food_items = c("pasta", "burrito", "butter chicken") class(food_items)

'character'

Case 2: Vector no_of_children with data of 3 different people of numeric datatype

no_of_children = c(0,2,3) class(no_of_children)

'numeric'

Case 3: Vector that has both character and numeric values

mixed_values = c(1,3,'red') class(mixed_values)

'character'

We can see that the numeric values are type casted to character in this case and the homogeinity is maintained

What Users are saying..

profile image

Savvy Sahai

Data Science Intern, Capgemini
linkedin profile url

As a student looking to break into the field of data engineering and data science, one can get really confused as to which path to take. Very few ways to do it are Google, YouTube, etc. I was one of... Read More

Relevant Projects

Build Multi Class Text Classification Models with RNN and LSTM
In this Deep Learning Project, you will use the customer complaints data about consumer financial products to build multi-class text classification models using RNN and LSTM.

Recommender System Machine Learning Project for Beginners-1
Recommender System Machine Learning Project for Beginners - Learn how to design, implement and train a rule-based recommender system in Python

Build a Collaborative Filtering Recommender System in Python
Use the Amazon Reviews/Ratings dataset of 2 Million records to build a recommender system using memory-based collaborative filtering in Python.

BERT Text Classification using DistilBERT and ALBERT Models
This Project Explains how to perform Text Classification using ALBERT and DistilBERT

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.

Build a Hybrid Recommender System in Python using LightFM
In this Recommender System project, you will build a hybrid recommender system in Python using LightFM .

NLP Project on LDA Topic Modelling Python using RACE Dataset
Use the RACE dataset to extract a dominant topic from each document and perform LDA topic modeling in python.

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.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

OpenCV Project for Beginners to Learn Computer Vision Basics
In this OpenCV project, you will learn computer vision basics and the fundamentals of OpenCV library using Python.