## py ##
a = 'Data Science'
b = '!'
'{}{}'.format(a, b)
#[1] 'Data Science!'
This file contains 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(shiny) | |
shinyApp( | |
ui = basicPage( | |
actionButton("show", "Show modal dialog"), | |
verbatimTextOutput("print") | |
), | |
server = function(input, output) { | |
This file contains 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
import webbrowser | |
url = 'http://idiotinside.com' | |
# Open URL in new browser window | |
webbrowser.open_new(url) # opens in default browser | |
# Opens in safari browser | |
webbrowser.get('safari').open_new(url) |
This file contains 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
import urllib | |
import webbrowser | |
def build_url(app, action, action_parameter_dict): | |
url = '%s://x-callback-url/%s' % (app, action) | |
if action_parameter_dict: | |
par_list = [] | |
for k, v in action_parameter_dict.items(): | |
par_list.append( |
This file contains 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 ========================================================================== | |
textModalInput = function(id) { | |
ns <- NS(id) | |
tagList( | |
textInput(ns("txt"), "Write something") | |
) | |
} |
This file contains 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(tidyverse) | |
mtcars %>% | |
ggplot() + | |
geom_point(aes(x = gear, y = wt)) + | |
scale_x_continuous(labels = round, breaks = 3:5) |
This file contains 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
var_names <- paste0("p", 1:10) | |
values <- seq(100, 1000, by = 100) | |
for (i in seq_along(var_names)) assign(var_names[[i]], values[[i]]) | |
mget(var_names) | |
# $p1 | |
# [1] 100 | |
# | |
# $p2 |
This file contains 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
d = {} | |
for x in range(1, 10): | |
d["string{0}".format(x)] = "Hello" | |
d["string5"] | |
#'Hello' | |
d | |
#{'string1': 'Hello', | |
# 'string2': 'Hello', |
This file contains 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(tidyverse) | |
library(httr) | |
library(jsonlite) | |
# API set up | |
api <- "https://api.airtable.com/v0/apphVdH23b9rXFd1p/" | |
api_key <- "keyL1Ja4L6pg3Uu9Q" # fake api_key | |
tables <- c("products", "brands", "stores") | |
# GET request |
This file contains 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
unnest_dataframes <- function(x) { | |
y <- do.call(data.frame, x) | |
if ("data.frame" %in% sapply(y, class)) unnest_dataframes(y) | |
y | |
} |