Can't read .dta file

Hello,

This is the first time I use R. I can't read a .dta file. I keep receiving errors when I try to install haven package or tidyverse package - in order to read a .dta file. But I'm not sure this is the only problem since I don't know the software. Could someone help me?

PS: I updated the R Studio to version 1.3.1093 and I have the same error and warning.
Warning in install.packages : installation of package ‘haven’ had non-zero exit status

Hello @tuttifrutti,

Welcome to the forum. Can you provide some more details? Which version of R do you have installed? Can you share the commands/code you tried to get haven to work?

I have R version 3.4.4-1ubuntu1. I tried with the Tools/Install Packages in RStudio and writing the command install.packages("haven")in the prompt.

My ubuntu knowledge is next to nothing unfortunately.

I take it you've worked through similar steps like here for your system: https://linuxize.com/post/how-to-install-r-on-ubuntu-18-04/ ?

Did you install the build-essential? Which version of Ubuntu are you running?

Not yet. It seems more complicated. Accordingly to this instruction, I guess I should install this CRAN repository, but I can't. There is a problem with the server that has the key. And I get two error messages, one when I try to install the key and another to the repository. I have Ubuntu 18.04.

Yeah, https://cran.r-project.org/ is the central place we all download R and packages typically.

Can you share those error messages?

Executing: /tmp/apt-key-gpghome.K6p38nduld/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
gpg: keyserver receive failed: Server indicated a failure

Hmm looks like that might be related to firewall settings. Look at the highest rated answer here: https://unix.stackexchange.com/questions/399027/gpg-keyserver-receive-failed-server-indicated-a-failure

I'm sorry. I appreciate your help, but I have basic knowlegde of computing and I don't understand the instructions on that answer.

I found the problem. There was a package in the wrong place. I removed and it worked. But the result is a tibble and I need the entire database in a format I can use - and I don't know how to use it in R yet.

It is in a tibble at the moment. What is wrong with that?

It has only 10 rows and the complete table has 13.000 entries. I can't read and work with the data.

If it is a tibble, is it just showing the first ten rows by default? Can you show some output?

For example:

> iris %>% 
+   as_tibble()
# A tibble: 150 x 5
   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
          <dbl>       <dbl>        <dbl>       <dbl> <fct>  
 1          5.1         3.5          1.4         0.2 setosa 
 2          4.9         3            1.4         0.2 setosa 
 3          4.7         3.2          1.3         0.2 setosa 
 4          4.6         3.1          1.5         0.2 setosa 
 5          5           3.6          1.4         0.2 setosa 
 6          5.4         3.9          1.7         0.4 setosa 
 7          4.6         3.4          1.4         0.3 setosa 
 8          5           3.4          1.5         0.2 setosa 
 9          4.4         2.9          1.4         0.2 setosa 
10          4.9         3.1          1.5         0.1 setosa 
# ... with 140 more rows

Even better, can you provide a reproducible example?

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.