setwd("G:/Mi unidad/Agrosavia/SOCODEVI/Informe final")
library(Plasticity)
library(agricolae)
## Warning: package 'agricolae' was built under R version 4.4.3
library(Rmisc)
## Cargando paquete requerido: lattice
## Cargando paquete requerido: plyr
library(dplyr)
## 
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:plyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(psych)
## Warning: package 'psych' was built under R version 4.4.3
## 
## Adjuntando el paquete: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
library(FSA)
## Warning: package 'FSA' was built under R version 4.4.3
## ## FSA v0.9.6. See citation('FSA') if used in publication.
## ## Run fishR() for related website and fishR('IFAR') for related book.
## 
## Adjuntando el paquete: 'FSA'
## The following object is masked from 'package:psych':
## 
##     headtail
## The following object is masked from 'package:plyr':
## 
##     mapvalues
library(forcats)
library(Hmisc)
## Warning: package 'Hmisc' was built under R version 4.4.3
## 
## Adjuntando el paquete: 'Hmisc'
## The following object is masked from 'package:psych':
## 
##     describe
## The following objects are masked from 'package:dplyr':
## 
##     src, summarize
## The following objects are masked from 'package:plyr':
## 
##     is.discrete, summarize
## The following objects are masked from 'package:base':
## 
##     format.pval, units
library("PerformanceAnalytics")
## Warning: package 'PerformanceAnalytics' was built under R version 4.4.3
## Cargando paquete requerido: xts
## Warning: package 'xts' was built under R version 4.4.3
## Cargando paquete requerido: zoo
## Warning: package 'zoo' was built under R version 4.4.3
## 
## Adjuntando el paquete: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## ######################### Warning from 'xts' package ##########################
## #                                                                             #
## # The dplyr lag() function breaks how base R's lag() function is supposed to  #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or       #
## # source() into this session won't work correctly.                            #
## #                                                                             #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop           #
## # dplyr from breaking base R's lag() function.                                #
## #                                                                             #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning.  #
## #                                                                             #
## ###############################################################################
## 
## Adjuntando el paquete: 'xts'
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## Adjuntando el paquete: 'PerformanceAnalytics'
## The following objects are masked from 'package:agricolae':
## 
##     kurtosis, skewness
## The following object is masked from 'package:graphics':
## 
##     legend
library(onewaytests)
## Warning: package 'onewaytests' was built under R version 4.4.3
## Registered S3 methods overwritten by 'car':
##   method       from
##   hist.boot    FSA 
##   confint.boot FSA
## 
## Adjuntando el paquete: 'onewaytests'
## The following object is masked from 'package:Hmisc':
## 
##     describe
## The following object is masked from 'package:psych':
## 
##     describe
library(emmeans)
## Welcome to emmeans.
## Caution: You lose important information if you filter this package's results.
## See '? untidy'
library(ggthemes)
## Warning: package 'ggthemes' was built under R version 4.4.3
library(multcompView)
## Warning: package 'multcompView' was built under R version 4.4.3
library(RColorBrewer)
library(correlation)
## Warning: package 'correlation' was built under R version 4.4.3
## 
## Adjuntando el paquete: 'correlation'
## The following object is masked from 'package:agricolae':
## 
##     correlation
library(tibble)
library(fmsb)
## Warning: package 'fmsb' was built under R version 4.4.3
##Reading data
clones <- read.table("senso.csv", header=T, sep=";")
# Assigning some variables to factors
clones$Vereda<-as.factor(clones$Vereda)
##Gráficos radar
# Seleccionando Curva 1
attach(clones)
#plot T3
radar6<-group_by(clones, Vereda) %>%
  summarise_at(vars(Amargo:Especiado), median, na.rm = TRUE) %>%
  column_to_rownames(var = "Vereda") %>% head()
radar6 <-rbind(rep(7,12) , rep(0,12) , radar6)
radar6
##             Amargo Astringente Ácido Cacao Frutal Vegetal Floral Dulce
## 1              7.0        7.00  7.00  7.00   7.00    7.00   7.00  7.00
## 2              0.0        0.00  0.00  0.00   0.00    0.00   0.00  0.00
## Caño Baul      4.0        3.00  3.75  4.00   2.75    2.00   1.00  1.75
## Mataredonda    3.5        3.25  3.50  4.00   2.25    1.50   0.50  1.50
## Mira Valle     4.0        3.75  3.75  2.75   1.25    1.25   0.25  1.00
##             Frutos.secos Lácteo Madera Especiado
## 1                   7.00      7    7.0      7.00
## 2                   0.00      0    0.0      0.00
## Caño Baul           1.25      0    1.0      0.00
## Mataredonda         1.50      1    0.5      0.25
## Mira Valle          1.25      0    0.0      0.00
# Color vector
colors_border=c( rgb(1,0,0.2,0.9), rgb(0.2,0.8,0.2,0.9) , rgb(0,0.2,1,0.9) )
colors_in=c( rgb(1,0,0.2,0.4), rgb(0.2,0.8,0.2,0.4) , rgb(0,0.2,1,0.4) )


radarchart(radar6, axistype=1, seg = 10, title = "Perfil de sabor",
            #custom polygon
            pcol=colors_border , pfcol=colors_in , plwd=4 , plty=1,
            #custom the grid
            cglcol="grey", cglty=1, axislabcol="grey", caxislabels=seq(0,10,1), calcex=0.8, cglwd=0.8,
            #custom labels
            vlcex=0.8, )

legend(x=1.475, y=1, legend = rownames(radar6[-c(1,2),]), bty = "n", pch=20 , col=colors_in , cex=0.8, pt.cex=1)