[R] Evaluation failure of IAPWS95 functions in a rowwise manner (tidyverse style)
Ista Zahn
|@t@z@hn @end|ng |rom gm@||@com
Wed May 30 21:28:23 CEST 2018
Hi Shawn,
I don't think it has anything to do with the tidyverse. If you keep
simplifying your example you'll get all the way down to
> DTp(T=c(279,294),p=c(0.46,0.46))
[1] 1000.12283
--Ista
On Wed, May 30, 2018 at 2:14 PM, Shawn Way <SWay using meco.com> wrote:
> I'm trying to use the IAPWS95 package with the tidyverse packages. For some reason, the function is not outputting the correct rho.
>
> A minimal example with results is below. I've also included the definition of the DTp function from the IAPWS95 library.
> ====================================
> library(IAPWS95)
> library(tidyverse)
>
> initial <- data.frame(T=c(279,294),p=c(0.46,0.46))
> initial2 <- initial %>%
> mutate(rho=DTp(T,p))
>
>> DTp
> function (T, p)
> {
> y <- 0
> icode <- 0
> res <- .Fortran("DTp", as.double(T), as.double(p), as.double(y),
> as.integer(icode))
> options(digits = 9)
> if (res[[4]] != 0) {
> error <- as.character(errorCodes[which(errorCodes[, 1] ==
> res[[4]]), 2])
> print(error)
> }
> print(res[[3]])
> }
> <bytecode: 0x0000000006f520e0>
> <environment: namespace:IAPWS95>
>
> Results:
>
>> initial2
> T p rho
> 1 279 0.46 1000.12283
> 2 294 0.46 1000.12283
>
>
> What the results should be:
>
>> initial2
> T p rho
> 1 279 0.46 1000.12283
> 2 294 0.46 998.19167
>
> I think something is evaluating incorrectly, but I don't know enough about NSE vs SE to figure this out.
>
> Any thoughts to what could be the reason why the second row has the same rho as the first? When I run the function DTp individually, I get the right results.
>
>
> Shawn Way
>
>
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list