Skip to content

Instantly share code, notes, and snippets.

View RCura's full-sized avatar

Robin Cura RCura

View GitHub Profile
@RCura
RCura / server.R
Created August 18, 2014 13:25
Shiny : Bug with updateSliderInput()
library(shiny)
shinyServer(function(input, output, session) {
# Keep general informations
userTabsInfo <- reactiveValues()
userTabsInfo$selectedTabTitle <- NULL # latest created tab
userTabsInfo$tabsOrder <- list('firstTab') # list of tabs in the order of their creation
@RCura
RCura / shinyApp.R
Created May 20, 2014 10:29
Shiny / R : csv to shapefile
require(shiny)
require(sp)
require(rgdal)
runApp(
list(
ui = bootstrapPage(
fileInput('inputdata', 'Input file',accept=c('.csv')),
plotOutput("xyPlot"),
downloadButton('downloadShp', 'DownloadSHP')
),
output$downloadShp <- downloadHandler(
filename = 'fbCrawlExport.zip',
content = function(file) {
if (length(Sys.glob("fbCrawl.*"))>0){
file.remove(Sys.glob("fbCrawl.*"))
}
writeOGR(getGeoContent(), dsn="fbCrawl.shp", layer="fbCrawl", driver="ESRI Shapefile")
write.csv(as.data.frame(cbind(getGeoContent()@data, as.data.frame(getGeoContent()@coords))), "fbCrawl.csv")
zip(zipfile='fbCrawlExport.zip', files=Sys.glob("fbCrawl.*"))
file.copy("fbCrawlExport.zip", file)
tabPanel("Maps",
tags$div(class="span4",selectInput("LatColumnSelected", "Latitude column :",choices="", multiple=FALSE)),
tags$div(class="span4",selectInput("LongColumnSelected", "Longitude column:",choices="", multiple=FALSE)),
selectInput('sizeAttribute', 'Scales points on :', choices="", multiple=FALSE),
htmlOutput('webmap'),
div(id='map',style='width: 100%; height: 600px;'),
div(id='status'),
sliderInput('maxSize', 'Max. point size', value=25, min=1, max=100),
plotOutput('ggmap')),
library(shiny)
require(maptools)
shinyServer(function(input, output) {
uploadShpfile <- reactive({
if (!is.null(input$shpFile)){
shpDF <- input$shpFile
prevWD <- getwd()
uploadDirectory <- dirname(shpDF$datapath[1])
<GDAL_WMS>
<Service name="TMS">
<ServerUrl>http://a.tiles.mapbox.com/v3/adrienvh.hf43flld/${z}/${x}/${y}.png</ServerUrl>
</Service>
<DataWindow>
<UpperLeftX>-20037508.34</UpperLeftX>
<UpperLeftY>20037508.34</UpperLeftY>
<LowerRightX>20037508.34</LowerRightX>
<LowerRightY>-20037508.34</LowerRightY>
<TileLevel>18</TileLevel>
@RCura
RCura / server.R
Last active December 25, 2015 09:09
Align table and buttons in Shiny
shinyServer(function(input, output,session) {
output$Fbuttons <- renderUI({
outlist <- list(verbatimTextOutput("Decrease"))
posButtons <- lapply(1:input$n, function(i) {
actionButton(paste0("btnF",i), "+")
})
outlist <- c(outlist, posButtons)
})
library(shiny)
shinyServer(function(input, output) {
output$webmap <- renderUI({
tags$script(sprintf('console.log(%d);', input$obs))
})
})
outputObj <- ""
brew(mapTemplate, output=textConnection("outputObj"))
return(outputObj)
returns :
Erreur dans brew(mapTemplate, output = textConnection("outputObj")) :
output connection is not writeable
<script type="text/javascript">
var map, selectControl, selectedFeature;
function onPopupClose(evt) {
selectControl.unselect(selectedFeature);
};
function onFeatureSelect(feature) {
selectedFeature = feature;