SlideShare una empresa de Scribd logo
1 de 5
Descargar para leer sin conexión
4/16/2020 R Programming Lab - 2 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 2.ipynb 1/5
R - Notebook [LAB EXPERIMENTS DEMONSTRATION] ---------------Prepared by - Asst. Prof.
Ashwini Mathur(CSSP)- Jain University
Following Tasks to Perform:
1. Create some complex data structure variables such as list and data fr
ames using list() and data.frame commands.
2. Create data using data.frames, lists, and tables.
3. Implement basic R operations (data input, missing values, Importing d
ata into R using different formats : xlsx, CSV, Text files).
4. Explore data type conversions from one data structure to another with
commands such as as.data.frame(), as.vector(), is.data.frame(), is.vecto
r; and find the data type with class() command.
5. Explore function programming in R.
6. Explore loops in R programming such as if-else-ifelse, for, while, re
peat-break, ect.
Question 1. Create some complex data structure variables such as list and data frames
using list() and data.frame commands.
In [1]:
$name
'Mike'
$gender
'M'
$company
'Data-Science'
#List Creation
x <- list(name="Mike", gender="M", company="Data-Science")
x #print the list stored in object x
4/16/2020 R Programming Lab - 2 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 2.ipynb 2/5
In [2]:
Question 2. Create data using data.frames, lists, and tables.
In [4]:
Question 3. Implement basic R operations (data input, missing values, Importing data into R
using different formats : xlsx, CSV, Text files).
A data.frame: 3 × 3
name age student
<fct> <dbl> <lgl>
Mike 20 TRUE
Lucy 25 FALSE
John 30 TRUE
High Low Middle
current 51 43 22
former 92 28 21
never 68 22 9
#Data-Frame Creation
name <- c("Mike", "Lucy", "John")
age <- c(20, 25, 30)
student <- c(TRUE, FALSE, TRUE)
df = data.frame(name, age, student) #creation of dataframe using dat.frame
df #Print the dataframe
#create matrix
smoke <- matrix(c(51,43,22,92,28,21,68,22,9),ncol=3,byrow=TRUE)
#Assigning column variables name
colnames(smoke) <- c("High","Low","Middle")
#Assigning row variables name
rownames(smoke) <- c("current","former","never")
#create a table by converting matrix into table by using command as.table
smoke <- as.table(smoke)
smoke #output
4/16/2020 R Programming Lab - 2 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 2.ipynb 3/5
In [ ]:
Question 4. Explore data type conversions from one data structure to another with
commands such as as.data.frame(), as.vector(), is.data.frame(), is.vector; and find the data
type with class() command.
In [5]:
In [6]:
In [7]:
Question 5. Explore function programming in R.
75 · 83 · 101 · 56 · 80
Warning message in eval(expr, envir, enclos):
“NAs introduced by coercion”
<NA> · <NA> · <NA> · <NA> · <NA>
'Kohli' · 'Tendulkar' · 'Dravid' · 'Yuvraj' · 'Dhoni'
'character'
'numeric'
#Following arguments passing into read.table() function
#dataset variable
dataset <- matrix(c(51,43,22,92,28,21,68,22,9),ncol=3,byrow=TRUE)
dataset
mydata <- read.table("C:UsersashwinmathurDesktopR FILEJupyter-R LAB", heade
india.player.runs <- c(75, 83, 101, 56, 80)
india.player.names <- c("Kohli", "Tendulkar", "Dravid", "Yuvraj", "Dhoni")
as.integer(india.player.runs)
as.numeric(india.player.names)
as.character(india.player.names)
class(india.player.names)
class(india.player.runs)
4/16/2020 R Programming Lab - 2 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 2.ipynb 4/5
In [8]:
Question 6. Explore loops in R programming such as if-else-ifelse, for, while, repeat-break.
In [9]:
In [10]:
[1] 1
[1] 4
[1] 9
[1] 16
[1] 25
[1] 36
[1] 3
[1] "Negative number"
#Create a function to print squares of numbers in sequence.
new.function <- function(a) {
for(i in 1:a) {
b <- i^2
print(b)
}
}
# Call the function new.function supplying 6 as an argument.
new.function(6)
#For loop
x <- c(2,5,3,9,8,11,6)
count <- 0
for (val in x) {
if(val %% 2 == 0) count = count+1
}
print(count)
#If else
x <- -5
if(x > 0){
print("Non-negative number")
} else {
print("Negative number")
}
4/16/2020 R Programming Lab - 2 - Jupyter Notebook
https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 2.ipynb 5/5
In [11]:
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
#While loop
i <- 1
while (i < 6) {
print(i)
i = i+1
}

Más contenido relacionado

La actualidad más candente

A Generic Mapping-based Query Translation from SPARQL to Various Target Datab...
A Generic Mapping-based Query Translation from SPARQL to Various Target Datab...A Generic Mapping-based Query Translation from SPARQL to Various Target Datab...
A Generic Mapping-based Query Translation from SPARQL to Various Target Datab...Franck Michel
 
Functional data structures
Functional data structuresFunctional data structures
Functional data structuresRalf Laemmel
 
Merge Multiple CSV in single data frame using R
Merge Multiple CSV in single data frame using RMerge Multiple CSV in single data frame using R
Merge Multiple CSV in single data frame using RYogesh Khandelwal
 
Is there a perfect data-parallel programming language? (Experiments with More...
Is there a perfect data-parallel programming language? (Experiments with More...Is there a perfect data-parallel programming language? (Experiments with More...
Is there a perfect data-parallel programming language? (Experiments with More...Julian Hyde
 
Next Generation Programming in R
Next Generation Programming in RNext Generation Programming in R
Next Generation Programming in RFlorian Uhlitz
 
RMySQL Tutorial For Beginners
RMySQL Tutorial For BeginnersRMySQL Tutorial For Beginners
RMySQL Tutorial For BeginnersRsquared Academy
 
Functional Programming for the Rest of Us in Javascript
Functional Programming for the Rest of Us in JavascriptFunctional Programming for the Rest of Us in Javascript
Functional Programming for the Rest of Us in Javascriptsathish316
 
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table packageJanuary 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table packageZurich_R_User_Group
 
Mandatory sql functions for beginners
Mandatory sql functions for beginnersMandatory sql functions for beginners
Mandatory sql functions for beginnersshravan kumar chelika
 
Java
JavaJava
Java/ /
 
Získáváme, čistíme a ukládáme data
Získáváme, čistíme a ukládáme dataZískáváme, čistíme a ukládáme data
Získáváme, čistíme a ukládáme dataJosef Šlerka
 
Morel, a Functional Query Language
Morel, a Functional Query LanguageMorel, a Functional Query Language
Morel, a Functional Query LanguageJulian Hyde
 

La actualidad más candente (19)

A Generic Mapping-based Query Translation from SPARQL to Various Target Datab...
A Generic Mapping-based Query Translation from SPARQL to Various Target Datab...A Generic Mapping-based Query Translation from SPARQL to Various Target Datab...
A Generic Mapping-based Query Translation from SPARQL to Various Target Datab...
 
What is data structure
What is data structureWhat is data structure
What is data structure
 
Functional data structures
Functional data structuresFunctional data structures
Functional data structures
 
Merge Multiple CSV in single data frame using R
Merge Multiple CSV in single data frame using RMerge Multiple CSV in single data frame using R
Merge Multiple CSV in single data frame using R
 
Reading Data into R
Reading Data into RReading Data into R
Reading Data into R
 
Is there a perfect data-parallel programming language? (Experiments with More...
Is there a perfect data-parallel programming language? (Experiments with More...Is there a perfect data-parallel programming language? (Experiments with More...
Is there a perfect data-parallel programming language? (Experiments with More...
 
Solr in Drupal
Solr in DrupalSolr in Drupal
Solr in Drupal
 
Next Generation Programming in R
Next Generation Programming in RNext Generation Programming in R
Next Generation Programming in R
 
RMySQL Tutorial For Beginners
RMySQL Tutorial For BeginnersRMySQL Tutorial For Beginners
RMySQL Tutorial For Beginners
 
Functional Programming for the Rest of Us in Javascript
Functional Programming for the Rest of Us in JavascriptFunctional Programming for the Rest of Us in Javascript
Functional Programming for the Rest of Us in Javascript
 
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table packageJanuary 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
 
Mandatory sql functions for beginners
Mandatory sql functions for beginnersMandatory sql functions for beginners
Mandatory sql functions for beginners
 
Clojure 3 new funcions
Clojure 3 new funcionsClojure 3 new funcions
Clojure 3 new funcions
 
Data recovery using pg_filedump
Data recovery using pg_filedumpData recovery using pg_filedump
Data recovery using pg_filedump
 
Dbms quiz
Dbms quiz Dbms quiz
Dbms quiz
 
R programming by ganesh kavhar
R programming by ganesh kavharR programming by ganesh kavhar
R programming by ganesh kavhar
 
Java
JavaJava
Java
 
Získáváme, čistíme a ukládáme data
Získáváme, čistíme a ukládáme dataZískáváme, čistíme a ukládáme data
Získáváme, čistíme a ukládáme data
 
Morel, a Functional Query Language
Morel, a Functional Query LanguageMorel, a Functional Query Language
Morel, a Functional Query Language
 

Similar a R programming lab 2 - jupyter notebook

r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packagesAjay Ohri
 
Modeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.pptModeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.pptanshikagoel52
 
Lecture1_R.pdf
Lecture1_R.pdfLecture1_R.pdf
Lecture1_R.pdfBusyBird2
 
SQLMAP Tool Usage - A Heads Up
SQLMAP Tool Usage - A  Heads UpSQLMAP Tool Usage - A  Heads Up
SQLMAP Tool Usage - A Heads UpMindfire Solutions
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R langsenthil0809
 
Terraform modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructuredAmi Mahloof
 
Terraform Modules Restructured
Terraform Modules RestructuredTerraform Modules Restructured
Terraform Modules RestructuredDoiT International
 
R programming lab 1 - jupyter notebook
R programming lab   1 - jupyter notebookR programming lab   1 - jupyter notebook
R programming lab 1 - jupyter notebookAshwini Mathur
 
R Programming: Importing Data In R
R Programming: Importing Data In RR Programming: Importing Data In R
R Programming: Importing Data In RRsquared Academy
 
R Programming Tutorial for Beginners - -TIB Academy
R Programming Tutorial for Beginners - -TIB AcademyR Programming Tutorial for Beginners - -TIB Academy
R Programming Tutorial for Beginners - -TIB Academyrajkamaltibacademy
 
The Very ^ 2 Basics of R
The Very ^ 2 Basics of RThe Very ^ 2 Basics of R
The Very ^ 2 Basics of RWinston Chen
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programmingizahn
 
Spline 0.3 and Plans for 0.4
Spline 0.3 and Plans for 0.4 Spline 0.3 and Plans for 0.4
Spline 0.3 and Plans for 0.4 Vaclav Kosar
 
Tutorial On Database Management System
Tutorial On Database Management SystemTutorial On Database Management System
Tutorial On Database Management Systempsathishcs
 
Introduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplotIntroduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplotOlga Scrivner
 

Similar a R programming lab 2 - jupyter notebook (20)

r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packages
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
 
Modeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.pptModeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.ppt
 
Lecture1_R.pdf
Lecture1_R.pdfLecture1_R.pdf
Lecture1_R.pdf
 
SQLMAP Tool Usage - A Heads Up
SQLMAP Tool Usage - A  Heads UpSQLMAP Tool Usage - A  Heads Up
SQLMAP Tool Usage - A Heads Up
 
R basics
R basicsR basics
R basics
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R lang
 
Terraform modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructured
 
Terraform Modules Restructured
Terraform Modules RestructuredTerraform Modules Restructured
Terraform Modules Restructured
 
R programming lab 1 - jupyter notebook
R programming lab   1 - jupyter notebookR programming lab   1 - jupyter notebook
R programming lab 1 - jupyter notebook
 
MYSQL -1.pptx
MYSQL -1.pptxMYSQL -1.pptx
MYSQL -1.pptx
 
SetFocus Portfolio
SetFocus PortfolioSetFocus Portfolio
SetFocus Portfolio
 
R Programming: Importing Data In R
R Programming: Importing Data In RR Programming: Importing Data In R
R Programming: Importing Data In R
 
R Programming Tutorial for Beginners - -TIB Academy
R Programming Tutorial for Beginners - -TIB AcademyR Programming Tutorial for Beginners - -TIB Academy
R Programming Tutorial for Beginners - -TIB Academy
 
The Very ^ 2 Basics of R
The Very ^ 2 Basics of RThe Very ^ 2 Basics of R
The Very ^ 2 Basics of R
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programming
 
Spline 0.3 and Plans for 0.4
Spline 0.3 and Plans for 0.4 Spline 0.3 and Plans for 0.4
Spline 0.3 and Plans for 0.4
 
Tutorial On Database Management System
Tutorial On Database Management SystemTutorial On Database Management System
Tutorial On Database Management System
 
Introduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplotIntroduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplot
 

Más de Ashwini Mathur

S3 classes and s4 classes
S3 classes and s4 classesS3 classes and s4 classes
S3 classes and s4 classesAshwini Mathur
 
Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r Ashwini Mathur
 
R programming lab 3 - jupyter notebook
R programming lab   3 - jupyter notebookR programming lab   3 - jupyter notebook
R programming lab 3 - jupyter notebookAshwini Mathur
 
R for statistics session 1
R for statistics session 1R for statistics session 1
R for statistics session 1Ashwini Mathur
 
Object oriented programming in r
Object oriented programming in r Object oriented programming in r
Object oriented programming in r Ashwini Mathur
 
Linear programming optimization in r
Linear programming optimization in r Linear programming optimization in r
Linear programming optimization in r Ashwini Mathur
 
Introduction to python along with the comparitive analysis with r
Introduction to python   along with the comparitive analysis with r Introduction to python   along with the comparitive analysis with r
Introduction to python along with the comparitive analysis with r Ashwini Mathur
 
Example 2 summerization notes for descriptive statistics using r
Example   2    summerization notes for descriptive statistics using r Example   2    summerization notes for descriptive statistics using r
Example 2 summerization notes for descriptive statistics using r Ashwini Mathur
 
Descriptive statistics assignment
Descriptive statistics assignment Descriptive statistics assignment
Descriptive statistics assignment Ashwini Mathur
 
Descriptive analytics in r programming language
Descriptive analytics in r programming languageDescriptive analytics in r programming language
Descriptive analytics in r programming languageAshwini Mathur
 
Data analysis for covid 19
Data analysis for covid 19Data analysis for covid 19
Data analysis for covid 19Ashwini Mathur
 
Correlation and linear regression
Correlation and linear regression Correlation and linear regression
Correlation and linear regression Ashwini Mathur
 
Calling c functions from r programming unit 5
Calling c functions from r programming    unit 5Calling c functions from r programming    unit 5
Calling c functions from r programming unit 5Ashwini Mathur
 
Anova (analysis of variance) test
Anova (analysis of variance) test Anova (analysis of variance) test
Anova (analysis of variance) test Ashwini Mathur
 

Más de Ashwini Mathur (18)

S3 classes and s4 classes
S3 classes and s4 classesS3 classes and s4 classes
S3 classes and s4 classes
 
Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r
 
Rpy2 demonstration
Rpy2 demonstrationRpy2 demonstration
Rpy2 demonstration
 
Rpy package
Rpy packageRpy package
Rpy package
 
R programming lab 3 - jupyter notebook
R programming lab   3 - jupyter notebookR programming lab   3 - jupyter notebook
R programming lab 3 - jupyter notebook
 
R for statistics session 1
R for statistics session 1R for statistics session 1
R for statistics session 1
 
R for statistics 2
R for statistics 2R for statistics 2
R for statistics 2
 
Play with matrix in r
Play with matrix in rPlay with matrix in r
Play with matrix in r
 
Object oriented programming in r
Object oriented programming in r Object oriented programming in r
Object oriented programming in r
 
Linear programming optimization in r
Linear programming optimization in r Linear programming optimization in r
Linear programming optimization in r
 
Introduction to python along with the comparitive analysis with r
Introduction to python   along with the comparitive analysis with r Introduction to python   along with the comparitive analysis with r
Introduction to python along with the comparitive analysis with r
 
Example 2 summerization notes for descriptive statistics using r
Example   2    summerization notes for descriptive statistics using r Example   2    summerization notes for descriptive statistics using r
Example 2 summerization notes for descriptive statistics using r
 
Descriptive statistics assignment
Descriptive statistics assignment Descriptive statistics assignment
Descriptive statistics assignment
 
Descriptive analytics in r programming language
Descriptive analytics in r programming languageDescriptive analytics in r programming language
Descriptive analytics in r programming language
 
Data analysis for covid 19
Data analysis for covid 19Data analysis for covid 19
Data analysis for covid 19
 
Correlation and linear regression
Correlation and linear regression Correlation and linear regression
Correlation and linear regression
 
Calling c functions from r programming unit 5
Calling c functions from r programming    unit 5Calling c functions from r programming    unit 5
Calling c functions from r programming unit 5
 
Anova (analysis of variance) test
Anova (analysis of variance) test Anova (analysis of variance) test
Anova (analysis of variance) test
 

Último

Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowVadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowgargpaaro
 
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...HyderabadDolls
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteedamy56318795
 
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxRESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxronsairoathenadugay
 
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...kumargunjan9515
 
Case Study 4 Where the cry of rebellion happen?
Case Study 4 Where the cry of rebellion happen?Case Study 4 Where the cry of rebellion happen?
Case Study 4 Where the cry of rebellion happen?RemarkSemacio
 
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...HyderabadDolls
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...nirzagarg
 
Giridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime Giridih
Giridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime GiridihGiridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime Giridih
Giridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime Giridihmeghakumariji156
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Klinik kandungan
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraGovindSinghDasila
 
20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdf20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdfkhraisr
 
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...vershagrag
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...HyderabadDolls
 
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...HyderabadDolls
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...nirzagarg
 
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...nirzagarg
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareGraham Ware
 

Último (20)

Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowVadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
 
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
Diamond Harbour \ Russian Call Girls Kolkata | Book 8005736733 Extreme Naught...
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxRESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
 
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
 
Case Study 4 Where the cry of rebellion happen?
Case Study 4 Where the cry of rebellion happen?Case Study 4 Where the cry of rebellion happen?
Case Study 4 Where the cry of rebellion happen?
 
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
Kalyani ? Call Girl in Kolkata | Service-oriented sexy call girls 8005736733 ...
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
 
Giridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime Giridih
Giridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime GiridihGiridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime Giridih
Giridih Escorts Service Girl ^ 9332606886, WhatsApp Anytime Giridih
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - Almora
 
20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdf20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdf
 
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...
💞 Safe And Secure Call Girls Agra Call Girls Service Just Call 🍑👄6378878445 🍑...
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
 
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
 
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
 
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham Ware
 

R programming lab 2 - jupyter notebook

  • 1. 4/16/2020 R Programming Lab - 2 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 2.ipynb 1/5 R - Notebook [LAB EXPERIMENTS DEMONSTRATION] ---------------Prepared by - Asst. Prof. Ashwini Mathur(CSSP)- Jain University Following Tasks to Perform: 1. Create some complex data structure variables such as list and data fr ames using list() and data.frame commands. 2. Create data using data.frames, lists, and tables. 3. Implement basic R operations (data input, missing values, Importing d ata into R using different formats : xlsx, CSV, Text files). 4. Explore data type conversions from one data structure to another with commands such as as.data.frame(), as.vector(), is.data.frame(), is.vecto r; and find the data type with class() command. 5. Explore function programming in R. 6. Explore loops in R programming such as if-else-ifelse, for, while, re peat-break, ect. Question 1. Create some complex data structure variables such as list and data frames using list() and data.frame commands. In [1]: $name 'Mike' $gender 'M' $company 'Data-Science' #List Creation x <- list(name="Mike", gender="M", company="Data-Science") x #print the list stored in object x
  • 2. 4/16/2020 R Programming Lab - 2 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 2.ipynb 2/5 In [2]: Question 2. Create data using data.frames, lists, and tables. In [4]: Question 3. Implement basic R operations (data input, missing values, Importing data into R using different formats : xlsx, CSV, Text files). A data.frame: 3 × 3 name age student <fct> <dbl> <lgl> Mike 20 TRUE Lucy 25 FALSE John 30 TRUE High Low Middle current 51 43 22 former 92 28 21 never 68 22 9 #Data-Frame Creation name <- c("Mike", "Lucy", "John") age <- c(20, 25, 30) student <- c(TRUE, FALSE, TRUE) df = data.frame(name, age, student) #creation of dataframe using dat.frame df #Print the dataframe #create matrix smoke <- matrix(c(51,43,22,92,28,21,68,22,9),ncol=3,byrow=TRUE) #Assigning column variables name colnames(smoke) <- c("High","Low","Middle") #Assigning row variables name rownames(smoke) <- c("current","former","never") #create a table by converting matrix into table by using command as.table smoke <- as.table(smoke) smoke #output
  • 3. 4/16/2020 R Programming Lab - 2 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 2.ipynb 3/5 In [ ]: Question 4. Explore data type conversions from one data structure to another with commands such as as.data.frame(), as.vector(), is.data.frame(), is.vector; and find the data type with class() command. In [5]: In [6]: In [7]: Question 5. Explore function programming in R. 75 · 83 · 101 · 56 · 80 Warning message in eval(expr, envir, enclos): “NAs introduced by coercion” <NA> · <NA> · <NA> · <NA> · <NA> 'Kohli' · 'Tendulkar' · 'Dravid' · 'Yuvraj' · 'Dhoni' 'character' 'numeric' #Following arguments passing into read.table() function #dataset variable dataset <- matrix(c(51,43,22,92,28,21,68,22,9),ncol=3,byrow=TRUE) dataset mydata <- read.table("C:UsersashwinmathurDesktopR FILEJupyter-R LAB", heade india.player.runs <- c(75, 83, 101, 56, 80) india.player.names <- c("Kohli", "Tendulkar", "Dravid", "Yuvraj", "Dhoni") as.integer(india.player.runs) as.numeric(india.player.names) as.character(india.player.names) class(india.player.names) class(india.player.runs)
  • 4. 4/16/2020 R Programming Lab - 2 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 2.ipynb 4/5 In [8]: Question 6. Explore loops in R programming such as if-else-ifelse, for, while, repeat-break. In [9]: In [10]: [1] 1 [1] 4 [1] 9 [1] 16 [1] 25 [1] 36 [1] 3 [1] "Negative number" #Create a function to print squares of numbers in sequence. new.function <- function(a) { for(i in 1:a) { b <- i^2 print(b) } } # Call the function new.function supplying 6 as an argument. new.function(6) #For loop x <- c(2,5,3,9,8,11,6) count <- 0 for (val in x) { if(val %% 2 == 0) count = count+1 } print(count) #If else x <- -5 if(x > 0){ print("Non-negative number") } else { print("Negative number") }
  • 5. 4/16/2020 R Programming Lab - 2 - Jupyter Notebook https://hub.gke.mybinder.org/user/binder-examples-r-kagj2wsh/notebooks/R Programming Lab - 2.ipynb 5/5 In [11]: [1] 1 [1] 2 [1] 3 [1] 4 [1] 5 #While loop i <- 1 while (i < 6) { print(i) i = i+1 }