Questions tagged [r-haven]

Use this tag for questions related to the `haven` package for the R programming language. The `haven` package "enables R to read and write various data formats used by other statistical packages". For more information on the `haven` package see the [package website](https://haven.tidyverse.org/index.html).

159 questions
0
votes
1 answer

Change levels and labels using the `as_factor` R haven function for table1 output

I am trying to create a descriptive statistics table using the table1 with p-values and data from an SAV file. I read in the file using read_sav from the haven package. library(haven) library(table1) library(tidyverse) df<-…
m13op22
  • 2,168
  • 2
  • 16
  • 35
0
votes
1 answer

failed to parse using R package haven read_sas

I'm importing a sas data file (.sas7bdat) and its corresponding formats (in R language called "labels") with a (.sas7bcat) file to R using haven's package command "read_sas". Importing the sas file on its own work just fine. However, when I try to…
ebay
  • 109
  • 1
  • 7
0
votes
1 answer

head() function failing

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)…
0
votes
0 answers

How to I update SPSS column labels in R?

In SPSS there appears to be the column name and then the column "label" which is like a description of the column. If I load an SPSS file into R via haven and a look at the file with the "View" function, I can see the column label written under the…
James B
  • 474
  • 2
  • 10
0
votes
1 answer

Read first column of .sav file in R

I want to read a .sav file into R. However, it is much too large (>11GB). If I could read in only portions of the data, that should be fine though not ideal. So, is there a way to do any of the following: Read just the header (for column…
Trent
  • 771
  • 5
  • 19
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
  • 34
  • 5
0
votes
1 answer

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 <-…
maguiremq
  • 1
  • 1
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

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
  • 39
  • 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
  • 560
  • 4
  • 23
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
  • 2
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
2 answers

How to read multiple large sas data files into R, filter rows and save subset datasets as .rds

I have 30 sas-files (dataset1.sas7bdat through dataset30.sas7bdat, approx. 10 GB per file) in a folder, and need to analyse a subset of rows in these data files (all rows where the character variable A begins with 10). Thus, I need to read each of…
Aastedet
  • 11
  • 4
0
votes
0 answers

Convert character column to factor preserving column label

I have a dataframe that I read from the XLSX file. Every column name looks like this: CODE___DESCRIPTION so for example A1___Some funky column here. It is easier to use the codes as colnames but I want to use description when needed so it must be…
Matiasko
  • 187
  • 9
1 2 3
10
11