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
You can also embed plots, for example:
echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.title: “Taller multivariados 1” author: “R” date: ‘2022-03-30’ output: html_document —
##Taller Métodos multivariados## ##1.1
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
set.seed(2095)
biomasa = c(round (rnorm (120, 5, 0.85), 2)); head (biomasa)
## [1] 4.55 4.55 6.22 5.26 4.68 5.43
biomasa
## [1] 4.55 4.55 6.22 5.26 4.68 5.43 3.96 3.82 4.01 5.29 4.09 7.01 5.44 3.64 4.76
## [16] 5.78 6.47 5.29 5.00 4.58 5.52 5.28 5.30 5.80 4.25 4.18 4.55 5.70 5.06 4.15
## [31] 5.32 4.69 5.13 4.40 6.50 4.54 4.57 4.25 4.36 5.53 2.78 4.09 4.01 6.31 4.25
## [46] 4.52 3.90 6.25 5.72 4.27 6.23 5.84 5.25 3.96 4.39 4.99 5.25 3.64 4.22 4.98
## [61] 4.79 3.17 6.17 4.78 4.10 5.21 4.90 4.93 5.57 5.48 5.72 4.50 5.11 6.01 5.62
## [76] 4.51 6.04 6.66 4.02 4.35 6.13 5.20 5.02 6.02 4.25 5.96 4.82 6.03 4.19 5.34
## [91] 4.67 3.56 5.37 5.49 5.59 4.20 5.22 4.73 6.06 5.77 5.07 5.81 5.55 4.27 5.00
## [106] 5.19 5.18 4.33 5.22 5.15 5.24 3.69 5.43 5.83 6.03 3.64 5.95 5.13 4.35 4.88
##1.2
flores.r = c(rbinom (120, 20, 0.8))
flores.r
## [1] 12 15 17 13 15 17 17 16 17 18 17 16 19 10 18 18 17 14 16 16 17 15 14 14 13
## [26] 15 16 13 15 13 15 18 15 16 15 12 17 15 15 19 17 14 16 16 18 11 16 15 15 14
## [51] 15 19 18 16 17 12 17 16 12 17 13 18 17 15 13 16 19 14 16 18 18 20 19 17 16
## [76] 17 16 15 17 15 16 15 18 14 15 14 15 18 17 14 18 17 18 18 18 16 15 16 14 14
## [101] 13 18 17 15 17 16 17 15 18 17 17 17 14 16 17 20 16 18 15 16
##1.3
flores.d = c (rpois (120, 10.5))
flores.d
## [1] 11 12 11 6 15 9 1 8 12 13 9 14 12 10 8 12 8 14 5 6 9 10 15 10 11
## [26] 13 9 11 13 8 10 9 9 5 16 12 4 15 8 12 11 9 13 10 12 10 10 12 11 7
## [51] 9 14 10 6 12 10 13 8 6 10 6 12 12 14 7 11 7 11 7 13 13 13 13 12 8
## [76] 5 12 11 8 14 11 15 8 9 9 9 8 6 15 8 15 9 8 14 7 5 9 11 12 14
## [101] 11 11 11 5 4 12 6 12 15 14 9 13 8 11 4 10 14 14 7 12
##1.4
hojas.d = sample.int (300, 120, replace = FALSE, prob = NULL)
hojas.d
## [1] 16 54 8 186 282 257 122 139 119 38 283 235 19 217 66 78 35 60
## [19] 224 248 230 43 111 205 56 55 241 231 87 171 31 166 258 150 261 236
## [37] 295 82 94 27 178 22 74 177 243 209 222 208 179 40 202 169 174 245
## [55] 134 297 28 221 36 172 24 188 285 277 98 62 253 105 89 211 140 73
## [73] 108 220 216 238 189 9 276 135 289 41 117 219 71 75 153 201 109 252
## [91] 273 214 68 160 6 158 137 23 161 284 157 287 198 72 131 147 97 254
## [109] 15 132 181 170 269 207 58 197 125 156 124 260
##1.5
library(purrr)
dist = rbernoulli(120, p=0.5)
plaga = ifelse(dist == FALSE, "ausente", "presente"); head (plaga)
## [1] "ausente" "ausente" "presente" "presente" "ausente" "presente"
##1.6
estatus = gl(3, 40, label=c ("S", "PA", "MA"))
estatus
## [1] S S S S S S S S S S S S S S S S S S S S S S S S S
## [26] S S S S S S S S S S S S S S S PA PA PA PA PA PA PA PA PA PA
## [51] PA PA PA PA PA PA PA PA PA PA PA PA PA PA PA PA PA PA PA PA PA PA PA PA PA
## [76] PA PA PA PA PA MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA
## [101] MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA MA
## Levels: S PA MA
##1.7
fert= round (runif(120, min = 0, max = 1),2)
ifelse (fert < 0.5, "FO", "FI")
## [1] "FI" "FI" "FO" "FI" "FI" "FO" "FI" "FI" "FO" "FI" "FO" "FO" "FI" "FI" "FO"
## [16] "FO" "FI" "FI" "FO" "FO" "FO" "FI" "FI" "FO" "FO" "FO" "FI" "FI" "FO" "FO"
## [31] "FO" "FI" "FI" "FO" "FO" "FI" "FI" "FO" "FO" "FO" "FO" "FO" "FI" "FI" "FO"
## [46] "FI" "FO" "FO" "FO" "FO" "FI" "FO" "FO" "FO" "FI" "FI" "FO" "FO" "FO" "FO"
## [61] "FI" "FI" "FO" "FI" "FO" "FO" "FI" "FI" "FI" "FI" "FO" "FO" "FI" "FO" "FI"
## [76] "FI" "FO" "FI" "FO" "FO" "FI" "FO" "FI" "FI" "FI" "FO" "FI" "FI" "FO" "FI"
## [91] "FO" "FI" "FI" "FI" "FO" "FI" "FI" "FO" "FI" "FO" "FO" "FO" "FI" "FI" "FO"
## [106] "FI" "FI" "FI" "FO" "FO" "FI" "FO" "FO" "FI" "FO" "FO" "FI" "FI" "FO" "FI"
##1.8
tib.c <- data.frame ("biomasa" = biomasa, "flores.r" = flores.r, "flores.d" =flores.d, "hojas.d"= hojas.d, "plaga"= plaga, "estatus"= estatus, "fertilizacion"= fert); head(tib.c)
## biomasa flores.r flores.d hojas.d plaga estatus fertilizacion
## 1 4.55 12 11 16 ausente S 0.90
## 2 4.55 15 12 54 ausente S 0.89
## 3 6.22 17 11 8 presente S 0.36
## 4 5.26 13 6 186 presente S 0.89
## 5 4.68 15 15 282 ausente S 0.93
## 6 5.43 17 9 257 presente S 0.26
tib.c
## biomasa flores.r flores.d hojas.d plaga estatus fertilizacion
## 1 4.55 12 11 16 ausente S 0.90
## 2 4.55 15 12 54 ausente S 0.89
## 3 6.22 17 11 8 presente S 0.36
## 4 5.26 13 6 186 presente S 0.89
## 5 4.68 15 15 282 ausente S 0.93
## 6 5.43 17 9 257 presente S 0.26
## 7 3.96 17 1 122 ausente S 0.62
## 8 3.82 16 8 139 ausente S 0.54
## 9 4.01 17 12 119 ausente S 0.44
## 10 5.29 18 13 38 presente S 0.89
## 11 4.09 17 9 283 presente S 0.06
## 12 7.01 16 14 235 ausente S 0.29
## 13 5.44 19 12 19 presente S 0.95
## 14 3.64 10 10 217 ausente S 0.95
## 15 4.76 18 8 66 presente S 0.17
## 16 5.78 18 12 78 ausente S 0.16
## 17 6.47 17 8 35 ausente S 0.78
## 18 5.29 14 14 60 ausente S 0.95
## 19 5.00 16 5 224 ausente S 0.07
## 20 4.58 16 6 248 presente S 0.03
## 21 5.52 17 9 230 ausente S 0.16
## 22 5.28 15 10 43 ausente S 0.69
## 23 5.30 14 15 111 presente S 0.59
## 24 5.80 14 10 205 ausente S 0.49
## 25 4.25 13 11 56 presente S 0.32
## 26 4.18 15 13 55 presente S 0.24
## 27 4.55 16 9 241 ausente S 0.80
## 28 5.70 13 11 231 presente S 0.91
## 29 5.06 15 13 87 presente S 0.32
## 30 4.15 13 8 171 presente S 0.40
## 31 5.32 15 10 31 presente S 0.19
## 32 4.69 18 9 166 presente S 0.78
## 33 5.13 15 9 258 presente S 0.77
## 34 4.40 16 5 150 ausente S 0.15
## 35 6.50 15 16 261 ausente S 0.14
## 36 4.54 12 12 236 ausente S 0.61
## 37 4.57 17 4 295 ausente S 0.53
## 38 4.25 15 15 82 ausente S 0.25
## 39 4.36 15 8 94 ausente S 0.44
## 40 5.53 19 12 27 presente S 0.36
## 41 2.78 17 11 178 presente PA 0.27
## 42 4.09 14 9 22 presente PA 0.39
## 43 4.01 16 13 74 presente PA 0.50
## 44 6.31 16 10 177 presente PA 0.63
## 45 4.25 18 12 243 ausente PA 0.44
## 46 4.52 11 10 209 presente PA 0.88
## 47 3.90 16 10 222 presente PA 0.40
## 48 6.25 15 12 208 ausente PA 0.22
## 49 5.72 15 11 179 presente PA 0.09
## 50 4.27 14 7 40 ausente PA 0.17
## 51 6.23 15 9 202 ausente PA 0.93
## 52 5.84 19 14 169 ausente PA 0.24
## 53 5.25 18 10 174 ausente PA 0.35
## 54 3.96 16 6 245 presente PA 0.49
## 55 4.39 17 12 134 ausente PA 0.54
## 56 4.99 12 10 297 ausente PA 0.70
## 57 5.25 17 13 28 presente PA 0.02
## 58 3.64 16 8 221 ausente PA 0.48
## 59 4.22 12 6 36 presente PA 0.13
## 60 4.98 17 10 172 presente PA 0.26
## 61 4.79 13 6 24 presente PA 0.76
## 62 3.17 18 12 188 ausente PA 0.86
## 63 6.17 17 12 285 ausente PA 0.11
## 64 4.78 15 14 277 presente PA 0.83
## 65 4.10 13 7 98 presente PA 0.26
## 66 5.21 16 11 62 ausente PA 0.35
## 67 4.90 19 7 253 ausente PA 0.51
## 68 4.93 14 11 105 ausente PA 0.73
## 69 5.57 16 7 89 presente PA 0.99
## 70 5.48 18 13 211 ausente PA 0.56
## 71 5.72 18 13 140 presente PA 0.04
## 72 4.50 20 13 73 presente PA 0.42
## 73 5.11 19 13 108 ausente PA 0.94
## 74 6.01 17 12 220 ausente PA 0.40
## 75 5.62 16 8 216 ausente PA 0.57
## 76 4.51 17 5 238 presente PA 0.97
## 77 6.04 16 12 189 presente PA 0.43
## 78 6.66 15 11 9 ausente PA 0.51
## 79 4.02 17 8 276 presente PA 0.25
## 80 4.35 15 14 135 presente PA 0.05
## 81 6.13 16 11 289 ausente MA 0.58
## 82 5.20 15 15 41 presente MA 0.17
## 83 5.02 18 8 117 presente MA 0.89
## 84 6.02 14 9 219 ausente MA 0.51
## 85 4.25 15 9 71 presente MA 0.84
## 86 5.96 14 9 75 ausente MA 0.32
## 87 4.82 15 8 153 presente MA 0.54
## 88 6.03 18 6 201 ausente MA 0.63
## 89 4.19 17 15 109 ausente MA 0.38
## 90 5.34 14 8 252 ausente MA 0.57
## 91 4.67 18 15 273 presente MA 0.36
## 92 3.56 17 9 214 ausente MA 0.94
## 93 5.37 18 8 68 ausente MA 0.92
## 94 5.49 18 14 160 ausente MA 0.71
## 95 5.59 18 7 6 ausente MA 0.48
## 96 4.20 16 5 158 presente MA 0.80
## 97 5.22 15 9 137 presente MA 0.74
## 98 4.73 16 11 23 presente MA 0.20
## 99 6.06 14 12 161 presente MA 0.80
## 100 5.77 14 14 284 ausente MA 0.29
## 101 5.07 13 11 157 ausente MA 0.10
## 102 5.81 18 11 287 ausente MA 0.15
## 103 5.55 17 11 198 ausente MA 0.72
## 104 4.27 15 5 72 presente MA 0.96
## 105 5.00 17 4 131 ausente MA 0.09
## 106 5.19 16 12 147 presente MA 0.62
## 107 5.18 17 6 97 ausente MA 0.85
## 108 4.33 15 12 254 ausente MA 0.77
## 109 5.22 18 15 15 ausente MA 0.35
## 110 5.15 17 14 132 presente MA 0.42
## 111 5.24 17 9 181 ausente MA 0.57
## 112 3.69 17 13 170 presente MA 0.11
## 113 5.43 14 8 269 ausente MA 0.43
## 114 5.83 16 11 207 ausente MA 0.93
## 115 6.03 17 4 58 ausente MA 0.28
## 116 3.64 20 10 197 ausente MA 0.25
## 117 5.95 16 14 125 ausente MA 0.65
## 118 5.13 18 14 156 presente MA 1.00
## 119 4.35 15 7 124 presente MA 0.01
## 120 4.88 16 12 260 ausente MA 0.85
dim (tib.c)
## [1] 120 7
str (tib.c)
## 'data.frame': 120 obs. of 7 variables:
## $ biomasa : num 4.55 4.55 6.22 5.26 4.68 5.43 3.96 3.82 4.01 5.29 ...
## $ flores.r : int 12 15 17 13 15 17 17 16 17 18 ...
## $ flores.d : int 11 12 11 6 15 9 1 8 12 13 ...
## $ hojas.d : int 16 54 8 186 282 257 122 139 119 38 ...
## $ plaga : chr "ausente" "ausente" "presente" "presente" ...
## $ estatus : Factor w/ 3 levels "S","PA","MA": 1 1 1 1 1 1 1 1 1 1 ...
## $ fertilizacion: num 0.9 0.89 0.36 0.89 0.93 0.26 0.62 0.54 0.44 0.89 ...
glimpse (tib.c)
## Rows: 120
## Columns: 7
## $ biomasa <dbl> 4.55, 4.55, 6.22, 5.26, 4.68, 5.43, 3.96, 3.82, 4.01, 5.~
## $ flores.r <int> 12, 15, 17, 13, 15, 17, 17, 16, 17, 18, 17, 16, 19, 10, ~
## $ flores.d <int> 11, 12, 11, 6, 15, 9, 1, 8, 12, 13, 9, 14, 12, 10, 8, 12~
## $ hojas.d <int> 16, 54, 8, 186, 282, 257, 122, 139, 119, 38, 283, 235, 1~
## $ plaga <chr> "ausente", "ausente", "presente", "presente", "ausente",~
## $ estatus <fct> S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,~
## $ fertilizacion <dbl> 0.90, 0.89, 0.36, 0.89, 0.93, 0.26, 0.62, 0.54, 0.44, 0.~
class (tib.c)
## [1] "data.frame"
names (tib.c)
## [1] "biomasa" "flores.r" "flores.d" "hojas.d"
## [5] "plaga" "estatus" "fertilizacion"
is.na (tib.c)
## biomasa flores.r flores.d hojas.d plaga estatus fertilizacion
## [1,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [2,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [3,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [4,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [5,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [6,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [7,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [8,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [9,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [10,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [11,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [12,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [13,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [14,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [15,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [16,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [17,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [18,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [19,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [20,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [21,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [22,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [23,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [24,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [25,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [26,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [27,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [28,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [29,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [30,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [31,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [32,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [33,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [34,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [35,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [36,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [37,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [38,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [39,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [40,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [41,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [42,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [43,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [44,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [45,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [46,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [47,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [48,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [49,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [50,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [51,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [52,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [53,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [54,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [55,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [56,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [57,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [58,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [59,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [60,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [61,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [62,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [63,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [64,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [65,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [66,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [67,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [68,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [69,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [70,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [71,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [72,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [73,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [74,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [75,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [76,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [77,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [78,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [79,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [80,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [81,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [82,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [83,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [84,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [85,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [86,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [87,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [88,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [89,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [90,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [91,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [92,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [93,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [94,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [95,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [96,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [97,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [98,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [99,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [100,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [101,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [102,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [103,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [104,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [105,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [106,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [107,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [108,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [109,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [110,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [111,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [112,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [113,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [114,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [115,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [116,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [117,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [118,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [119,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [120,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
##1.9
tib.i=sample_n(tib.c, 120*0.75)
dim(tib.i)
## [1] 90 7
tib.i[60,3]<-NA
tib.i[15,4]<-NA
head(tib.i)
## biomasa flores.r flores.d hojas.d plaga estatus fertilizacion
## 1 5.72 18 13 140 presente PA 0.04
## 2 5.25 18 10 174 ausente PA 0.35
## 3 5.32 15 10 31 presente S 0.19
## 4 5.26 13 6 186 presente S 0.89
## 5 4.02 17 8 276 presente PA 0.25
## 6 4.09 17 9 283 presente S 0.06
tib.i
## biomasa flores.r flores.d hojas.d plaga estatus fertilizacion
## 1 5.72 18 13 140 presente PA 0.04
## 2 5.25 18 10 174 ausente PA 0.35
## 3 5.32 15 10 31 presente S 0.19
## 4 5.26 13 6 186 presente S 0.89
## 5 4.02 17 8 276 presente PA 0.25
## 6 4.09 17 9 283 presente S 0.06
## 7 6.02 14 9 219 ausente MA 0.51
## 8 4.69 18 9 166 presente S 0.78
## 9 5.07 13 11 157 ausente MA 0.10
## 10 4.15 13 8 171 presente S 0.40
## 11 5.37 18 8 68 ausente MA 0.92
## 12 3.96 16 6 245 presente PA 0.49
## 13 6.66 15 11 9 ausente PA 0.51
## 14 4.33 15 12 254 ausente MA 0.77
## 15 4.27 14 7 NA ausente PA 0.17
## 16 4.51 17 5 238 presente PA 0.97
## 17 4.98 17 10 172 presente PA 0.26
## 18 5.00 16 5 224 ausente S 0.07
## 19 3.96 17 1 122 ausente S 0.62
## 20 5.18 17 6 97 ausente MA 0.85
## 21 5.06 15 13 87 presente S 0.32
## 22 3.90 16 10 222 presente PA 0.40
## 23 4.35 15 7 124 presente MA 0.01
## 24 5.95 16 14 125 ausente MA 0.65
## 25 6.01 17 12 220 ausente PA 0.40
## 26 5.00 17 4 131 ausente MA 0.09
## 27 4.55 12 11 16 ausente S 0.90
## 28 4.58 16 6 248 presente S 0.03
## 29 4.25 18 12 243 ausente PA 0.44
## 30 4.36 15 8 94 ausente S 0.44
## 31 6.50 15 16 261 ausente S 0.14
## 32 4.55 15 12 54 ausente S 0.89
## 33 4.01 16 13 74 presente PA 0.50
## 34 3.69 17 13 170 presente MA 0.11
## 35 5.62 16 8 216 ausente PA 0.57
## 36 5.77 14 14 284 ausente MA 0.29
## 37 5.96 14 9 75 ausente MA 0.32
## 38 5.59 18 7 6 ausente MA 0.48
## 39 4.40 16 5 150 ausente S 0.15
## 40 4.93 14 11 105 ausente PA 0.73
## 41 5.48 18 13 211 ausente PA 0.56
## 42 5.81 18 11 287 ausente MA 0.15
## 43 5.22 15 9 137 presente MA 0.74
## 44 3.64 20 10 197 ausente MA 0.25
## 45 5.72 15 11 179 presente PA 0.09
## 46 4.82 15 8 153 presente MA 0.54
## 47 4.57 17 4 295 ausente S 0.53
## 48 5.83 16 11 207 ausente MA 0.93
## 49 5.34 14 8 252 ausente MA 0.57
## 50 4.35 15 14 135 presente PA 0.05
## 51 5.53 19 12 27 presente S 0.36
## 52 5.49 18 14 160 ausente MA 0.71
## 53 4.73 16 11 23 presente MA 0.20
## 54 4.55 16 9 241 ausente S 0.80
## 55 5.13 18 14 156 presente MA 1.00
## 56 7.01 16 14 235 ausente S 0.29
## 57 5.84 19 14 169 ausente PA 0.24
## 58 6.04 16 12 189 presente PA 0.43
## 59 4.10 13 7 98 presente PA 0.26
## 60 5.21 16 NA 62 ausente PA 0.35
## 61 4.78 15 14 277 presente PA 0.83
## 62 4.25 15 15 82 ausente S 0.25
## 63 4.54 12 12 236 ausente S 0.61
## 64 4.19 17 15 109 ausente MA 0.38
## 65 5.13 15 9 258 presente S 0.77
## 66 5.24 17 9 181 ausente MA 0.57
## 67 4.68 15 15 282 ausente S 0.93
## 68 4.22 12 6 36 presente PA 0.13
## 69 5.78 18 12 78 ausente S 0.16
## 70 3.64 16 8 221 ausente PA 0.48
## 71 4.25 15 9 71 presente MA 0.84
## 72 4.20 16 5 158 presente MA 0.80
## 73 6.25 15 12 208 ausente PA 0.22
## 74 6.47 17 8 35 ausente S 0.78
## 75 5.28 15 10 43 ausente S 0.69
## 76 3.17 18 12 188 ausente PA 0.86
## 77 5.43 17 9 257 presente S 0.26
## 78 6.03 18 6 201 ausente MA 0.63
## 79 6.06 14 12 161 presente MA 0.80
## 80 6.13 16 11 289 ausente MA 0.58
## 81 4.52 11 10 209 presente PA 0.88
## 82 6.31 16 10 177 presente PA 0.63
## 83 5.11 19 13 108 ausente PA 0.94
## 84 2.78 17 11 178 presente PA 0.27
## 85 4.39 17 12 134 ausente PA 0.54
## 86 4.01 17 12 119 ausente S 0.44
## 87 6.17 17 12 285 ausente PA 0.11
## 88 5.70 13 11 231 presente S 0.91
## 89 5.30 14 15 111 presente S 0.59
## 90 5.22 18 15 15 ausente MA 0.35
#1.10 ##1.
library(dplyr)
variable = dplyr::select(tib.c, hojas.d)
head(variable)
## hojas.d
## 1 16
## 2 54
## 3 8
## 4 186
## 5 282
## 6 257
##2.
dplyr::select(tib.c,c (3:6))
## flores.d hojas.d plaga estatus
## 1 11 16 ausente S
## 2 12 54 ausente S
## 3 11 8 presente S
## 4 6 186 presente S
## 5 15 282 ausente S
## 6 9 257 presente S
## 7 1 122 ausente S
## 8 8 139 ausente S
## 9 12 119 ausente S
## 10 13 38 presente S
## 11 9 283 presente S
## 12 14 235 ausente S
## 13 12 19 presente S
## 14 10 217 ausente S
## 15 8 66 presente S
## 16 12 78 ausente S
## 17 8 35 ausente S
## 18 14 60 ausente S
## 19 5 224 ausente S
## 20 6 248 presente S
## 21 9 230 ausente S
## 22 10 43 ausente S
## 23 15 111 presente S
## 24 10 205 ausente S
## 25 11 56 presente S
## 26 13 55 presente S
## 27 9 241 ausente S
## 28 11 231 presente S
## 29 13 87 presente S
## 30 8 171 presente S
## 31 10 31 presente S
## 32 9 166 presente S
## 33 9 258 presente S
## 34 5 150 ausente S
## 35 16 261 ausente S
## 36 12 236 ausente S
## 37 4 295 ausente S
## 38 15 82 ausente S
## 39 8 94 ausente S
## 40 12 27 presente S
## 41 11 178 presente PA
## 42 9 22 presente PA
## 43 13 74 presente PA
## 44 10 177 presente PA
## 45 12 243 ausente PA
## 46 10 209 presente PA
## 47 10 222 presente PA
## 48 12 208 ausente PA
## 49 11 179 presente PA
## 50 7 40 ausente PA
## 51 9 202 ausente PA
## 52 14 169 ausente PA
## 53 10 174 ausente PA
## 54 6 245 presente PA
## 55 12 134 ausente PA
## 56 10 297 ausente PA
## 57 13 28 presente PA
## 58 8 221 ausente PA
## 59 6 36 presente PA
## 60 10 172 presente PA
## 61 6 24 presente PA
## 62 12 188 ausente PA
## 63 12 285 ausente PA
## 64 14 277 presente PA
## 65 7 98 presente PA
## 66 11 62 ausente PA
## 67 7 253 ausente PA
## 68 11 105 ausente PA
## 69 7 89 presente PA
## 70 13 211 ausente PA
## 71 13 140 presente PA
## 72 13 73 presente PA
## 73 13 108 ausente PA
## 74 12 220 ausente PA
## 75 8 216 ausente PA
## 76 5 238 presente PA
## 77 12 189 presente PA
## 78 11 9 ausente PA
## 79 8 276 presente PA
## 80 14 135 presente PA
## 81 11 289 ausente MA
## 82 15 41 presente MA
## 83 8 117 presente MA
## 84 9 219 ausente MA
## 85 9 71 presente MA
## 86 9 75 ausente MA
## 87 8 153 presente MA
## 88 6 201 ausente MA
## 89 15 109 ausente MA
## 90 8 252 ausente MA
## 91 15 273 presente MA
## 92 9 214 ausente MA
## 93 8 68 ausente MA
## 94 14 160 ausente MA
## 95 7 6 ausente MA
## 96 5 158 presente MA
## 97 9 137 presente MA
## 98 11 23 presente MA
## 99 12 161 presente MA
## 100 14 284 ausente MA
## 101 11 157 ausente MA
## 102 11 287 ausente MA
## 103 11 198 ausente MA
## 104 5 72 presente MA
## 105 4 131 ausente MA
## 106 12 147 presente MA
## 107 6 97 ausente MA
## 108 12 254 ausente MA
## 109 15 15 ausente MA
## 110 14 132 presente MA
## 111 9 181 ausente MA
## 112 13 170 presente MA
## 113 8 269 ausente MA
## 114 11 207 ausente MA
## 115 4 58 ausente MA
## 116 10 197 ausente MA
## 117 14 125 ausente MA
## 118 14 156 presente MA
## 119 7 124 presente MA
## 120 12 260 ausente MA
##3.
tib.c_sin_3_6<-select (tib.c,!(3:6))
head (tib.c_sin_3_6)
## biomasa flores.r fertilizacion
## 1 4.55 12 0.90
## 2 4.55 15 0.89
## 3 6.22 17 0.36
## 4 5.26 13 0.89
## 5 4.68 15 0.93
## 6 5.43 17 0.26
##4.
dplyr::select(tib.c, !ends_with(".d"))
## biomasa flores.r plaga estatus fertilizacion
## 1 4.55 12 ausente S 0.90
## 2 4.55 15 ausente S 0.89
## 3 6.22 17 presente S 0.36
## 4 5.26 13 presente S 0.89
## 5 4.68 15 ausente S 0.93
## 6 5.43 17 presente S 0.26
## 7 3.96 17 ausente S 0.62
## 8 3.82 16 ausente S 0.54
## 9 4.01 17 ausente S 0.44
## 10 5.29 18 presente S 0.89
## 11 4.09 17 presente S 0.06
## 12 7.01 16 ausente S 0.29
## 13 5.44 19 presente S 0.95
## 14 3.64 10 ausente S 0.95
## 15 4.76 18 presente S 0.17
## 16 5.78 18 ausente S 0.16
## 17 6.47 17 ausente S 0.78
## 18 5.29 14 ausente S 0.95
## 19 5.00 16 ausente S 0.07
## 20 4.58 16 presente S 0.03
## 21 5.52 17 ausente S 0.16
## 22 5.28 15 ausente S 0.69
## 23 5.30 14 presente S 0.59
## 24 5.80 14 ausente S 0.49
## 25 4.25 13 presente S 0.32
## 26 4.18 15 presente S 0.24
## 27 4.55 16 ausente S 0.80
## 28 5.70 13 presente S 0.91
## 29 5.06 15 presente S 0.32
## 30 4.15 13 presente S 0.40
## 31 5.32 15 presente S 0.19
## 32 4.69 18 presente S 0.78
## 33 5.13 15 presente S 0.77
## 34 4.40 16 ausente S 0.15
## 35 6.50 15 ausente S 0.14
## 36 4.54 12 ausente S 0.61
## 37 4.57 17 ausente S 0.53
## 38 4.25 15 ausente S 0.25
## 39 4.36 15 ausente S 0.44
## 40 5.53 19 presente S 0.36
## 41 2.78 17 presente PA 0.27
## 42 4.09 14 presente PA 0.39
## 43 4.01 16 presente PA 0.50
## 44 6.31 16 presente PA 0.63
## 45 4.25 18 ausente PA 0.44
## 46 4.52 11 presente PA 0.88
## 47 3.90 16 presente PA 0.40
## 48 6.25 15 ausente PA 0.22
## 49 5.72 15 presente PA 0.09
## 50 4.27 14 ausente PA 0.17
## 51 6.23 15 ausente PA 0.93
## 52 5.84 19 ausente PA 0.24
## 53 5.25 18 ausente PA 0.35
## 54 3.96 16 presente PA 0.49
## 55 4.39 17 ausente PA 0.54
## 56 4.99 12 ausente PA 0.70
## 57 5.25 17 presente PA 0.02
## 58 3.64 16 ausente PA 0.48
## 59 4.22 12 presente PA 0.13
## 60 4.98 17 presente PA 0.26
## 61 4.79 13 presente PA 0.76
## 62 3.17 18 ausente PA 0.86
## 63 6.17 17 ausente PA 0.11
## 64 4.78 15 presente PA 0.83
## 65 4.10 13 presente PA 0.26
## 66 5.21 16 ausente PA 0.35
## 67 4.90 19 ausente PA 0.51
## 68 4.93 14 ausente PA 0.73
## 69 5.57 16 presente PA 0.99
## 70 5.48 18 ausente PA 0.56
## 71 5.72 18 presente PA 0.04
## 72 4.50 20 presente PA 0.42
## 73 5.11 19 ausente PA 0.94
## 74 6.01 17 ausente PA 0.40
## 75 5.62 16 ausente PA 0.57
## 76 4.51 17 presente PA 0.97
## 77 6.04 16 presente PA 0.43
## 78 6.66 15 ausente PA 0.51
## 79 4.02 17 presente PA 0.25
## 80 4.35 15 presente PA 0.05
## 81 6.13 16 ausente MA 0.58
## 82 5.20 15 presente MA 0.17
## 83 5.02 18 presente MA 0.89
## 84 6.02 14 ausente MA 0.51
## 85 4.25 15 presente MA 0.84
## 86 5.96 14 ausente MA 0.32
## 87 4.82 15 presente MA 0.54
## 88 6.03 18 ausente MA 0.63
## 89 4.19 17 ausente MA 0.38
## 90 5.34 14 ausente MA 0.57
## 91 4.67 18 presente MA 0.36
## 92 3.56 17 ausente MA 0.94
## 93 5.37 18 ausente MA 0.92
## 94 5.49 18 ausente MA 0.71
## 95 5.59 18 ausente MA 0.48
## 96 4.20 16 presente MA 0.80
## 97 5.22 15 presente MA 0.74
## 98 4.73 16 presente MA 0.20
## 99 6.06 14 presente MA 0.80
## 100 5.77 14 ausente MA 0.29
## 101 5.07 13 ausente MA 0.10
## 102 5.81 18 ausente MA 0.15
## 103 5.55 17 ausente MA 0.72
## 104 4.27 15 presente MA 0.96
## 105 5.00 17 ausente MA 0.09
## 106 5.19 16 presente MA 0.62
## 107 5.18 17 ausente MA 0.85
## 108 4.33 15 ausente MA 0.77
## 109 5.22 18 ausente MA 0.35
## 110 5.15 17 presente MA 0.42
## 111 5.24 17 ausente MA 0.57
## 112 3.69 17 presente MA 0.11
## 113 5.43 14 ausente MA 0.43
## 114 5.83 16 ausente MA 0.93
## 115 6.03 17 ausente MA 0.28
## 116 3.64 20 ausente MA 0.25
## 117 5.95 16 ausente MA 0.65
## 118 5.13 18 presente MA 1.00
## 119 4.35 15 presente MA 0.01
## 120 4.88 16 ausente MA 0.85
##5.
dplyr::select(tib.c, starts_with("FI"))
## data frame with 0 columns and 120 rows
##6.
dplyr::select(tib.c, starts_with("FI")& ends_with(".d"))
## data frame with 0 columns and 120 rows
##7.
order<-tib.c %>%
group_by(estatus) %>%
select(biomasa)
## Adding missing grouping variables: `estatus`
##8
var.estatus <- tib.c %>%
arrange(desc(biomasa), by_group = TRUE)
head(var.estatus)
## biomasa flores.r flores.d hojas.d plaga estatus fertilizacion
## 1 7.01 16 14 235 ausente S 0.29
## 2 6.66 15 11 9 ausente PA 0.51
## 3 6.50 15 16 261 ausente S 0.14
## 4 6.47 17 8 35 ausente S 0.78
## 5 6.31 16 10 177 presente PA 0.63
## 6 6.25 15 12 208 ausente PA 0.22
##9*.
#flores_MA<-tib.c%%
# select_at(starts_with("estatus"))
#filter(estatus == "MA")
#head(flores_MA)
#10*
filter(tib.c, biomasa >5)
## biomasa flores.r flores.d hojas.d plaga estatus fertilizacion
## 1 6.22 17 11 8 presente S 0.36
## 2 5.26 13 6 186 presente S 0.89
## 3 5.43 17 9 257 presente S 0.26
## 4 5.29 18 13 38 presente S 0.89
## 5 7.01 16 14 235 ausente S 0.29
## 6 5.44 19 12 19 presente S 0.95
## 7 5.78 18 12 78 ausente S 0.16
## 8 6.47 17 8 35 ausente S 0.78
## 9 5.29 14 14 60 ausente S 0.95
## 10 5.52 17 9 230 ausente S 0.16
## 11 5.28 15 10 43 ausente S 0.69
## 12 5.30 14 15 111 presente S 0.59
## 13 5.80 14 10 205 ausente S 0.49
## 14 5.70 13 11 231 presente S 0.91
## 15 5.06 15 13 87 presente S 0.32
## 16 5.32 15 10 31 presente S 0.19
## 17 5.13 15 9 258 presente S 0.77
## 18 6.50 15 16 261 ausente S 0.14
## 19 5.53 19 12 27 presente S 0.36
## 20 6.31 16 10 177 presente PA 0.63
## 21 6.25 15 12 208 ausente PA 0.22
## 22 5.72 15 11 179 presente PA 0.09
## 23 6.23 15 9 202 ausente PA 0.93
## 24 5.84 19 14 169 ausente PA 0.24
## 25 5.25 18 10 174 ausente PA 0.35
## 26 5.25 17 13 28 presente PA 0.02
## 27 6.17 17 12 285 ausente PA 0.11
## 28 5.21 16 11 62 ausente PA 0.35
## 29 5.57 16 7 89 presente PA 0.99
## 30 5.48 18 13 211 ausente PA 0.56
## 31 5.72 18 13 140 presente PA 0.04
## 32 5.11 19 13 108 ausente PA 0.94
## 33 6.01 17 12 220 ausente PA 0.40
## 34 5.62 16 8 216 ausente PA 0.57
## 35 6.04 16 12 189 presente PA 0.43
## 36 6.66 15 11 9 ausente PA 0.51
## 37 6.13 16 11 289 ausente MA 0.58
## 38 5.20 15 15 41 presente MA 0.17
## 39 5.02 18 8 117 presente MA 0.89
## 40 6.02 14 9 219 ausente MA 0.51
## 41 5.96 14 9 75 ausente MA 0.32
## 42 6.03 18 6 201 ausente MA 0.63
## 43 5.34 14 8 252 ausente MA 0.57
## 44 5.37 18 8 68 ausente MA 0.92
## 45 5.49 18 14 160 ausente MA 0.71
## 46 5.59 18 7 6 ausente MA 0.48
## 47 5.22 15 9 137 presente MA 0.74
## 48 6.06 14 12 161 presente MA 0.80
## 49 5.77 14 14 284 ausente MA 0.29
## 50 5.07 13 11 157 ausente MA 0.10
## 51 5.81 18 11 287 ausente MA 0.15
## 52 5.55 17 11 198 ausente MA 0.72
## 53 5.19 16 12 147 presente MA 0.62
## 54 5.18 17 6 97 ausente MA 0.85
## 55 5.22 18 15 15 ausente MA 0.35
## 56 5.15 17 14 132 presente MA 0.42
## 57 5.24 17 9 181 ausente MA 0.57
## 58 5.43 14 8 269 ausente MA 0.43
## 59 5.83 16 11 207 ausente MA 0.93
## 60 6.03 17 4 58 ausente MA 0.28
## 61 5.95 16 14 125 ausente MA 0.65
## 62 5.13 18 14 156 presente MA 1.00
#head(bio5)
#11
filter (tib.c, fertilizacion=="FO"| estatus=="PA")
## biomasa flores.r flores.d hojas.d plaga estatus fertilizacion
## 1 2.78 17 11 178 presente PA 0.27
## 2 4.09 14 9 22 presente PA 0.39
## 3 4.01 16 13 74 presente PA 0.50
## 4 6.31 16 10 177 presente PA 0.63
## 5 4.25 18 12 243 ausente PA 0.44
## 6 4.52 11 10 209 presente PA 0.88
## 7 3.90 16 10 222 presente PA 0.40
## 8 6.25 15 12 208 ausente PA 0.22
## 9 5.72 15 11 179 presente PA 0.09
## 10 4.27 14 7 40 ausente PA 0.17
## 11 6.23 15 9 202 ausente PA 0.93
## 12 5.84 19 14 169 ausente PA 0.24
## 13 5.25 18 10 174 ausente PA 0.35
## 14 3.96 16 6 245 presente PA 0.49
## 15 4.39 17 12 134 ausente PA 0.54
## 16 4.99 12 10 297 ausente PA 0.70
## 17 5.25 17 13 28 presente PA 0.02
## 18 3.64 16 8 221 ausente PA 0.48
## 19 4.22 12 6 36 presente PA 0.13
## 20 4.98 17 10 172 presente PA 0.26
## 21 4.79 13 6 24 presente PA 0.76
## 22 3.17 18 12 188 ausente PA 0.86
## 23 6.17 17 12 285 ausente PA 0.11
## 24 4.78 15 14 277 presente PA 0.83
## 25 4.10 13 7 98 presente PA 0.26
## 26 5.21 16 11 62 ausente PA 0.35
## 27 4.90 19 7 253 ausente PA 0.51
## 28 4.93 14 11 105 ausente PA 0.73
## 29 5.57 16 7 89 presente PA 0.99
## 30 5.48 18 13 211 ausente PA 0.56
## 31 5.72 18 13 140 presente PA 0.04
## 32 4.50 20 13 73 presente PA 0.42
## 33 5.11 19 13 108 ausente PA 0.94
## 34 6.01 17 12 220 ausente PA 0.40
## 35 5.62 16 8 216 ausente PA 0.57
## 36 4.51 17 5 238 presente PA 0.97
## 37 6.04 16 12 189 presente PA 0.43
## 38 6.66 15 11 9 ausente PA 0.51
## 39 4.02 17 8 276 presente PA 0.25
## 40 4.35 15 14 135 presente PA 0.05
##12
filter (tib.c, fertilizacion=="FI"| estatus=="PA")
## biomasa flores.r flores.d hojas.d plaga estatus fertilizacion
## 1 2.78 17 11 178 presente PA 0.27
## 2 4.09 14 9 22 presente PA 0.39
## 3 4.01 16 13 74 presente PA 0.50
## 4 6.31 16 10 177 presente PA 0.63
## 5 4.25 18 12 243 ausente PA 0.44
## 6 4.52 11 10 209 presente PA 0.88
## 7 3.90 16 10 222 presente PA 0.40
## 8 6.25 15 12 208 ausente PA 0.22
## 9 5.72 15 11 179 presente PA 0.09
## 10 4.27 14 7 40 ausente PA 0.17
## 11 6.23 15 9 202 ausente PA 0.93
## 12 5.84 19 14 169 ausente PA 0.24
## 13 5.25 18 10 174 ausente PA 0.35
## 14 3.96 16 6 245 presente PA 0.49
## 15 4.39 17 12 134 ausente PA 0.54
## 16 4.99 12 10 297 ausente PA 0.70
## 17 5.25 17 13 28 presente PA 0.02
## 18 3.64 16 8 221 ausente PA 0.48
## 19 4.22 12 6 36 presente PA 0.13
## 20 4.98 17 10 172 presente PA 0.26
## 21 4.79 13 6 24 presente PA 0.76
## 22 3.17 18 12 188 ausente PA 0.86
## 23 6.17 17 12 285 ausente PA 0.11
## 24 4.78 15 14 277 presente PA 0.83
## 25 4.10 13 7 98 presente PA 0.26
## 26 5.21 16 11 62 ausente PA 0.35
## 27 4.90 19 7 253 ausente PA 0.51
## 28 4.93 14 11 105 ausente PA 0.73
## 29 5.57 16 7 89 presente PA 0.99
## 30 5.48 18 13 211 ausente PA 0.56
## 31 5.72 18 13 140 presente PA 0.04
## 32 4.50 20 13 73 presente PA 0.42
## 33 5.11 19 13 108 ausente PA 0.94
## 34 6.01 17 12 220 ausente PA 0.40
## 35 5.62 16 8 216 ausente PA 0.57
## 36 4.51 17 5 238 presente PA 0.97
## 37 6.04 16 12 189 presente PA 0.43
## 38 6.66 15 11 9 ausente PA 0.51
## 39 4.02 17 8 276 presente PA 0.25
## 40 4.35 15 14 135 presente PA 0.05
##13.
filter (tib.c, flores.d > median (flores.d)& plaga == "ausente")
## biomasa flores.r flores.d hojas.d plaga estatus fertilizacion
## 1 4.55 12 11 16 ausente S 0.90
## 2 4.55 15 12 54 ausente S 0.89
## 3 4.68 15 15 282 ausente S 0.93
## 4 4.01 17 12 119 ausente S 0.44
## 5 7.01 16 14 235 ausente S 0.29
## 6 5.78 18 12 78 ausente S 0.16
## 7 5.29 14 14 60 ausente S 0.95
## 8 6.50 15 16 261 ausente S 0.14
## 9 4.54 12 12 236 ausente S 0.61
## 10 4.25 15 15 82 ausente S 0.25
## 11 4.25 18 12 243 ausente PA 0.44
## 12 6.25 15 12 208 ausente PA 0.22
## 13 5.84 19 14 169 ausente PA 0.24
## 14 4.39 17 12 134 ausente PA 0.54
## 15 3.17 18 12 188 ausente PA 0.86
## 16 6.17 17 12 285 ausente PA 0.11
## 17 5.21 16 11 62 ausente PA 0.35
## 18 4.93 14 11 105 ausente PA 0.73
## 19 5.48 18 13 211 ausente PA 0.56
## 20 5.11 19 13 108 ausente PA 0.94
## 21 6.01 17 12 220 ausente PA 0.40
## 22 6.66 15 11 9 ausente PA 0.51
## 23 6.13 16 11 289 ausente MA 0.58
## 24 4.19 17 15 109 ausente MA 0.38
## 25 5.49 18 14 160 ausente MA 0.71
## 26 5.77 14 14 284 ausente MA 0.29
## 27 5.07 13 11 157 ausente MA 0.10
## 28 5.81 18 11 287 ausente MA 0.15
## 29 5.55 17 11 198 ausente MA 0.72
## 30 4.33 15 12 254 ausente MA 0.77
## 31 5.22 18 15 15 ausente MA 0.35
## 32 5.83 16 11 207 ausente MA 0.93
## 33 5.95 16 14 125 ausente MA 0.65
## 34 4.88 16 12 260 ausente MA 0.85
##14.
filter(tib.c, hojas.d > median (hojas.d, na.rm = TRUE) & plaga=="presente")
## biomasa flores.r flores.d hojas.d plaga estatus fertilizacion
## 1 5.26 13 6 186 presente S 0.89
## 2 5.43 17 9 257 presente S 0.26
## 3 4.09 17 9 283 presente S 0.06
## 4 4.58 16 6 248 presente S 0.03
## 5 5.70 13 11 231 presente S 0.91
## 6 4.15 13 8 171 presente S 0.40
## 7 4.69 18 9 166 presente S 0.78
## 8 5.13 15 9 258 presente S 0.77
## 9 2.78 17 11 178 presente PA 0.27
## 10 6.31 16 10 177 presente PA 0.63
## 11 4.52 11 10 209 presente PA 0.88
## 12 3.90 16 10 222 presente PA 0.40
## 13 5.72 15 11 179 presente PA 0.09
## 14 3.96 16 6 245 presente PA 0.49
## 15 4.98 17 10 172 presente PA 0.26
## 16 4.78 15 14 277 presente PA 0.83
## 17 4.51 17 5 238 presente PA 0.97
## 18 6.04 16 12 189 presente PA 0.43
## 19 4.02 17 8 276 presente PA 0.25
## 20 4.67 18 15 273 presente MA 0.36
## 21 6.06 14 12 161 presente MA 0.80
## 22 3.69 17 13 170 presente MA 0.11
##15*
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 flores.r flores.d hojas.d plaga estatus fertilizacion
## 1 5.29 18 13 38 presente S 0.89
## 2 7.01 16 14 235 ausente S 0.29
## 3 4.01 16 13 74 presente PA 0.50
## 4 5.84 19 14 169 ausente PA 0.24
## 5 5.25 17 13 28 presente PA 0.02
## 6 5.48 18 13 211 ausente PA 0.56
## 7 5.72 18 13 140 presente PA 0.04
## 8 4.50 20 13 73 presente PA 0.42
## 9 5.11 19 13 108 ausente PA 0.94
## 10 4.19 17 15 109 ausente MA 0.38
## 11 4.67 18 15 273 presente MA 0.36
## 12 5.49 18 14 160 ausente MA 0.71
## 13 5.22 18 15 15 ausente MA 0.35
## 14 5.15 17 14 132 presente MA 0.42
## 15 3.69 17 13 170 presente MA 0.11
## 16 5.95 16 14 125 ausente MA 0.65
## 17 5.13 18 14 156 presente MA 1.00
#16*.
library(scales)
##
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
##
## discard
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 12 11 16 0.2 0.6666667
## 2 15 12 54 0.5 0.7333333
## 3 17 11 8 0.7 0.6666667
## 4 13 6 186 0.3 0.3333333
## 5 15 15 282 0.5 0.9333333
## 6 17 9 257 0.7 0.5333333
## hojas.d_estandar
## 1 0.034364261
## 2 0.164948454
## 3 0.006872852
## 4 0.618556701
## 5 0.948453608
## 6 0.862542955
#17*.
tib.e = tib.c %>%
mutate(flores.r/flores.d)
head (tib.e)
## biomasa flores.r flores.d hojas.d plaga estatus fertilizacion
## 1 4.55 12 11 16 ausente S 0.90
## 2 4.55 15 12 54 ausente S 0.89
## 3 6.22 17 11 8 presente S 0.36
## 4 5.26 13 6 186 presente S 0.89
## 5 4.68 15 15 282 ausente S 0.93
## 6 5.43 17 9 257 presente S 0.26
## flores.r/flores.d
## 1 1.090909
## 2 1.250000
## 3 1.545455
## 4 2.166667
## 5 1.000000
## 6 1.888889
##18.
rangomin <- tib.e %>% group_by (plaga) %>% select("flores.r/flores.d") %>% filter_at(vars("flores.r/flores.d"),
all_vars(. == min(.))
); rangomin
## Adding missing grouping variables: `plaga`
## # A tibble: 2 x 2
## # Groups: plaga [2]
## plaga `flores.r/flores.d`
## <chr> <dbl>
## 1 presente 0.933
## 2 ausente 0.938
##19.
names(tib.e)
## [1] "biomasa" "flores.r" "flores.d"
## [4] "hojas.d" "plaga" "estatus"
## [7] "fertilizacion" "flores.r/flores.d"
tib.e_rename <- rename (tib.e, "flores.r.e" = flores.r, "flores.d.e" = flores.d, "hojas.d.e" = hojas.d); names(tib.e_rename)
## [1] "biomasa" "flores.r.e" "flores.d.e"
## [4] "hojas.d.e" "plaga" "estatus"
## [7] "fertilizacion" "flores.r/flores.d"
#20.
#tib.e_MAYUS <- select_all(tib.e_rename , toupper); names(tib.e_mayus)
#21.
tib.i%>%
summarise(mean(biomasa),N_datos=n())
## mean(biomasa) N_datos
## 1 5.005333 90
#22.
tib.i%>%
group_by(fertilizacion) %>%
summarise(mean(biomasa),N_datos=n())
## # A tibble: 63 x 3
## fertilizacion `mean(biomasa)` N_datos
## <dbl> <dbl> <int>
## 1 0.01 4.35 1
## 2 0.03 4.58 1
## 3 0.04 5.72 1
## 4 0.05 4.35 1
## 5 0.06 4.09 1
## 6 0.07 5 1
## 7 0.09 5.36 2
## 8 0.1 5.07 1
## 9 0.11 4.93 2
## 10 0.13 4.22 1
## # ... with 53 more rows
#23.
tib.i%>%
group_by(fertilizacion) %>%
summarise(Q.10=quantile(tib.i$biomasa,0.10), Q.20=quantile(tib.i$biomasa,0.20), Q.30=quantile(tib.i$biomasa,0.30), Q.40=quantile(tib.i$biomasa,0.40),Q.50=quantile(tib.i$biomasa,0.50))
## # A tibble: 63 x 6
## fertilizacion Q.10 Q.20 Q.30 Q.40 Q.50
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.01 4.01 4.25 4.48 4.69 5.06
## 2 0.03 4.01 4.25 4.48 4.69 5.06
## 3 0.04 4.01 4.25 4.48 4.69 5.06
## 4 0.05 4.01 4.25 4.48 4.69 5.06
## 5 0.06 4.01 4.25 4.48 4.69 5.06
## 6 0.07 4.01 4.25 4.48 4.69 5.06
## 7 0.09 4.01 4.25 4.48 4.69 5.06
## 8 0.1 4.01 4.25 4.48 4.69 5.06
## 9 0.11 4.01 4.25 4.48 4.69 5.06
## 10 0.13 4.01 4.25 4.48 4.69 5.06
## # ... with 53 more rows
#24*
#25*
#26*