corb1999 / cheatcraft Goto Github PK
View Code? Open in Web Editor NEWA potluck of R code snippets and small helper functions.
A potluck of R code snippets and small helper functions.
write a function/snippet that will identify all packages used in a script and their versions and then compile that information into a dataframe and write it out as metadata. this could probably be done with an existing package like packrat, so maybe look there for inspo, but would be good practice to try and build something proprietary. may ultimately be put into skelly repo/project instead of cheatcraft
tired of having to type so much to alter my analysis scripts to correctly print a timeframe's title and to get the filter to adjust appropriately, and this can also create errors.
i would prefer to have a function that if supplied a year and month number it can then give me filter dates to pass to a filter function in a dplyr pipe, and will print me a nice quick text label of what timeframe i am looking at
maybe a function that takes years and months as args and then returns a list object, with one part of the list being the formated date values which can be passed to a dplyr pipe and the other part of the list a text value that summarizes the timeframe in a way that it can be included as a title/subtitle/caption that can be included in a ggplot or a table exhibit
create a snippet that helps generate synthetic data that can be used either to test other scripts or functions, or can be used as filler for visuals that are being designed. the snippet should help make different complex types of data and should be able to make datasets that resemble real world datasets that are encountered in industry
create a generic function that can accept a vector of nominal values and calculate the HHI. Can be useful for marketshare analysis or other distribution/concentration/fragmentation analysis
create a snippet to support quick highlighting a time period and annotating with a note
want to add a little more information to the simple regression visualization function. want to add a layer to the plot that plots a single point which is the median x and median y value, and also add some reference vlines and hlines. think it could be another helpful layer in the visual. make it the first layer so it does not distract from the more important scatter plot and regression line.
self explanatory
leverage nitrogen project and scaurus attempts
simplify and make it work with the skelly script
its all in the description. borrow a snippet from the hurricane playground repo if needed
to get more use and better interpret the simple regression plot function, use patchwork to add a second plot that gives a quick look at the residuals.
self explanatory, have made this in other scripts but should put it here for consolidated referencing
create a template for faster shiny app builds
global.R
ui.R
server.R
.Rprofile
source_functions.R
Write a script template that can read and combine multiple disparate but similar files into one combined data object. @corb1999
Write a script that serves as a template for manually naming a number of columns from a very wide dataset without a helpful column naming schema
right now the function would require the variables you want to plot to be renamed to the format that fits the function argument names. instead, i want to pass the dataframe, and name the variables that will be plotted, so that the function snippet does not have to be rewrittten in order to be useful.
Build a function to assist in bootstrap sampling analysis. @corb1999
create a function for printing a timestamp to be included in a filepath, extract something like this from this fun:
qp <- function(pltname, pltpath_suffix = NA, plt_inch = 5) {
plt_timestamp <- paste(year(Sys.time()), month(Sys.time()),
day(Sys.time()), hour(Sys.time()), minute(Sys.time()),
floor(second(Sys.time())), sep = "-")
aa <- ifelse(is.na(pltpath_suffix), "", pltpath_suffix)
plt_filepath <- paste0(getwd(), aa)
plt_name <- paste0("plt_", pltname, "_", plt_timestamp, ".png")
ggsave(filename = plt_name, plot = last_plot(),
path = plt_filepath, scale = 1, device = "png",
height = plt_inch, width = plt_inch * 1.61803399, units = "in")}
Create a script containing best practice snippets for reading data from different places and for common writing operations. The idea being that these can just be popped into any script, slightly adapted, and then run. This saves a few lines of typing each time and enforces consistent, repeated patterns in code. @corb1999
play around and see if there is a way to add some kind of component to the function that will append a timestamp of when the plot was generated
just have to make sure it does not overwrite or cause problems with any of the other plot components, like if there is already a caption
borrow from the hurricane-playground repo and make an abstract/generic function for downloading a file from the internet and unzipping it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.