Comments (11)
There is no non-standard evaluation (NSE) feature implemented in eplusr yet.
AAA1
is treated as normal IDF field name. But by using rlang package, I think you could achieve what you want. Considering this below:
library(rlang)
library(eplusr)
AAA1 <- "Gross_Rated_Cooling_COP";
model6012Try$"Coil:Cooling:DX:SingleSpeed"$Thermal_Zone_ComputerRoom1_Coil_Cooling_DX_Single_Speed$set_value(!!AAA1:=3.2);
Please note the using of !!
and :=
which come from rlang package. I haven't try on my side yet as I can't access to my computer right now.
I am currently refactoring model editing functionalities to make $set_value()
more programming friendly. Stay tuned for next release.
from eplusr.
from eplusr.
The images were not uploaded.
I would suggest to comment in GitHub Issues instead of directly replying using email in order to make sure the images can be displayed correctly.
from eplusr.
Thanks for your kind help!
These two are the missed pictures in the last section:
from eplusr.
I think there are some problems to use $set_value if some variables are used to replace the class, object or field.
Can u suggest any other alternative ways to set new value for a specific field in a object in a class, e.g. changing value in the "Default" column of the following screen shot?
Thanks a lot.
from eplusr.
Thanks for reporting that.
Thanks for your kind help!
These two are the missed pictures in the last section:
There are probably some bugs in $set_value()
. It would be great if you could send me the debugging info by running traceback()
after each error occurred. That will make it much easier for me to find where the problem was.
I think there are some problems to use $set_value if some variables are used to replace the class, object or field.
Can u suggest any other alternative ways to set new value for a specific field in a object in a class, e.g. changing value in the "Default" column of the following screen shot?
Thanks a lot.
Could you please send me the IDF file if there is no confidential concern? Then I can try on my side.
As for alternative ways to set values, you can use $set_object()
in Idf
class. As I don't have the model, just using an example file here to demonstrate:
library(eplusr)
library(data.table) # for reading input data
# taking this as an example
path_idf <- file.path(eplus_config(8.8)$dir, "ExampleFiles", "HospitalLowEnergy.idf")
idf <- read_idf(path_idf)
# read input data
input <- data.table::fread(
"
index , class , object , field , default , new_value
1 , Coil:Heating:Fuel , Floor 1 Cafe Heat Pump Sup Heat Coil , 4 , 0.8 , 0.7
2 , Coil:Heating:Fuel , Floor 1 Clean Heat Pump Sup Heat Coil , 4 , 0.8 , 0.6
3 , Coil:Heating:Fuel , Floor 1 Conference Heat Pump Sup Heat Coil , 4 , 0.8 , 0.5
4 , Coil:Heating:Fuel , Floor 1 Dining Heat Pump Sup Heat Coil , 4 , 0.8 , 0.4
"
)
# get target field names
input[, `:=`(field_name = idf$definition(class)[[1L]]$field_name(field)), by = index]
# get correct input value format for $set_object()
format_input_value <- function (field_name, value) {
val <- list(value)
names(val) <- field_name
val
}
input[, `:=`(value = list(format_input_value(field_name, new_value))), by = index]
idf$set_object(object = input$object, value = input$value)
# check results
vapply(idf$object(input$object), function (obj) obj$get_value(4), list(1))
# $Floor_1_Cafe_Heat_Pump_Sup_Heat_Coil
# [1] 0.7
#
# $Floor_1_Clean_Heat_Pump_Sup_Heat_Coil
# [1] 0.6
#
# $Floor_1_Conference_Heat_Pump_Sup_Heat_Coil
# [1] 0.5
#
# $Floor_1_Dining_Heat_Pump_Sup_Heat_Coil
# [1] 0.4
#
from eplusr.
Also, please make sure to use the develop version as there was a bug in the CRAN version (v0.9.2) when updating value references (see #20).
You can install the develop version by doing:
devtools::install_github("hongyuanjia/eplusr")
from eplusr.
Also, please make sure to use the develop version as there was a bug in the CRAN version (v0.9.2) when updating value references (see #20).
You can install the develop version by doing:
devtools::install_github("hongyuanjia/eplusr")
Thanks,
I try to run "devtools::install_github("hongyuanjia/eplusr")"; But there is something wrong:
from eplusr.
Please restart R and RStudio and then do the installation.
You may also want to manually run install.packages(c("data.table", "lubridate"))
as they failed to install automatically in your case.
from eplusr.
The new version of 0.9.3 has been landed on CRAN. You can install the latest version from CRAN which has already fixed the issue #20.
from eplusr.
In version v0.10.0, $set()
in Idf
and IdfObject
class directly support inputs as lists. Close this.
from eplusr.
Related Issues (20)
- Viewer only renders 1 zone in 3 zone model HOT 4
- Provide a way to save and reload `EplusJob` and `EplusGroupJob`
- Document of the `IdfGeometry$coord_system()` isn't correct
- `IdfGeometry$coord_system()` did not work
- `IdfViewer$snapshot()` did not work for PNG output
- `Idf$load()` did not work with single string with no line break
- `$<-.IdfObject` did not work for `ScheduleCompact` object
- File encoding issue for `Idf$save()` HOT 1
- Add support for EnergyPlus v22.1.0
- Enable to use functions to modify fields in `Idf$set()`
- Update weather database based on the updates from OneBuilding
- `read_epw()` should respect `validate_level` option
- Failed to extract EPW data if the data of Feb. 28 is from a leap year HOT 1
- Plotting meter data HOT 2
- [CRAN] CRAN check NOTEs on HTML version of manual
- Release eplusr 0.15.2
- CRAN NOTE on duplicated `\item` entries in doc
- Add support for EnergyPlus v22.2.0
- Failed to parse EPW date due to an update of lubridate
- Consider to use stringi for date time manipulation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eplusr.