We’re tickled pink to announce the release of
haven
2.3.0. haven allows you to read and write SAS, SPSS, and Stata data formats from R, thanks to the wonderful
ReadStat
C library written by
Evan Miller
.
You can install haven from CRAN with:
1
|
install.packages("haven")
|
This release is mainly in preparation for dplyr 1.0.0. It includes improved
vctrs support
for the labelled() class that haven uses to represent labelled vectors that come from SAS, Stata, and SPSS. This is not terribly exciting, but it means that the labelled class is now preserved by every dplyr operation where it makes sense:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
library(haven)
library(dplyr, warn.conflicts = FALSE)
x <- labelled(sample(5), c("bad" = 1, "good" = 5), "scores")
df <- tibble(x, y = letters[c(1, 3, 5, 7, 9)])
df
#> # A tibble: 5 x 2
#> x y
#> <int+lbl> <chr>
#> 1 5 [good] a
#> 2 3 c
#> 3 4 e
#> 4 1 [bad] g
#> 5 2 i
df %>% arrange(x)
#> # A tibble: 5 x 2
#> x y
#> <int+lbl> <chr>
#> 1 1 [bad] g
#> 2 2 i
#> 3 3 c
#> 4 4 e
#> 5 5 [good] a
df %>% filter(y %in% c("a", "c"))
#> # A tibble: 2 x 2
#> x y
#> <int+lbl> <chr>
#> 1 5 [good] a
#> 2 3 c
bind_rows(df, df)
#> # A tibble: 10 x 2
#> x y
#> <int+lbl> <chr>
#> 1 5 [good] a
#> 2 3 c
#> 3 4 e
#> 4 1 [bad] g
#> 5 2 i
#> 6 5 [good] a
#> 7 3 c
#> 8 4 e
#> 9 1 [bad] g
#> 10 2 i
df2 <- tibble(y = letters[1:10])
df2 %>% left_join(df)
#> Joining, by = "y"
#> # A tibble: 10 x 2
#> y x
#> <chr> <int+lbl>
#> 1 a 5 [good]
#> 2 b NA
#> 3 c 3
#> 4 d NA
#> 5 e 4
#> 6 f NA
#> 7 g 1 [bad]
#> 8 h NA
#> 9 i 2
#> 10 j NA
|
Acknowledgements#
As always thanks to the GitHub community who helped make this release happen:
@180312allison
,
@armenic
,
@batpigandme
,
@beckerbenj
,
@bergen288
,
@courtiol
,
@deschen1
,
@edvbb
,
@Ghanshyamsavaliya
,
@hadley
,
@JackLandry
,
@Jagadeeshkb
,
@jimhester
,
@kurt-vd
,
@larmarange
,
@lionel-
,
@mayer79
,
@mikmart
,
@mitchelloharawild
,
@omsai
,
@pdbailey0
,
@randrescastaneda
,
@richarddmorey
,
@romainfrancois
,
@rubenarslan
,
@sda030
,
@Sdurier
, and
@tobwen
.