This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ui <- fluidPage( | |
tags$script(' | |
Shiny.addCustomMessageHandler("toggleWellPanel", | |
function(message) { | |
document.getElementById(message["id"]).style.display = message["status"]; | |
} | |
); | |
'), | |
fileInput('file', 'File'), | |
selectInput('col_select', 'Columns', choices=c(''), multiple=TRUE), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ui <- fluidPage( | |
fileInput('file', 'File'), | |
selectInput('col_select', 'Columns', choices=c(''), multiple=TRUE), | |
wellPanel(uiOutput('wellpanels')) | |
) | |
server <- function(input, output, session) { | |
data <- reactive({ | |
f <- input$file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(grid) | |
plot1 <- ggplot(data.frame(x=1:10, y=1:10), aes(x=x, y=y)) + geom_point() | |
plot2 <- plot1 | |
plot3 <- plot1 | |
nrow <- 1 | |
ncol <- 3 | |
vp <- viewport(layout=grid.layout(nrow, ncol)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
layout.mat <- matrix(c(1,1,1,1,1,1,2,3,3), nrow=3) | |
layout.mat | |
layout(layout.mat) | |
plot(1:10) | |
plot(1:10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(reshape2) # gives you the melt function | |
d1 <- data.frame(time=1:10, x1=1:10) | |
d2 <- data.frame(time=1:10, x2=1:10/2) | |
d <- merge(d1, d2, by='time') | |
d.molten <- melt(d, id.var='time') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num.cols <- 10 | |
# allocate space for your ten columns | |
cols <- vector('list', num.cols) | |
# add key column, such as timestamp | |
cols[[1]] <- 1:5 | |
for (i in 2:num.cols) { | |
cols[[i]] <- rnorm(5) # add the next column, 5 random numbers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
options(RCurlOptions=list(proxy='web.proxy.com:8080')) | |
py <- plotly("me", "mec3g0e1z7") | |
p <- ggplot(mtcars, aes(x=mpg, y=cyl)) + geom_point() | |
res <- py$ggplotly(k, kwargs=list(auto_open=FALSE)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ui <- navbarPage('TEST', id='page', collapsable=TRUE, inverse=FALSE, | |
# define a message handler that will receive the variables on the client side | |
# from the server and update the page accordingly. | |
tags$head(tags$script(" | |
Shiny.addCustomMessageHandler('updateSelections', | |
function(data) { | |
var nav_ref = '#page a:contains(\"' + data.nav + '\")'; | |
var tabpanel_id = data.nav == 'Alpha' ? '#alpha_tabs' : '#beta_tabs'; | |
var tab_ref = tabpanel_id + ' a:contains(\"' + data.tab + '\")'; | |
$(nav_ref).tab('show'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
options(shiny.reactlog=TRUE, warn=2, show.error.locations=TRUE, error=recover) | |
# interactive session | |
browser() | |
# print message | |
message('message') | |
# error handling | |
err.hanlder <- function(e) message(e) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## R | |
# install possible missing dependencies for R packages | |
apt-get -y install libcurl4-gnutls-dev | |
apt-get -y install libcairo2-dev | |
apt-get -y install libgdal1-dev libproj-dev | |
apt-get -y install libxt-dev | |
apt-get -y install libiodbc2 libiodbc2-dev | |
apt-get -y install libgdal-dev libproj-dev | |
# then install these packages | |
shiny # devtools::install_github('shiny', 'rstudio') |
OlderNewer