NPlantas= round((4635)*(1/(0.5*0.3)))
NPlantas
## [1] 30900
NPlantas=47100
p=0.5
n=ceiling(NPlantas*p*(1-p)/((NPlantas-1)*(0.05/1.96)^2+p*(1-p)));n
## [1] 382
muestras<-sample(1580,124,replace = F);muestras
##   [1]  411  184 1220  507  964  842 1433 1214  770 1498 1077  654  338 1038 1098
##  [16] 1357  804  175  368  879  916  504  351  688  857  959   95 1551 1010  113
##  [31]  235  109  798  270 1425 1492  723  126  238 1198 1337  889 1033  147 1466
##  [46]  302  543 1461  387 1257  893  449 1137  405  906  220  221 1020 1477 1163
##  [61] 1574  687  289  203  645  762 1392 1391 1467  389  744  192 1062 1047  377
##  [76] 1383  125  998  116  997   73  725  390  236  532  118  583  776 1336  528
##  [91]  642  734 1140  497  182  383 1559  991   92  268 1044  176 1516  792 1082
## [106]  590  702  248  107  610  295 1166 1217  961  834 1442  217 1396  701  215
## [121]  563 1146 1065 1526
xy<-expand.grid(y=seq(1,55), x=seq(1,4));
plot(xy[muestras,], pch=15,col="red4", main = "Puntos de muestreo Botrytis Colombian Organics");
points(xy[-muestras,], pch=18,col="royalblue2")

muestras<-sample(1580,224,replace = F);muestras
##   [1] 1060 1334  292 1186  575  360  651 1556  409 1560  741 1102 1232 1327  627
##  [16] 1365 1196 1238 1243  119 1558  467  719   19  203  736 1432  810 1234  665
##  [31] 1248 1127 1335 1120 1258   50 1516 1470  811 1191  816  509  636    1 1205
##  [46]  303 1366 1176 1038   66  178  656 1524 1573 1224 1501  449  628 1188  630
##  [61]  250 1448 1367  954  326 1520  622  763  122  249  534 1472 1450  548  453
##  [76]  547  144 1063  225 1265 1058  994 1437  686 1000 1378  254  194 1227  751
##  [91]  812  756 1277 1376  540  168 1473 1230   58 1247 1368  796 1100  230  226
## [106] 1084 1383  820  804 1449  461  237  717  197   24 1427  941  639  578  873
## [121]  624  163  369  115  109  140  485  963 1354  515 1513  259  539 1235  772
## [136]  972  513  966  862   28 1566  428 1413  187 1221 1379 1576  995 1322 1314
## [151] 1308 1325  398 1157  561  138 1319 1572 1320 1490  690  909 1506 1499 1547
## [166] 1105 1167   70  419  649  570  164  524 1346  232 1510  899 1241   43  123
## [181]  529  869 1151   11 1116 1351 1229  737  531 1509  711  269  206  653 1098
## [196] 1153   79 1397 1331  124  985  139 1041  991  613  635   89  800  827    9
## [211] 1531 1357  307  358 1344  605  506 1040  202 1394  610 1155  631 1110
xy<-expand.grid(y=seq(1,85), x=seq(1,4));
plot(xy[muestras,], pch=15,col="red4", main = "Puntos de muestreo Botrytis Colombian Organics");
points(xy[-muestras,], pch=18,col="royalblue2")

# Generar las muestras
muestras <- sample(1580, 99, replace = FALSE)

# Crear el grid de puntos
xy <- expand.grid(y = seq(1, 55), x = seq(1, 4))

# Graficar los puntos de muestreo
plot(
  xy[muestras,],
  pch = 15,
  col = "red4",
  main = "Puntos de muestreo Botrytis Colombian Organics",
  xlab = "Distancia de la cama",
  ylab = "Lote EST/COM_1"
)

# Agregar los puntos restantes
points(xy[-muestras,], pch = 18, col = "royalblue2")

# Generar las muestras
muestras <- sample(1580, 84, replace = FALSE)

# Crear el grid de puntos
xy <- expand.grid(y = seq(1, 85), x = seq(1, 4))

# Graficar los puntos de muestreo
plot(
  xy[muestras,],
  pch = 15,
  col = "red4",
  main = "Puntos de muestreo Botrytis Colombian Organics",
  xlab = "Distancia de la cama",
  ylab = "Lote INV/COM_1"
)

# Agregar los puntos restantes
points(xy[-muestras,], pch = 18, col = "royalblue2")

#presente = 1 , Ausente = 0

mode<- function(x){
  
}

mode(x)
## NULL
# Cargar las librerías necesarias
library(ggplot2)
library(tidyr)
library(readxl)

# Cargar los datos desde el archivo Excel
datos <- read_excel("C:/Users/luisc/Downloads/Muestreo_Botrytis.xlsx")

# Filtrar los puntos muestreados
muestras <- which(datos$Muestreo == 1)

# Crear el mapa de calor
ggplot(datos, aes(X, Y, fill = Incidencia)) +
  geom_tile() +
  scale_fill_gradient(low = "white", high = "red") +
  labs(title = "Mapa de calor de incidencia de Botrytis",
       x = "Coordenada X",
       y = "Coordenada Y") +
  theme_minimal() +
  geom_point(data = datos[muestras, ], color = "red4", size = 3, shape = 15) +
  geom_point(data = datos[-muestras, ], color = "royalblue2", size = 3, shape = 18)

R Markdown

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

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

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

Including Plots

You can also embed plots, for example:

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