Questions tagged [r-haven]

The `haven` package for `R`

118 questions
0
votes
1 answer

Assign value labels as string values in R

Hello I imported a dataset from SPSS in R, the dataset has labels and I want to use value labels as string values. Is there a way to do it? head(dataset$A7B1) : A7b1. Cantón de San José en que reside [1] NA NA NA 2 8 NA 4 NA…
jruizri
  • 36
  • 4
0
votes
0 answers

Using unz() to read in SAS data set into R

I am trying to read in a data set from SAS using the unz() function in R. I do not want to unzip the file. I have successfully used the following to read one of them in: dir <- "C:/Users/michael/data/" setwd(dir) dir_files <-…
0
votes
2 answers

Reading Dates/Times from a SAS file: read_sas vs. read.SAS7bdat

I am trying to replace the read.SAS7bdat function with read_sas from the haven package in a number of my programs due to speed. Simply substituting it in works perfectly and reads so much quicker. However, the only hang-up I encounter has to deal…
Nathan
  • 11
  • 2
0
votes
0 answers

Cannot install Haven R

I tried using both install.packages("tidyverse") and install.packages("haven"). However, it says -bash: syntax error near unexpected token '(' After running brew doctor, I received this message: Warning: "config" scripts exist outside your system or…
K24
  • 1
0
votes
0 answers

haven_labelled characters not compatible with srvyr package

hHI there: I have a large dataset imported from SPSS with the haven package and I'm trying to weight weight the data using the srvyr package; but it looks like the two do not play well together. It looks like I need to somehow to convert…
spindoctor
  • 1,359
  • 1
  • 11
  • 27
0
votes
1 answer

Error: `t.haven_labelled()` not supported while attempting MICE package in R

Here is my sample code: library(haven) community_surveys <- read_sav("community_surveys.sav") diss_data <- as.data.frame(community_surveys) diss_data$FOC_1 <- as.factor(diss_data$FOC_1) diss_data$DR_1 <- as.factor(diss_data$DR_1) diss_data$IR_1 <-…
0
votes
0 answers

Looping in Haven package

I have a dataset that contains about 9 million obs across 241 variables. So to avoid stress on the system, I tried to breakdown into chunks of a million each and then looping it. chunksize <- 1000000 index <- 0 repeat { index <- index + 1 …
0
votes
0 answers

How can I solve the "Haven_labelled error"

I need to run an ANOVA. My grouping variable is stored as a character - everything is fine. However, when I run the analysis I get that error: Don't know how to automatically pick scale for an object of type haven_labelled. Defaulting to…
Mariella
  • 21
  • 4
0
votes
0 answers

Reactive plots with R Shiny

I'm quite new to R and Shiny and wanted to create a boxplot with Shiny. Here is my code UI part ui <- shinyUI(fluidPage( titlePanel("Shiny app"), tabsetPanel( tabPanel( "Lab data (boxplot)", titlePanel("Lab data over time"), …
akben2
  • 19
  • 5
0
votes
2 answers

How to get labelled spss data back which is converted by as_factor in R

I am working on SPSS data in R. TO modify/append data from different files, I had to convert the data into factor (as_factor(x, levels = "both") method). Now I need to write data back into an .SAV file but I am not able to convert my factor…
kawsleo
  • 401
  • 2
  • 17
0
votes
0 answers

Problems with installing package haven

I'm trying to install the package haven, but when opening it in the library it is said: there is no package "hms". So I've tryed to install the packing "hms". But it gives me this error messages: > install.packages("hms", dependencies =…
Merete
  • 1
  • 1
0
votes
2 answers

if_else with haven_labelled column fails because of wrong class

I have the following data: dat <- structure(list(value = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "value: This is my label", …
deschen
  • 2,415
  • 2
  • 13
  • 25
0
votes
0 answers

Can the psych package help reverse code questions from data frames imported from SPSS with the haven package?

Most of the data I practice R with is imported from my SPSS files using the haven package. I am trying to reverse code a few columns for scales that go from 1 to 9 (i.e., trying to convert all 1s into 9s, 2s into 8s, etc.) and found another forum…
0
votes
1 answer

Extract Value Labels from a Stata file loaded with Haven (Value Labels not Variable Labels)

I am trying to get a list of the value labels from a data.frame I loaded with haven. My variables are stored as haven_labelled and I know that the value labels are there because when I run str() they are listed as an attribute. str( x$tranwork…
MatthewR
  • 2,399
  • 3
  • 20
  • 29
0
votes
1 answer

Difficulty with haven package Reading SPSS data in R

I am trying to use the haven package to read spss data and am getting the following error: Error in df_parse_sav_file(spec, encoding, user_na, cols_skip, n_max, : Failed to parse ~FilePath/Dataset: The file's timestamp string is …
hcav
  • 1