The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
The algo
package allows you to implement the Algolia Places Address
Search Auto Completion Menu on shiny Text Inputs.
In order to use the Algolia Places JavaScript library, you’ll need create a free Places application in which you can get an ID and an API KEY. When you sign up, you’ll be able to run 100,000 requests/month which is quite cool for most users.
After that, set your credentials within the .Renviron file which can be opened with:
# install.packages("usethis")
::edit_r_environ() usethis
Then, store the value of your credentials as follows:
# These credentials are fakes and used to give you an idea
= LSKDFNSFSD
ALGOLIA_ID
= 29453SKVNEV43T3G3KVEEV ALGOLIA_KEY
Finally, save your .Renviron file, close it and restart your R session.
You can install the development version of algo
from
Github with:
# install.packages("remotes")
::install_github("feddelegrand7/algo") remotes
The algo
package has two functions:
use_algolia()
: you must put the
use_algolia()
function at the beginning of your shiny UI.
It doesn’t take any argument. It only allows you to activate the Algolia
Places JavaScript library.
algo()
: you’ll implement an address search auto
completion menu on any shiny text input using this function.
Let’s create a basic shiny application to demonstrate the features of the package:
library(shiny)
library(algo)
<- fluidPage(
ui
use_algolia(),
textInput(inputId = "inp1", label = "Please introduce your address", width = "800px"),
algo(element = "#inp1", type = "address") # Don't forget to add the # to your ID
)
<- function(input, output) {}
server
shinyApp(ui, server)
Using the type
argument you can specify which type of
geographic information to collect:
library(shiny)
library(algo)
<- fluidPage(
ui
use_algolia(),
textInput(inputId = "inp1", label = "Please introduce your country", width = "800px"),
textInput(inputId = "inp2", label = "Now introduce your city", width = "800px"),
algo(element = "#inp1", type = "country"), # Don't forget to add the # to your ID
algo(element = "#inp2", type = "city")
)
<- function(input, output) {}
server
shinyApp(ui, server)
You can also specify in which country (or countries) you want to get the addresses. This will set a delimitation according to the chosen country:
library(shiny)
library(algo)
<- fluidPage(
ui
use_algolia(),
textInput(inputId = "inp1", label = "Where do you live in Japon ?", width = "800px"),
algo(element = "#inp1", type = "address", countries = "jp") # Don't forget to add the # to your ID
)
<- function(input, output) {}
server
shinyApp(ui, server)
Further, you can specify which language should be displayed when collecting the addresses (note that it will only translate partially the addresses):
library(shiny)
library(algo)
<- fluidPage(
ui
use_algolia(),
textInput(inputId = "inp1", label = "Where do you live in Spain ?", width = "800px"),
algo(element = "#inp1", type = "city", countries = "es", language = "de") # Don't forget to add the # to your ID
)
<- function(input, output) {}
server
shinyApp(ui, server)
Finally, you can collect the addresses the same way as any other shiny inputs:
library(shiny)
library(algo)
<- fluidPage(
ui
use_algolia(),
textInput(inputId = "inp1", label = "Where do you live in Spain ?", width = "800px"),
algo(element = "#inp1", type = "city", countries = "es", language = "de"), # Don't forget to add the # to your ID
textOutput(outputId = "txt1")
)
<- function(input, output) {
server
$txt1 <- renderText({
output
req(input$inp1)
paste0("I KNOW WHERE YOU LIVE O_O: ", input$inp1)
})
}
shinyApp(ui, server)
Please note that the algo project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.