Skip to content

Instantly share code, notes, and snippets.

@jimbrig
jimbrig / r_logo.R
Created October 22, 2020 16:47 — forked from thomasp85/r_logo.R
library(magick)
library(reshape2)
library(dplyr)
library(tidygraph)
library(particles)
library(animation)
plot_fun <- function(sim) {
df <- as_tibble(sim)
plot(df$x, df$y, col = df$color, pch = '.', axes = FALSE, xlim = c(-100, 317), ylim = c(-268, 100), xlab = NA, ylab = NA)
@jimbrig
jimbrig / 00-New setup.md
Created October 22, 2020 16:56 — forked from cderv/00-New setup.md
New computer setup
# installed by winget
winget install PowerShell-Preview
winget install git
git config --global user.name "Christophe Dervieux"
git config --global user.email christophe.dervieux@gmail.com
winget install rstudio
winget install vscode
winget install -e R
winget install Github.GithubDesktop
library(shiny)
library(shinyEx)
ui <- fluidPage(
fluidRow(
column(
width = 4,
wellPanel(
arrowButtonGroupInput(inputId = "test1",type = "h"),
textOutput("test11")
@jimbrig
jimbrig / app.R
Created November 19, 2020 16:48
Shiny Clipboard Button
library(rclipboard)
library(shiny)
# The UI
ui <- bootstrapPage(
rclipboardSetup(),
# Add a text input
textInput("copytext", "Copy this:", "Zlika!"),
library(shiny)
library(DT)
library(dplyr)
source_data <-
iris %>%
mutate(Species = as.factor(Species))
source_data$Date <- Sys.time() + seq_len(nrow(source_data))
@jimbrig
jimbrig / Get-Github-Stars.R
Last active December 1, 2020 04:54
[Github Stars] R Script to Retrieve Github Starred Repos #dev #github #pinned #r
if (!require("pacman")) install.packages("pacman")
pacman::p_load(
dplyr,
tidyselect,
DT,
gh
)
pacman::p_load_current_gh("ropenscilabs/roomba")
@jimbrig
jimbrig / .leptoprc
Last active December 1, 2020 04:55
[Lepton Settings] Settings and configuration for my ~/.leptonrc config file #dev #dotfiles #config
{
"theme": "dark",
"autoUpdate": true,
"snippet": {
"expanded": true,
"newSnippetPrivate": false,
"sorting": "updated_at",
"sortingReverse": true
},
"editor" : {
@jimbrig
jimbrig / defuse_shiny_reactives.R
Created December 1, 2020 05:22
[Defuse Shiny Reactives] Useful R Code Displaying How to "Defuse" Reactives into Static Values #dev #shiny #pinned
code <-
"library(shiny)
library(dplyr)
library(ggplot2)
input <- list(cty = 15)
df = shiny::reactive({
x <- input$cty
mpg %>% filter(cty < x)
})
@jimbrig
jimbrig / reinstall_packages.R
Created December 1, 2020 05:25
[Re-Install R Packages] Cross-platform script to analyze, extract, and re-install packages to a new library. #dev #r #pinned #config
# Step 1 ------------------------------------------------------------------
# Before updating R...
`%>%` <- magrittr::`%>%`
# Thanks Chuck Powell - https://ibecav.github.io/update_libraries/
package_source <- function(pkg){
x <- as.character(packageDescription(pkg)$Repository)
if (length(x)==0) {
y <- as.character(packageDescription(pkg)$GithubRepo)
@jimbrig
jimbrig / get_os.R
Last active December 1, 2020 05:35
get_os <- function() {
if (.Platform$OS.type == "windows") {
"win"
} else if (Sys.info()["sysname"] == "Darwin") {
"mac"
} else if (.Platform$OS.type == "unix") {
"unix"
} else {
stop("Unknown OS")
}