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

Changing units? #70

Closed
atillmanns opened this issue Mar 10, 2017 · 4 comments
Closed

Changing units? #70

atillmanns opened this issue Mar 10, 2017 · 4 comments
Assignees

Comments

@atillmanns
Copy link

atillmanns commented Mar 10, 2017

Somewhere in this package is there code for changing units of the parameters? e.g. the ability to select parameters reporting out in ug/L and change this to mg/L? Could you please point me to that section of code?

Thanks!

@joethorley
Copy link
Collaborator

@ateucher
Copy link
Contributor

@atillmanns did this help you solve your problem?

@ateucher
Copy link
Contributor

I will start by exporting the convert_values and add a few examples.

@ateucher ateucher self-assigned this May 30, 2017
@ateucher
Copy link
Contributor

@atillmanns You can use the convert_values function now like this:

library(wqbc)

convert_values(1, "ug/L", "mg/L", messages = FALSE)
#> [1] 0.001

df <- data.frame(value = c(1.256, 5400000, 12300, .00098),
                 units = c("mg/L", "ng/L", "ug/L", "g/L"),
                 stringsAsFactors = FALSE)
df
#>       value units
#> 1 1.256e+00  mg/L
#> 2 5.400e+06  ng/L
#> 3 1.230e+04  ug/L
#> 4 9.800e-04   g/L

df$units_mg_L <- convert_values(df$value, from = df$units, to = "mg/L", messages = FALSE)
df
#>       value units units_mg_L
#> 1 1.256e+00  mg/L      1.256
#> 2 5.400e+06  ng/L      5.400
#> 3 1.230e+04  ug/L     12.300
#> 4 9.800e-04   g/L      0.980

cc @HeatherGranger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants