Definimos la semilla inicial
#Definimos la semilla
set.seed(2022)
RStudio 1.1: Genere una muestra de tamãno 120 de la distribucíon normal con media 5, desviacíon estándar 0.85. Use solo dos ńumeros decimales (rnorm())
Biomasa = c(round(rnorm(120,5,0.85),2)); head(Biomasa)
## [1] 5.77 4.00 4.24 3.77 4.72 2.53
RStudio 1.2: Genere una muestra de tamaño 120 de la distribucíon binomial con parámetros 0.8 (probabilidad) y 20 (ensayos independientes) (rbinom())
Flores.r = c(round(rbinom(120,size = 20,prob = 0.8),2)); head(Flores.r)
## [1] 17 16 15 18 18 18
RStudio 1.3: Genere una muestra de tamaño 120 de la distribucíon Poisson con parámetro 10.5 (media) (rpois())
Flores.d = c(round(rpois(120,n = 10.5),2)); head(Flores.d)
## [1] 146 117 114 123 121 131
RStudio 1.4: Genere una muestra con reemplazo de tamaño 120 de una secuencia de 300 ńumeros (sample.int())
Hojas.d = sample.int(n=300,size = 120,replace = T)
RStudio 1.5: Usando la librería “purrr” genere una muestra de la distribucíon de Bernoulli de tamaño 120 y parámetro 0.75 (probabilidad) (rbernoulli()) y cambie el FALSE (ausente) y el TRUE por (presente).
library(purrr)
dist = rbernoulli(n = 120,p = 0.75)
Plaga = ifelse(dist == FALSE, "ausente", "presente"); head(Plaga)
## [1] "presente" "presente" "presente" "presente" "presente" "presente"
RStudio 1.6: Genere tres niveles de un factor, cada uno con 40 datos y etiquételos con (S) para identificar la planta (sana), (PA) para las plantas parcialmente afectadas y (MA) para las muy afectadas. Use la función (gl()).
Estatus = gl(3,40,120,labels = c("S","PA","MA")); head(Estatus)
## [1] S S S S S S
## Levels: S PA MA
RStudio 1.7: Genere dos niveles de un factor usando la distribucíon uniforme con parámetros 0 y 1.2, ponga para cada datos a generar de los 120 la condición de si el número generado es menor a 0.5, los etiquetamos como (FO) para asociarlo a fertilización orgánica, de lo contrario, use (FI) para asociarlo a fertilización inorgánica. Use la función (runif()). Si lo desea use la función (ifelse()) o (if else()) para condicionar.
fact_fert = runif(120,0,1.20)
cat_fert = ifelse(fact_fert<0.5,"FO","FI")
fertilizacion = data.frame(fact_fert, cat_fert); head(fertilizacion)
## fact_fert cat_fert
## 1 0.3590462 FO
## 2 0.5290298 FI
## 3 0.1874474 FO
## 4 0.9175104 FI
## 5 0.4567908 FO
## 6 0.4477445 FO
RStudio 1.8: Construya un marco de datos (data.frame()) o una tableta (tibble()) con todas la variables antes generadas y asigne repectivamente los nombres de variable: Biomasa(gramos), Flores.r (conteo de flores en tres ramas), Flores.d (conteo de flores desprendidas), Hojas.d (conteo de hojas desprendidas), Plaga , Estatus y Fertlización.Revise del objeto creado, su dimensión (dim()), su estructura con (str()) o (glimpse()), la clase (class()), los nombres en las variables (names()), la presencia de faltantes (is.na())
df_datos = data.frame("Biomasa(gramos)"=Biomasa, "Flores.r"=Flores.r, "Flores.d"=Flores.d, "Hojas.d "=Hojas.d, "Plaga"=Plaga, "Estatus"=Estatus, "Fertilizacion"=fertilizacion); head(df_datos)
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## 1 5.77 17 146 287 presente S
## 2 4.00 16 117 182 presente S
## 3 4.24 15 114 174 presente S
## 4 3.77 18 123 78 presente S
## 5 4.72 18 121 229 presente S
## 6 2.53 18 131 205 presente S
## Fertilizacion.fact_fert Fertilizacion.cat_fert
## 1 0.3590462 FO
## 2 0.5290298 FI
## 3 0.1874474 FO
## 4 0.9175104 FI
## 5 0.4567908 FO
## 6 0.4477445 FO
Dimensión
#dimension
dim(df_datos)
## [1] 120 8
Estructura de los datos
#Estructura
str(df_datos)
## 'data.frame': 120 obs. of 8 variables:
## $ Biomasa.gramos. : num 5.77 4 4.24 3.77 4.72 2.53 4.1 5.24 5.64 5.21 ...
## $ Flores.r : num 17 16 15 18 18 18 17 17 14 16 ...
## $ Flores.d : num 146 117 114 123 121 131 115 126 135 113 ...
## $ Hojas.d. : int 287 182 174 78 229 205 112 260 66 191 ...
## $ Plaga : chr "presente" "presente" "presente" "presente" ...
## $ Estatus : Factor w/ 3 levels "S","PA","MA": 1 1 1 1 1 1 1 1 1 1 ...
## $ Fertilizacion.fact_fert: num 0.359 0.529 0.187 0.918 0.457 ...
## $ Fertilizacion.cat_fert : chr "FO" "FI" "FO" "FI" ...
Clases
#Clases
class(df_datos)
## [1] "data.frame"
Nombre de las clases
#Nombre de las clases
names(df_datos)
## [1] "Biomasa.gramos." "Flores.r"
## [3] "Flores.d" "Hojas.d."
## [5] "Plaga" "Estatus"
## [7] "Fertilizacion.fact_fert" "Fertilizacion.cat_fert"
Presencia de datos faltantes
#Presencia de faltantes
head(is.na(df_datos))
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## [1,] FALSE FALSE FALSE FALSE FALSE FALSE
## [2,] FALSE FALSE FALSE FALSE FALSE FALSE
## [3,] FALSE FALSE FALSE FALSE FALSE FALSE
## [4,] FALSE FALSE FALSE FALSE FALSE FALSE
## [5,] FALSE FALSE FALSE FALSE FALSE FALSE
## [6,] FALSE FALSE FALSE FALSE FALSE FALSE
## Fertilizacion.fact_fert Fertilizacion.cat_fert
## [1,] FALSE FALSE
## [2,] FALSE FALSE
## [3,] FALSE FALSE
## [4,] FALSE FALSE
## [5,] FALSE FALSE
## [6,] FALSE FALSE
RStudio 1.9: Usando la información del punto anterior, Seleccione un subconjunto (el 75 % de las filas de todas las columnas) de todo el marco de datos o tableta. Use la función (samplen()) y asigne un valor faltante NA a dos variables cuantitativas cualesquiera del conjunto de datos muestreado. LLame tib.c al data.frame completo y tic.i al pequeño. Con estos dos data.frames resuelva los puntos que se presentas en los ejercicios posteriores.
library(dplyr)
##
## 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
tib.c = df_datos
tib.i = sample_n(tib.c ,size = round(length(tib.c$Hojas.d.)*0.75),replace = T)
#creamos una lista con elementos del tib.i que queremos reemplazar
reempl_hojas <- c(sample(tib.i$Hojas.d., 5, replace=F))
reempl_biom <- c(sample(tib.i$Biomasa.gramos., 5, replace=F))
#reemplazamos los valores aleatorios por NA
for (i in reempl_hojas) {
tib.i$Hojas.d.= ifelse(tib.i$Hojas.d.== i, NA, tib.i$Hojas.d.)
}
for (i in reempl_biom) {
tib.i$Biomasa.gramos.= ifelse(tib.i$Biomasa.gramos.== i, NA, tib.i$Biomasa.gramos.)
}
table(is.na(tib.i))
##
## FALSE TRUE
## 702 18
table(is.na(tib.c))
##
## FALSE
## 960
dim(tib.c)
## [1] 120 8
head(tib.c)
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## 1 5.77 17 146 287 presente S
## 2 4.00 16 117 182 presente S
## 3 4.24 15 114 174 presente S
## 4 3.77 18 123 78 presente S
## 5 4.72 18 121 229 presente S
## 6 2.53 18 131 205 presente S
## Fertilizacion.fact_fert Fertilizacion.cat_fert
## 1 0.3590462 FO
## 2 0.5290298 FI
## 3 0.1874474 FO
## 4 0.9175104 FI
## 5 0.4567908 FO
## 6 0.4477445 FO
dim(tib.i)
## [1] 90 8
head(tib.i)
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## 1 5.40 13 113 12 ausente MA
## 2 5.55 19 115 41 presente S
## 3 5.31 14 146 35 presente S
## 4 NA 16 114 143 presente MA
## 5 5.31 14 146 35 presente S
## 6 4.80 18 113 123 presente S
## Fertilizacion.fact_fert Fertilizacion.cat_fert
## 1 0.5578087 FI
## 2 0.5769830 FI
## 3 0.7096141 FI
## 4 1.1487266 FI
## 5 0.7096141 FI
## 6 0.5715544 FI
RStudio 1.10: 1. Seleccione una variable cualquiera con (select()) para tib.c
library(dplyr)
var_aux <- dplyr::select(tib.c, Biomasa.gramos.)
head(var_aux)
## Biomasa.gramos.
## 1 5.77
## 2 4.00
## 3 4.24
## 4 3.77
## 5 4.72
## 6 2.53
dplyr::select(tib.c,c(3:6))
## Flores.d Hojas.d. Plaga Estatus
## 1 146 287 presente S
## 2 117 182 presente S
## 3 114 174 presente S
## 4 123 78 presente S
## 5 121 229 presente S
## 6 131 205 presente S
## 7 115 112 ausente S
## 8 126 260 ausente S
## 9 135 66 presente S
## 10 113 191 ausente S
## 11 146 104 ausente S
## 12 117 61 presente S
## 13 114 257 presente S
## 14 123 81 ausente S
## 15 121 195 ausente S
## 16 131 66 presente S
## 17 115 245 ausente S
## 18 126 272 ausente S
## 19 135 242 presente S
## 20 113 216 presente S
## 21 146 35 presente S
## 22 117 55 presente S
## 23 114 146 presente S
## 24 123 107 presente S
## 25 121 85 presente S
## 26 131 169 ausente S
## 27 115 41 presente S
## 28 126 239 presente S
## 29 135 234 presente S
## 30 113 123 presente S
## 31 146 86 ausente S
## 32 117 40 presente S
## 33 114 73 ausente S
## 34 123 223 presente S
## 35 121 251 presente S
## 36 131 275 presente S
## 37 115 56 presente S
## 38 126 94 ausente S
## 39 135 229 ausente S
## 40 113 161 presente S
## 41 146 207 presente PA
## 42 117 147 presente PA
## 43 114 7 presente PA
## 44 123 251 presente PA
## 45 121 115 presente PA
## 46 131 6 presente PA
## 47 115 300 presente PA
## 48 126 41 presente PA
## 49 135 53 ausente PA
## 50 113 35 presente PA
## 51 146 276 ausente PA
## 52 117 138 presente PA
## 53 114 94 presente PA
## 54 123 223 presente PA
## 55 121 260 presente PA
## 56 131 210 ausente PA
## 57 115 8 presente PA
## 58 126 49 presente PA
## 59 135 182 presente PA
## 60 113 279 presente PA
## 61 146 157 presente PA
## 62 117 289 ausente PA
## 63 114 83 presente PA
## 64 123 65 presente PA
## 65 121 56 presente PA
## 66 131 74 ausente PA
## 67 115 24 presente PA
## 68 126 58 ausente PA
## 69 135 278 presente PA
## 70 113 265 presente PA
## 71 146 147 presente PA
## 72 117 247 presente PA
## 73 114 230 presente PA
## 74 123 169 presente PA
## 75 121 145 ausente PA
## 76 131 154 presente PA
## 77 115 298 presente PA
## 78 126 42 presente PA
## 79 135 205 presente PA
## 80 113 89 presente PA
## 81 146 29 ausente MA
## 82 117 201 ausente MA
## 83 114 189 presente MA
## 84 123 130 presente MA
## 85 121 36 ausente MA
## 86 131 124 ausente MA
## 87 115 33 presente MA
## 88 126 226 presente MA
## 89 135 194 presente MA
## 90 113 257 presente MA
## 91 146 196 presente MA
## 92 117 234 presente MA
## 93 114 273 presente MA
## 94 123 142 presente MA
## 95 121 133 presente MA
## 96 131 246 presente MA
## 97 115 262 presente MA
## 98 126 239 presente MA
## 99 135 294 presente MA
## 100 113 12 ausente MA
## 101 146 103 presente MA
## 102 117 63 ausente MA
## 103 114 143 presente MA
## 104 123 19 presente MA
## 105 121 63 presente MA
## 106 131 271 presente MA
## 107 115 269 ausente MA
## 108 126 275 presente MA
## 109 135 176 ausente MA
## 110 113 84 ausente MA
## 111 146 193 presente MA
## 112 117 96 presente MA
## 113 114 240 ausente MA
## 114 123 252 ausente MA
## 115 121 138 presente MA
## 116 131 38 presente MA
## 117 115 267 ausente MA
## 118 126 187 ausente MA
## 119 135 158 presente MA
## 120 113 266 presente MA
dplyr::select(tib.c,c(3:6))
## Flores.d Hojas.d. Plaga Estatus
## 1 146 287 presente S
## 2 117 182 presente S
## 3 114 174 presente S
## 4 123 78 presente S
## 5 121 229 presente S
## 6 131 205 presente S
## 7 115 112 ausente S
## 8 126 260 ausente S
## 9 135 66 presente S
## 10 113 191 ausente S
## 11 146 104 ausente S
## 12 117 61 presente S
## 13 114 257 presente S
## 14 123 81 ausente S
## 15 121 195 ausente S
## 16 131 66 presente S
## 17 115 245 ausente S
## 18 126 272 ausente S
## 19 135 242 presente S
## 20 113 216 presente S
## 21 146 35 presente S
## 22 117 55 presente S
## 23 114 146 presente S
## 24 123 107 presente S
## 25 121 85 presente S
## 26 131 169 ausente S
## 27 115 41 presente S
## 28 126 239 presente S
## 29 135 234 presente S
## 30 113 123 presente S
## 31 146 86 ausente S
## 32 117 40 presente S
## 33 114 73 ausente S
## 34 123 223 presente S
## 35 121 251 presente S
## 36 131 275 presente S
## 37 115 56 presente S
## 38 126 94 ausente S
## 39 135 229 ausente S
## 40 113 161 presente S
## 41 146 207 presente PA
## 42 117 147 presente PA
## 43 114 7 presente PA
## 44 123 251 presente PA
## 45 121 115 presente PA
## 46 131 6 presente PA
## 47 115 300 presente PA
## 48 126 41 presente PA
## 49 135 53 ausente PA
## 50 113 35 presente PA
## 51 146 276 ausente PA
## 52 117 138 presente PA
## 53 114 94 presente PA
## 54 123 223 presente PA
## 55 121 260 presente PA
## 56 131 210 ausente PA
## 57 115 8 presente PA
## 58 126 49 presente PA
## 59 135 182 presente PA
## 60 113 279 presente PA
## 61 146 157 presente PA
## 62 117 289 ausente PA
## 63 114 83 presente PA
## 64 123 65 presente PA
## 65 121 56 presente PA
## 66 131 74 ausente PA
## 67 115 24 presente PA
## 68 126 58 ausente PA
## 69 135 278 presente PA
## 70 113 265 presente PA
## 71 146 147 presente PA
## 72 117 247 presente PA
## 73 114 230 presente PA
## 74 123 169 presente PA
## 75 121 145 ausente PA
## 76 131 154 presente PA
## 77 115 298 presente PA
## 78 126 42 presente PA
## 79 135 205 presente PA
## 80 113 89 presente PA
## 81 146 29 ausente MA
## 82 117 201 ausente MA
## 83 114 189 presente MA
## 84 123 130 presente MA
## 85 121 36 ausente MA
## 86 131 124 ausente MA
## 87 115 33 presente MA
## 88 126 226 presente MA
## 89 135 194 presente MA
## 90 113 257 presente MA
## 91 146 196 presente MA
## 92 117 234 presente MA
## 93 114 273 presente MA
## 94 123 142 presente MA
## 95 121 133 presente MA
## 96 131 246 presente MA
## 97 115 262 presente MA
## 98 126 239 presente MA
## 99 135 294 presente MA
## 100 113 12 ausente MA
## 101 146 103 presente MA
## 102 117 63 ausente MA
## 103 114 143 presente MA
## 104 123 19 presente MA
## 105 121 63 presente MA
## 106 131 271 presente MA
## 107 115 269 ausente MA
## 108 126 275 presente MA
## 109 135 176 ausente MA
## 110 113 84 ausente MA
## 111 146 193 presente MA
## 112 117 96 presente MA
## 113 114 240 ausente MA
## 114 123 252 ausente MA
## 115 121 138 presente MA
## 116 131 38 presente MA
## 117 115 267 ausente MA
## 118 126 187 ausente MA
## 119 135 158 presente MA
## 120 113 266 presente MA
dplyr::select(tib.c,!ends_with(".d"))
## Biomasa.gramos. Flores.r Hojas.d. Plaga Estatus Fertilizacion.fact_fert
## 1 5.77 17 287 presente S 0.35904619
## 2 4.00 16 182 presente S 0.52902980
## 3 4.24 15 174 presente S 0.18744741
## 4 3.77 18 78 presente S 0.91751036
## 5 4.72 18 229 presente S 0.45679084
## 6 2.53 18 205 presente S 0.44774445
## 7 4.10 17 112 ausente S 0.19249755
## 8 5.24 17 260 ausente S 0.66999365
## 9 5.64 14 66 presente S 0.86001348
## 10 5.21 16 191 ausente S 0.03503845
## 11 5.86 17 104 ausente S 0.85554073
## 12 4.84 17 61 presente S 1.14914838
## 13 4.17 19 257 presente S 0.33609514
## 14 5.08 17 81 ausente S 0.86662550
## 15 4.96 14 195 ausente S 1.01547069
## 16 4.93 16 66 presente S 0.98936010
## 17 4.44 19 245 ausente S 0.44836130
## 18 4.19 15 272 ausente S 1.14439284
## 19 5.87 12 242 presente S 0.58129234
## 20 5.73 18 216 presente S 1.04645425
## 21 5.31 14 35 presente S 0.70961414
## 22 5.33 15 55 presente S 0.32508769
## 23 5.95 16 146 presente S 1.09348951
## 24 6.03 15 107 presente S 0.08609217
## 25 4.70 16 85 presente S 1.08911700
## 26 4.27 15 169 ausente S 0.39585461
## 27 5.55 19 41 presente S 0.57698299
## 28 5.28 18 239 presente S 1.18899615
## 29 4.56 19 234 presente S 0.33021889
## 30 4.80 18 123 presente S 0.57155435
## 31 5.10 17 86 ausente S 0.87398277
## 32 5.71 14 40 presente S 0.44143101
## 33 3.67 15 73 ausente S 0.95272219
## 34 4.81 16 223 presente S 0.81715715
## 35 4.31 14 251 presente S 0.50144033
## 36 5.92 18 275 presente S 0.85456195
## 37 5.92 18 56 presente S 0.11900541
## 38 5.12 18 94 ausente S 1.03665150
## 39 5.13 16 229 ausente S 0.78889276
## 40 4.86 17 161 presente S 0.77367106
## 41 4.77 13 207 presente PA 0.86106750
## 42 5.69 16 147 presente PA 0.90374726
## 43 4.04 16 7 presente PA 0.30562767
## 44 3.78 14 251 presente PA 0.41377359
## 45 5.05 13 115 presente PA 0.17747251
## 46 4.33 15 6 presente PA 0.15068317
## 47 5.29 14 300 presente PA 0.75672722
## 48 4.78 17 41 presente PA 0.22674625
## 49 3.89 16 53 ausente PA 0.27900894
## 50 5.31 11 35 presente PA 0.49759043
## 51 6.44 15 276 ausente PA 0.55413997
## 52 5.85 16 138 presente PA 0.38040856
## 53 5.16 15 94 presente PA 1.14414601
## 54 6.05 18 223 presente PA 0.02445485
## 55 5.26 18 260 presente PA 0.46483691
## 56 5.54 16 210 ausente PA 1.03836835
## 57 5.02 19 8 presente PA 0.99906717
## 58 6.00 17 49 presente PA 1.04850211
## 59 4.61 14 182 presente PA 0.28233844
## 60 5.35 14 279 presente PA 0.96493334
## 61 3.86 16 157 presente PA 0.70968232
## 62 3.90 15 289 ausente PA 0.56767841
## 63 4.74 18 83 presente PA 1.15802219
## 64 5.13 16 65 presente PA 0.94741459
## 65 4.29 18 56 presente PA 0.32517873
## 66 4.98 16 74 ausente PA 1.04581145
## 67 4.03 18 24 presente PA 0.20708207
## 68 5.91 17 58 ausente PA 0.68740187
## 69 6.97 15 278 presente PA 0.84953091
## 70 5.36 16 265 presente PA 0.17878690
## 71 4.88 17 147 presente PA 0.75417331
## 72 6.13 15 247 presente PA 0.82676865
## 73 5.37 18 230 presente PA 0.41635158
## 74 5.06 17 169 presente PA 0.51416950
## 75 6.11 18 145 ausente PA 0.18600712
## 76 4.82 16 154 presente PA 0.66184763
## 77 5.87 18 298 presente PA 0.31854228
## 78 6.16 15 42 presente PA 0.27349235
## 79 6.26 19 205 presente PA 0.93958938
## 80 5.75 19 89 presente PA 1.15777389
## 81 4.14 17 29 ausente MA 1.19576117
## 82 6.59 16 201 ausente MA 0.48023071
## 83 5.91 19 189 presente MA 1.16262545
## 84 4.09 17 130 presente MA 0.17946849
## 85 3.13 17 36 ausente MA 1.05681400
## 86 5.45 17 124 ausente MA 0.78774832
## 87 6.14 18 33 presente MA 0.51768801
## 88 6.18 16 226 presente MA 0.65322185
## 89 7.33 19 194 presente MA 0.02887014
## 90 4.96 15 257 presente MA 0.19727674
## 91 5.63 14 196 presente MA 0.48572619
## 92 5.22 18 234 presente MA 1.19738474
## 93 5.36 19 273 presente MA 0.17761635
## 94 4.69 13 142 presente MA 0.54167510
## 95 7.45 13 133 presente MA 0.95449317
## 96 4.48 15 246 presente MA 0.84414681
## 97 3.40 18 262 presente MA 0.01889923
## 98 5.61 15 239 presente MA 0.01066292
## 99 5.21 17 294 presente MA 0.73035457
## 100 5.40 13 12 ausente MA 0.55780872
## 101 4.81 18 103 presente MA 1.02847258
## 102 3.96 12 63 ausente MA 0.46969139
## 103 4.36 16 143 presente MA 1.14872662
## 104 5.16 17 19 presente MA 0.65015030
## 105 5.89 17 63 presente MA 0.74147758
## 106 5.93 18 271 presente MA 1.02641572
## 107 5.59 18 269 ausente MA 1.03704666
## 108 4.55 15 275 presente MA 0.33987652
## 109 5.22 18 176 ausente MA 0.83590800
## 110 6.06 13 84 ausente MA 0.45090745
## 111 5.55 16 193 presente MA 0.82528666
## 112 4.15 18 96 presente MA 0.83141712
## 113 3.30 17 240 ausente MA 0.18785544
## 114 4.60 17 252 ausente MA 0.65457122
## 115 5.04 17 138 presente MA 0.86843633
## 116 3.83 15 38 presente MA 0.40372298
## 117 5.21 14 267 ausente MA 0.49388462
## 118 5.19 18 187 ausente MA 1.07251945
## 119 5.73 14 158 presente MA 0.12356616
## 120 4.21 18 266 presente MA 0.09060518
## Fertilizacion.cat_fert
## 1 FO
## 2 FI
## 3 FO
## 4 FI
## 5 FO
## 6 FO
## 7 FO
## 8 FI
## 9 FI
## 10 FO
## 11 FI
## 12 FI
## 13 FO
## 14 FI
## 15 FI
## 16 FI
## 17 FO
## 18 FI
## 19 FI
## 20 FI
## 21 FI
## 22 FO
## 23 FI
## 24 FO
## 25 FI
## 26 FO
## 27 FI
## 28 FI
## 29 FO
## 30 FI
## 31 FI
## 32 FO
## 33 FI
## 34 FI
## 35 FI
## 36 FI
## 37 FO
## 38 FI
## 39 FI
## 40 FI
## 41 FI
## 42 FI
## 43 FO
## 44 FO
## 45 FO
## 46 FO
## 47 FI
## 48 FO
## 49 FO
## 50 FO
## 51 FI
## 52 FO
## 53 FI
## 54 FO
## 55 FO
## 56 FI
## 57 FI
## 58 FI
## 59 FO
## 60 FI
## 61 FI
## 62 FI
## 63 FI
## 64 FI
## 65 FO
## 66 FI
## 67 FO
## 68 FI
## 69 FI
## 70 FO
## 71 FI
## 72 FI
## 73 FO
## 74 FI
## 75 FO
## 76 FI
## 77 FO
## 78 FO
## 79 FI
## 80 FI
## 81 FI
## 82 FO
## 83 FI
## 84 FO
## 85 FI
## 86 FI
## 87 FI
## 88 FI
## 89 FO
## 90 FO
## 91 FO
## 92 FI
## 93 FO
## 94 FI
## 95 FI
## 96 FI
## 97 FO
## 98 FO
## 99 FI
## 100 FI
## 101 FI
## 102 FO
## 103 FI
## 104 FI
## 105 FI
## 106 FI
## 107 FI
## 108 FO
## 109 FI
## 110 FO
## 111 FI
## 112 FI
## 113 FO
## 114 FI
## 115 FI
## 116 FO
## 117 FO
## 118 FI
## 119 FO
## 120 FO
dplyr::select(tib.c,starts_with("Fl"))
## Flores.r Flores.d
## 1 17 146
## 2 16 117
## 3 15 114
## 4 18 123
## 5 18 121
## 6 18 131
## 7 17 115
## 8 17 126
## 9 14 135
## 10 16 113
## 11 17 146
## 12 17 117
## 13 19 114
## 14 17 123
## 15 14 121
## 16 16 131
## 17 19 115
## 18 15 126
## 19 12 135
## 20 18 113
## 21 14 146
## 22 15 117
## 23 16 114
## 24 15 123
## 25 16 121
## 26 15 131
## 27 19 115
## 28 18 126
## 29 19 135
## 30 18 113
## 31 17 146
## 32 14 117
## 33 15 114
## 34 16 123
## 35 14 121
## 36 18 131
## 37 18 115
## 38 18 126
## 39 16 135
## 40 17 113
## 41 13 146
## 42 16 117
## 43 16 114
## 44 14 123
## 45 13 121
## 46 15 131
## 47 14 115
## 48 17 126
## 49 16 135
## 50 11 113
## 51 15 146
## 52 16 117
## 53 15 114
## 54 18 123
## 55 18 121
## 56 16 131
## 57 19 115
## 58 17 126
## 59 14 135
## 60 14 113
## 61 16 146
## 62 15 117
## 63 18 114
## 64 16 123
## 65 18 121
## 66 16 131
## 67 18 115
## 68 17 126
## 69 15 135
## 70 16 113
## 71 17 146
## 72 15 117
## 73 18 114
## 74 17 123
## 75 18 121
## 76 16 131
## 77 18 115
## 78 15 126
## 79 19 135
## 80 19 113
## 81 17 146
## 82 16 117
## 83 19 114
## 84 17 123
## 85 17 121
## 86 17 131
## 87 18 115
## 88 16 126
## 89 19 135
## 90 15 113
## 91 14 146
## 92 18 117
## 93 19 114
## 94 13 123
## 95 13 121
## 96 15 131
## 97 18 115
## 98 15 126
## 99 17 135
## 100 13 113
## 101 18 146
## 102 12 117
## 103 16 114
## 104 17 123
## 105 17 121
## 106 18 131
## 107 18 115
## 108 15 126
## 109 18 135
## 110 13 113
## 111 16 146
## 112 18 117
## 113 17 114
## 114 17 123
## 115 17 121
## 116 15 131
## 117 14 115
## 118 18 126
## 119 14 135
## 120 18 113
dplyr::select(tib.c,starts_with("Fl")&ends_with(".d"))
## Flores.d
## 1 146
## 2 117
## 3 114
## 4 123
## 5 121
## 6 131
## 7 115
## 8 126
## 9 135
## 10 113
## 11 146
## 12 117
## 13 114
## 14 123
## 15 121
## 16 131
## 17 115
## 18 126
## 19 135
## 20 113
## 21 146
## 22 117
## 23 114
## 24 123
## 25 121
## 26 131
## 27 115
## 28 126
## 29 135
## 30 113
## 31 146
## 32 117
## 33 114
## 34 123
## 35 121
## 36 131
## 37 115
## 38 126
## 39 135
## 40 113
## 41 146
## 42 117
## 43 114
## 44 123
## 45 121
## 46 131
## 47 115
## 48 126
## 49 135
## 50 113
## 51 146
## 52 117
## 53 114
## 54 123
## 55 121
## 56 131
## 57 115
## 58 126
## 59 135
## 60 113
## 61 146
## 62 117
## 63 114
## 64 123
## 65 121
## 66 131
## 67 115
## 68 126
## 69 135
## 70 113
## 71 146
## 72 117
## 73 114
## 74 123
## 75 121
## 76 131
## 77 115
## 78 126
## 79 135
## 80 113
## 81 146
## 82 117
## 83 114
## 84 123
## 85 121
## 86 131
## 87 115
## 88 126
## 89 135
## 90 113
## 91 146
## 92 117
## 93 114
## 94 123
## 95 121
## 96 131
## 97 115
## 98 126
## 99 135
## 100 113
## 101 146
## 102 117
## 103 114
## 104 123
## 105 121
## 106 131
## 107 115
## 108 126
## 109 135
## 110 113
## 111 146
## 112 117
## 113 114
## 114 123
## 115 121
## 116 131
## 117 115
## 118 126
## 119 135
## 120 113
var <- dplyr::select(tib.c,c(Flores.d,Estatus)) %>% group_by(Estatus); head(var)
## # A tibble: 6 x 2
## # Groups: Estatus [1]
## Flores.d Estatus
## <dbl> <fct>
## 1 146 S
## 2 117 S
## 3 114 S
## 4 123 S
## 5 121 S
## 6 131 S
var %>% arrange(desc(Flores.d),.by_group = T)
## # A tibble: 120 x 2
## # Groups: Estatus [3]
## Flores.d Estatus
## <dbl> <fct>
## 1 146 S
## 2 146 S
## 3 146 S
## 4 146 S
## 5 135 S
## 6 135 S
## 7 135 S
## 8 135 S
## 9 131 S
## 10 131 S
## # ... with 110 more rows
filter(tib.c,Estatus== "MA") %>% select(c(2,3,6))
## Flores.r Flores.d Estatus
## 1 17 146 MA
## 2 16 117 MA
## 3 19 114 MA
## 4 17 123 MA
## 5 17 121 MA
## 6 17 131 MA
## 7 18 115 MA
## 8 16 126 MA
## 9 19 135 MA
## 10 15 113 MA
## 11 14 146 MA
## 12 18 117 MA
## 13 19 114 MA
## 14 13 123 MA
## 15 13 121 MA
## 16 15 131 MA
## 17 18 115 MA
## 18 15 126 MA
## 19 17 135 MA
## 20 13 113 MA
## 21 18 146 MA
## 22 12 117 MA
## 23 16 114 MA
## 24 17 123 MA
## 25 17 121 MA
## 26 18 131 MA
## 27 18 115 MA
## 28 15 126 MA
## 29 18 135 MA
## 30 13 113 MA
## 31 16 146 MA
## 32 18 117 MA
## 33 17 114 MA
## 34 17 123 MA
## 35 17 121 MA
## 36 15 131 MA
## 37 14 115 MA
## 38 18 126 MA
## 39 14 135 MA
## 40 18 113 MA
filter(tib.c,Biomasa.gramos.>5)
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## 1 5.77 17 146 287 presente S
## 2 5.24 17 126 260 ausente S
## 3 5.64 14 135 66 presente S
## 4 5.21 16 113 191 ausente S
## 5 5.86 17 146 104 ausente S
## 6 5.08 17 123 81 ausente S
## 7 5.87 12 135 242 presente S
## 8 5.73 18 113 216 presente S
## 9 5.31 14 146 35 presente S
## 10 5.33 15 117 55 presente S
## 11 5.95 16 114 146 presente S
## 12 6.03 15 123 107 presente S
## 13 5.55 19 115 41 presente S
## 14 5.28 18 126 239 presente S
## 15 5.10 17 146 86 ausente S
## 16 5.71 14 117 40 presente S
## 17 5.92 18 131 275 presente S
## 18 5.92 18 115 56 presente S
## 19 5.12 18 126 94 ausente S
## 20 5.13 16 135 229 ausente S
## 21 5.69 16 117 147 presente PA
## 22 5.05 13 121 115 presente PA
## 23 5.29 14 115 300 presente PA
## 24 5.31 11 113 35 presente PA
## 25 6.44 15 146 276 ausente PA
## 26 5.85 16 117 138 presente PA
## 27 5.16 15 114 94 presente PA
## 28 6.05 18 123 223 presente PA
## 29 5.26 18 121 260 presente PA
## 30 5.54 16 131 210 ausente PA
## 31 5.02 19 115 8 presente PA
## 32 6.00 17 126 49 presente PA
## 33 5.35 14 113 279 presente PA
## 34 5.13 16 123 65 presente PA
## 35 5.91 17 126 58 ausente PA
## 36 6.97 15 135 278 presente PA
## 37 5.36 16 113 265 presente PA
## 38 6.13 15 117 247 presente PA
## 39 5.37 18 114 230 presente PA
## 40 5.06 17 123 169 presente PA
## 41 6.11 18 121 145 ausente PA
## 42 5.87 18 115 298 presente PA
## 43 6.16 15 126 42 presente PA
## 44 6.26 19 135 205 presente PA
## 45 5.75 19 113 89 presente PA
## 46 6.59 16 117 201 ausente MA
## 47 5.91 19 114 189 presente MA
## 48 5.45 17 131 124 ausente MA
## 49 6.14 18 115 33 presente MA
## 50 6.18 16 126 226 presente MA
## 51 7.33 19 135 194 presente MA
## 52 5.63 14 146 196 presente MA
## 53 5.22 18 117 234 presente MA
## 54 5.36 19 114 273 presente MA
## 55 7.45 13 121 133 presente MA
## 56 5.61 15 126 239 presente MA
## 57 5.21 17 135 294 presente MA
## 58 5.40 13 113 12 ausente MA
## 59 5.16 17 123 19 presente MA
## 60 5.89 17 121 63 presente MA
## 61 5.93 18 131 271 presente MA
## 62 5.59 18 115 269 ausente MA
## 63 5.22 18 135 176 ausente MA
## 64 6.06 13 113 84 ausente MA
## 65 5.55 16 146 193 presente MA
## 66 5.04 17 121 138 presente MA
## 67 5.21 14 115 267 ausente MA
## 68 5.19 18 126 187 ausente MA
## 69 5.73 14 135 158 presente MA
## Fertilizacion.fact_fert Fertilizacion.cat_fert
## 1 0.35904619 FO
## 2 0.66999365 FI
## 3 0.86001348 FI
## 4 0.03503845 FO
## 5 0.85554073 FI
## 6 0.86662550 FI
## 7 0.58129234 FI
## 8 1.04645425 FI
## 9 0.70961414 FI
## 10 0.32508769 FO
## 11 1.09348951 FI
## 12 0.08609217 FO
## 13 0.57698299 FI
## 14 1.18899615 FI
## 15 0.87398277 FI
## 16 0.44143101 FO
## 17 0.85456195 FI
## 18 0.11900541 FO
## 19 1.03665150 FI
## 20 0.78889276 FI
## 21 0.90374726 FI
## 22 0.17747251 FO
## 23 0.75672722 FI
## 24 0.49759043 FO
## 25 0.55413997 FI
## 26 0.38040856 FO
## 27 1.14414601 FI
## 28 0.02445485 FO
## 29 0.46483691 FO
## 30 1.03836835 FI
## 31 0.99906717 FI
## 32 1.04850211 FI
## 33 0.96493334 FI
## 34 0.94741459 FI
## 35 0.68740187 FI
## 36 0.84953091 FI
## 37 0.17878690 FO
## 38 0.82676865 FI
## 39 0.41635158 FO
## 40 0.51416950 FI
## 41 0.18600712 FO
## 42 0.31854228 FO
## 43 0.27349235 FO
## 44 0.93958938 FI
## 45 1.15777389 FI
## 46 0.48023071 FO
## 47 1.16262545 FI
## 48 0.78774832 FI
## 49 0.51768801 FI
## 50 0.65322185 FI
## 51 0.02887014 FO
## 52 0.48572619 FO
## 53 1.19738474 FI
## 54 0.17761635 FO
## 55 0.95449317 FI
## 56 0.01066292 FO
## 57 0.73035457 FI
## 58 0.55780872 FI
## 59 0.65015030 FI
## 60 0.74147758 FI
## 61 1.02641572 FI
## 62 1.03704666 FI
## 63 0.83590800 FI
## 64 0.45090745 FO
## 65 0.82528666 FI
## 66 0.86843633 FI
## 67 0.49388462 FO
## 68 1.07251945 FI
## 69 0.12356616 FO
filter(tib.c,Fertilizacion.cat_fert=="FO",Estatus=="PA")
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## 1 4.04 16 114 7 presente PA
## 2 3.78 14 123 251 presente PA
## 3 5.05 13 121 115 presente PA
## 4 4.33 15 131 6 presente PA
## 5 4.78 17 126 41 presente PA
## 6 3.89 16 135 53 ausente PA
## 7 5.31 11 113 35 presente PA
## 8 5.85 16 117 138 presente PA
## 9 6.05 18 123 223 presente PA
## 10 5.26 18 121 260 presente PA
## 11 4.61 14 135 182 presente PA
## 12 4.29 18 121 56 presente PA
## 13 4.03 18 115 24 presente PA
## 14 5.36 16 113 265 presente PA
## 15 5.37 18 114 230 presente PA
## 16 6.11 18 121 145 ausente PA
## 17 5.87 18 115 298 presente PA
## 18 6.16 15 126 42 presente PA
## Fertilizacion.fact_fert Fertilizacion.cat_fert
## 1 0.30562767 FO
## 2 0.41377359 FO
## 3 0.17747251 FO
## 4 0.15068317 FO
## 5 0.22674625 FO
## 6 0.27900894 FO
## 7 0.49759043 FO
## 8 0.38040856 FO
## 9 0.02445485 FO
## 10 0.46483691 FO
## 11 0.28233844 FO
## 12 0.32517873 FO
## 13 0.20708207 FO
## 14 0.17878690 FO
## 15 0.41635158 FO
## 16 0.18600712 FO
## 17 0.31854228 FO
## 18 0.27349235 FO
filter(tib.c,Fertilizacion.fact_fert=="FO"|Estatus=="PA")
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## 1 4.77 13 146 207 presente PA
## 2 5.69 16 117 147 presente PA
## 3 4.04 16 114 7 presente PA
## 4 3.78 14 123 251 presente PA
## 5 5.05 13 121 115 presente PA
## 6 4.33 15 131 6 presente PA
## 7 5.29 14 115 300 presente PA
## 8 4.78 17 126 41 presente PA
## 9 3.89 16 135 53 ausente PA
## 10 5.31 11 113 35 presente PA
## 11 6.44 15 146 276 ausente PA
## 12 5.85 16 117 138 presente PA
## 13 5.16 15 114 94 presente PA
## 14 6.05 18 123 223 presente PA
## 15 5.26 18 121 260 presente PA
## 16 5.54 16 131 210 ausente PA
## 17 5.02 19 115 8 presente PA
## 18 6.00 17 126 49 presente PA
## 19 4.61 14 135 182 presente PA
## 20 5.35 14 113 279 presente PA
## 21 3.86 16 146 157 presente PA
## 22 3.90 15 117 289 ausente PA
## 23 4.74 18 114 83 presente PA
## 24 5.13 16 123 65 presente PA
## 25 4.29 18 121 56 presente PA
## 26 4.98 16 131 74 ausente PA
## 27 4.03 18 115 24 presente PA
## 28 5.91 17 126 58 ausente PA
## 29 6.97 15 135 278 presente PA
## 30 5.36 16 113 265 presente PA
## 31 4.88 17 146 147 presente PA
## 32 6.13 15 117 247 presente PA
## 33 5.37 18 114 230 presente PA
## 34 5.06 17 123 169 presente PA
## 35 6.11 18 121 145 ausente PA
## 36 4.82 16 131 154 presente PA
## 37 5.87 18 115 298 presente PA
## 38 6.16 15 126 42 presente PA
## 39 6.26 19 135 205 presente PA
## 40 5.75 19 113 89 presente PA
## Fertilizacion.fact_fert Fertilizacion.cat_fert
## 1 0.86106750 FI
## 2 0.90374726 FI
## 3 0.30562767 FO
## 4 0.41377359 FO
## 5 0.17747251 FO
## 6 0.15068317 FO
## 7 0.75672722 FI
## 8 0.22674625 FO
## 9 0.27900894 FO
## 10 0.49759043 FO
## 11 0.55413997 FI
## 12 0.38040856 FO
## 13 1.14414601 FI
## 14 0.02445485 FO
## 15 0.46483691 FO
## 16 1.03836835 FI
## 17 0.99906717 FI
## 18 1.04850211 FI
## 19 0.28233844 FO
## 20 0.96493334 FI
## 21 0.70968232 FI
## 22 0.56767841 FI
## 23 1.15802219 FI
## 24 0.94741459 FI
## 25 0.32517873 FO
## 26 1.04581145 FI
## 27 0.20708207 FO
## 28 0.68740187 FI
## 29 0.84953091 FI
## 30 0.17878690 FO
## 31 0.75417331 FI
## 32 0.82676865 FI
## 33 0.41635158 FO
## 34 0.51416950 FI
## 35 0.18600712 FO
## 36 0.66184763 FI
## 37 0.31854228 FO
## 38 0.27349235 FO
## 39 0.93958938 FI
## 40 1.15777389 FI
#filtrado para usencia de plaga
filter(tib.c,Flores.d>median(Flores.d)& Plaga=="ausente")
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## 1 5.24 17 126 260 ausente S
## 2 5.86 17 146 104 ausente S
## 3 5.08 17 123 81 ausente S
## 4 4.19 15 126 272 ausente S
## 5 4.27 15 131 169 ausente S
## 6 5.10 17 146 86 ausente S
## 7 5.12 18 126 94 ausente S
## 8 5.13 16 135 229 ausente S
## 9 3.89 16 135 53 ausente PA
## 10 6.44 15 146 276 ausente PA
## 11 5.54 16 131 210 ausente PA
## 12 4.98 16 131 74 ausente PA
## 13 5.91 17 126 58 ausente PA
## 14 4.14 17 146 29 ausente MA
## 15 5.45 17 131 124 ausente MA
## 16 5.22 18 135 176 ausente MA
## 17 4.60 17 123 252 ausente MA
## 18 5.19 18 126 187 ausente MA
## Fertilizacion.fact_fert Fertilizacion.cat_fert
## 1 0.6699936 FI
## 2 0.8555407 FI
## 3 0.8666255 FI
## 4 1.1443928 FI
## 5 0.3958546 FO
## 6 0.8739828 FI
## 7 1.0366515 FI
## 8 0.7888928 FI
## 9 0.2790089 FO
## 10 0.5541400 FI
## 11 1.0383684 FI
## 12 1.0458115 FI
## 13 0.6874019 FI
## 14 1.1957612 FI
## 15 0.7877483 FI
## 16 0.8359080 FI
## 17 0.6545712 FI
## 18 1.0725194 FI
filter(tib.i,Hojas.d.>median(Hojas.d., na.rm = TRUE)& Plaga=="presente")
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## 1 4.72 18 121 229 presente S
## 2 5.63 14 146 196 presente MA
## 3 5.63 14 146 196 presente MA
## 4 5.55 16 146 193 presente MA
## 5 NA 16 113 265 presente PA
## 6 5.63 14 146 196 presente MA
## 7 4.17 19 114 257 presente S
## 8 5.92 18 131 275 presente S
## 9 6.18 16 126 226 presente MA
## 10 5.37 18 114 230 presente PA
## 11 5.77 17 146 287 presente S
## 12 5.73 18 113 216 presente S
## 13 4.17 19 114 257 presente S
## 14 4.48 15 131 246 presente MA
## 15 5.91 19 114 189 presente MA
## 16 6.18 16 126 226 presente MA
## 17 NA 16 113 265 presente PA
## 18 NA 16 113 265 presente PA
## 19 5.29 14 115 300 presente PA
## 20 5.87 18 115 298 presente PA
## 21 NA 16 113 265 presente PA
## 22 NA 15 126 239 presente MA
## 23 6.26 19 135 205 presente PA
## 24 5.26 18 121 260 presente PA
## 25 3.40 18 115 262 presente MA
## 26 NA 19 114 273 presente MA
## 27 NA 15 126 239 presente MA
## 28 6.26 19 135 205 presente PA
## Fertilizacion.fact_fert Fertilizacion.cat_fert
## 1 0.45679084 FO
## 2 0.48572619 FO
## 3 0.48572619 FO
## 4 0.82528666 FI
## 5 0.17878690 FO
## 6 0.48572619 FO
## 7 0.33609514 FO
## 8 0.85456195 FI
## 9 0.65322185 FI
## 10 0.41635158 FO
## 11 0.35904619 FO
## 12 1.04645425 FI
## 13 0.33609514 FO
## 14 0.84414681 FI
## 15 1.16262545 FI
## 16 0.65322185 FI
## 17 0.17878690 FO
## 18 0.17878690 FO
## 19 0.75672722 FI
## 20 0.31854228 FO
## 21 0.17878690 FO
## 22 0.01066292 FO
## 23 0.93958938 FI
## 24 0.46483691 FO
## 25 0.01889923 FO
## 26 0.17761635 FO
## 27 0.01066292 FO
## 28 0.93958938 FI
v1 =c("Flores.r","Flores.d")
v2= c(quantile(tib.c$Flores.r,
names = FALSE,
probs = 0.25
),
quantile(tib.c$Flores.d,
names = FALSE,
probs = 0.75)
)
tib.c %>% filter( .data[[v1[[1]]]] > v2[[1]], .data[[v1[[2]]]] > v2[[2]])
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## 1 5.77 17 146 287 presente S
## 2 5.86 17 146 104 ausente S
## 3 4.56 19 135 234 presente S
## 4 5.10 17 146 86 ausente S
## 5 5.13 16 135 229 ausente S
## 6 3.89 16 135 53 ausente PA
## 7 3.86 16 146 157 presente PA
## 8 4.88 17 146 147 presente PA
## 9 6.26 19 135 205 presente PA
## 10 4.14 17 146 29 ausente MA
## 11 7.33 19 135 194 presente MA
## 12 5.21 17 135 294 presente MA
## 13 4.81 18 146 103 presente MA
## 14 5.22 18 135 176 ausente MA
## 15 5.55 16 146 193 presente MA
## Fertilizacion.fact_fert Fertilizacion.cat_fert
## 1 0.35904619 FO
## 2 0.85554073 FI
## 3 0.33021889 FO
## 4 0.87398277 FI
## 5 0.78889276 FI
## 6 0.27900894 FO
## 7 0.70968232 FI
## 8 0.75417331 FI
## 9 0.93958938 FI
## 10 1.19576117 FI
## 11 0.02887014 FO
## 12 0.73035457 FI
## 13 1.02847258 FI
## 14 0.83590800 FI
## 15 0.82528666 FI
library(scales)
##
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
##
## discard
#Estandarización variables discretas
Estandar_disc <- mutate_all(tib.c[,2:4], funs("estandar" = rescale( . ))); head(Estandar_disc)
## Warning: `funs()` was deprecated in dplyr 0.8.0.
## Please use a list of either functions or lambdas:
##
## # Simple named list:
## list(mean = mean, median = median)
##
## # Auto named with `tibble::lst()`:
## tibble::lst(mean, median)
##
## # Using lambdas
## list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.
## Flores.r Flores.d Hojas.d. Flores.r_estandar Flores.d_estandar
## 1 17 146 287 0.750 1.00000000
## 2 16 117 182 0.625 0.12121212
## 3 15 114 174 0.500 0.03030303
## 4 18 123 78 0.875 0.30303030
## 5 18 121 229 0.875 0.24242424
## 6 18 131 205 0.875 0.54545455
## Hojas.d._estandar
## 1 0.9557823
## 2 0.5986395
## 3 0.5714286
## 4 0.2448980
## 5 0.7585034
## 6 0.6768707
#Estandarización de la variable continua
Estandar_cont = mutate(tib.c , "Biomasa_scoreZ"= scale(tib.c$Biomasa.gramos.)); head(Estandar_cont)
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## 1 5.77 17 146 287 presente S
## 2 4.00 16 117 182 presente S
## 3 4.24 15 114 174 presente S
## 4 3.77 18 123 78 presente S
## 5 4.72 18 121 229 presente S
## 6 2.53 18 131 205 presente S
## Fertilizacion.fact_fert Fertilizacion.cat_fert Biomasa_scoreZ
## 1 0.3590462 FO 0.8033942
## 2 0.5290298 FI -1.2705111
## 3 0.1874474 FO -0.9893036
## 4 0.9175104 FI -1.5400017
## 5 0.4567908 FO -0.4268886
## 6 0.4477445 FO -2.9929071
#Unir datos
tib.e = mutate(Estandar_cont,Estandar_disc); head(tib.e)
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## 1 5.77 17 146 287 presente S
## 2 4.00 16 117 182 presente S
## 3 4.24 15 114 174 presente S
## 4 3.77 18 123 78 presente S
## 5 4.72 18 121 229 presente S
## 6 2.53 18 131 205 presente S
## Fertilizacion.fact_fert Fertilizacion.cat_fert Biomasa_scoreZ
## 1 0.3590462 FO 0.8033942
## 2 0.5290298 FI -1.2705111
## 3 0.1874474 FO -0.9893036
## 4 0.9175104 FI -1.5400017
## 5 0.4567908 FO -0.4268886
## 6 0.4477445 FO -2.9929071
## Flores.r_estandar Flores.d_estandar Hojas.d._estandar
## 1 0.750 1.00000000 0.9557823
## 2 0.625 0.12121212 0.5986395
## 3 0.500 0.03030303 0.5714286
## 4 0.875 0.30303030 0.2448980
## 5 0.875 0.24242424 0.7585034
## 6 0.875 0.54545455 0.6768707
tib.e = mutate(tib.e , "Flores_r_div_d"= Flores.r/Flores.d); head(tib.e[c(0,13)])
## Flores_r_div_d
## 1 0.1164384
## 2 0.1367521
## 3 0.1315789
## 4 0.1463415
## 5 0.1487603
## 6 0.1374046
rangomin <- tib.e %>% group_by(Plaga) %>% select("Flores_r_div_d") %>% filter_at(vars("Flores_r_div_d"),
all_vars(. == min(.))
); rangomin
## Adding missing grouping variables: `Plaga`
## # A tibble: 2 x 2
## # Groups: Plaga [2]
## Plaga Flores_r_div_d
## <chr> <dbl>
## 1 presente 0.0889
## 2 ausente 0.103
names(tib.e)
## [1] "Biomasa.gramos." "Flores.r"
## [3] "Flores.d" "Hojas.d."
## [5] "Plaga" "Estatus"
## [7] "Fertilizacion.fact_fert" "Fertilizacion.cat_fert"
## [9] "Biomasa_scoreZ" "Flores.r_estandar"
## [11] "Flores.d_estandar" "Hojas.d._estandar"
## [13] "Flores_r_div_d"
tib.e_rename <- rename(tib.e, "Biomasa_gr" = Biomasa.gramos.,
"Flores_en_ramas" = Flores.r,
"Flores_desplendidas" = Flores.d,
"Hojas_desplendidas" = Hojas.d.,
"Factor_fert" = Fertilizacion.fact_fert,
"categoria_fert" = Fertilizacion.cat_fert
); names(tib.e_rename)
## [1] "Biomasa_gr" "Flores_en_ramas" "Flores_desplendidas"
## [4] "Hojas_desplendidas" "Plaga" "Estatus"
## [7] "Factor_fert" "categoria_fert" "Biomasa_scoreZ"
## [10] "Flores.r_estandar" "Flores.d_estandar" "Hojas.d._estandar"
## [13] "Flores_r_div_d"
tib.e_mayus <- select_all(tib.e_rename , toupper); names(tib.e_mayus)
## [1] "BIOMASA_GR" "FLORES_EN_RAMAS" "FLORES_DESPLENDIDAS"
## [4] "HOJAS_DESPLENDIDAS" "PLAGA" "ESTATUS"
## [7] "FACTOR_FERT" "CATEGORIA_FERT" "BIOMASA_SCOREZ"
## [10] "FLORES.R_ESTANDAR" "FLORES.D_ESTANDAR" "HOJAS.D._ESTANDAR"
## [13] "FLORES_R_DIV_D"
tib.i %>% filter(!is.na(Biomasa.gramos.)) %>% summarise_at(vars(Biomasa.gramos.),
funs(mean,length)
)
## mean length
## 1 5.089103 78
tib.i %>% group_by(Fertilizacion.cat_fert) %>% filter(!is.na(Biomasa.gramos.)) %>% summarise_at(vars(Biomasa.gramos.),
funs(mean,length)
)
## # A tibble: 2 x 3
## Fertilizacion.cat_fert mean length
## <chr> <dbl> <int>
## 1 FI 5.28 43
## 2 FO 4.85 35
tib.i %>% group_by(Fertilizacion.cat_fert) %>% filter(!is.na(Biomasa.gramos.)) %>% summarise_at(vars(Biomasa.gramos.),
funs(quantile(Biomasa.gramos.,
probs = c(0.1, 0.2, 0.3, 0.4, 0.5)
)
)
)
## # A tibble: 10 x 2
## # Groups: Fertilizacion.cat_fert [2]
## Fertilizacion.cat_fert Biomasa.gramos.
## <chr> <dbl>
## 1 FI 4.53
## 2 FI 4.8
## 3 FI 4.93
## 4 FI 5.13
## 5 FI 5.29
## 6 FO 3.99
## 7 FO 4.04
## 8 FO 4.17
## 9 FO 4.38
## 10 FO 4.72
tib.i %>% group_by(Fertilizacion.cat_fert, Plaga) %>% summarise_at(vars(Biomasa.gramos.),
funs(length,
mean,
sd,
max,
min,
median,
"media_truncada" = mean(Biomasa.gramos.,
trim = 0.1
),
var
)
)
## # A tibble: 4 x 10
## # Groups: Fertilizacion.cat_fert [2]
## Fertilizacion.cat~ Plaga length mean sd max min median media_truncada
## <chr> <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 FI ause~ 10 5.24 0.716 6.44 4.19 5.16 5.22
## 2 FI pres~ 35 NA NA NA NA NA NA
## 3 FO ause~ 12 NA NA NA NA NA NA
## 4 FO pres~ 33 NA NA NA NA NA NA
## # ... with 1 more variable: var <dbl>
tib.i %>% filter(Estatus == "S") %>% group_by(Fertilizacion.cat_fert, Plaga) %>% summarise_at(vars(Biomasa.gramos.), funs(length,
mean,
sd,
max,
min,
median,
"media_truncada" = mean(Biomasa.gramos.,
trim = 0.1
),
var
)
)
## # A tibble: 4 x 10
## # Groups: Fertilizacion.cat_fert [2]
## Fertilizacion.cat_~ Plaga length mean sd max min median media_truncada
## <chr> <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 FI ause~ 5 4.89 0.709 5.86 4.19 5.08 4.89
## 2 FI pres~ 12 5.13 0.545 5.92 4 5.08 5.16
## 3 FO ause~ 6 4.77 0.499 5.21 4.1 4.82 4.77
## 4 FO pres~ 7 4.99 0.848 5.92 4.17 4.72 4.99
## # ... with 1 more variable: var <dbl>
tib.i_dropNa <- na.omit(tib.i)
tib.i_dropNa %>% filter(Estatus == "S") %>% group_by(Fertilizacion.cat_fert, Plaga) %>% summarise_at(vars(Biomasa.gramos.), funs(length,
mean,
sd,
max,
min,
median,
"media_truncada" = mean(Biomasa.gramos.,
trim = 0.1
),
var
)
)
## # A tibble: 4 x 10
## # Groups: Fertilizacion.cat_fert [2]
## Fertilizacion.cat_~ Plaga length mean sd max min median media_truncada
## <chr> <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 FI ause~ 4 4.83 0.805 5.86 4.19 4.64 4.83
## 2 FI pres~ 12 5.13 0.545 5.92 4 5.08 5.16
## 3 FO ause~ 6 4.77 0.499 5.21 4.1 4.82 4.77
## 4 FO pres~ 6 5.11 0.856 5.92 4.17 5.24 5.11
## # ... with 1 more variable: var <dbl>
filter(tib.i, Estatus %in% c("PA", "MA"))
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## 1 5.40 13 113 12 ausente MA
## 2 NA 16 114 143 presente MA
## 3 5.31 11 113 35 presente PA
## 4 5.63 14 146 196 presente MA
## 5 5.16 17 123 NA presente MA
## 6 3.89 16 135 53 ausente PA
## 7 6.59 16 117 201 ausente MA
## 8 5.04 17 121 138 presente MA
## 9 5.63 14 146 196 presente MA
## 10 4.82 16 131 154 presente PA
## 11 5.55 16 146 193 presente MA
## 12 5.19 18 126 187 ausente MA
## 13 3.83 15 131 NA presente MA
## 14 5.89 17 121 63 presente MA
## 15 4.82 16 131 154 presente PA
## 16 3.86 16 146 157 presente PA
## 17 NA 16 113 265 presente PA
## 18 5.85 16 117 138 presente PA
## 19 5.69 16 117 147 presente PA
## 20 5.63 14 146 196 presente MA
## 21 NA 17 114 240 ausente MA
## 22 5.69 16 117 147 presente PA
## 23 NA 17 114 240 ausente MA
## 24 4.29 18 121 56 presente PA
## 25 6.18 16 126 226 presente MA
## 26 5.16 17 123 NA presente MA
## 27 4.04 16 114 7 presente PA
## 28 5.37 18 114 230 presente PA
## 29 5.91 17 126 58 ausente PA
## 30 6.44 15 146 276 ausente PA
## 31 4.48 15 131 246 presente MA
## 32 NA 16 114 143 presente MA
## 33 5.91 19 114 189 presente MA
## 34 6.18 16 126 226 presente MA
## 35 4.61 14 135 182 presente PA
## 36 5.13 16 123 65 presente PA
## 37 NA 16 113 265 presente PA
## 38 NA 16 113 265 presente PA
## 39 4.04 16 114 7 presente PA
## 40 5.29 14 115 300 presente PA
## 41 5.87 18 115 298 presente PA
## 42 3.96 12 117 63 ausente MA
## 43 NA 16 113 265 presente PA
## 44 5.35 14 113 NA presente PA
## 45 4.04 16 114 7 presente PA
## 46 4.74 18 114 83 presente PA
## 47 4.03 18 115 24 presente PA
## 48 4.03 18 115 24 presente PA
## 49 4.98 16 131 74 ausente PA
## 50 5.89 17 121 63 presente MA
## 51 NA 15 126 239 presente MA
## 52 6.26 19 135 205 presente PA
## 53 5.26 18 121 260 presente PA
## 54 3.40 18 115 262 presente MA
## 55 NA 19 114 273 presente MA
## 56 NA 17 114 240 ausente MA
## 57 NA 15 126 239 presente MA
## 58 5.05 13 121 115 presente PA
## 59 5.85 16 117 138 presente PA
## 60 6.26 19 135 205 presente PA
## Fertilizacion.fact_fert Fertilizacion.cat_fert
## 1 0.55780872 FI
## 2 1.14872662 FI
## 3 0.49759043 FO
## 4 0.48572619 FO
## 5 0.65015030 FI
## 6 0.27900894 FO
## 7 0.48023071 FO
## 8 0.86843633 FI
## 9 0.48572619 FO
## 10 0.66184763 FI
## 11 0.82528666 FI
## 12 1.07251945 FI
## 13 0.40372298 FO
## 14 0.74147758 FI
## 15 0.66184763 FI
## 16 0.70968232 FI
## 17 0.17878690 FO
## 18 0.38040856 FO
## 19 0.90374726 FI
## 20 0.48572619 FO
## 21 0.18785544 FO
## 22 0.90374726 FI
## 23 0.18785544 FO
## 24 0.32517873 FO
## 25 0.65322185 FI
## 26 0.65015030 FI
## 27 0.30562767 FO
## 28 0.41635158 FO
## 29 0.68740187 FI
## 30 0.55413997 FI
## 31 0.84414681 FI
## 32 1.14872662 FI
## 33 1.16262545 FI
## 34 0.65322185 FI
## 35 0.28233844 FO
## 36 0.94741459 FI
## 37 0.17878690 FO
## 38 0.17878690 FO
## 39 0.30562767 FO
## 40 0.75672722 FI
## 41 0.31854228 FO
## 42 0.46969139 FO
## 43 0.17878690 FO
## 44 0.96493334 FI
## 45 0.30562767 FO
## 46 1.15802219 FI
## 47 0.20708207 FO
## 48 0.20708207 FO
## 49 1.04581145 FI
## 50 0.74147758 FI
## 51 0.01066292 FO
## 52 0.93958938 FI
## 53 0.46483691 FO
## 54 0.01889923 FO
## 55 0.17761635 FO
## 56 0.18785544 FO
## 57 0.01066292 FO
## 58 0.17747251 FO
## 59 0.38040856 FO
## 60 0.93958938 FI
tib.i %>% filter(complete.cases(tib.i))
## Biomasa.gramos. Flores.r Flores.d Hojas.d. Plaga Estatus
## 1 5.40 13 113 12 ausente MA
## 2 5.55 19 115 41 presente S
## 3 5.31 14 146 35 presente S
## 4 5.31 14 146 35 presente S
## 5 4.80 18 113 123 presente S
## 6 5.21 16 113 191 ausente S
## 7 5.31 11 113 35 presente PA
## 8 4.72 18 121 229 presente S
## 9 5.63 14 146 196 presente MA
## 10 3.89 16 135 53 ausente PA
## 11 6.59 16 117 201 ausente MA
## 12 5.04 17 121 138 presente MA
## 13 5.63 14 146 196 presente MA
## 14 4.82 16 131 154 presente PA
## 15 5.55 16 146 193 presente MA
## 16 5.19 18 126 187 ausente MA
## 17 5.89 17 121 63 presente MA
## 18 4.82 16 131 154 presente PA
## 19 3.86 16 146 157 presente PA
## 20 4.00 16 117 182 presente S
## 21 5.85 16 117 138 presente PA
## 22 5.69 16 117 147 presente PA
## 23 5.63 14 146 196 presente MA
## 24 5.69 16 117 147 presente PA
## 25 5.92 18 115 56 presente S
## 26 5.21 16 113 191 ausente S
## 27 4.17 19 114 257 presente S
## 28 4.29 18 121 56 presente PA
## 29 5.92 18 131 275 presente S
## 30 6.18 16 126 226 presente MA
## 31 5.92 18 115 56 presente S
## 32 4.04 16 114 7 presente PA
## 33 5.37 18 114 230 presente PA
## 34 5.77 17 146 287 presente S
## 35 4.80 18 113 123 presente S
## 36 5.73 18 113 216 presente S
## 37 5.91 17 126 58 ausente PA
## 38 6.44 15 146 276 ausente PA
## 39 4.17 19 114 257 presente S
## 40 4.48 15 131 246 presente MA
## 41 5.86 17 146 104 ausente S
## 42 5.91 19 114 189 presente MA
## 43 6.18 16 126 226 presente MA
## 44 4.61 14 135 182 presente PA
## 45 5.13 16 123 65 presente PA
## 46 4.80 18 113 123 presente S
## 47 4.19 15 126 272 ausente S
## 48 5.64 14 135 66 presente S
## 49 4.04 16 114 7 presente PA
## 50 5.29 14 115 300 presente PA
## 51 4.86 17 113 161 presente S
## 52 4.44 19 115 245 ausente S
## 53 5.87 18 115 298 presente PA
## 54 4.19 15 126 272 ausente S
## 55 3.96 12 117 63 ausente MA
## 56 4.04 16 114 7 presente PA
## 57 4.10 17 115 112 ausente S
## 58 4.74 18 114 83 presente PA
## 59 4.03 18 115 24 presente PA
## 60 5.08 17 123 81 ausente S
## 61 4.03 18 115 24 presente PA
## 62 4.98 16 131 74 ausente PA
## 63 5.21 16 113 191 ausente S
## 64 5.89 17 121 63 presente MA
## 65 4.80 18 113 123 presente S
## 66 6.26 19 135 205 presente PA
## 67 5.26 18 121 260 presente PA
## 68 3.40 18 115 262 presente MA
## 69 4.44 19 115 245 ausente S
## 70 5.05 13 121 115 presente PA
## 71 5.85 16 117 138 presente PA
## 72 6.26 19 135 205 presente PA
## Fertilizacion.fact_fert Fertilizacion.cat_fert
## 1 0.55780872 FI
## 2 0.57698299 FI
## 3 0.70961414 FI
## 4 0.70961414 FI
## 5 0.57155435 FI
## 6 0.03503845 FO
## 7 0.49759043 FO
## 8 0.45679084 FO
## 9 0.48572619 FO
## 10 0.27900894 FO
## 11 0.48023071 FO
## 12 0.86843633 FI
## 13 0.48572619 FO
## 14 0.66184763 FI
## 15 0.82528666 FI
## 16 1.07251945 FI
## 17 0.74147758 FI
## 18 0.66184763 FI
## 19 0.70968232 FI
## 20 0.52902980 FI
## 21 0.38040856 FO
## 22 0.90374726 FI
## 23 0.48572619 FO
## 24 0.90374726 FI
## 25 0.11900541 FO
## 26 0.03503845 FO
## 27 0.33609514 FO
## 28 0.32517873 FO
## 29 0.85456195 FI
## 30 0.65322185 FI
## 31 0.11900541 FO
## 32 0.30562767 FO
## 33 0.41635158 FO
## 34 0.35904619 FO
## 35 0.57155435 FI
## 36 1.04645425 FI
## 37 0.68740187 FI
## 38 0.55413997 FI
## 39 0.33609514 FO
## 40 0.84414681 FI
## 41 0.85554073 FI
## 42 1.16262545 FI
## 43 0.65322185 FI
## 44 0.28233844 FO
## 45 0.94741459 FI
## 46 0.57155435 FI
## 47 1.14439284 FI
## 48 0.86001348 FI
## 49 0.30562767 FO
## 50 0.75672722 FI
## 51 0.77367106 FI
## 52 0.44836130 FO
## 53 0.31854228 FO
## 54 1.14439284 FI
## 55 0.46969139 FO
## 56 0.30562767 FO
## 57 0.19249755 FO
## 58 1.15802219 FI
## 59 0.20708207 FO
## 60 0.86662550 FI
## 61 0.20708207 FO
## 62 1.04581145 FI
## 63 0.03503845 FO
## 64 0.74147758 FI
## 65 0.57155435 FI
## 66 0.93958938 FI
## 67 0.46483691 FO
## 68 0.01889923 FO
## 69 0.44836130 FO
## 70 0.17747251 FO
## 71 0.38040856 FO
## 72 0.93958938 FI
tib_sinFlores = tib.c %>% select(!starts_with("Flores")); names(tib_sinFlores)
## [1] "Biomasa.gramos." "Hojas.d."
## [3] "Plaga" "Estatus"
## [5] "Fertilizacion.fact_fert" "Fertilizacion.cat_fert"
tib.c %>% select(contains("d")) %>% select(everything(vars = c("flores","hojas")))
## Flores.d Hojas.d.
## 1 146 287
## 2 117 182
## 3 114 174
## 4 123 78
## 5 121 229
## 6 131 205
## 7 115 112
## 8 126 260
## 9 135 66
## 10 113 191
## 11 146 104
## 12 117 61
## 13 114 257
## 14 123 81
## 15 121 195
## 16 131 66
## 17 115 245
## 18 126 272
## 19 135 242
## 20 113 216
## 21 146 35
## 22 117 55
## 23 114 146
## 24 123 107
## 25 121 85
## 26 131 169
## 27 115 41
## 28 126 239
## 29 135 234
## 30 113 123
## 31 146 86
## 32 117 40
## 33 114 73
## 34 123 223
## 35 121 251
## 36 131 275
## 37 115 56
## 38 126 94
## 39 135 229
## 40 113 161
## 41 146 207
## 42 117 147
## 43 114 7
## 44 123 251
## 45 121 115
## 46 131 6
## 47 115 300
## 48 126 41
## 49 135 53
## 50 113 35
## 51 146 276
## 52 117 138
## 53 114 94
## 54 123 223
## 55 121 260
## 56 131 210
## 57 115 8
## 58 126 49
## 59 135 182
## 60 113 279
## 61 146 157
## 62 117 289
## 63 114 83
## 64 123 65
## 65 121 56
## 66 131 74
## 67 115 24
## 68 126 58
## 69 135 278
## 70 113 265
## 71 146 147
## 72 117 247
## 73 114 230
## 74 123 169
## 75 121 145
## 76 131 154
## 77 115 298
## 78 126 42
## 79 135 205
## 80 113 89
## 81 146 29
## 82 117 201
## 83 114 189
## 84 123 130
## 85 121 36
## 86 131 124
## 87 115 33
## 88 126 226
## 89 135 194
## 90 113 257
## 91 146 196
## 92 117 234
## 93 114 273
## 94 123 142
## 95 121 133
## 96 131 246
## 97 115 262
## 98 126 239
## 99 135 294
## 100 113 12
## 101 146 103
## 102 117 63
## 103 114 143
## 104 123 19
## 105 121 63
## 106 131 271
## 107 115 269
## 108 126 275
## 109 135 176
## 110 113 84
## 111 146 193
## 112 117 96
## 113 114 240
## 114 123 252
## 115 121 138
## 116 131 38
## 117 115 267
## 118 126 187
## 119 135 158
## 120 113 266