Establecer un espejo de CRAN

options(repos = c(CRAN = “https://cloud.r-project.org/”))

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

Cargar Librerías y Datos

## Installing packages into 'C:/Users/narci/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'readxl' successfully unpacked and MD5 sums checked
## package 'dplyr' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'dplyr'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problema al copiar
## C:\Users\narci\AppData\Local\R\win-library\4.3\00LOCK\dplyr\libs\x64\dplyr.dll
## a C:\Users\narci\AppData\Local\R\win-library\4.3\dplyr\libs\x64\dplyr.dll:
## Permission denied
## Warning: restored 'dplyr'
## package 'ggplot2' successfully unpacked and MD5 sums checked
## package 'corrplot' successfully unpacked and MD5 sums checked
## package 'ggcorrplot' successfully unpacked and MD5 sums checked
## package 'ggfortify' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\narci\AppData\Local\Temp\Rtmpc3ipOw\downloaded_packages
## Warning: package 'readxl' was built under R version 4.3.3
## Warning: package 'dplyr' was built under R version 4.3.3
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
## Warning: package 'corrplot' was built under R version 4.3.3
## corrplot 0.95 loaded
## Warning: package 'ggplot2' was built under R version 4.3.3
## Warning: package 'ggcorrplot' was built under R version 4.3.3
## Warning: package 'ggfortify' was built under R version 4.3.3

Cargar Librerías y Datos

## Warning: packages 'readxl', 'dplyr', 'ggplot2', 'corrplot', 'ggcorrplot',
## 'ggfortify' are in use and will not be installed

Visualizar Datos

##  [1] "Muestra"                   "Catalasa"                 
##  [3] "Tincion de Gram"           "UFC"                      
##  [5] "Penicillium terlikowskii"  "Penicillium oxalicum"     
##  [7] "Trichoderma spp"           "Penicillium atramentosum" 
##  [9] "Penicillium claviforme"    "Penicillium sp2"          
## [11] "Penicillium spinulosum"    "Penicillium biforme"      
## [13] "Aspergillus fumigatus"     "Fusarium sp"              
## [15] "Aspergillus terricola"     "Penicillium piscarium"    
## [17] "Penicillium sotoloniferum" "P"                        
## [19] "K"                         "Ca"                       
## [21] "Mg"                        "Al"                       
## [23] "S"                         "Cu"                       
## [25] "Fe"                        "Zn"                       
## [27] "Mn"                        "MO%"                      
## [29] "pH"                        "Arena %"                  
## [31] "Limo %"                    "Arcilla %"                
## [33] "CE  ds/m"                  "Humedad"                  
## [35] "Estructura"

Calcular y Visualizar la Matriz de Correlación

Gráfico de Dispersión: pH vs Humedad

Mapa de Calor de Correlaciones

Análisis de Regresión

## 
## Call:
## lm(formula = Humedad ~ pH + K + Ca, data = data_subset)
## 
## Residuals:
##       1       2       3       4       5       6       7       8       9 
##  0.8274  0.1557 -0.8139  1.5047 -0.7759  0.6239 -0.6542 -1.6626  0.7949 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 70.0997754 10.2062765   6.868 0.001000 ** 
## pH          -6.5889109  0.8657664  -7.610 0.000622 ***
## K            0.0001438  0.0896115   0.002 0.998781    
## Ca          -1.2067728  0.2345446  -5.145 0.003630 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.3 on 5 degrees of freedom
## Multiple R-squared:  0.925,  Adjusted R-squared:   0.88 
## F-statistic: 20.56 on 3 and 5 DF,  p-value: 0.003051

ANOVA

##             Df Sum Sq Mean Sq
## Muestra      8  3.672   0.459

Análisis de Componentes Principales (PCA)

## Importance of components:
##                           PC1    PC2    PC3     PC4     PC5     PC6     PC7
## Standard deviation     2.2293 1.8936 1.7289 1.23087 1.20339 0.92317 0.65464
## Proportion of Variance 0.3106 0.2241 0.1868 0.09469 0.09051 0.05326 0.02678
## Cumulative Proportion  0.3106 0.5347 0.7215 0.81622 0.90673 0.95999 0.98678
##                            PC8       PC9
## Standard deviation     0.45997 1.315e-15
## Proportion of Variance 0.01322 0.000e+00
## Cumulative Proportion  1.00000 1.000e+00