Open raphael-gouvea opened 6 years ago
I still think the POF_files_metadata_harmonization.csv
needs review because of the get_available_filetypes
.
The problem with the read_POF, however, is simple. Line 206 of the import_wrapper_functions.R
is invisible(file.remove(paste0(data_path,names(out),".txt")))
. The object out
was defined inside a previous if
statement that is valid only for years equal to 1987, 1995 and 1997 (I don't get why 1997 was included). Then, this line breaks the code when read_POF
is used for years 2002 and 2008. I'm not sending as a PR because I don't understand why this line is relevant. I only commented out the line to test and it does solve the problem.
It seems there is a similar issue with the POF 2008-2009 data. I get this error when I try to read the data.
# Set working directory
setwd("R:/Dropbox/bases_de_dados/POF/POF_2008-2009")
# download POF data
download_sourceData("POF", 2008, unzip = T)
# read POF data layout [This part works fine]
pof_dic_moradores <- get_import_dictionary(dataset = "POF",i = 2008, ft = "morador")
# read data
df_moradores <- read_POF(ft = "morador", i = 2008)
> Error in read_data(dataset = "POF", ft = ft, i = i, root_path = root_path, :
> Data not found. Check if you have unziped the data
@rafapereirabr, have you checked if the files were unzipped as stated in the error message? In your case, POF2008 files are zipped as .7z and you need to unzip them manually. As I stated in my previous comment, if you remove line 206 or move it to inside the if
statement of the import_wrapper_functions.R
and build the package you shold be able to use the read_POF function for 2002 and 2008.
Thank you for the heads up !
I also had an small issue using the read_POF function for the POF 2008-2009 data. I believe it came from using the download_sourceData function, which unzipped the microdata files as "Dadosyyyymmdd" instead of only "Dados" as required (I think) by the read_POF function to properly process the data. Manually renaming the folder fixed the issue.
After the update to include POF 1987/88 and 1995/95, the package is not working for POF 2002. I think you need to review the
POF_files_metada_harmonization.csv
and the read_POF seems to have a bug when creating the data_path. See reprex below.Created on 2018-07-25 by the reprex package (v0.2.0).