Teach yourself to Code

R Python
Kelly L. Sovacool https://sovacool.dev/ , Zena M. Lapp https://zenalapp.github.io
2020-03-20

This post was originally published on the DANG! blog

As most lab work at the University of Michigan comes to a temporary halt due to the ongoing COVID-19 pandemic, we’ve heard some of our fellow grad students and other researchers express an interest in learning how to code as they’re not able to conduct experimental work at this time. We thought we could help out by putting together this short guide on how to teach yourself to code.

First above all, take care of yourself and your loved ones! We don’t want to contribute to the voices pressuring academics to be productive at a time when we should all be prioritizing our mental and physical health and that of our families. If you also have found the motivation and time to teach yourself how to code, then this guide is for you.

We wrote this guide with grad students, postdocs, and other scientists who have never written code before in mind, but most of the content applies to just about anyone wanting to learn.

📣 UPDATE 25 Mar. 2020: Pat Schloss is running a weekly Code Club via Zoom for those who want to learn R and improve their data analysis skills. All experience levels are welcome! See details here: riffomonas.org/code_club.

Why learn to code?

What language to learn?

If there’s a single popular language that everyone else in your lab, department, or field uses, just start with that one. Why? You will want to be able to learn from others and ask for help when you need it. For scientific research, both R and Python are popular languages and great for getting started quickly with data analysis. R and Python are open source, meaning they are free as in libre and free as in free food at the department seminar! So you don’t need to buy a license to use them, you’ll have access after you leave the university, and anyone else with a computer will be able to run your code too.

Scientists in the DANG! community use R, Python, and/or other languages, but R seems to be the most common. If you’re not sure which one to pick and you’d like to get help from the DANG! community, try R. We also particularly like R for a package called R Markdown for turning code into analysis reports, manuscripts, and even presentations to easily & reproducibly share our work with others.

The logic of programming is the most important thing to learn, so deciding to pick up another language once you have experience in one should be easier. And it’s definitely not an “either/or” scenario; many experienced programmers use multiple languages regularly in their work. However, we recommend sticking to learning just one language at first so you don’t get overwhelmed.

How to get started?

If you’ve exhausted these options, here’s an overwhelmingly long list of links to even more resources and tools you might like to learn.

How to use it in the real world?

If you want to automate tasks, run your code on supercomputers, and make your friends think you’re a hacker, you should definitely learn the Unix Shell. You can find The Carpentries’ lesson on the Unix Shell here.

The Carpentries has instructions for installing the tools you’ll need: - Python - R - Unix Shell

How to get help?

  1. Google is your best friend. No, really. We Google questions every day!
  2. Ask your friends, colleagues, etc. Especially when you’re just starting out, it can be difficult to know what to Google to get the answers you need. Ask a more advanced programmer as soon as you hit a wall.
  3. Join the DANG! Slack workspace and use the #analysis_questions channel. DANG! exists because we think it’s important to have a community of practice so you can learn from other people, get personalized help when you need it, and help others.

Further reading:



Written by Zena Lapp & Kelly Sovacool. Edited by Ari Kozik.

Corrections

If you see mistakes or want to suggest changes, please create an issue on the source repository.