library(readr)
## Warning: package 'readr' was built under R version 4.3.3
cubic_zirconia <- read_csv("C:/Users/USER/Desktop/cubic_zirconia.csv")
## New names:
## Rows: 26967 Columns: 11
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (3): cut, color, clarity dbl (8): ...1, carat, depth, table, x, y, z, price
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
gem<-cubic_zirconia
gem$color<-as.factor(gem$color)
gem$clarity<-as.factor(gem$clarity)
gem$cut<-as.factor(gem$cut)
str(gem)
## spc_tbl_ [26,967 × 11] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ ...1 : num [1:26967] 1 2 3 4 5 6 7 8 9 10 ...
## $ carat : num [1:26967] 0.3 0.33 0.9 0.42 0.31 1.02 1.01 0.5 1.21 0.35 ...
## $ cut : Factor w/ 5 levels "Fair","Good",..: 3 4 5 3 3 3 2 4 2 3 ...
## $ color : Factor w/ 7 levels "D","E","F","G",..: 2 4 2 3 3 1 5 2 5 3 ...
## $ clarity: Factor w/ 8 levels "I1","IF","SI1",..: 3 2 8 5 7 6 3 3 3 6 ...
## $ depth : num [1:26967] 62.1 60.8 62.2 61.6 60.4 61.5 63.7 61.5 63.8 60.5 ...
## $ table : num [1:26967] 58 58 60 56 59 56 60 62 64 57 ...
## $ x : num [1:26967] 4.27 4.42 6.04 4.82 4.35 6.46 6.35 5.09 6.72 4.52 ...
## $ y : num [1:26967] 4.29 4.46 6.12 4.8 4.43 6.49 6.3 5.06 6.63 4.6 ...
## $ z : num [1:26967] 2.66 2.7 3.78 2.96 2.65 3.99 4.03 3.12 4.26 2.76 ...
## $ price : num [1:26967] 499 984 6289 1082 779 ...
## - attr(*, "spec")=
## .. cols(
## .. ...1 = col_double(),
## .. carat = col_double(),
## .. cut = col_character(),
## .. color = col_character(),
## .. clarity = col_character(),
## .. depth = col_double(),
## .. table = col_double(),
## .. x = col_double(),
## .. y = col_double(),
## .. z = col_double(),
## .. price = col_double()
## .. )
## - attr(*, "problems")=<externalptr>
summary(gem)
## ...1 carat cut color clarity
## Min. : 1 Min. :0.2000 Fair : 781 D:3344 SI1 :6571
## 1st Qu.: 6742 1st Qu.:0.4000 Good : 2441 E:4917 VS2 :6099
## Median :13484 Median :0.7000 Ideal :10816 F:4729 SI2 :4575
## Mean :13484 Mean :0.7984 Premium : 6899 G:5661 VS1 :4093
## 3rd Qu.:20226 3rd Qu.:1.0500 Very Good: 6030 H:4102 VVS2 :2531
## Max. :26967 Max. :4.5000 I:2771 VVS1 :1839
## J:1443 (Other):1259
## depth table x y
## Min. :50.80 Min. :49.00 Min. : 0.00 Min. : 0.000
## 1st Qu.:61.00 1st Qu.:56.00 1st Qu.: 4.71 1st Qu.: 4.710
## Median :61.80 Median :57.00 Median : 5.69 Median : 5.710
## Mean :61.75 Mean :57.46 Mean : 5.73 Mean : 5.734
## 3rd Qu.:62.50 3rd Qu.:59.00 3rd Qu.: 6.55 3rd Qu.: 6.540
## Max. :73.60 Max. :79.00 Max. :10.23 Max. :58.900
## NA's :697
## z price
## Min. : 0.000 Min. : 326
## 1st Qu.: 2.900 1st Qu.: 945
## Median : 3.520 Median : 2375
## Mean : 3.538 Mean : 3940
## 3rd Qu.: 4.040 3rd Qu.: 5360
## Max. :31.800 Max. :18818
##
head(gem)
## # A tibble: 6 × 11
## ...1 carat cut color clarity depth table x y z price
## <dbl> <dbl> <fct> <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 0.3 Ideal E SI1 62.1 58 4.27 4.29 2.66 499
## 2 2 0.33 Premium G IF 60.8 58 4.42 4.46 2.7 984
## 3 3 0.9 Very Good E VVS2 62.2 60 6.04 6.12 3.78 6289
## 4 4 0.42 Ideal F VS1 61.6 56 4.82 4.8 2.96 1082
## 5 5 0.31 Ideal F VVS1 60.4 59 4.35 4.43 2.65 779
## 6 6 1.02 Ideal D VS2 61.5 56 6.46 6.49 3.99 9502
str(gem)
## spc_tbl_ [26,967 × 11] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ ...1 : num [1:26967] 1 2 3 4 5 6 7 8 9 10 ...
## $ carat : num [1:26967] 0.3 0.33 0.9 0.42 0.31 1.02 1.01 0.5 1.21 0.35 ...
## $ cut : Factor w/ 5 levels "Fair","Good",..: 3 4 5 3 3 3 2 4 2 3 ...
## $ color : Factor w/ 7 levels "D","E","F","G",..: 2 4 2 3 3 1 5 2 5 3 ...
## $ clarity: Factor w/ 8 levels "I1","IF","SI1",..: 3 2 8 5 7 6 3 3 3 6 ...
## $ depth : num [1:26967] 62.1 60.8 62.2 61.6 60.4 61.5 63.7 61.5 63.8 60.5 ...
## $ table : num [1:26967] 58 58 60 56 59 56 60 62 64 57 ...
## $ x : num [1:26967] 4.27 4.42 6.04 4.82 4.35 6.46 6.35 5.09 6.72 4.52 ...
## $ y : num [1:26967] 4.29 4.46 6.12 4.8 4.43 6.49 6.3 5.06 6.63 4.6 ...
## $ z : num [1:26967] 2.66 2.7 3.78 2.96 2.65 3.99 4.03 3.12 4.26 2.76 ...
## $ price : num [1:26967] 499 984 6289 1082 779 ...
## - attr(*, "spec")=
## .. cols(
## .. ...1 = col_double(),
## .. carat = col_double(),
## .. cut = col_character(),
## .. color = col_character(),
## .. clarity = col_character(),
## .. depth = col_double(),
## .. table = col_double(),
## .. x = col_double(),
## .. y = col_double(),
## .. z = col_double(),
## .. price = col_double()
## .. )
## - attr(*, "problems")=<externalptr>
class(gem$clarity)
## [1] "factor"
#write.csv(x = gem,file = "datas.csv")
#datas<- read_csv("C:/Users/USER/Desktop/datas.csv")
datas <- read_csv("C:/Users/USER/Desktop/datas.csv")
## New names:
## Rows: 26967 Columns: 12
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (3): cut, color, clarity dbl (9): ...1, ...2, carat, depth, table, x, y, z,
## price
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
## • `...1` -> `...2`
str(datas)
## spc_tbl_ [26,967 × 12] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ ...1 : num [1:26967] 1 2 3 4 5 6 7 8 9 10 ...
## $ ...2 : num [1:26967] 1 2 3 4 5 6 7 8 9 10 ...
## $ carat : num [1:26967] 0.3 0.33 0.9 0.42 0.31 1.02 1.01 0.5 1.21 0.35 ...
## $ cut : chr [1:26967] "Ideal" "Premium" "Very Good" "Ideal" ...
## $ color : chr [1:26967] "E" "G" "E" "F" ...
## $ clarity: chr [1:26967] "SI1" "IF" "VVS2" "VS1" ...
## $ depth : num [1:26967] 62.1 60.8 62.2 61.6 60.4 61.5 63.7 61.5 63.8 60.5 ...
## $ table : num [1:26967] 58 58 60 56 59 56 60 62 64 57 ...
## $ x : num [1:26967] 4.27 4.42 6.04 4.82 4.35 6.46 6.35 5.09 6.72 4.52 ...
## $ y : num [1:26967] 4.29 4.46 6.12 4.8 4.43 6.49 6.3 5.06 6.63 4.6 ...
## $ z : num [1:26967] 2.66 2.7 3.78 2.96 2.65 3.99 4.03 3.12 4.26 2.76 ...
## $ price : num [1:26967] 499 984 6289 1082 779 ...
## - attr(*, "spec")=
## .. cols(
## .. ...1 = col_double(),
## .. ...2 = col_double(),
## .. carat = col_double(),
## .. cut = col_character(),
## .. color = col_character(),
## .. clarity = col_character(),
## .. depth = col_double(),
## .. table = col_double(),
## .. x = col_double(),
## .. y = col_double(),
## .. z = col_double(),
## .. price = col_double()
## .. )
## - attr(*, "problems")=<externalptr>
head(datas)
## # A tibble: 6 × 12
## ...1 ...2 carat cut color clarity depth table x y z price
## <dbl> <dbl> <dbl> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 1 0.3 Ideal E SI1 62.1 58 4.27 4.29 2.66 499
## 2 2 2 0.33 Premium G IF 60.8 58 4.42 4.46 2.7 984
## 3 3 3 0.9 Very Good E VVS2 62.2 60 6.04 6.12 3.78 6289
## 4 4 4 0.42 Ideal F VS1 61.6 56 4.82 4.8 2.96 1082
## 5 5 5 0.31 Ideal F VVS1 60.4 59 4.35 4.43 2.65 779
## 6 6 6 1.02 Ideal D VS2 61.5 56 6.46 6.49 3.99 9502
class(gem$clarity)
## [1] "factor"
d<-data.frame(datas$carat,datas$cut)
#write.csv(x = datas,file = "dat.csv")