Chapter 2 Computing Tips
Almost all of the students here use macs. It is not required, but it will make your life easier. These are some tips that I feel have made me successful, but there are definitely other ways to do it.
2.1 Downloads
Here are some things you should get on your computer before you get started.
2.1.1 Homebrew
Install homebrew. Homebrew is essentially a package manager. Paste the command below in your terminal prompt.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
After doing that double check that you’ve got it installed correctly by running
brew doctor
If you see Your system is ready to brew
you are good to go. You install packages by running brew install package-name
, for example brew install git
to install git (which you should do RIGHT NOW if you don’t have it yet).
Some things I recommend getting now that you have brew installed:
- git
- python
- cowsay
- thefuck
2.1.2 Bash-it
Make your terminal beautiful.
I really like Bash-it. Both because I like to say it outloud, and because it makes my terminal look baller. It has sweet plugins (like showing git branches!) and awesome aliases that will save your pretty little fingers.
To install, type this in terminal,
git clone https://github.com/revans/bash-it.git ~/.bash_it
then run,
~/.bash_it/install.sh
I use a slightly edited bobby
theme. Here are some other themes to choose from.
2.2 File Organization
File organization is super important. And fun! There are a lot of different conventions, I took a while iterating towards one I actually really like.
2.2.1 Naming conventions
Since we have gone to so much effort to make our terminal look dope, we should be congizent of how to name folders to most easily use it (for example, folder and file names with spaces are a pain because you have to add quotation marks).
- Instead of spaces, uses - between words for folder & filenames
- name folders consistently within projects to allow you to reuse functions/run scripts (more below)
2.2.2 Folders
I have 3 main folders:
phd
working
archive
The phd
folder is pretty self explanatory. Within this folder I have:
courses
journal-club
teaching
The working
folder contains projects I am actively working on. This includes RA work, projects I am working on with professors, consulting, and tutoring files. I have these separated because I am acutely aware of making sure these are backed up regularly on github. Within each of these, I have:
code
data
reports
src
The consistent naming convention allows me to have set code to run everything for each different project I am on. The src
folder is especially useful for holding functions I have written that I reuse a bazillion times.
The archive
folder contains projects that I have completed. These are backed up every time a new folder is added, but not as regularly as the working
folder.
2.3 Github
If you do not already have one, set up a github account – make sure that you get an education discount so you can set up private repos.
- Jenny Bryan has an awesome course on Github for the useR.
- Gitkraken is a nice GUI to avoid using git at the command line
- For some giggles
2.4 Bash Profile
Now that we’ve downloaded a bunch of nifty programs using brew
and we have github
up & running, you can save some typing time in terminal by adding aliases (shortcuts) to your .bash_profile
.
- Open Terminal and type
open -e ~/.bash_profile
(if you installed bash-it this will work, if you do not have a.bash_profile
in your home directory yet, you can create one using your favorite text editor, for examplenano .bash_profile
) - Add some aliases like this:
alias alias_name = "terminal command"
For example:
# Edit profile
alias edit_profile="open -e ~/.bash_profile"
Here are some we \(\heartsuit\):
# Set RStudio alias
alias RS="open -a RStudio"
# Set reload profile alias
alias reload_profile=". ~/.bash_profile"
# Edit profile
alias edit_profile="open -e ~/.bash_profile"
#Lazy git - will add, commit, and push with one command
# NOTE: each command (add, commit, push) in this function is progressively harder
# to undo/fix if you muck something up (e.g., adding PHI to a public repo!)
# so make sure you understand what you're doing
#Set our default branch to push to as the one we are in
git config --global push.default current
function lgit() {
git add -A
git commit -m "$1"
git push
}
2.5 Statistical Software
In this department, we conduct the majority of our analyses using R
& python
. We use Stata
for a few classes, so you may want to get that as well. If you are interested in learning SAS, check this out.