Skip to content

Instantly share code, notes, and snippets.

View daranzolin's full-sized avatar
📈

David Ranzolin daranzolin

📈
View GitHub Profile
@daranzolin
daranzolin / sqlWizardGadget
Created December 19, 2023 20:08
Shiny Gadget to load SQL Queries (ugly and not totally working)
library(shiny)
library(miniUI)
ui <- miniPage(
gadgetTitleBar("Import SQL Query"),
miniTabstripPanel(
selected = "Input",
# --- UI - Tab - Input ----
miniTabPanel(
"Input",
```{r}
path <- fs::path("mtcars", ext = "csv")
cmd <- paste0("{{< downloadthis ", "'", path, "'", ' dname=Mtcars label="Download the mtcars data" icon=database-fill-down type=info class=data-button id=mtcars >}}')
```
```{r}
#| results: asis
cat(cmd)
```
---
title: "downloadthis reprex"
format: html
include-after-body: button.html
---
# Head1
<br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br>
library(tidyverse)
library(ggalt)
library(ggforce)
df <- tibble(
x = 1:43,
y = c(rep(1, 10), 3.5, 6.5, 9, 2.75, 3, 13, 14, 15, 16, 17, 17.5, 18, 8, 9, 11.5, 13, 14, 15, 25.75, 27.75, 28, 28, 28.5, 28.75, 29, 34, 39, rep(NA, 6)),
desc = c(
"Creates GitHub Account",
rep(NA, 7),
@daranzolin
daranzolin / query.sql
Created September 26, 2022 17:40
SQL Query and R Script for DS412
-- !preview conn=rsfsu::connect_to_datamart()
WITH ds412 AS (
SELECT CRS_SID AS SID,
TO_NUMBER(CRS_YEAR_TERM) AS DS412_TERM,
CRS_SEMESTER AS SEMESTER,
CRS_SECT AS SECTION,
CRS_GRADE AS DS412_GRADE,
CASE WHEN RTRIM(ETHNIC_URM1) = '1.URM' THEN 'Yes' ELSE 'No' END AS URM
FROM IRDMSTG.DM_CRS_EOT
WHERE RTRIM(COURSE_ID12) = 'DS 0412'
@daranzolin
daranzolin / display_raster_attribute_table.py
Created February 17, 2022 00:36
Display a raster's 'attribute' table w/arcpy
import pandas as pd
def display_raster_attribute_table(ras):
if ras.hasRAT:
flds = [fld.name for fld in arcpy.ListFields(ras)]
table = []
cur = arcpy.SearchCursor(ras, flds)
for row in cur:
rowList = [row.getValue(fld) for fld in flds]
table.append(rowList)
del cur
@daranzolin
daranzolin / geom_heart.r
Created February 16, 2021 23:23 — forked from EmilHvitfeldt/geom_heart.r
geom that uses hearts instead of points.
geom_heart <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
..., parse = FALSE, nudge_x = 0, nudge_y = 0, check_overlap = FALSE,
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE)
{
if (!missing(nudge_x) || !missing(nudge_y)) {
if (!missing(position)) {
stop("Specify either `position` or `nudge_x`/`nudge_y`",
call. = FALSE)
}
position <- position_nudge(nudge_x, nudge_y)
#' Connect to the data mart
#'
#' You must set three variables in your .Renviron: 'DATAMART_DSN', 'DATAMART_ID', and 'DATAMART_PW'.
#' @export
#' @examples
#'\dontrun{
#'irdb <- connect_to_datamart()
#'}
connect_to_datamart <- function() {
DBI::dbConnect(odbc::odbc(),
text_id word
A lorem
A ipsum
A dolor
A sit
A amet
A consectetur
A adipiscing
A elit
A sed
year,day,month,max
2010,1,Jan,57
2010,2,Jan,55
2010,3,Jan,55
2010,4,Jan,54
2010,5,Jan,61
2010,6,Jan,54
2010,7,Jan,53
2010,8,Jan,54
2010,9,Jan,54