Data Analysis for Social Science: A Friendly and Practical Introduction

Looking to get started with data science, but scared it’d be too complicated? There’s a new book by Elena Llaudet and Kosuke Imai that will get you covered. Data Analysis for Social Science: A Friendly and Practical Introduction is now available as an e-book, and it truly delivers what the title claims: friendly and practical. It’s also up-to-date, with a focus on experimental data and causal inference much more than on multiple regression analysis. I don’t think I’ve seen a more accessible introduction to R and Rstudio — cheat-sheets included!

readODS and column specifications

The R package readODS allows you to import ODS spreadsheets to R. It’s slow, but it works. In an attempt to speed up things, I thought providing column types would help. I didn’t find an improvement, but I noticed that the documentation wasn’t really clear (“refer to readr::type_convert to specify cols specification”). It seems like you do need to refer to type_convert to understand how to specify column types, and then feed them to readODS like this:

col_types=cols(VAR1 = "f", VAR2 ="i")

etc.

So an entire call would be:

data = read_ods("spreadsheet.ods", col_names=TRUE, col_types=cols(VAR1 = "f", VAR2 = "i", VAR3= "-"))

Note: I had to explicitly use library(readr) before calling read_ods(), otherwise the cols() function was not available.

Unfortunately, the short approach using col_types=as.col_spec(“fi-“) does not seem to work.