library(readr)
## Warning: package 'readr' was built under R version 4.2.3
library(broom)
## Warning: package 'broom' was built under R version 4.2.3
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.2.3
## Warning: package 'ggplot2' was built under R version 4.2.3
## Warning: package 'tibble' was built under R version 4.2.3
## Warning: package 'tidyr' was built under R version 4.2.3
## Warning: package 'purrr' was built under R version 4.2.3
## Warning: package 'dplyr' was built under R version 4.2.3
## Warning: package 'forcats' was built under R version 4.2.3
## Warning: package 'lubridate' was built under R version 4.2.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.2     ✔ purrr     1.0.1
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.2     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
datos <- read_csv("C:/Users/isra9/Downloads/cyclzyx.csv")
## Rows: 38 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (2): CCND3 Cyclin D3, Zyxin
## 
## ℹ 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.
View(datos)
getwd()
## [1] "C:/Users/isra9/Desktop"

#REALIZAREMOS EL METODO DE CONGLOMERADOS CON NUESTRA BASE DE DATOS (K-MEDIAS)

cluster=kmeans(datos,2)
broom::tidy(cluster)
## # A tibble: 2 × 5
##   `CCND3 Cyclin D3`  Zyxin  size withinss cluster
##               <dbl>  <dbl> <int>    <dbl> <fct>  
## 1             0.636  1.59     11     4.73 1      
## 2             1.89  -0.295    27    19.8  2

#centroides y numero de observaciones

En la tabla anterior nos muestra los centroides 1 y 2

el 1er centroide(0.6355,1.5866) de nuestro primer cluster contiene 11 observaciones

el 2do centroide(1.8938 -0.2947) de nuestro segundo cluster contiene 27 observaciones

broom::augment(cluster,datos)
## # A tibble: 38 × 3
##    `CCND3 Cyclin D3`  Zyxin .cluster
##                <dbl>  <dbl> <fct>   
##  1              2.11 -0.450 2       
##  2              1.52 -0.401 2       
##  3              1.96 -0.470 2       
##  4              2.34  0.409 2       
##  5              1.85  0.393 2       
##  6              1.99 -0.378 2       
##  7              2.07 -1.37  2       
##  8              1.82 -1.37  2       
##  9              2.18 -1.48  2       
## 10              1.81  0.250 2       
## # ℹ 28 more rows

En la tabla anterior podemos visualizar los individuos junto al cluster perteneciente y asi mismo sus cordenadas

broom::glance(cluster)
## # A tibble: 1 × 4
##   totss tot.withinss betweenss  iter
##   <dbl>        <dbl>     <dbl> <int>
## 1  64.6         24.6      40.0     1
broom::augment(cluster,datos)|>filter(.cluster==2)|> select("CCND3 Cyclin D3")|>unlist()|>boxplot()

broom::augment(cluster,datos) |> filter((.cluster == 1)) |> 
  select('CCND3 Cyclin D3') |> boxplot()

broom::augment(cluster,datos) |> filter((.cluster == 2)) |> 
  select('Zyxin') |> boxplot()

broom::augment(cluster,datos) |> filter((.cluster == 1)) |> 
  select('Zyxin') |> boxplot()

a <- broom::augment(cluster,datos) 
plot(a$`CCND3 Cyclin D3`,a$Zyxin,col = a$.cluster)

Sacamos el grafico de individuos de cada cluster