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,24,replace = F);muestras
##  [1]  895 1163   42   41  149 1536 1026 1424  401  554  723  171   57 1153  489
## [16]  773 1156 1496  427 1525  539  411 1039  563
xy<-expand.grid(x=seq(1,25), y=seq(1,50));
plot(xy[muestras,], pch=15,col="firebrick", main = "Resultados=Muestreo aleatorio cultivo de puerro");
points(xy[-muestras,], pch=22,col="darkslategray3")
legend("topleft",c("Plantas no muestreadas", "Plantas muestreadas"), fill=c("darkslategray3","red"))

library(readxl)
Premuestreo_plagas <- read_excel("C:/Users/luisc/Downloads/Premuestreo plagas.xlsx", 
    sheet = "premuestreo plagas")
## New names:
## * `` -> ...1
#presente = 1 , Ausente = 0

mode<- function(x){
  
}

mode(x)
## NULL

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.