I met this week with a psychology student who was interested in learning to code but had absolutely no experience. I personally think it’s a travesty that programming is not part of the basic psychology curriculum, because doing novel and interesting research in psychology increasingly requires the ability to collect and work with large datasets and build new analysis tools, which are almost impossible without solid coding skills.
Because it’s been a while since I learned to code (back when programs were stored on cassette tapes), I decided to ask my friends on the interwebs for some suggestions. I got some really great feedback, which I thought I would synthesize for others who might be in the same boat.
Some of the big questions that one should probably answer before getting started are:
- Why do you want to learn to code? For most people who land in my office, it’s because they want to be able to analyze and wrangle data, run simulations, implement computational models, or create experiments to collect data.
- How do you learn best? I can’t stand watching videos, but some people swear by them. Some people like to just jump in and start doing, whereas others like to learn the concepts and theories first. Different strokes...
- What problem do you want to solve? Some people can learn for the sake of learning, but I find that I need a problem in order to keep me motivated. I would recommend thinking of a relevant problem that you want to solve and then targeting your learning towards that problem. One good general strategy is to find a paper in your area of research interest, and try to implement their analysis. Another (suggested by Christina van Heer) is to take some data output from an experiment (e.g. in an Excel file), read it in, and compute some basic statistics. If you don't have your own data, another alternative is to take a large open dataset (such as health data from NHANES or an openfmri dataset from openfmri.org ) and try to wrangle the data into a format that lets you ask an interesting question.
OK then, so where do you look for help in getting started?
The overwhelming favorite in my social media poll was codeacademy. It offers interactive exercises in lots of different languages, including Python. Another Pythonic suggestion was http://learnpythonthehardway.org/book/ which looks quite good.
For those of you who prefer video courses, there were also a number of votes for online courses, including those from Coursera:
If you like video courses then these would be a good option.
Other suggestions included:
- Learning statistics with R: A tutorial for psychologists and other beginners (free pdf book)
- http://pythontutor.com - this looks like a pretty cool tool to help see what a program is doing when it runs
- codemonkey (coding in a game environment)
- Swirl for R
- Python for Vision Research
- Programming for Psychology in Python
- lynda.com (commercial, but offers a free trial)
Here are some suggested sites with various potentially useful tips
- Resources for Learning to Program using Python and Code Experiments Using Psychopy
- Reading Python source code to improve programming skills
- Introduction to R
- 6 inspiring web sites that teach you to code
- Kendrick Kay's course on Statistics and Data Analysis in MATLAB
- Several people recommended Spyder as a development environment for Python (though I gave up on it because I found it to be too sluggish on the Mac)
- Here is a nice curated list of python tutorials for data science and machine learning
- 9 places you can learn how to code (for free)
Finally, it’s also worth keeping an eye out for local Software Carpentry workshops.
If you have additional suggestions, please leave them in the comments!