Skip to content

Instantly share code, notes, and snippets.

View isteves's full-sized avatar

Irene Steves isteves

View GitHub Profile
@isteves
isteves / command_line_python.Rmd
Last active February 15, 2018 18:59
Intro to Python and the Command Line for an R User
---
title: "Intro to Python and the Command Line for an R User"
author: "Irene Steves"
date: "`r format(Sys.Date())`"
output: github_document
---
Some things are just faster on the command line. But if you're not used to it, the command line is a dark and scary place. Thankfully, I had [amoeba](https://github.com/amoeba) to help me through:
1. Copying a file to another folder
@isteves
isteves / whichtip.Rmd
Last active July 26, 2018 20:31
Rendering markdown text
---
output:
html_document:
df_print: paged
runtime: shiny
---
```{r include = FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
@isteves
isteves / partyparrotR.Rmd
Created August 8, 2018 22:26
party parrot
party parrot
@isteves
isteves / MKrene.tmTheme
Created May 1, 2020 11:53
Modified Monokai theme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Generated by: TmTheme-Editor -->
<!-- ============================================ -->
<!-- app: http://tmtheme-editor.herokuapp.com -->
<!-- code: https://github.com/aziz/tmTheme-Editor -->
<plist version="1.0">
<dict>
<key>name</key>
<string>MKrene</string>
@isteves
isteves / tidyselect.md
Last active May 4, 2020 15:28
Trying to grok tidyselect

Trying to grok tidyselect

Key takeaways:

  • everything inside vars(...) is exactly the same as the stuff inside select(...)!!!
  • vars() is used for all scoped variants of dplyr verbs (I assume bc the variables need to “fit” into a single argument, .vars. In select(...), the ellipses take everything)
  • vars_select() is probably more of a developer-facing function (seen in select_helpers documentation)

Some "gotchas":

@isteves
isteves / rmd_snippets.md
Last active May 14, 2020 12:54
Useful Rmd snippets

Preferred YAML header:

---
title: My title
subtitle: My subtitle
author: My name
date: "`r Sys.Date()`"
output:
 html_document:
@isteves
isteves / style_table_values.R
Created July 14, 2020 13:32
Flexible way to format table values using dplyr & formattable
library(tidyverse) #need dplyr 1.0.0+ https://www.tidyverse.org/blog/2020/03/dplyr-1-0-0-summarise/
library(formattable)
df <- tibble(spent = 1:10,
refund = 100:109,
perc = seq(0.1, 1, 0.1),
num = 1000:1009,
blah = 1000:1009)
style_table_values <- function(df,
@isteves
isteves / two_githubs.md
Last active July 19, 2020 20:50
Dealing with two GitHub accounts

Dealing with two GitHub accounts on one computer

I keep messing this up, so documenting what I currently remember here. If future Irene arrived here because of a bad commit, this is how you undo the latest commit: git reset HEAD~ (SO post)

To start, I set up my work and personal accounts with separate SSH keys (id_rsa files, etc) using this guide.

I'm never clear on what's going on behind the scenes in the RStudio git pane, so I tend to use the terminal when using my secondary (personal) account. Each time I open a new personal project, I need the following steps.

  1. When cloning the repo, add "personal" to the URL (this is how I have it set up): git@personal.github.com:isteves/my_repo.git
  2. After cloning and creating a new RProject, run ssh-add ~/.ssh/id_rsa_personal in the terminal to switch to the persona
@isteves
isteves / pycharm_shortcuts.md
Last active January 5, 2021 09:06
pycharm shortcuts

Pycharm shortcuts

Useful shortcuts

  • control + shift + r -- runs the script ("source")

Matching RStudio

It's a pain to relearn shortcuts for every program, so I adjusted a few Pycharm shortcuts to match what I'm used to in RStudio.

@isteves
isteves / pkg_db_connection.md
Last active January 10, 2021 09:20
Managing a DB connection in an R package

In our department, there's almost always just a single database that we want to connect to. Thus, managing the connection throughout our code quickly becomes annoying and redundant:

conn <- odbc::dbConnect(odbc::odbc(), ...)

dbGetQuery(conn, statement1)
dbGetQuery(conn, statement2)
dbGetQuery(conn, statement3)