Questions tagged [r-haven]

The `haven` package for `R`

118 questions
1
vote
1 answer

How do I apply R column attributes (from SAS formats, via rio's import), like as_factor in haven?

I have imported SAS data into R, using rio: library(rio) r<-import("S:/MyFolder/MyData.sas7bdat", catalog_file = "S:/MyFolder/formatsforr.sas7bcat") That gives my r, which has column r$Race (storing atomic values 1,2,3, and 4), which has an…
user3799203
  • 294
  • 3
  • 12
1
vote
0 answers

Error: package or namespace load failed for ‘haven’ in dyn.load(file, DLLpath = DLLpath, ...):

I am not able to open install the 'haven' packages. It gives me the following error: *** copying figures ** building package indices ** installing vignettes ** testing if installed package can be loaded Error: package or namespace load failed for…
tidyx
  • 45
  • 5
1
vote
1 answer

Loading SPSS files from github

I don't understand how to import SPSS files (or .rdata or Stata) files that are hosted on github. I have a repository with some data files here, but using the URL for the sav file in there does not work.…
spindoctor
  • 1,359
  • 1
  • 11
  • 27
1
vote
0 answers

Why does preProcess ignore some columns when scaling all columns?

I have a data set - no missing values anywhere. I read it into R using package 'haven' - the file itself was an SPSS file ".sav" - so I used "read_sav". I want to standardize all numeric columns using caret's pre-process. Important: here is the…
user3245256
  • 1,522
  • 3
  • 17
  • 37
1
vote
0 answers

Error trying to write a data frame to a sas7bdat file in R

I am working with a data.frame in R that I want to export (write) as a sas7bdat file. The package that I am using is haven when I use the command line: write_sas(df, "newsasdata.sas7bdat") I get the following error: Error in write_sas_(data,…
1
vote
1 answer

Export variable label for SPSS with haven

I would like to export a data set I work on in R for my colleagues to use in SPSS. When I export the data set I would like to include variable labels (i.e. the column below), I am not asking about value labels which describe the levels of the…
Phil
  • 3,936
  • 1
  • 20
  • 31
1
vote
0 answers

Evaluation error: column 1 must be named

I am getting the following error when reading a column from sas data in R library(haven) Sas_temp=read_sas("My_sas_file.sas7bdat",cols_only="Bth_dt") This produces the error Error in…
1
vote
0 answers

Alternative to loop for double brackets in data frame

I have an unusual problem with an spss dataset that I import to R via the Haven package (I also made a post about this on GitHub). The dataset is full of variables with missing value definitions that are not included among value labels, which leads…
20salmon
  • 31
  • 5
1
vote
0 answers

write_dta not working in R

When I run stackQuestion.R in RStudio containing the following code: library(haven) write_dta(data.frame(a=1), "test.dta") it works fine. When I run RScript --vanilla stackQuestion.R from the Mac Terminal I get the error Fehler in…
Ruediger Ziege
  • 300
  • 3
  • 17
1
vote
1 answer

R - Loss labels when I ordered a data frame after using read_sav from haven package

I use the read_sav function from haven package to import an SPSS file. Therefore I have column names and associate labels (class labelled). I lost the labels when I ordered the data frame. I can avoid the problem with a conversion in factor before…
Kumpelka
  • 749
  • 2
  • 10
  • 27
1
vote
0 answers

Error when reading in SAS file in R

I try to read in a SAS file using the haven package in R. However, when I try to read a file like this: read_sas("query_for_dm_abonnement_detail1.sas7bdat") I get the following error Error: Failed to parse …
Frits Verstraten
  • 1,539
  • 5
  • 18
  • 32
1
vote
0 answers

Subsetting SPSS data imported into r with package haven?

I've used the package haven to read SPSS data into R. All seems ok, except that when I try to subset the data it doesn't seem to behave correctly. Here's the code (I don't have SPSS to create example data and can't post the real stuff):…
ssp3nc3r
  • 3,247
  • 2
  • 9
  • 22
1
vote
1 answer

Efficiently converting labelled variables to factors

I'm struggling with ways to efficiently turn labelled variables into factors. The dataset I'm working with is available from here: [https://www.dropbox.com/s/jhp780hd0ii3dnj/out.sav?dl=0][1]. It was an spss data file, which I like to use because of…
spindoctor
  • 1,359
  • 1
  • 11
  • 27
1
vote
1 answer

R importing using haven, use Stata 12 or sab7bdat source file?

The University of Cape Town make data available through it's DataFirst Portal. All their data is made available in the following formats: SAS (sab7bdat) SPSS Stata (12) I would like to import a dataset into R using the Haven package, which…
Bastiaan Quast
  • 2,057
  • 19
  • 43
1
vote
1 answer

R: Installing package from github/version?

I had previously installed haven from CRAN, but then installed haven from Github using devtools::install_github("hadley/haven") and wanted to check whether I got the correct version. sessionInfo() says, among other things: other attached…
FooBar
  • 13,456
  • 10
  • 65
  • 140