R in Clinical World: WEEK5

PinnacleVex KA Analytics
1 min readMay 29, 2021

--

Continuation of Week4
3. Lists(Hybrid data type): A list is a collection of objects or components and which contain elements of different types like numbers, strings, vectors, and another list inside it. A list can also contain a matrix, or a function as its elements. We can create a list using list() function.
We say, a vector in which all the element can be of a diverse type. The objects in a list need not have to be of the same type, or length.

x <- c(1:50)
y <- FALSE
z<-”PinnacleVex”
numb<-50
df1<-students_data
chr1<-”This is a list of all my R elements”

str(x)
str(y)
str(z)
str(num)
str(df1)
str(chr1)

first_list<-list(chr1,x,y,z,numb,df1)

Accessing Lists:
str(first_list)
first_list
first_list[1] #getting 1st element
first_list[2] #getting 2nd element
first_list[6] #getting 6th element
first_list[[2]][1]

If we want to select 2nd element, then from that access 3rd element. So here we need to freeze element using[] and then access required one.

first_list[[2]][3]

Example for list: Creating a reg_model list using cars dataset with linear regression.

cars
reg_model <-lm(cars$dist~cars$speed)
reg_model
str(reg_model)
reg_model[1]
reg_model[3]
reg_model[6]
reg_model[7]
reg_model[[7]][1]
reg_model[[7]][2]

Happy Learning !!! :)

Related Articles:

R in Clinical World: WEEK4

R in Clinical World: WEEK3

R in Clinical World: WEEK2

R in Clinical World: WEEK1

Introduction to POWER BI

PinnacleVex KA Analytics: BASICS OF MICROSOFT EXCEL

PinnacleVex KA Analytics: Basic Excel Formulas For Your Daily Workflow

PinnacleVex KA Analytics: Simple introduction to SQL

PinnacleVex KA Analytics: Clinical Trials

PinnacleVex KA Analytics Clinical Data Management

My_website

LinkedIn

Youtube

Facebook

Twitter

Instagram

Youtube

--

--

PinnacleVex KA Analytics
PinnacleVex KA Analytics

Written by PinnacleVex KA Analytics

PinnacleVex KA Analytics is a Healthcare and IT Service Provider Headquartered at Hyderabad, India.

No responses yet