Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes in read_data() #65

Merged

Conversation

nicolassoarespinto
Copy link
Collaborator

@nicolassoarespinto nicolassoarespinto commented Aug 10, 2016

@lucasmation This request makes significant changes in both main_import_functions.R and import_wrapper_functions.R, so do not accept without reviewing.

I propose some modifications in our main functions to improve the user experience in 2 points:

Adds the possibility to point direct to a file in the import functions

To do that i added a new argument file to the functions. The new call becames:

d<- read_PME(ft = "vinculos",i = "2012.01", file= "C:/.../PME/PMEnova_2015/PMEnova.012012.txt")

The problem i see is confusion between root_path and file. To partially solve it i made the function to give feedback for the user linking the filled parameters with the expected behavior.

Example:

d<- read_PME(ft = "vinculos",i = "2012.01", file= "C:/.../PME/PMEnova_2015/PMEnova.012012.txt")

You have specified only the 'file' argument, in this case we will assume that data is in a .txt or .csv file stored in the adress specified by the 'file' parameter.

[1] "2012.01"
[1] "PMEnova.012012.txt"
[1] "PMEnova_2012"
[1] "PMEnova_2012/"
[1] "fwf"
[1] "C:/.../PME/PMEnova_2015/PMEnova.012012.txt"
Time difference of 2.155179 secs
0.1 Gb

Simplify read_data() to turn feasible to the user to use it instead of the wrapper functions

To do that, i made the argument metadata optional and excluded the argument dic_list and added an argument dataset, that should receive the name of the dataset to be imported.

The old call to read_data was:

data<-read_data(ft = "pessoas", i = 2014, read_metadata("PNAD"), dic = PNAD_dics,root_path = root_path)

Where PNAD_dics was an object with all dictionaries and a confusing construction. Although it is easy to obtain it with data(PNAD_dics).

The new call is:

data<-read_data(dataset = "PNAD", ft = "pessoas", i = 2014, root_path = root_path, file = file)

Where every argument has a unique and easy meaning.

As we were previously calling data("PNAD_dics") inside the wrapper function, this also solves some warnings in devtools:check() about the use of global variables.

…ation of the data and import data tha has been renamed.

Also, adds feedback to the user about the use of "root_path" , "file" or none of them to find the data files.

Also, remove "dic_list" argument, and put "dataset" instead, the function now get the dictionary with the wrapper get_import_dictionary()

Also, turn 'metadata' parameter into optional, if is not inputed the function will get the metadata with read_metadata(dataset)
@lucasmation
Copy link
Owner

Ok. I like the read_data() idea a lot. The other one adds a bit of complexity, so I don't know. Lets decide on monday

@lucasmation lucasmation merged commit b127bc0 into lucasmation:master Aug 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants