Skip to content

Instantly share code, notes, and snippets.

@rexarski
rexarski / rotation.R
Created January 7, 2023 03:39 — forked from ivelasq/rotation.R
Rotated ggplot2 graph
# Credits to this Stack Overflow post
# https://stackoverflow.com/questions/13445753/force-ggplot2-scatter-plot-to-be-square-shaped
library(ggplot2)
library(grid)
rotation <- 45
p <-
ggplot() +
@rexarski
rexarski / delete_git_submodule.md
Created October 7, 2020 06:34 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@rexarski
rexarski / non-ascii.R
Created December 6, 2019 09:52 — forked from nassimhaddad/non-ascii.R
remove non-ascii characters
# remove non-ascii characters
df$text <- gsub("[^\x20-\x7E]", "", df$text)
@rexarski
rexarski / README.md
Created November 22, 2018 13:49 — forked from jslefche/README.md
ggplot2: theme_black()

Black theme for ggplot2

This is an additional theme for ggplot2 that generates an inverse black and white color scheme.

Example

ggplot(mtcars, aes(wt, mpg)) + geom_point()
# Add theme_black()
ggplot(mtcars, aes(wt, mpg)) + geom_point(color = "white") + theme_black()
@rexarski
rexarski / markdown.R
Created August 8, 2018 02:39 — forked from alistaire47/markdown.R
read markdown table into R data frame
# base R version
read.markdown <- function(file, stringsAsFactors = FALSE, strip.white = TRUE, ...){
if (length(file) > 1) {
lines <- file
} else if (grepl('\n', file)) {
con <- textConnection(file)
lines <- readLines(con)
close(con)
} else {
lines <- readLines(file)