I want to use the head()
function to have an overview of the data set but it doesn't work.
> library(haven)
> corona <- read_sav("Corona_FB/Corona_FB/TRR265_CoronaFB_16-12-2020.sav")
> View(corona)
> head(corona)
Error in is.character(subclass) : argument "subclass" is missing, with no default
> head(corona,n=3)
Error in is.character(subclass) : argument "subclass" is missing, with no default
Since your object is a tibble (class "tbl_df" "tbl" "data.frame"), which is a very widely used object class, the problem is probably with the
head()
function/method. In a clean R session (i.e., no other objects in the workspace), with only thehaven
andtidyverse
packages loaded, this works fine:There is about a 99% chance that you have somehow gotten a weird version of
head
defined (a 1% chance that your data object (corona
) is weird). To be sure that it's not your data object, we would need a reproducible example, i.e. you would have to give us access to your data file or to your data object dumped withsave()
ordput()
).If
find("head")
returns anything other than "package:utils", then you do indeed have a differenthead()
function masking the base-R version. You can make sure you are using the base-R version by usingutils::head()
instead ofhead()
. If the weird version ofhead()
is in your global workspace (i.e.find("head")
returns ".GlobalEnv") then you may want to get rid of it by sayingrm("head")
.Alternatively, as suggested in the comments, you could see if your code works in a clean R session, i.e. one where you have no other packages loaded or objects defined in your workspace. (Restarting R usually works, but you need to make sure that you're not restoring a workspace from a previous R session.)
In the meantime, if you want an "overview" of your data set, you could also try
summary()
orstr()
.