SlideShare a Scribd company logo
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 1/18
EXPERIMENT no. 5 and 6 [ R PROGRAMMING LANGUAGE ]
- Asst. Prof. Ashwini Mathur
Question 1. What happens when the following code is run? gender <- c("M" , "M" , "F" , "F" , "F" )
whereF<- (gender == "F" ) gender[whereF] <- "Female"
Question 2. In R, evaluate the expressions
2^52 + k – 2^52
2^53 + k – 2^53
2^54 + k – 2^54,
for the cases where k = 1, 2, 3, 4. Explain what you observe. What could be done to obtain results
in R which are mathematically correct?
Question 3. Construct the data frame char-num in the following way: char <- c("2" , "1" , "0" )
num<- 0:2 charnum<- data.frame(char, num);
Question 4. The following are a sample of observations on incoming solar radiation at a
greenhouse: 11.1 10.6 6.3 8.8 10.7 11.2 8.9 12.2
a. Assign the data to an object called solar.radiation.
b. Find the mean, median, range, and variance of the radiation o
bservations.
c. Add 10 to each observation of solar.radiation, and assign the
result to sr10. Find the mean, median, range, and va
riance of sr10. Which statistics change, and by how much?
d. Plot a histogram of the solar.radiation, sr10, and srm2.
Question 4. Modify the code to generate the Fibonacci sequence in the following ways.
1. Change the first two elements to 2 and 2.
2. Change the first two elements to 3 and 2.
Question 5. Use the inbuilt data car and uses the possible graphical plots using ggplot2 graphical
packages.
Question 1. What happens when the following code is run? gender <- c("M" , "M" , "F" , "F" , "F" )
whereF<- (gender == "F" ) gender[whereF] <- "Female"
In [45]:
'M' · 'M' · 'Female' · 'Female' · 'Female'
gender <- c("M" , "M" , "F" , "F" , "F" )
whereF <- (gender == "F" )
gender[whereF] <- "Female"
#Print gender
gender
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 2/18
Question 2. In R, evaluate the expressions
2^52 + k – 2^52
2^53 + k – 2^53
2^54 + k – 2^54,
for the cases where k = 1, 2, 3, 4. Explain what you observe. What could be done to obtain results
in R which are mathematically correct?
In [46]:
We are right at the borderline of accuracy for double precision foating point. The first expression
is done accurately, the other two suffer rounding error. The result would be correct if done in a
different order, e.g.
In [47]:
Question 2. Construct the data frame char-num in the following way: char <- c("2" , "1" , "0" )
num<- 0:2 charnum<- data.frame(char, num);
1 · 2 · 3 · 4
0 · 2 · 4 · 4
0 · 0 · 4 · 4
1 · 2 · 3 · 4
0 · 2 · 4 · 4
1 · 2 · 3 · 4
k <- 1:4
#1
2^52 + k - 2^52
#2
2^53 + k - 2^53
#3
2^54 + k - 2^54
2^52 - 2^52 + k
2^53 + k - 2^53
2^54 - 2^54 + k
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 3/18
In [48]:
Question 3. Modify the code to generate the Fibonacci sequence in the following ways.
1. Change the first two elements to 2 and 2.
2. Change the first two elements to 3 and 2.
In [49]:
2 · 1 · 0
Levels:
0 · 1 · 2
0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0
2 · 2 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0
2 · 2 · 4 · 6 · 10 · 16 · 26 · 42 · 68 · 110 · 178 · 288
char <- c("2", "1", "0")
num <- 0:2
charnum <- data.frame(char, num)
#as.numeric(char)
charnum$char
charnum$num
# Implement the code to generate the Fibonacci sequence.
Fibonacci <- numeric(12)
Fibonacci
Fibonacci[1] <- 2
Fibonacci[2] <- 2
Fibonacci
for (i in 3:12) Fibonacci[i] <- Fibonacci[i-2] + Fibonacci[i-1]
Fibonacci
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 4/18
In [50]:
Question 4. The following are a sample of observations on incoming solar radiation at a
greenhouse:
11.1 10.6 6.3 8.8 10.7 11.2 8.9 12.2
a. Assign the data to an object called solar.radiation.
b. Find the mean, median, range, and variance of the radiation o
bservations.
c. Add 10 to each observation of solar.radiation, and assign the
result to sr10. Find the mean, median, range,and variance of sr10. W
hich statistics change, and by how much?
d. Plot a histogram of the solar.radiation, sr10, and srm2.
In [51]:
In [52]:
In [53]:
1 · 1 · 0 · -1 · -1 · 0 · 1 · 1 · 0 · -1 · -1 · 0
11.1 · 10.6 · 6.3 · 8.8 · 10.7 · 11.2 · 8.9 · 12.2
9.975
10.65
6.3 · 12.2
3.525
Fibonacci <- numeric(12)
Fibonacci[1] <- Fibonacci[2] <- 1
for (i in 3:12) Fibonacci[i] <- Fibonacci[i-1] - Fibonacci[i-2]
Fibonacci
# Assign the data to an object called solar.radiation.
solar.radiation <- c(11.1,10.6,6.3,8.8,10.7,11.2,8.9,12.2)
solar.radiation
#b. Find the mean, median, range, and variance of the radiation observations.
mean(solar.radiation)
median(solar.radiation)
range(solar.radiation)
var(solar.radiation)
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 5/18
In [54]:
19.975
20.65
16.3 · 22.2
3.525
#Add 10 to each observation of solar.radiation, and assign the result to sr10. F
sr10 <- solar.radiation + 10
mean(sr10)
median(sr10)
range(sr10)
var(sr10)
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 6/18
In [55]: #d. Plot a histogram of the solar.radiation, sr10.
hist(solar.radiation)
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 7/18
Question 5. Use the inbuilt data car and uses the possible graphical plots using ggplot2 graphical
packages.
In [56]:
In [57]:
data(mtcars)
?mtcars
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 8/18
In [58]:
A data.frame: 32 × 11
mpg cyl disp hp drat wt qsec vs am gear carb
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4
Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4
Datsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1
Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1
Hornet Sportabout 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2
Valiant 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1
Duster 360 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4
Merc 240D 24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2
Merc 230 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2
Merc 280 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4
Merc 280C 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4
Merc 450SE 16.4 8 275.8 180 3.07 4.070 17.40 0 0 3 3
Merc 450SL 17.3 8 275.8 180 3.07 3.730 17.60 0 0 3 3
Merc 450SLC 15.2 8 275.8 180 3.07 3.780 18.00 0 0 3 3
Cadillac
Fleetwood
10.4 8 472.0 205 2.93 5.250 17.98 0 0 3 4
Lincoln
Continental
10.4 8 460.0 215 3.00 5.424 17.82 0 0 3 4
Chrysler Imperial 14.7 8 440.0 230 3.23 5.345 17.42 0 0 3 4
Fiat 128 32.4 4 78.7 66 4.08 2.200 19.47 1 1 4 1
Honda Civic 30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2
Toyota Corolla 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 1
Toyota Corona 21.5 4 120.1 97 3.70 2.465 20.01 1 0 3 1
Dodge Challenger 15.5 8 318.0 150 2.76 3.520 16.87 0 0 3 2
AMC Javelin 15.2 8 304.0 150 3.15 3.435 17.30 0 0 3 2
Camaro Z28 13.3 8 350.0 245 3.73 3.840 15.41 0 0 3 4
Pontiac Firebird 19.2 8 400.0 175 3.08 3.845 17.05 0 0 3 2
Fiat X1-9 27.3 4 79.0 66 4.08 1.935 18.90 1 1 4 1
Porsche 914-2 26.0 4 120.3 91 4.43 2.140 16.70 0 1 5 2
Lotus Europa 30.4 4 95.1 113 3.77 1.513 16.90 1 1 5 2
Ford Pantera L 15.8 8 351.0 264 4.22 3.170 14.50 0 1 5 4
Ferrari Dino 19.7 6 145.0 175 3.62 2.770 15.50 0 1 5 6
Maserati Bora 15.0 8 301.0 335 3.54 3.570 14.60 0 1 5 8
mtcars
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 9/18
In [59]:
In [60]:
In [61]:
In [62]:
mpg cyl disp hp drat wt qsec vs am gear carb
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
Volvo 142E 21.4 4 121.0 109 4.11 2.780 18.60 1 1 4 2
A data.frame: 6 × 11
mpg cyl disp hp drat wt qsec vs am gear carb
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
Porsche 914-2 26.0 4 120.3 91 4.43 2.140 16.7 0 1 5 2
Lotus Europa 30.4 4 95.1 113 3.77 1.513 16.9 1 1 5 2
Ford Pantera L 15.8 8 351.0 264 4.22 3.170 14.5 0 1 5 4
Ferrari Dino 19.7 6 145.0 175 3.62 2.770 15.5 0 1 5 6
Maserati Bora 15.0 8 301.0 335 3.54 3.570 14.6 0 1 5 8
Volvo 142E 21.4 4 121.0 109 4.11 2.780 18.6 1 1 4 2
11
32
32 · 11
tail(mtcars)
ncol(mtcars)
nrow(mtcars)
dim(mtcars)
library(ggplot2)
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 10/18
In [63]: my_plot = ggplot(mtcars,aes(x=cyl)) + geom_histogram(binwidth=0.4)
my_plot
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 11/18
aes = aesthetic here meaning a mapping between a variable and a characteristic of the plot
x relates to the x-axis (ie wt links to x)
In [64]:
labs adds labels to a plot
# using full ggplot syntax
ggplot(data = mtcars, aes(x = wt, y = mpg)) +
geom_point()
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 12/18
In [65]: my_plot + xlab('Miles per Gallon')+ylab('Number of Cars')
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 13/18
In [66]: #For changing the theme
my_plot + xlab('Miles per Gallon')+ylab('Number of Cars') + theme_dark()
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 14/18
In [67]: my_scatplot <- ggplot(mtcars,aes(x=wt,y=mpg)) + geom_point()
my_scatplot + xlab('Weight (x 1000lbs)') + ylab('Miles per Gallon')
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 15/18
In [68]: my_scatplot <- ggplot(mtcars,aes(x=wt,y=mpg,col=gear)) + geom_point()
my_scatplot + labs(x='Weight (x1000lbs)',y='Miles per Gallon',colour='Number of
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 16/18
In [69]: my_scatplot <- ggplot(mtcars,aes(x=wt,y=mpg,col=gear)) + geom_point()
my_scatplot + facet_grid(~gear)
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 17/18
In [70]:
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
my_scatplot <- ggplot(mtcars,aes(x=wt,y=mpg)) + geom_point()
my_scatplot + xlab('Weight (x 1000lbs)') + ylab('Miles per Gallon') + geom_smoot
5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook
localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 18/18

More Related Content

What's hot

Comparative study of algorithms of nonlinear optimization
Comparative study of algorithms of nonlinear optimizationComparative study of algorithms of nonlinear optimization
Comparative study of algorithms of nonlinear optimizationPranamesh Chakraborty
 
Application of recursive perturbation approach for multimodal optimization
Application of recursive perturbation approach for multimodal optimizationApplication of recursive perturbation approach for multimodal optimization
Application of recursive perturbation approach for multimodal optimizationPranamesh Chakraborty
 
Bind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning NightmareBind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning Nightmare
Sage Computing Services
 
Do snow.rwn
Do snow.rwnDo snow.rwn
Do snow.rwn
ARUN DN
 
Input Shaft Project
Input Shaft ProjectInput Shaft Project
Input Shaft Project
garrett harker
 
R演習補講 (2腕バンディット問題を題材に)
R演習補講 (2腕バンディット問題を題材に)R演習補講 (2腕バンディット問題を題材に)
R演習補講 (2腕バンディット問題を題材に)
Masatoshi Yoshida
 
Verification of Concurrent and Distributed Systems
Verification of Concurrent and Distributed SystemsVerification of Concurrent and Distributed Systems
Verification of Concurrent and Distributed Systems
Mykola Novik
 
ANSI vs Oracle language
ANSI vs Oracle languageANSI vs Oracle language
ANSI vs Oracle language
Connor McDonald
 
Function problem p
Function problem pFunction problem p
Function problem p
Thanuphong Ngoapm
 
Enjoyable Front-end Development with Reagent
Enjoyable Front-end Development with ReagentEnjoyable Front-end Development with Reagent
Enjoyable Front-end Development with Reagent
Thiago Fernandes Massa
 
Losing Data in a Safe Way – Advanced Replication Strategies in Apache Hadoop ...
Losing Data in a Safe Way – Advanced Replication Strategies in Apache Hadoop ...Losing Data in a Safe Way – Advanced Replication Strategies in Apache Hadoop ...
Losing Data in a Safe Way – Advanced Replication Strategies in Apache Hadoop ...
DataWorks Summit
 
Real problem2 p
Real problem2 pReal problem2 p
Real problem2 p
Thanuphong Ngoapm
 
EKON22 Introduction to Machinelearning
EKON22 Introduction to MachinelearningEKON22 Introduction to Machinelearning
EKON22 Introduction to Machinelearning
Max Kleiner
 

What's hot (14)

Comparative study of algorithms of nonlinear optimization
Comparative study of algorithms of nonlinear optimizationComparative study of algorithms of nonlinear optimization
Comparative study of algorithms of nonlinear optimization
 
Application of recursive perturbation approach for multimodal optimization
Application of recursive perturbation approach for multimodal optimizationApplication of recursive perturbation approach for multimodal optimization
Application of recursive perturbation approach for multimodal optimization
 
Bind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning NightmareBind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning Nightmare
 
Do snow.rwn
Do snow.rwnDo snow.rwn
Do snow.rwn
 
Input Shaft Project
Input Shaft ProjectInput Shaft Project
Input Shaft Project
 
R演習補講 (2腕バンディット問題を題材に)
R演習補講 (2腕バンディット問題を題材に)R演習補講 (2腕バンディット問題を題材に)
R演習補講 (2腕バンディット問題を題材に)
 
Verification of Concurrent and Distributed Systems
Verification of Concurrent and Distributed SystemsVerification of Concurrent and Distributed Systems
Verification of Concurrent and Distributed Systems
 
Sas tutorial 0308
Sas tutorial 0308Sas tutorial 0308
Sas tutorial 0308
 
ANSI vs Oracle language
ANSI vs Oracle languageANSI vs Oracle language
ANSI vs Oracle language
 
Function problem p
Function problem pFunction problem p
Function problem p
 
Enjoyable Front-end Development with Reagent
Enjoyable Front-end Development with ReagentEnjoyable Front-end Development with Reagent
Enjoyable Front-end Development with Reagent
 
Losing Data in a Safe Way – Advanced Replication Strategies in Apache Hadoop ...
Losing Data in a Safe Way – Advanced Replication Strategies in Apache Hadoop ...Losing Data in a Safe Way – Advanced Replication Strategies in Apache Hadoop ...
Losing Data in a Safe Way – Advanced Replication Strategies in Apache Hadoop ...
 
Real problem2 p
Real problem2 pReal problem2 p
Real problem2 p
 
EKON22 Introduction to Machinelearning
EKON22 Introduction to MachinelearningEKON22 Introduction to Machinelearning
EKON22 Introduction to Machinelearning
 

Similar to Descriptive analytics in r programming language

Hailey_Database_Performance_Made_Easy_through_Graphics.pdf
Hailey_Database_Performance_Made_Easy_through_Graphics.pdfHailey_Database_Performance_Made_Easy_through_Graphics.pdf
Hailey_Database_Performance_Made_Easy_through_Graphics.pdf
cookie1969
 
R Programming: Transform/Reshape Data In R
R Programming: Transform/Reshape Data In RR Programming: Transform/Reshape Data In R
R Programming: Transform/Reshape Data In R
Rsquared Academy
 
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
Masayuki Matsushita
 
LG DA0LG2MB6D0 REV D PDF.pdf
LG DA0LG2MB6D0 REV D PDF.pdfLG DA0LG2MB6D0 REV D PDF.pdf
LG DA0LG2MB6D0 REV D PDF.pdf
HomeCell3
 
re:Invent 2019 BPF Performance Analysis at Netflix
re:Invent 2019 BPF Performance Analysis at Netflixre:Invent 2019 BPF Performance Analysis at Netflix
re:Invent 2019 BPF Performance Analysis at Netflix
Brendan Gregg
 
Acer aspire 4252_4552_4552g_quanta_zqa_rev_1a_sch
Acer aspire 4252_4552_4552g_quanta_zqa_rev_1a_schAcer aspire 4252_4552_4552g_quanta_zqa_rev_1a_sch
Acer aspire 4252_4552_4552g_quanta_zqa_rev_1a_sch
juan carlos pintos
 
SQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX DevelopersSQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX Developers
Connor McDonald
 
LSFMM 2019 BPF Observability
LSFMM 2019 BPF ObservabilityLSFMM 2019 BPF Observability
LSFMM 2019 BPF Observability
Brendan Gregg
 
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Anne Nicolas
 
Kernel Recipes 2017: Performance Analysis with BPF
Kernel Recipes 2017: Performance Analysis with BPFKernel Recipes 2017: Performance Analysis with BPF
Kernel Recipes 2017: Performance Analysis with BPF
Brendan Gregg
 
Writing Readable Code with Pipes
Writing Readable Code with PipesWriting Readable Code with Pipes
Writing Readable Code with Pipes
Rsquared Academy
 
OOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresOOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL features
Connor McDonald
 
Klessydra t - designing vector coprocessors for multi-threaded edge-computing...
Klessydra t - designing vector coprocessors for multi-threaded edge-computing...Klessydra t - designing vector coprocessors for multi-threaded edge-computing...
Klessydra t - designing vector coprocessors for multi-threaded edge-computing...
RISC-V International
 
Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...
Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...
Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...
Hsien-Hsin Sean Lee, Ph.D.
 
OSSNA 2017 Performance Analysis Superpowers with Linux BPF
OSSNA 2017 Performance Analysis Superpowers with Linux BPFOSSNA 2017 Performance Analysis Superpowers with Linux BPF
OSSNA 2017 Performance Analysis Superpowers with Linux BPF
Brendan Gregg
 
Debugging Ruby
Debugging RubyDebugging Ruby
Debugging Ruby
Aman Gupta
 
Sangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesSangam 2019 - The Latest Features
Sangam 2019 - The Latest Features
Connor McDonald
 
Comparative Study on DES and Triple DES Algorithms and Proposal of a New Algo...
Comparative Study on DES and Triple DES Algorithms and Proposal of a New Algo...Comparative Study on DES and Triple DES Algorithms and Proposal of a New Algo...
Comparative Study on DES and Triple DES Algorithms and Proposal of a New Algo...
Associate Professor in VSB Coimbatore
 
ATO Linux Performance 2018
ATO Linux Performance 2018ATO Linux Performance 2018
ATO Linux Performance 2018
Brendan Gregg
 

Similar to Descriptive analytics in r programming language (20)

Hailey_Database_Performance_Made_Easy_through_Graphics.pdf
Hailey_Database_Performance_Made_Easy_through_Graphics.pdfHailey_Database_Performance_Made_Easy_through_Graphics.pdf
Hailey_Database_Performance_Made_Easy_through_Graphics.pdf
 
R Programming: Transform/Reshape Data In R
R Programming: Transform/Reshape Data In RR Programming: Transform/Reshape Data In R
R Programming: Transform/Reshape Data In R
 
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
 
LG DA0LG2MB6D0 REV D PDF.pdf
LG DA0LG2MB6D0 REV D PDF.pdfLG DA0LG2MB6D0 REV D PDF.pdf
LG DA0LG2MB6D0 REV D PDF.pdf
 
re:Invent 2019 BPF Performance Analysis at Netflix
re:Invent 2019 BPF Performance Analysis at Netflixre:Invent 2019 BPF Performance Analysis at Netflix
re:Invent 2019 BPF Performance Analysis at Netflix
 
LalitBDA2015V3
LalitBDA2015V3LalitBDA2015V3
LalitBDA2015V3
 
Acer aspire 4252_4552_4552g_quanta_zqa_rev_1a_sch
Acer aspire 4252_4552_4552g_quanta_zqa_rev_1a_schAcer aspire 4252_4552_4552g_quanta_zqa_rev_1a_sch
Acer aspire 4252_4552_4552g_quanta_zqa_rev_1a_sch
 
SQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX DevelopersSQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX Developers
 
LSFMM 2019 BPF Observability
LSFMM 2019 BPF ObservabilityLSFMM 2019 BPF Observability
LSFMM 2019 BPF Observability
 
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
 
Kernel Recipes 2017: Performance Analysis with BPF
Kernel Recipes 2017: Performance Analysis with BPFKernel Recipes 2017: Performance Analysis with BPF
Kernel Recipes 2017: Performance Analysis with BPF
 
Writing Readable Code with Pipes
Writing Readable Code with PipesWriting Readable Code with Pipes
Writing Readable Code with Pipes
 
OOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresOOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL features
 
Klessydra t - designing vector coprocessors for multi-threaded edge-computing...
Klessydra t - designing vector coprocessors for multi-threaded edge-computing...Klessydra t - designing vector coprocessors for multi-threaded edge-computing...
Klessydra t - designing vector coprocessors for multi-threaded edge-computing...
 
Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...
Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...
Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...
 
OSSNA 2017 Performance Analysis Superpowers with Linux BPF
OSSNA 2017 Performance Analysis Superpowers with Linux BPFOSSNA 2017 Performance Analysis Superpowers with Linux BPF
OSSNA 2017 Performance Analysis Superpowers with Linux BPF
 
Debugging Ruby
Debugging RubyDebugging Ruby
Debugging Ruby
 
Sangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesSangam 2019 - The Latest Features
Sangam 2019 - The Latest Features
 
Comparative Study on DES and Triple DES Algorithms and Proposal of a New Algo...
Comparative Study on DES and Triple DES Algorithms and Proposal of a New Algo...Comparative Study on DES and Triple DES Algorithms and Proposal of a New Algo...
Comparative Study on DES and Triple DES Algorithms and Proposal of a New Algo...
 
ATO Linux Performance 2018
ATO Linux Performance 2018ATO Linux Performance 2018
ATO Linux Performance 2018
 

More from Ashwini Mathur

S3 classes and s4 classes
S3 classes and s4 classesS3 classes and s4 classes
S3 classes and s4 classes
Ashwini 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
 
Rpy2 demonstration
Rpy2 demonstrationRpy2 demonstration
Rpy2 demonstration
Ashwini Mathur
 
Rpy package
Rpy packageRpy package
Rpy package
Ashwini Mathur
 
R programming lab 3 - jupyter notebook
R programming lab   3 - jupyter notebookR programming lab   3 - jupyter notebook
R programming lab 3 - jupyter notebook
Ashwini Mathur
 
R programming lab 2 - jupyter notebook
R programming lab   2 - jupyter notebookR programming lab   2 - jupyter notebook
R programming lab 2 - jupyter notebook
Ashwini Mathur
 
R programming lab 1 - jupyter notebook
R programming lab   1 - jupyter notebookR programming lab   1 - jupyter notebook
R programming lab 1 - jupyter notebook
Ashwini Mathur
 
R for statistics session 1
R for statistics session 1R for statistics session 1
R for statistics session 1
Ashwini Mathur
 
R for statistics 2
R for statistics 2R for statistics 2
R for statistics 2
Ashwini Mathur
 
Play with matrix in r
Play with matrix in rPlay with matrix in r
Play with matrix in r
Ashwini 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
 
Data analysis for covid 19
Data analysis for covid 19Data analysis for covid 19
Data analysis for covid 19
Ashwini 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 5
Ashwini Mathur
 
Anova (analysis of variance) test
Anova (analysis of variance) test Anova (analysis of variance) test
Anova (analysis of variance) test
Ashwini Mathur
 

More from Ashwini Mathur (19)

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 programming lab 2 - jupyter notebook
R programming lab   2 - jupyter notebookR programming lab   2 - jupyter notebook
R programming lab 2 - jupyter notebook
 
R programming lab 1 - jupyter notebook
R programming lab   1 - jupyter notebookR programming lab   1 - jupyter notebook
R programming lab 1 - 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
 
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
 

Recently uploaded

Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
ewymefz
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
nscud
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
ewymefz
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
ocavb
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
oz8q3jxlp
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
MaleehaSheikh2
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
TravisMalana
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
balafet
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
v3tuleee
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
haila53
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
ahzuo
 

Recently uploaded (20)

Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
 

Descriptive analytics in r programming language

  • 1. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 1/18 EXPERIMENT no. 5 and 6 [ R PROGRAMMING LANGUAGE ] - Asst. Prof. Ashwini Mathur Question 1. What happens when the following code is run? gender <- c("M" , "M" , "F" , "F" , "F" ) whereF<- (gender == "F" ) gender[whereF] <- "Female" Question 2. In R, evaluate the expressions 2^52 + k – 2^52 2^53 + k – 2^53 2^54 + k – 2^54, for the cases where k = 1, 2, 3, 4. Explain what you observe. What could be done to obtain results in R which are mathematically correct? Question 3. Construct the data frame char-num in the following way: char <- c("2" , "1" , "0" ) num<- 0:2 charnum<- data.frame(char, num); Question 4. The following are a sample of observations on incoming solar radiation at a greenhouse: 11.1 10.6 6.3 8.8 10.7 11.2 8.9 12.2 a. Assign the data to an object called solar.radiation. b. Find the mean, median, range, and variance of the radiation o bservations. c. Add 10 to each observation of solar.radiation, and assign the result to sr10. Find the mean, median, range, and va riance of sr10. Which statistics change, and by how much? d. Plot a histogram of the solar.radiation, sr10, and srm2. Question 4. Modify the code to generate the Fibonacci sequence in the following ways. 1. Change the first two elements to 2 and 2. 2. Change the first two elements to 3 and 2. Question 5. Use the inbuilt data car and uses the possible graphical plots using ggplot2 graphical packages. Question 1. What happens when the following code is run? gender <- c("M" , "M" , "F" , "F" , "F" ) whereF<- (gender == "F" ) gender[whereF] <- "Female" In [45]: 'M' · 'M' · 'Female' · 'Female' · 'Female' gender <- c("M" , "M" , "F" , "F" , "F" ) whereF <- (gender == "F" ) gender[whereF] <- "Female" #Print gender gender
  • 2. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 2/18 Question 2. In R, evaluate the expressions 2^52 + k – 2^52 2^53 + k – 2^53 2^54 + k – 2^54, for the cases where k = 1, 2, 3, 4. Explain what you observe. What could be done to obtain results in R which are mathematically correct? In [46]: We are right at the borderline of accuracy for double precision foating point. The first expression is done accurately, the other two suffer rounding error. The result would be correct if done in a different order, e.g. In [47]: Question 2. Construct the data frame char-num in the following way: char <- c("2" , "1" , "0" ) num<- 0:2 charnum<- data.frame(char, num); 1 · 2 · 3 · 4 0 · 2 · 4 · 4 0 · 0 · 4 · 4 1 · 2 · 3 · 4 0 · 2 · 4 · 4 1 · 2 · 3 · 4 k <- 1:4 #1 2^52 + k - 2^52 #2 2^53 + k - 2^53 #3 2^54 + k - 2^54 2^52 - 2^52 + k 2^53 + k - 2^53 2^54 - 2^54 + k
  • 3. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 3/18 In [48]: Question 3. Modify the code to generate the Fibonacci sequence in the following ways. 1. Change the first two elements to 2 and 2. 2. Change the first two elements to 3 and 2. In [49]: 2 · 1 · 0 Levels: 0 · 1 · 2 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 2 · 2 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 · 0 2 · 2 · 4 · 6 · 10 · 16 · 26 · 42 · 68 · 110 · 178 · 288 char <- c("2", "1", "0") num <- 0:2 charnum <- data.frame(char, num) #as.numeric(char) charnum$char charnum$num # Implement the code to generate the Fibonacci sequence. Fibonacci <- numeric(12) Fibonacci Fibonacci[1] <- 2 Fibonacci[2] <- 2 Fibonacci for (i in 3:12) Fibonacci[i] <- Fibonacci[i-2] + Fibonacci[i-1] Fibonacci
  • 4. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 4/18 In [50]: Question 4. The following are a sample of observations on incoming solar radiation at a greenhouse: 11.1 10.6 6.3 8.8 10.7 11.2 8.9 12.2 a. Assign the data to an object called solar.radiation. b. Find the mean, median, range, and variance of the radiation o bservations. c. Add 10 to each observation of solar.radiation, and assign the result to sr10. Find the mean, median, range,and variance of sr10. W hich statistics change, and by how much? d. Plot a histogram of the solar.radiation, sr10, and srm2. In [51]: In [52]: In [53]: 1 · 1 · 0 · -1 · -1 · 0 · 1 · 1 · 0 · -1 · -1 · 0 11.1 · 10.6 · 6.3 · 8.8 · 10.7 · 11.2 · 8.9 · 12.2 9.975 10.65 6.3 · 12.2 3.525 Fibonacci <- numeric(12) Fibonacci[1] <- Fibonacci[2] <- 1 for (i in 3:12) Fibonacci[i] <- Fibonacci[i-1] - Fibonacci[i-2] Fibonacci # Assign the data to an object called solar.radiation. solar.radiation <- c(11.1,10.6,6.3,8.8,10.7,11.2,8.9,12.2) solar.radiation #b. Find the mean, median, range, and variance of the radiation observations. mean(solar.radiation) median(solar.radiation) range(solar.radiation) var(solar.radiation)
  • 5. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 5/18 In [54]: 19.975 20.65 16.3 · 22.2 3.525 #Add 10 to each observation of solar.radiation, and assign the result to sr10. F sr10 <- solar.radiation + 10 mean(sr10) median(sr10) range(sr10) var(sr10)
  • 6. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 6/18 In [55]: #d. Plot a histogram of the solar.radiation, sr10. hist(solar.radiation)
  • 7. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 7/18 Question 5. Use the inbuilt data car and uses the possible graphical plots using ggplot2 graphical packages. In [56]: In [57]: data(mtcars) ?mtcars
  • 8. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 8/18 In [58]: A data.frame: 32 × 11 mpg cyl disp hp drat wt qsec vs am gear carb <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4 Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4 Datsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1 Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1 Hornet Sportabout 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2 Valiant 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1 Duster 360 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4 Merc 240D 24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2 Merc 230 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2 Merc 280 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4 Merc 280C 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4 Merc 450SE 16.4 8 275.8 180 3.07 4.070 17.40 0 0 3 3 Merc 450SL 17.3 8 275.8 180 3.07 3.730 17.60 0 0 3 3 Merc 450SLC 15.2 8 275.8 180 3.07 3.780 18.00 0 0 3 3 Cadillac Fleetwood 10.4 8 472.0 205 2.93 5.250 17.98 0 0 3 4 Lincoln Continental 10.4 8 460.0 215 3.00 5.424 17.82 0 0 3 4 Chrysler Imperial 14.7 8 440.0 230 3.23 5.345 17.42 0 0 3 4 Fiat 128 32.4 4 78.7 66 4.08 2.200 19.47 1 1 4 1 Honda Civic 30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2 Toyota Corolla 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 1 Toyota Corona 21.5 4 120.1 97 3.70 2.465 20.01 1 0 3 1 Dodge Challenger 15.5 8 318.0 150 2.76 3.520 16.87 0 0 3 2 AMC Javelin 15.2 8 304.0 150 3.15 3.435 17.30 0 0 3 2 Camaro Z28 13.3 8 350.0 245 3.73 3.840 15.41 0 0 3 4 Pontiac Firebird 19.2 8 400.0 175 3.08 3.845 17.05 0 0 3 2 Fiat X1-9 27.3 4 79.0 66 4.08 1.935 18.90 1 1 4 1 Porsche 914-2 26.0 4 120.3 91 4.43 2.140 16.70 0 1 5 2 Lotus Europa 30.4 4 95.1 113 3.77 1.513 16.90 1 1 5 2 Ford Pantera L 15.8 8 351.0 264 4.22 3.170 14.50 0 1 5 4 Ferrari Dino 19.7 6 145.0 175 3.62 2.770 15.50 0 1 5 6 Maserati Bora 15.0 8 301.0 335 3.54 3.570 14.60 0 1 5 8 mtcars
  • 9. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 9/18 In [59]: In [60]: In [61]: In [62]: mpg cyl disp hp drat wt qsec vs am gear carb <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> Volvo 142E 21.4 4 121.0 109 4.11 2.780 18.60 1 1 4 2 A data.frame: 6 × 11 mpg cyl disp hp drat wt qsec vs am gear carb <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> Porsche 914-2 26.0 4 120.3 91 4.43 2.140 16.7 0 1 5 2 Lotus Europa 30.4 4 95.1 113 3.77 1.513 16.9 1 1 5 2 Ford Pantera L 15.8 8 351.0 264 4.22 3.170 14.5 0 1 5 4 Ferrari Dino 19.7 6 145.0 175 3.62 2.770 15.5 0 1 5 6 Maserati Bora 15.0 8 301.0 335 3.54 3.570 14.6 0 1 5 8 Volvo 142E 21.4 4 121.0 109 4.11 2.780 18.6 1 1 4 2 11 32 32 · 11 tail(mtcars) ncol(mtcars) nrow(mtcars) dim(mtcars) library(ggplot2)
  • 10. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 10/18 In [63]: my_plot = ggplot(mtcars,aes(x=cyl)) + geom_histogram(binwidth=0.4) my_plot
  • 11. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 11/18 aes = aesthetic here meaning a mapping between a variable and a characteristic of the plot x relates to the x-axis (ie wt links to x) In [64]: labs adds labels to a plot # using full ggplot syntax ggplot(data = mtcars, aes(x = wt, y = mpg)) + geom_point()
  • 12. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 12/18 In [65]: my_plot + xlab('Miles per Gallon')+ylab('Number of Cars')
  • 13. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 13/18 In [66]: #For changing the theme my_plot + xlab('Miles per Gallon')+ylab('Number of Cars') + theme_dark()
  • 14. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 14/18 In [67]: my_scatplot <- ggplot(mtcars,aes(x=wt,y=mpg)) + geom_point() my_scatplot + xlab('Weight (x 1000lbs)') + ylab('Miles per Gallon')
  • 15. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 15/18 In [68]: my_scatplot <- ggplot(mtcars,aes(x=wt,y=mpg,col=gear)) + geom_point() my_scatplot + labs(x='Weight (x1000lbs)',y='Miles per Gallon',colour='Number of
  • 16. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 16/18 In [69]: my_scatplot <- ggplot(mtcars,aes(x=wt,y=mpg,col=gear)) + geom_point() my_scatplot + facet_grid(~gear)
  • 17. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 17/18 In [70]: `geom_smooth()` using method = 'loess' and formula 'y ~ x' my_scatplot <- ggplot(mtcars,aes(x=wt,y=mpg)) + geom_point() my_scatplot + xlab('Weight (x 1000lbs)') + ylab('Miles per Gallon') + geom_smoot
  • 18. 5/2/2020 Plots in built in R data [Experiment no. 5 and 6] - Jupyter Notebook localhost:8888/notebooks/Desktop/Plots in built in R data %5BExperiment no. 5 and 6%5D.ipynb# 18/18