anttsou / qmj

8 stars 8 forks source link

Documentation for get_companies is unintuitive in explaining how it works. #12

Closed rynkwn closed 9 years ago

rynkwn commented 9 years ago

The documentation implies the function automagically retrieves the data, formats it as a text file, and then reads it in. I intend to edit this to make the requisite steps clearer.

Working on this now. Will close when I submit the pull request.

rynkwn commented 9 years ago

Facing a series of import issues, so I may leave this to someone who's more familiar with the process.

As a heads up, my editted documentation went as follows:

#' Gets the company names and tickers from a provided text
#' file made from the Russell 3000 Index list of component
#' companies.
#' 
#' This function makes it easier to update your
#' companies data set. Currently, there does not seem to be a 
#' good way of automatically converting a pdf to a text 
#' file, or to automatically read in pdf data in R.
#' 
#' In order to use this function, 

I suggest that what follows be more like a list, explicitly detailing what needs to happen in order for the function to work as intended. Preferably also including links to the Russell 3000 Index PDF document that's intended to be used (I think their link doesn't change for their most recent component list.) It's also unclear to me what part of the original document I was supposed to copy and paste (I played around with the entire document, and then was a bit more discriminating in copying and pasting what was more likely to be a friendly copy and paste).

I'm also unsure if the regex is complicated enough to correctly get the desired data. The reason for this is that any contiguous copy and paste will also get extra words as noise, like "Russell Investments" or "Russell Index". I wasn't able to test this due to the above importing errors, but intuitively I feel like this noise would make it into the resulting data set. Happily, I also think that our functions are robust enough that it would be alright, but the above is, I believe, an accurate observation.

I hadn't incorporated the regex section yet, but originally it was:

#' Reads in the contents of a text file created from the 
#' pdf of company names and tickers given by the Russell 
#' 3000 Index. As of now, there does not seem to be a very 
#' good way of converting from pdf to txt file in R, so 
#' the txt file is directly copied and pasted from the pdf 
#' and uses the following regex: [ ](?=[^ ]+$)
#' to create comma separated values. 

Suggested Improvements

1) Perhaps we wouldn't need to require that the companies.txt file be in extdata? It seems like it might be better to have the location of the companies.txt file be more flexible, though having it default to extdata might be fine. 2) Perhaps it'd be a bit easier to have the function read in the raw copied and pasted text file, apply the regex itself, and then read it in as a CSV file? This doesn't seem like a step the user need to do manually.

rynkwn commented 9 years ago

Anthoney, I think you'd be better off with the documentation here, since I believe you're a lot more comfortable with this process right now. Let me know if there's any way I can help.

anttsou commented 9 years ago

Hey Ryan, I will try to get get_companies to do that, but that is a bit tricky as I do not know how to directly modify txt files in R. The only reason for applying the regex before was so that it could be read as a csv, but there may be a way to do this in R that I haven't looked into yet.

anttsou commented 9 years ago

Found a way to automate the process. The user still needs to copy and paste from the pdf and save from the txt file, but apart from that the function will automate the rest. Will push soon.

rynkwn commented 9 years ago

Solved by Anthoney in Commit 785.