I am trying to filter my database to project the correct location of the apartments based on rental cost in Rshiny. But I keep receiving an error Error in if: missing value where TRUE/FALSE needed.
I am not too sure where the code went wrong.
UI
sliderInput("RentCost", "Rental Cost:",
min = 0, max = 2000, value = 100
),
Server
buildingData <- reactive (
{
residential_data_sf %>%
filter (`Rental Cost` <= input$RentCost)
}
)
Output
tm_shape(buildingData()) +
tm_bubbles (
col = "Shared Apartment",
size = "Rental Cost",
border.col = "black",
border.lwd = 1
)
Apartment Details in DPUT(Head)
structure(list(`Apartment ID` = c(1, 2, 3, 4, 5, 6), `Rental Cost` = c(768.16,
1014.55, 1057.39, 1259.1, 411.5, 859.58), Region = c("South",
"South", "East", "East", "South", "East"), geometry = structure(list(
structure(list(structure(c(1066.10838104037, 1105.7151133168,
1089.28750782269, 1049.68077554626, 1066.10838104037, 709.382909403734,
703.787665138951, 587.502523336757, 593.09776760154, 709.382909403734
), dim = c(5L, 2L))), class = c("XY", "POLYGON", "sfg")),
structure(list(structure(c(-154.286315321707, -148.04493467673,
-288.23808515368, -288.593034919988, -190.784844036364, -203.303918195384,
-239.825531721312, -238.853792308071, -278.845945883648,
-280.654617432266, -168.728938630421, -154.286315321707,
1563.54806719816, 1470.77125644069, 1469.52716930795, 1509.52559441023,
1510.39355344633, 1620.04050724593, 1621.32064482673, 1572.26770767792,
1571.4754625218, 1662.77633041731, 1658.85316673809, 1563.54806719816
), dim = c(12L, 2L))), class = c("XY", "POLYGON", "sfg")),
structure(list(structure(c(2104.28955272338, 2144.280146607,
2141.73881835514, 2101.74822447152, 2104.28955272338, 5185.76913461207,
5184.90172419298, 5067.73777987393, 5068.60519029303, 5185.76913461207
), dim = c(5L, 2L))), class = c("XY", "POLYGON", "sfg")),
structure(list(structure(c(2137.10187767258, 2080.3660601155,
2080.26443313323, 2177.75453283414, 2176.39939507571, 2075.52296640997,
2076.27363919139, 2137.10187767258, 4250.30064414455, 4250.15649643118,
4290.15636733043, 4290.40405874571, 4206.46512455798, 4208.35858775223,
4248.35154326161, 4250.30064414455), dim = c(8L, 2L))), class = c("XY",
"POLYGON", "sfg")), structure(list(structure(c(50.743854482575,
-7.98743404227132, -39.9371702113566, 10.9542113748137, 12.1741764135598,
52.1640854064344, 50.743854482575, 87.8315063758449, 6.01671816029014,
30.0835908014507, 97.6439356456564, 151.945575251771, 151.047143984726,
87.8315063758449), dim = c(7L, 2L))), class = c("XY", "POLYGON",
"sfg")), structure(list(structure(c(2332.02764694872, 2335.77335276496,
2276.91500743698, 2284.51456250385, 2165.68106639359, 2174.89768045119,
2332.02764694872, 5303.47852749332, 5263.65429256108, 5258.11831561627,
5228.94577798365, 5197.98920818328, 5288.69952093068, 5303.47852749332
), dim = c(7L, 2L))), class = c("XY", "POLYGON", "sfg"))), class = c("sfc_POLYGON",
"sfc"), precision = 0, bbox = structure(c(xmin = -288.593034919988,
ymin = 6.01671816029014, xmax = 2335.77335276496, ymax = 5303.47852749332
), class = "bbox"), crs = structure(list(input = NA_character_,
wkt = NA_character_), class = "crs"), n_empty = 0L), Vacancy = c("False",
"False", "True", "True", "False", "True"), `Shared Apartment` = c("False",
"False", "False", "False", "False", "False")), row.names = c(NA,
-6L), sf_column = "geometry", agr = structure(c(`Apartment ID` = NA_integer_,
`Rental Cost` = NA_integer_, Region = NA_integer_, Vacancy = NA_integer_,
`Shared Apartment` = NA_integer_), levels = c("constant", "aggregate",
"identity"), class = "factor"), class = c("sf", "tbl_df", "tbl",
"data.frame"))