Skip to content

using haven::write_xpt to write a data frame with one column ignores empty rows at the bottom #754

@ynsec37

Description

@ynsec37

The below data frame has 3 rows that the end of 2 rows are NA and "", the output xpt file only keeps the first non missing rows.

whether this case is normal or how to keep all 3 rows

  df <- data.frame(a = c("a", NA, ""))

  df2 <- haven::write_xpt(df, "test.xpt")

  identical(df, df2)
#> [1] TRUE

  df3 <- haven::read_xpt("test.xpt")
  
  df3
#> # A tibble: 1 × 1
#>   a    
#>   <chr>
#> 1 a

  identical(df, df3)
#> [1] FALSE

Created on 2024-05-15 with reprex v2.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorreadstatrequires updates to ReadStat

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions