wpinvestigative / arcos

https://wpinvestigative.github.io/arcos/
Other
30 stars 18 forks source link

Function Not Found "drug_county_raw" #12

Open MLSun-A opened 3 years ago

MLSun-A commented 3 years ago

Hi! I want to get county-level data for the use of Oxycodone only and tried the function "drug_county_raw" to filter for it. However, it reminds me that the function can not be found in R. I was wondering whether I did something wrong. Did anyone else meet the same problem and could guide me through it? Thanks in advance!

jeffcsauer commented 3 years ago

@MLSun-A I think you are referencing an older version (<1.0) of the docs. Could you try the following?

This currently works for me:

library(arcos)
test <- county_raw(state="WV", county="Mingo", key="WaPo")
head(test)

# A tibble: 6 x 42
  REPORTER_DEA_NO REPORTER_BUS_ACT REPORTER_NAME REPORTER_ADDL_C~ REPORTER_ADDRES~
  <chr>           <chr>            <chr>         <chr>            <chr>           
1 PH0035964       DISTRIBUTOR      H D SMITH WH~ null             4650 INDUSTRIAL~
2 PH0035964       DISTRIBUTOR      H D SMITH WH~ null             4650 INDUSTRIAL~
3 PH0035964       DISTRIBUTOR      H D SMITH WH~ null             4650 INDUSTRIAL~
4 PH0035964       DISTRIBUTOR      H D SMITH WH~ null             4650 INDUSTRIAL~
5 PH0035964       DISTRIBUTOR      H D SMITH WH~ null             4650 INDUSTRIAL~
6 RD0277409       DISTRIBUTOR      MASTERS PHAR~ DBA: RIVER CITY~ 11930 KEMPER SP~
MLSun-A commented 3 years ago

@jeffcsauer Thanks for your reply!

Sorry for not making it clear. What I want to look at is different drug disperses at a county-year level. For example, the disperse of Oxycontin at county Mingo in the year 2009 is needed. And I want to collect the disperse of Oxycontin for every county from 2006 to 2014. The function "drug_county_raw" is perfect for data requirement since it reports the disperse for every drug at a county level across years. However, the function cannot be found when I followed the arcos API wrappers. Would you mind taking a look at this?

library(arcos) mingo_wv_oxy <- drug_county_raw(drug="Oxycodone", county = "Mingo", state="WV", key="WaPo") Error in drug_county_raw(drug = "Oxycodone", county = "Mingo", state = "WV", : could not find function "drug_county_raw"

I also tried the function "county_raw", while it seems the server is overwhelmed.

library(arcos) test <- county_raw(state="WV", county="Mingo", key="WaPo") Sorry, our server must be overwhelmed. Try again in a little bit. If it persists, let us know at https://github.com/wpinvestigative/arcos/issues Sorry, our server must be overwhelmed. Try again in a little bit. If it persists, let us know at https://github.com/wpinvestigative/arcos/issues

jeffcsauer commented 3 years ago

@MLSun-A no need to apologize, all good!

If you examine the core R file that contains all the available functions in arcos, you will see that drug_county_raw() does not exist. I'm not sure why this is - it may be a planned or deprecated function.

I believe you can get the data you want using the drug_fips_biz command. For example, the following command returns all shipments involving Fentanyl in Autauga, AL:

drug_fips_biz(drug="Fentanyl", fips="01001", key="WaPo")

You can get the date of the shipment from the TRANSACTION_DATE field.

Regarding the 'Sorry, our server must be overwhelmed. Try again in a little bit. If it persists, let us know at https://github.com/wpinvestigative/arcos/issues', other users have also recently started reporting this issue. I'm not sure why this is happening, but it may be that the server is being queried too frequently. If you are using a loop of sorts, definitely build in a pause between queries.

andrewbtran commented 3 years ago

Hi, drug_county_raw in the api is drug_county_biz (or drug_fips_biz) in the R wrapper because there's the added functionality of being able to query by business type. Well, the filtering is in process. At the moment it will give you all businesses.

https://wpinvestigative.github.io/arcos/reference/drug_county_biz.html

The server is overwhelmed messages seem inconsistent and I'm still trying to figure out what's happening.

On my laptop, it loads but when I remotely log in to another computer and run that query, I get that overwhelmed error and it won't go away. I'm literally running the functions repeatedly in one window locally and in another window over a vpn and one works and one doesn't. It's so weird.

jeffcsauer commented 3 years ago

Thanks for the quick reply!

Totally understand - no worries. I have not yet received the 'overwhelmed' error. If it keeps popping up perhaps I could type up some simple instructions to access the arcos_all.tsv file as a SQLite database via R. It's just a few lines of code and so long as people have some free space on their drive (100-200GB) it could be an alternative solution.

MLSun-A commented 3 years ago

@andrewbtran @jeffcsauer Thanks for your helpful suggestion! The drug_fips_biz command works perfectly and the data is exactly what I want. However, I have a follow-up question. Using this drug_fips_biz command, I can only get the drug details for one county each time. Is there any other function or operations that I can get the same information for all counties in one time? I know that is kind of unrelated with the original issue I posted, but I really appreciate your time and help!