0 votes
I am new to R Programming and want to understand the difference between List and Vector Data Types. I know that both of them are linear data types but am not sure where to use List and where to use Vector.

I'd like to know the differences between List and Vector along with some use cases. May 8, 2018 148 views

## 2 answers to this question.

0 votes

You are right in saying that both list and vector are linear data types, but the difference comes in the type of data they store.

A vector stores only homogenous data, while a list stores heterogenous data.

Below is an example to demonstrate that:

Vector:

`names<-c("Raj","Amy","Sheldon","Leonerd")`

This is a vector which comprises of only character elements.

List:

`MixBag<-list(name="Raj",Indian=TRUE,Salary=64283)`

Now, we have defined a list comprising of three elements of three different types. answered May 8, 2018 by
• 4,620 points
0 votes

Well, you are right in  saying that both of them are linear data types, but the difference comes in the type of data they store.

A vector stores only homogenous data, while a list stores heterogenous data.

Below is an example to demonstrate that:

Vector:

`names<-c("Raj","Amy","Sheldon","Leonerd")`

This is a vector which comprises of elements of only one type;

List:

`MixBag<-list(name="Raj",Indian=TRUE,Salary=64283)`

Now, we have defined a list comprising of three elements, all of which are of different data types.

`So, if you want to use a linear homogenous data types then you can go with Vector, but on the other hand if you want to use a linear heterogenous data type then you can use a list.` answered May 8, 2018 by anonymous

0 votes
1 answer

## Slicing a list using an index vector in r

Use index within [] and provide an ...READ MORE

0 votes
1 answer

## reverse a list or vector in R

@ch, Use rev function to reverse R objects ...READ MORE

0 votes
1 answer

## What is the difference between list and vector in R?

The difference are - A list holds different ...READ MORE

0 votes
1 answer

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

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

0 votes
1 answer

## By using dpylr package sum of multiple columns

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

0 votes
1 answer

## How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

0 votes
1 answer

## In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

0 votes
1 answer

## How to create a list of Data frames?

Basically all we have to do is ...READ MORE

0 votes
1 answer

## How can I delete multiple values from a vector in R?

The %in% operator tells  which elements are ...READ MORE

0 votes
2 answers

## Installing MXNet for R in Windows System

You can install it for python in ...READ MORE