Import multiple .dta files, remove haven labelled fomat, create a dataframe from all imported dta files

HI,
I am trying to import multiple .dta files and create a dataframe from all imported dta files . I try using the following code but it didn't work. It works for csv files, but I don't have stata to save the plus 100 files I am trying to import and get into a dataframe.

head(vnm)
#> # A tibble: 6 x 352
#>   idstd  id    preference rotation a0    a1    a1a   a2    a3a   a3a2  a3b  
#>   <chr>  <chr> <chr>      <lgl>    <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 598835 7     28         NA       1     99    7     3     3     7     2    
#> 2 598836 14    10         NA       1     99    7     3     3     7     2    
#> 3 598837 17    35         NA       1     99    7     3     2     7     2    
#> 4 598838 45    40         NA       1     99    7     3     3     7     2    
#> 5 598839 48    6          NA       1     99    7     3     3     7     2    
#> 6 598840 50    24         NA       1     99    7     3     3     7     2    
#> # ... with 341 more variables: a3c <chr>, a3 <chr>, a4a <chr>, a4b <chr>,
library(tidyverse)
tbl1 <-
  list.files(pattern = "*.dta") %>% 
  map_df(~read_dta(.))
Error: Can't convert from `$a1` <labelled<double>> to `$a1` <labelled<double>> due to loss of precision.
* Locations: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, ...
Values are labelled in `$a1` but not in `$a1`.

Obviously we don't need all hundred files (or even the entirety of any one file), but it's going to be hard to troubleshoot this without some sort of reproducible example.

Could you please turn this into a self-contained reprex (short for reproducible example)?

There's a nice FAQ on how to do a minimal reprex for beginners, below:

For pointers specific to the community site, check out the reprex FAQ.

Thank you for your comment. I've edited my post.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.