Press "Enter" to skip to content

Author: Erik Marsja

PhD Student in Psychology, Umeå University. Main interest is experimental and cognitive psychology. Enjoy programming in Python and R.

How to Read & Write SPSS Files in R Statistical Environment

In this post we are going to learn 1) how to read SPSS (.sav) files in R, and 2) how to write to SPSS (.sav) files using R.  More specifically, here we are going to work with the following two R packages haven (from the Tidyverse) and foreign to:

  • Read a .sav file into an R dataframe
  • Writing an R dataframe to a .sav file

Learn all About Installing & Updating Packages in Python

In this tutorial, we will learn the basics of installing, working and updating packages in Python. First, we will learn how to install Python packages, then how to use them, and finally, how to update Python packages when needed. More specifically, we are going to learn how to install and upgrade packages using pip, conda, and Anaconda Navigator.

Tutorial: How to Read Stata Files in Python with Pandas

In this post, we are going to learn how to read Stata (.dta) files in Python.

As previously described (in the read .sav files in Python post) Python is a general-purpose language that also can be used for doing data analysis and data visualization. One example of data visualization will be found in this post.

One potential downside, however, is that Python is not really user-friendly for data storage. This has, of course, lead to that our data many times are stored using Excel, SPSS, SAS, or similar software. See, for instance, the posts about reading .sav, and sas files in Python:

How to Import Data: Reading SAS Files in R

In this post, we are going to learn how to read SAS (. sas7bdat) files in R. More specifically, we are going to use the packages haven, and sas7bdat. Furthermore, we will also learn how to load .sas7bdat files into R using RStudio.

If you are interested in other methods on how to import data in R:

How to Make a Scatter Plot in R with Ggplot2

In this post, we will learn how make scatter plots using R and the package ggplot2.

More specifically, we will learn how to make scatter plots, change the size of the dots, change the markers, the colors, and change the number of ticks. 

Furthermore, we will learn how to plot a trend line, add text, plot a distribution on a scatter plot, among other things. In the final section of the scatter plot in R tutorial, we will learn how to save plots in high resolution.

How to Read SAS Files in Python with Pandas

In this post, we are going to learn how to read SAS (.sas7bdat) files in Python.

As previously described (in the read .sav files in Python post) Python is a general-purpose language that also can be used for doing data analysis and data visualization.

One potential downside, however, is that Python is not really user-friendly for data storage. This has, of course, lead to that our data many times are stored using Excel, SPSS, SAS, or similar software. See, for instance, the posts about reading .sav, .dta, and .xlxs files in Python:

How to use iloc and loc for Indexing and Slicing Pandas Dataframes

In this post, we are going to work with Pandas iloc, and loc. More specifically, we are going to learn slicing and indexing by iloc and loc examples.

Once we have a dataset loaded as a Pandas dataframe, we often want to start accessing specific parts of the data based on some criteria. For instance, if our dataset contains the result of an experiment comparing different experimental groups, we may want to calculate descriptive statistics for each experimental group separately.