Problem in installing 'foreign' package to read SPSS files

Hi,

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):

install.packages("foreign")
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://lib.ugent.be/CRAN/bin/macosx/el-capitan/contrib/3.6/foreign_0.8-72.tgz'
Content type 'application/x-gzip' length 328795 bytes (321 KB)
==================================================
downloaded 321 KB

The downloaded binary packages are in
/var/folders/gq/p8sv07ls2xn66vthd8cpbfb1yys37c/T//RtmpgsnS17/downloaded_packages

library(foreign)
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, to.data.frame=TRUE)
Error in read.spss("Lecturer Data.sav", use.value.labels = TRUE, to.data.frame = 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.

Julie

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.