Comments (8)
Could you please attach a minimal example
from haven.
Here's an example:
library(haven)
# umlaut-test
mydf <- read_sav("umlauts.sav")
str(mydf)
# > str(mydf)
# Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 4 obs. of 1 variable:
# $ var1:Class 'labelled' atomic [1:4] 1 2 1 3
# .. ..- attr(*, "label")= chr "This is an ä-umlaut"
# .. ..- attr(*, "labels")= Named int [1:3] 1 2 3
# .. .. ..- attr(*, "names")= chr [1:3] "the ä umlaut" "the ü umlaut" "the ö umlaut"
library(sjPlot)
# my read_spss function is a wrapper for read.spss
# of the foreign-package. read_spss only available
# in current development snaphot at github.com/sjPlot/devel
mydf <- read_spss("umlauts.sav")
str(mydf)
# > str(mydf)
# 'data.frame': 4 obs. of 1 variable:
# $ var1: atomic 1 2 1 3
# ..- attr(*, "value.labels")= Named num 3 2 1
# .. ..- attr(*, "names")= chr "the ö umlaut" "the ü umlaut" "the ä umlaut"
# - attr(*, "variable.labels")= Named chr "This is an ä-umlaut"
# ..- attr(*, "names")= chr "var1"
# - attr(*, "codepage")= int 65001
# changing the encoding helps
mydf <- read_spss("umlauts.sav", enc = "UTF-8")
str(mydf)
# > str(mydf)
# 'data.frame': 4 obs. of 1 variable:
# $ var1: atomic 1 2 1 3
# ..- attr(*, "value.labels")= Named chr "3" "2" "1"
# .. ..- attr(*, "names")= chr "the ö umlaut" "the ü umlaut" "the ä umlaut"
# - attr(*, "variable.labels")= Named chr "This is an ä-umlaut"
# ..- attr(*, "names")= chr "var1"
# - attr(*, "codepage")= int 65001
from haven.
Can you attach the umlauts.sav file itself?
from haven.
@evanmiller it's possible this is a bug on my end - can I assume readstat_string_value()
is always UTF-8?
from haven.
Yes, it should always return UTF-8.
from haven.
@sjPlot can you please try again with the latest version? I pushed a possible fix
from haven.
Oh hmm, I only fixed it in one place (variable values) - I'll need to think a bit more to fix the labels.
from haven.
I don't know how to attach sav-files, but I just sent them to Hadley.
from haven.
Related Issues (20)
- Vulnerability in SAS7BCAT reader HOT 2
- Progress Bar for XPT HOT 1
- Returning full variable labels HOT 1
- New feature proposal: Reads creation/modified time of SAS7BDAT HOT 3
- Unable to allocate memory when opening a dta file HOT 1
- Upkeep for haven (2023)
- Use standard argument checkers
- `write_dta()` can error if labelled values are large enough
- Zero-length label worse than null label
- Remind the novice user of labelled-format? HOT 2
- Dates in labelled_spss HOT 3
- Release haven 2.5.4
- Allow `labels` to be passed through to `labelled()` as unnamed vector of same length as `x`
- Dataset label truncated after `write_xpt` HOT 5
- `read_xpt()` fails on misconstructed dates HOT 3
- typo in docs for as_factor
- read_sav default is to NOT encode user defined data
- `haven::read_sas` generates some message
- How to solve non-ascii output for `write_xpt` HOT 1
- write_sav is acting inconsistently for long string variables.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from haven.