Problem in installing 'foreign' package to read SPSS files


I am working in Andy Field's book on R, and am trying to get the 'foreign' package to work.
I was able to download it, but I can seem to load it or use it.

I get the following message when using library(foreign):

--- Please select a CRAN mirror for use in this session ---
trying URL ''
Content type 'application/x-gzip' length 328795 bytes (321 KB)
downloaded 321 KB

The downloaded binary packages are in

Error in value[3L] :
Package 'foreign' version 0.8.71 cannot be unloaded:
Error in unloadNamespace(package) : namespace 'foreign' is imported by 'RcmdrMisc', 'rio', 'Hmisc' so cannot be unloaded
lecturerData<-read.spss("Lecturer Data.sav", use.value.labels=TRUE,
Error in read.spss("Lecturer Data.sav", use.value.labels = TRUE, = TRUE) :
could not find function "read.spss"

I have not taken any steps so far as I am a novice and do not know what to do.

I am using R 3.6.0 GUI 1.70 El Capitan build on a mac laptop (OS Mojave version 10.14.5).

Thanks very much for your help! It would be really useful to be able to import SPSS files in R.


Try with this steps.

  • Restart your R session (Ctrl+Shift+F10)
  • Uninstall your previous foreing version with remove.packages("foreign")
  • Reinstall foreing package with install.packages("foreign")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.