Open ecking opened 4 years ago
Stack overflow for the win. Nevermind!
Do you mind sharing the solution? Was it stored as a factor?
I'm not looking at the code but...
choices = c(sort(dat$StreetName))
...would likely result in thousands of selections and at least hundreds of duplicates. I imagine using unique()
would be a good start!
choices = c(sort(unique(dat$StreetName)))
Hi there! @jamisoncrawford I tried adding unique and I still received the number values.
So here is what I learned from an example on stack overflow:
dat$StreetName must be a factor rather than a character so when c() is used on a factor it strips "all information used and converts it to a simple numeric column." So basically -- dont use c(). So to convert the factor to a character value use as.character.
Here is what is left:
selectInput( inputId = "Street", label = h4("Street Name"), choices = as.character(sort(unique(dat$StreetName))), selected = c("Rural Rd"))
Not sure if that makes 100% sense. But adding as.character works wonderfully!
Ah, that makes sense! I didn't even notice function c()
when I rewrote the code, haha.
Great knowledge add - thanks for explaining this for us and others @ecking!
Hi there,
I'm perplexed. I'm trying to set up a widget where the user selects the street name. Instead of returning the street name, its only returning values 1-300+. I've done nothing to modify the code except for adding the following.