ropensci

Shiny error while using nearPoints in renderPlotly click event

早过忘川 提交于 2021-01-27 21:11:24
问题 I would like to fetch nearPoints using the data from a click event. I have found the below snippet from the Shiny webpage and it works fine as expected. output$plot <- renderPlot({ d <- data() plot(d$speed, d$dist) }) output$plot_clickedpoints <- renderPrint({ # For base graphics, we need to specify columns, though for ggplot2, # it's usually not necessary. res <- nearPoints(data(), input$plot_click, "speed", "dist") if (nrow(res) == 0) return() res }) I tried to mimic the above the approach

Error when using install_github: 'exdir' does not exist

99封情书 提交于 2020-01-11 09:15:08
问题 I am trying to install a package from github, but keep getting the following error; "Error in unzip(src, list = TRUE) : 'exdir' does not exist". I'm guessing that unzip doesn't have permission to create a directory to unzip into, but I don't know a way to pass a parameter in to the exdir argument. > require(devtools) > install_github("rvertnet", "ropensci") Installing github repo(s) rvertnet/master from ropensci Installing rvertnet.zip from https://api.github.com/repos/ropensci/rvertnet

dynamically adjust height and/or width of shiny-plotly output based on window size

瘦欲@ 提交于 2019-12-28 16:07:05
问题 I would like to have the shiny-plotly output height and width adjusted to the current window size. I have tried to use the below but of no use. ShinyUi <- fluidPage( # Application title titlePanel("title"), sidebarLayout( sidebarPanel( ... inputs ... ), mainPanel( plotlyOutput("distPlot", height = 'auto', width = 'auto') ) )) ShinyServer <- function(input, output, session) { output$distPlot <- renderPlotly({ p <- ggplot(dataShow, aes(x=dataShow$X, y=dataShow$Y)) + geom_point(shape=1, alpha =

How to load *part* of a multifeature geojson file in R?

青春壹個敷衍的年華 提交于 2019-12-12 16:18:57
问题 I have a geojson that is a FeatureCollection containing 2 geographic data types: a LineString and a waypoint - see the raw file here - this is how it looks on GitHub: I want to load only only the LineString , so this is what I do: library(RCurl) obj <- getURL("https://raw.githubusercontent.com/Robinlovelace/stplanr/master/inst/extdata/route_data.geojson") writeLines(obj, "/tmp/obj.geojson") obj <- readLines("/tmp/obj.geojson") just_lines <- obj[14:(length(obj) - 28)] just_lines[1] <- paste0("

How to search PubMed or other databases using R

Deadly 提交于 2019-12-03 13:57:23
问题 I have recently been using the excellent rplos package, which makes it very easy to search through papers hosted on the Public Library of Science (PLOS) API. I've hit a snag, in that the API itself seems to have some missing information - a major one being that there are at least 2012 papers on the API for which there is no information in the "journal" field. I have the DOIs of each paper, so it is simple to Google the DOI and show that these are real papers published in real journals,

Error when using install_github: 'exdir' does not exist

爷,独闯天下 提交于 2019-12-01 19:40:00
I am trying to install a package from github, but keep getting the following error; "Error in unzip(src, list = TRUE) : 'exdir' does not exist". I'm guessing that unzip doesn't have permission to create a directory to unzip into, but I don't know a way to pass a parameter in to the exdir argument. > require(devtools) > install_github("rvertnet", "ropensci") Installing github repo(s) rvertnet/master from ropensci Installing rvertnet.zip from https://api.github.com/repos/ropensci/rvertnet/zipball/master Error in unzip(src, list = TRUE) : 'exdir' does not exist This is my first time installing

Using 2+ legends from R to plotly / plot.ly

筅森魡賤 提交于 2019-11-29 15:56:53
I am using R's ggplot to create a static plot and pass that on to plot.ly to create an interactive plot. My aim to project a categorical variable to the color and a numeric variable to size. With R's [iris] data that works perfect - Like that: testplot <- ggplot(iris, aes(Sepal.Length, Sepal.Width, color=Species, size=Petal.Length)) + geom_point() py$ggplotly(testplot) https://plot.ly/~SyTpp/11/sepalwidth-vs-sepallength/ Now, I have my own dataset, a, ... > a Country OR_Edu OR_Illn total num Peru 1.75 1.67 25367 10 Philippines 1.33 0.43 33543 1 Rwanda 0.29 4.00 6443 2 Senegal 5.00 1.60 32743 3

Using 2+ legends from R to plotly / plot.ly

廉价感情. 提交于 2019-11-28 09:47:06
问题 I am using R's ggplot to create a static plot and pass that on to plot.ly to create an interactive plot. My aim to project a categorical variable to the color and a numeric variable to size. With R's [iris] data that works perfect - Like that: testplot <- ggplot(iris, aes(Sepal.Length, Sepal.Width, color=Species, size=Petal.Length)) + geom_point() py$ggplotly(testplot) https://plot.ly/~SyTpp/11/sepalwidth-vs-sepallength/ Now, I have my own dataset, a, ... > a Country OR_Edu OR_Illn total num

Shiny update the clicked point to highlight it

浪尽此生 提交于 2019-11-28 05:55:36
问题 Here is a working example of extracting the on-click event. I would like to ask you if there is a way to update the clicked point with either increase in size or highlight it etc.,? library(shiny) library(plotly) ui <- fluidPage( plotlyOutput("plot"), verbatimTextOutput("click") ) server <- function(input, output, session) { nms <- row.names(mtcars) output$plot <- renderPlotly({ p <- ggplot(mtcars, aes(x = mpg, y = wt, col = as.factor(cyl), key = nms)) + geom_point() ggplotly(p) }) output