我有一个带有属性的矩阵,当你删除每行中的非ui = dashboardPage(
dashboardHeader(title="Deteccao de arvores individuais de LiDAR em Shiny App - R", align="center"),
dashboardSidebar(
sidebarMenu(
menuItem("Defina seus parametros e preferencias")),
sidebarLayout(
sidebarPanel(
fileInput('layer', 'Select the CHM.asc file', multiple=FALSE, accept='asc', width = "350px"),
selectInput("fws", "Select the size of windows to find trees", choices = c("3x3"= (fws<-3), "5x5"= (fws<-5), "7x7"= (fws<-7)), width = "350px"),
wellPanel(checkboxInput("checkbox", "Would you like to apply the smoothing model for canopy?", value = FALSE, width = "350px"), selectInput("sws", "Select the size of the smoothing window for trees", choices = c("3x3" = (sws<-3), "5x5" = (sws<-5), "7x7"=(sws<-7)), width = "350px")),
checkboxInput("checkp", "Plot individual trees detected in CHM", value=FALSE, width="350px"),
checkboxInput("checkpd", "Download the shapefile (.shp) of Individual trees detected", value = FALSE, width = "350px"), uiOutput("shapefile"),
actionButton("action", "RUN!")))
),
dashboardBody(
fluidRow(
tabBox(side="right", height = "500px",
tabPanel("Visualization of CHM", plotOutput("mapPlot")),
tabPanel("Trees detected from rLiDAR", tableOutput("arvlist"), downloadButton("downList", "Download Tree List")),
tabPanel("Summary of LiDAR metrics", tableOutput("sumy"), downloadButton("downSumy", "Download Summary of LiDAR metrics")),
tabPanel("Profile of height model", plotOutput("hist"), downloadButton("downHist", "Download Height's Histogram of Density")), #histograma de densidade
tabPanel("Individual trees detected - Model 2D of CHM", plotOutput("plotTrees"), downloadButton("downDetec", "Download CHM of Trees Detected"))
)
))
)
条目时,你会留下一个较小的矩形矩阵。例如:
NA
是矩阵:
is_na_mat <- structure(c(TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE,
FALSE, TRUE, FALSE, TRUE), .Dim = c(4L, 3L))
tmp_b <- matrix(nrow = 4, ncol = 3)
tmp_b[!is_na_mat] <- 0
删除 [,1] [,2] [,3]
[1,] NA NA 0
[2,] 0 NA NA
[3,] NA NA 0
[4,] NA 0 NA
的非NA
条目会为您留下tmp_b
的4x2子矩阵矩阵。
我希望用NA
替换这个子矩阵,矩阵:
tmp_a
以便得到的矩阵是:
tmp_a <- cbind(1:4,-(1:4))
[,1] [,2]
[1,] 1 -1
[2,] 2 -2
[3,] 3 -3
[4,] 4 -4
我有 [,1] [,2] [,3]
[1,] 1 -1 0
[2,] 0 2 -2
[3,] 3 -3 0
[4,] 4 0 -4
但这会产生:
tmp_b[is_na_mat] <- tmp_a
这是错误的,因为索引到> tmp_b
[,1] [,2] [,3]
[1,] 1 4 0
[2,] 0 -1 -3
[3,] 2 -2 0
[4,] 3 0 -4
会导致tmp_b
条目按列顺序替换。