0% found this document useful (0 votes)
19 views

Da Print

Uploaded by

kalash satypal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
19 views

Da Print

Uploaded by

kalash satypal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 13
# Create vector x1 = c(4, 5, 5, 6, 7, 8, 8, 1€) xd # Create vector x2 = c(12, 14, 13, 7, 8, 8, 9, 13) x2 12: 14: 13. 7- 8. 8 9 13 # Create vector x3 = (22, 24, 26, 26, 29, 32, 20, 14) x3 22. 24- 26- 26- 29- 32- 20-14 #create data frame df <- data.frame(x1, x2, x3) dt A data far xt x2 Xd 5 14 5 13 25 8 7 2 7 8 2 a 8 2 a 8 2 0 13 # Create correlation matrix cor(dF) Amati 2 <2 of ype ob a 2 6 xt 1.0090000 0.244960 -0.3298720 x2 02448608 1.000000 -0.6220017 x3 03205730 05220817 1.000000 iris A data frame: 160 x 6 SepalLength Sepal.Width Petal.Length PetalWidth Species 54 35 14 02 setosa 4g 30 14 02 setosa 4a 32 13 02 setosa 46 34 15 02 setosa 50 36 14 02 setosa iris_new <- sapply(iris, unclass) # Convert categorical. variables iris_new # Print updated data frame A matrix: 160 * § of type dbl SepalLenath Sepal.Width Petal.Lenath Petal Wicth Species 54 35 14 02 1 49 30 14 02 4 47 32 13 02 1 48 34 15 02 1 50 36 14 02 4 54 a9 7 04 1 iris_new <- sapply(iris, unclass) # Convert categorical variables to numeric corr < round(cor(iris new), 1) # CorreLation Matrix head (corr[, 1:5]) Amati: 5» 5 of type 4b) SepalLengtn Sepal.Widtn Petal.Length PetalWwidth Species ‘Sepal Length 10 a oe oe oe sepat warn oa 10 vy at at PetaLLengin 08 oa 10 10 Peta. win 08 08 10 191 Species 08 os og 1010 iris_new <- sapply(iris, uncles) # Convert categorical variables to numeric corr <- round(cor(dris neu), 2) # Visualize the corretation matréx r- # method = “square” (default) ggcorrplot (corr, lab = TRUE) species avin PoteLtenath ‘Sepa. Sepal tenth install .packages("ggplot2") Installing package into ‘/srv/rlibs’ (as ‘lib? is unspecified) Library (ggplot2) data(" head (iris) A data frame: 66 SepalLength Sepal.Width Petal.length Petal Width Species
fot» 1 BA 35 14 02 setose 2 49 30 14 02 setosa 3 a7 32 43 02 setose 4 46 34 18 02 setose 5 50 36 14 02 setosa 6 54 38 17 D4 setosa lggplot(datasiris,eapping-ees(x-sepe1. Lengt,ysPetol. Length)) jeon_point()+ geom_smocth(method=" Ia") * geon_encath( |” using formula *y =! ‘Threshold Value y=03 Ee ces Ee EL EE Fess ¢ eee admit gre gpa rank 1 0 3803 2 16603 3 18004. 4 16403 5 05202 6 17603 admit Nin. :@.200 Ast Qu. 2.200 Medien :€.000 Mean 0.318 3rd Qu.:1.000 Max. 1.000 admit gre 0.466 115.517 rank adnit 1 2 3 61 87 20 19 93 08 3 3 1 4 4 2 gre Min, ist Qu Median Mean 3rd Qu Max. 2.381 4 @ 28 97 93 55 133 54 28 12 gpa Min. :2.26 Ast Qu.:3.13 3580 Median :3.40 1588 Mean 33.39 3rd Qu.:3.67 1800 Max. 24.00 rank aca Nin. ast Qu, Medion : Nean 3rd Qu, Max. [1]: install.packages("rpart. plot”) Installing package into ‘/srv/elibs? (a5 ‘Lib? is unspecified) [2]: | install.packages("tree") Installing package into ‘/srv/rlibs? (as ‘Lib? is unspecified) [3]: install. packages("ISLR") Installing package into ‘/srv/rlibs? (as ‘lib? is unspecified) [4]: | install. packages("rettle") Installing packege Into ‘/srv/rlibs’ (a5 ‘Lib? is unspecified) Loading required package: rpert Loading required package: tibble Loading required package: bitops Rattle: A free graphical interface for data science with R. Version 5.4.0 Copyright (c) 2006-2620 Togauare Pty Ltd. Type “rattle()’ to shake, rattle, and roll your data. ose =e em ees «8 ef os sm A we eo ae wee ona Histogram of Hitters$Salary Histogram of Hitters$Salary requency 2 30480 10 Regression tree: tree(formila = Salary ~ Hits + Years, data = Hitters) Number of terminal nodes: 8 Min. Ist Qu. Median Mean 3rd Qu. Max. -2.2400 -0.2980 -2.0365 0.0000 0.3233 2.1520 sn ain cans ore ane ‘ g esl ne 3 s . Fetallength Cluster Dendrogram te ir — oor ooe L oz s96u3|/@u> a6poa “sosb 290 350Sp 2/01 315080 2190 Jewounuo djooun boomaaig 2e1pe) — euadul saisiy5, og nemsen oot 0 qu8IH helust (+, "complete) Component 2 clusplot(pam(x = x, k = 2)) component 1 ‘These two components explain 100 % of the point variability Component 2 clusplot(pam(x = x4, k 2) 2 r T 2 a ° ‘These two components explain 61.57 % of the point variability. Component 1

You might also like