How to import .dat file into R

4

I downloaded a .dat file that is basically an array with data.

However, it seems to me that the only way to work with it is by doing the following command (I am using R and I do not have much experience with R):

   setwd("C:")
    load("dat73_1")

After this command "load" this file is "hidden" by R ??

The code used to read this file is as follows:

mylist<-c("CAN","FRA","DEU","ITA","JPN","GBR","G6") 

If I want the information regarding "CAN", it is only modify " cno in 1:7 " to " cno in 1:1 ".

  for (cno in 1:7){
      init_date<-c(1973,3)
      start_date <- init_date+c(6,3)
      end_date<-c(2009,10) 
      country<-mylist[cno]
      Cdat<-data.frame(window(ts(get(country),start=init_date,freq=12),start=start_date, end=end_date))}

I did this and was able to retrieve this file for all countries of mylist and created a new file in Excel. But I can not adapt the code to excel file. Is there any way to do this?

If I can "find" this .dat file it would help a lot.

OBS (Edited): When I use the command read.table the output is this (RStudio):

    
asked by anonymous 04.04.2017 / 04:58

1 answer

0

To open files in ".dta" format another alternative is to use the haven package. Then look for the read_dta function.

install.packages("haven")
library("haven")
read_dta()
    
27.04.2018 / 18:45