mark-andrews / psyntur

Tools to help teach data analysis using R to NTU Psychology students
Other
5 stars 2 forks source link

Add `glimpse` #35

Open lvjustice opened 2 years ago

lvjustice commented 2 years ago

It would be useful if we could include glimpse in the package rather than having to install tidyverse or use str which doesn't always create a clean output. We don't need tidyverse for anything else, at least in year 1, so it seems like it would be more efficient to have it in psyntur

jensroes commented 2 years ago

I use mutate in my year 1 lectures and I think instead of avoiding tidyverse we should make use of it. Partly because it is a useful package that should really replace base R but also because when students get to the year 2 session in which they have to reverse code their psychometrics data they suddenly meet mutate, select, across, start_with etc. So I think we should make use of at least mutate and select earlier, maybe even in year 1 (we do already a little) rather than throwing a hole host of new functions at them in one session. Alternatively, we need to reduce the complexity of the reverse coding bit by doing it in base R style (data$item <- re_code(data$item, 1:5, 5:1)) which isn't efficient coding although probably more transparent for students. Aside, str doesn't just produce unclean output, str is made for data frames and glimpse is made for tibbles. So as long as we keep using tidyverse and use read_csv instead of read.csv etc we should be using glimpse. Also, in year 1 students only have to install two packages, right? Working with packages is fundamental for R. I do agree that they are some issues with that but removing this removes an opportunity to learn something really important ;)

mark-andrews commented 2 years ago

When psyntur is installed, as opposed to loaded, it installs pillar, which contains glimpse, so no actual need to install tidyverse. To get glimpse, do pillar::glimpse or even dplyr::glimpse, or libary(pillar) or library(dplyr). However, I think what we are talking about here is the need for re-exporting functions, so that when we do, e.g. library(psyntur), we have immediate access to functions like glimpse etc from other packages. When we do library(dplyr) we get access to glimpse because it re-rexported after importing from pillar, see https://dplyr.tidyverse.org/reference/reexports.html We can do that in psyntur too as much as we want.