DIFM-Brain / ofpetrial

GNU General Public License v3.0
0 stars 1 forks source link

copy conv_unit frome measurements package but acknowledge the package #13

Closed tmieno2 closed 4 months ago

tmieno2 commented 4 months ago

https://stackoverflow.com/questions/35958856/using-another-r-package-function-without-using-the-whole-package-as-dependency

tmieno2 commented 4 months ago

So is the permn from the combinat package

tmieno2 commented 4 months ago

@brittanikedge, actually, should we just write our own function in place of conv_unit? We really don't use this function for many different kinds of conversions. The vast majority is ft to m and m to ft with several others like kg-lb.

brittanikedge commented 4 months ago

@tmieno2 Sorry, I had meetings and trials to design today. We can certainly do it. As you said, it is generally for ft/m, acres/hectares, and the other options for input units.

tmieno2 commented 4 months ago
Screenshot 2024-04-18 at 11 41 22 AM
brittanikedge commented 4 months ago

@tmieno2 I created the .csv file with the necessary units and the function. But I have two questions about this change.

First, I noticed that the conversion of the inputs still exists in the prepare_rate_info.R. Do you want me to make that another issue and remove it as we discussed in another meeting last week?

Second, I know you wanted to put things in data-raw rather than the inst/extdata. Then how is the data accessed when the function is used? I'm not familiar with that process as system.file seems designed to work with files only in the inst folder.

tmieno2 commented 4 months ago

@brittanikedge, sorry I just saw this!

Okay, so you can create the data object in R and then use usethis::use_data() along with other internal datasets. Then the data will be automatically saved to systata.rda in the R folder. Work in generate_datasets.R in the data-raw folder. Screenshot below shows the process of saving the objects. I am pretty sure once you take a look, it become very clear.

Screenshot 2024-04-30 at 7 56 42 AM
brittanikedge commented 4 months ago

@tmieno2 Thanks! No problem, I've been working on other things in the meantime. This is definitely very straightforward to do. I will save the conversion factors this way, check that it's working well, and close this issue!