eplusr provides a rich toolkit of using whole building energy simulation program EnergyPlus directly in R, which enables programmatic navigation, modification of EnergyPlus, conducts parametric simulations and retrieves outputs. More information about EnergyPlus can be found at its website.


You can install the latest stable release of eplusr from CRAN.

Alternatively, you can install the development version from GitHub.

Since running the IDF files requires EnergyPlus (https://energyplus.net), EnergyPlus has to be installed if you want to run EnergyPlus models in R. There are helper functions in eplusr to download and install it automatically on major operating systems (Windows, macOS and Linux):

Note that the installation process in install_eplus() requires administrative privileges. You have to run R with administrator (or with sudo if you are on macOS or Linux) to make it work if you are not in interactive mode.


  • Read, parse and modify EnergyPlus Input Data File (IDF)
  • Read, parse and modify EnergyPlus Weather File (EPW)
  • Query on models, including classes, objects and fields
  • Directly add, modify, duplicate, insert, and delete objects of IDF
  • Automatically change referenced fields when modifying objects
  • Save changed models into standard formats in the same way as IDFEditor distributed along with EnergyPlus
  • Run your models and collect the simulation output
  • Conduct parametric energy simulations and collect all results in one go

Class structure

Below shows the class structure in eplusr.

Basically, eplusr uses Idf class to present the whole IDF file and IdfObject class to present a single object in an IDF. Both Idf and IdfObject class contain member functions for helping modify the data in IDF so it complies with the underlying EnergyPlus IDD (Input Data Dictionary). Similarly, IDD file is wrapped into two classes, i.e. Idd and IddObject.

Besides, Epw class is used to present EnergyPlus Weather files; EplusJob to run single EnergyPlus simulation and collect outputs, ParametricJob to run parametric EnergyPlus simulations and collect all outputs.

It is highly recommended to read the documentation to get a thorough understanding on each class.

Read and parse

All IDF reading process starts with function read_idf(), which returns an Idf object. The model will be printed in a similar style you see in IDFEditor, with additional heading lines showing the Path, Version of the model. The classes of objects in the model are ordered by groups and the number of objects in classes are shown in square bracket.

Parsing an IDF requires the IDD data of that version, which serves as the schema. Usually, when you try to edit an IDF, the corresponding EnergyPlus is likely to be installed already. If EnergyPlus is installed in standard location (C:\EnergyPlusVX-Y-0 on Windows, /usr/local/EnergyPlus-X-Y-0 on Linux and /Applications/EnergyPlus-X-Y-0 on macOS), eplusr is able to find it and use the Energy+.idd file distributed with that release to parse the input IDF. The IDD file will be parsed first and an Idd object will be created and cached. That Idd object will be reused whenever parsing IDFs with that version. For more details, please see ?use_idd() and ?idd.

Sometimes you may just want to edit the model without installing the whole EnergyPlus software. You can just download the IDD file of that version using download_idd() or set download to TRUE in use_idd(). The code below will download IDD file for EnergyPlus v8.8.0, parse it and create an Idd object that will be used whenever parsing all EnergyPlus models of that version.

path_idd <- download_idd(8.8)

# OR
use_idd(8.8, download = TRUE)

Now let’s read an IDF file distributed with EnergyPlus 8.8.0. As we have already got the IDD, we can just ignore the idd argument.

Idf class provides lots of methods to programmatically query and modify EnergyPlus models. See table below. This vignette will demonstrate some of them.

Methods of Idf class
Category Method Functionality
Basic Info $version() Get Idf version
$path() Get Idf file path
$group_name() Get group names
$class_name() Get class names
$is_valid_group() Check group existence
$is_valid_class() Check class existence
Definition $definition() Get corresponding IddObject
Object Info $object_id() Get object unique ID
$object_name() Get object name
$object_num() Get object number in class
$is_valid_id() Check object ID existence
$is_valid_name() Check object name existence
Object Relation $object_relation() Get object relation with others
Object Query $object() Get object relation with others
$object() Get single object
$objects() Get multiple objects
$object_unique() Get the unique object
$objects_in_class() Get objects in class
$objects_in_group() Get objects in group
$objects_in_relation() Get objects in relation
$search_object() Get objects using regular expression
Object Modification $dup() Duplicate objects
$add() Add new objects
$set() Modify existing objects
$del() Delete existing objects
$rename() Change object names
$insert() Add new objects from other IdfObjects
$load() Add new objects from strings and data.frames
$paste() Add new objects from IDF Editor
$search_value() Get objects whose values match regular expression
$replace_value() Modify object values using regular expression
Validation $validate() Check any errors in Idf
$is_valid() Check if no error exists in Idf
Data Extraction $to_table() Extract Idf data in data.frames
$to_string() Extract Idf data in strings
Save $is_unsaved() Check if unsaved changes exist
$save() Save Idf to an .idf file
Clone $clone() Create an copy
Run $run() Run Idf together with an Epw
Print $print() Print Idf in different details

Below will show same example usage of methods listed above.

Class definition

You can get class definition using $definition(), which returns an IddObject. All required fields in each class are marked with *. For example, you can get the IddObject of class Material:

You can also achieve this using methods in Idd class.

With the IddObject, you can easily get class and field properties using methods it has.

For example, you can get all default field values using $field_default(). As we did not give any field index or name, a list is returned containing default values of all fields. The type of each value will be consistent with the field definition.

NOTE: For numeric fields with default values being "autosize" or "autocalculate", the type of returned values will be “character”.

Please see ?IddObject for detailed documentation on IddObject class.

Get object

In an Idf, all objects in the model are assigned with an unique ID according to their appearance sequences in the IDF file. You can find all valid IDs using $object_id().

You can get all object names using $object_name(). If the class does not have name attribute, NA will returned.

Object number in each class can be retrieved using $object_num().

model$object_num(c("BuildingSurface:Detailed", "Material", "Output:Variable"))
#> [1] 40 10 13

Having the object ID or name, you can easily get any object using $object() which returns an IdfObject or using $objects() which returns a list of IdfObjects.

NOTE: The matching of object names is case-insensitive. For instance, model$object("rOoF") is equivalent to model$object("roof").

If you want to get all objects in a single class, use $objects_in_class().

Also, you can get all objects in a single class using "$" or "[[". Class names can be given in underscore-style. For example, you can just use model$Material_NoMass instead of model$`Material:Nomass` to save some typing.

Based on the above, if you want to get the first object in class RunPeriod, you can simply run:

For unique object, such like SimulationControl and Building, you can use $object_unique()

Many fields in a model can be referred by others. For example, the Outside Layer and other fields in Construction class refer to the Name field in Material class and other material related classes. Here it means that the Outside Layer field refers to the Name field and the Name field is referred by the Outside Layer. $object_relation() provides a simple interface to get this kind of relation. It takes a single object ID or name and also a relation direction, and returns an IdfRelation object which contains data presenting such relation above.

Above shows that no-mass material MAT-CLNG-1 is used at the outside layer of a construction named CLNG-1. You can extract both of them using $objects_in_relation().

After you get the objects, you can perform detailed modifications on them using methods $set() in both Idf and IdfObject class.

Similarly, you can use "$" and "[[" to get a single value in an IdfObject class or "[" to get multiple values just like normal lists in R.

You can also make a chain.

Modify object

There are two ways to modify objects in eplusr. One is using methods in Idf which works on multiple objects, and the other way is using methods in IdfObject which only works for a single object.

NOTE: Validations are performed during object modifications under different strictness level (none, draft, final or custom yours using custom_validate()). For detailed explanations, please see ?level_checks.

Idf class provides 8 methods for modifying objects, including $dup(), $add(), $set(), $del(), $rename(), $insert(), $load() and $paste().

Object IDs will be appended after new objects are added, and the most-newly added object will always have the max ID. Object IDs will never be reused, even though their binded objects have been deleted using $del().

For modifying object’s comments and values, you can also use $comment() and $set() in IdfObject class.

Duplicate objects

$dup() duplicates objects specified by object IDs or names. If the target classes have a name attribute, you can assign new names to the duplicated objects in form new_name = "old_name". If new name is not given, the newly added object will have the same name as the original object except a appended suffix of “_1”, “_2” and etc.

Add new objects

You can add new objects using $add(). With .default being TRUE, the default behavior, all empty fields are filled with default values, if possible. Only minimum fields will be added by default. But you can change it by setting .all to TRUE.

You can also add new comments alongside with new values using the special element .comment.

For example, here we add two new objects with comments in RunPeriod class:

rp1 <- list(RunPeriod = list("rp_test_1", 1, 1, 2, 1, .comment = c("Comment for new object 1", "Another comment")))

  RunPeriod = list(name = "rp_test_2", begin_month = 3, begin_day_of_month = 1,
    end_month = 4, end_day_of_month = 1, .comment = "Comment for new object 2"
#> $rp_test_1
#> <IdfObject: `RunPeriod`> [ID:326] `rp_test_1`
#> ── COMMENTS ───────────────────────────────────────────────────────────────
#> !Comment for new object 1
#> !Another comment
#> ── VALUES ─────────────────────────────────────────────────────────────────
#> Class: <RunPeriod>
#> ├─ 01: "rp_test_1",      !- Name
#> │─ 02: 1,                !- Begin Month
#> │─ 03: 1,                !- Begin Day of Month
#> │─ 04: 2,                !- End Month
#> │─ 05: 1,                !- End Day of Month
#> │─ 06: "UseWeatherFile", !- Day of Week for Start Day
#> │─ 07: "Yes",            !- Use Weather File Holidays and Special Days
#> │─ 08: "Yes",            !- Use Weather File Daylight Saving Period
#> │─ 09: "No",             !- Apply Weekend Holiday Rule
#> │─ 10: "Yes",            !- Use Weather File Rain Indicators
#> └─ 11: "Yes";            !- Use Weather File Snow Indicators
#> $rp_test_2
#> <IdfObject: `RunPeriod`> [ID:327] `rp_test_2`
#> ── COMMENTS ───────────────────────────────────────────────────────────────
#> !Comment for new object 2
#> ── VALUES ─────────────────────────────────────────────────────────────────
#> Class: <RunPeriod>
#> ├─ 01: "rp_test_2",      !- Name
#> │─ 02: 3,                !- Begin Month
#> │─ 03: 1,                !- Begin Day of Month
#> │─ 04: 4,                !- End Month
#> │─ 05: 1,                !- End Day of Month
#> │─ 06: "UseWeatherFile", !- Day of Week for Start Day
#> │─ 07: "Yes",            !- Use Weather File Holidays and Special Days
#> │─ 08: "Yes",            !- Use Weather File Daylight Saving Period
#> │─ 09: "No",             !- Apply Weekend Holiday Rule
#> │─ 10: "Yes",            !- Use Weather File Rain Indicators
#> └─ 11: "Yes";            !- Use Weather File Snow Indicators

Set new values and comments

Changing values of existing objects can be conducted using $set() in Idf and IdfObject:

For setting a single value, you can even write in a chain:

Also, if the modified fields are referenced by fields in other objects, the corresponding fields will also be updated.

mat <- model$Material$CC03

#> ── Refer to Others ────────────────────────────────────────────────────────
#>   └─ 1: "CC03";        !- Name
#> ── Referred by Others ─────────────────────────────────────────────────────
#>   └─ 1: "CC03";        !- Name
#>      ^~~~~~~~~~~~~~~~~~~~~~~~~
#>      └─ Class: <Construction>
#>         └─ Object [ID:69] <FLOOR-SLAB-1>
#>            └─ 2: "CC03";        !- Outside Layer

mat$set(name = "CC03_renamed")
#> <IdfObject: `Material`> [ID:52] `CC03_renamed`
#> Class: <Material>
#> ├─ 1: "CC03_renamed", !- Name
#> │─ 2: "MediumRough",  !- Roughness
#> │─ 3: 0.1016,         !- Thickness {m}
#> │─ 4: 1.31,           !- Conductivity {W/m-K}
#> │─ 5: 2243,           !- Density {kg/m3}
#> │─ 6: 837,            !- Specific Heat {J/kg-K}
#> │─ 7: 0.9,            !- Thermal Absorptance
#> │─ 8: 0.65,           !- Solar Absorptance
#> └─ 9: 0.65;           !- Visible Absorptance

#> ── Refer to Others ────────────────────────────────────────────────────────
#>   └─ 1: "CC03_renamed";!- Name
#> ── Referred by Others ─────────────────────────────────────────────────────
#>   └─ 1: "CC03_renamed";!- Name
#>      ^~~~~~~~~~~~~~~~~~~~~~~~~
#>      └─ Class: <Construction>
#>         └─ Object [ID:69] <FLOOR-SLAB-1>
#>            └─ 2: "CC03_renamed";!- Outside Layer

Sometimes, you may want to get all possible values of fields before you change them. You can achieve that by using $value_possible() method in IdfObject class.

Insert objects

Sometimes it may be useful to insert objects from other IDFs. For example, you may want to import some design days and update location data from a “.ddy” file. You can achieve that using $insert().

# read ddy file as normal IDF
ddy <- read_idf("San_Francisco.ddy", idd = 8.8)

#> $`San Francisco Intl Ap Ann Htg 99.6% Condns DB`
#> <IdfObject: `SizingPeriod:DesignDay`> [ID:328] `San Francisco Intl Ap Ann Htg 99.6% Condns DB`
#> ── COMMENTS ───────────────────────────────────────────────────────────────
#> ! Using Design Conditions from "Climate Design Data 2009 ASHRAE Handbo...
#> ! San Francisco Intl Ap_CA_USA Extreme Annual Wind Speeds, 1%=12.8m/s,...
#> ! San Francisco Intl Ap_CA_USA Extreme Annual Temperatures, Max Drybul...
#> ! San Francisco Intl Ap_CA_USA Annual Heating Design Conditions Wind S...
#> ! Coldest Month=JAN
#> ! San Francisco Intl Ap_CA_USA Annual Heating 99.6%, MaxDB=3.8�C
#> ── VALUES ─────────────────────────────────────────────────────────────────
#> Class: <SizingPeriod:DesignDay>
#> ├─ 01: "San Francisco Intl Ap Ann Htg 99.6% Condns DB",  !- Name
#> │─ 02: 1,                  !- Month
#> │─ 03: 21,                 !- Day of Month
#> │─ 04: "WinterDesignDay",  !- Day Type
#> │─ 05: 3.8,                !- Maximum Dry-Bulb Temperature {C}
#> │─ 06: 0,                  !- Daily Dry-Bulb Temperature Range {deltaC}
#> │─ 07: "DefaultMultipliers",  !- Dry-Bulb Temperature Range Modifier T...
#> │─ 08: <"Blank">,          !- Dry-Bulb Temperature Range Modifier Day ...
#> │─ 09: "Wetbulb",          !- Humidity Condition Type

# get location data
loc <- ddy$Site_Location$value()

#> <IdfObject: `Site:Location`> [ID:10] `San Francisco Intl Ap_CA_USA Design_Conditions`
#> Class: <Site:Location>
#> ├─ 1: "San Francisco Intl Ap_CA_USA Design_Conditions",  !- Name
#> │─ 2: 37.62,              !- Latitude {deg}
#> │─ 3: -122.4,             !- Longitude {deg}
#> │─ 4: -8,                 !- Time Zone {hr}
#> └─ 5: 2;                  !- Elevation {m}

Load objects

Here load means insert. You can use character vectors or data.frames to load new objects.

The relation is automatically generated whenever new fields are added or modified.

#> ── Refer to Others ────────────────────────────────────────────────────────
#>   Class: <Construction>
#>   └─ Object [ID:346] <new_const1>
#>      └─ 2: "WD10";        !- Outside Layer
#>         v~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#>         └─ Class: <Material>
#>            └─ Object [ID:43] <WD10>
#>               └─ 1: "WD10";        !- Name
#> ── Referred by Others ─────────────────────────────────────────────────────
#> Target(s) is not referred by any other field.
#> ── Refer to Others ────────────────────────────────────────────────────────
#>   Class: <Construction>
#>   └─ Object [ID:347] <new_const2>
#>      ├─ 2: "RG01",        !- Outside Layer
#>      │  v~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#>      │  └─ Class: <Material>
#>      │     └─ Object [ID:44] <RG01>
#>      │        └─ 1: "RG01";        !- Name
#>      │     
#>      │─ 3: "BR01",        !- Layer 2
#>      │  v~~~~~~~~~~~~~~~~~~~~~~~~~~~
#>      │  └─ Class: <Material>
#>      │     └─ Object [ID:45] <BR01>
#>      │        └─ 1: "BR01";        !- Name
#>      │     
#>      │─ 4: "IN46",        !- Layer 3
#>      │  v~~~~~~~~~~~~~~~~~~~~~~~~~~~
#>      │  └─ Class: <Material>
#>      │     └─ Object [ID:46] <IN46>
#>      │        └─ 1: "IN46";        !- Name
#>      │     
#>      └─ 5: "WD01";        !- Layer 4
#>         v~~~~~~~~~~~~~~~~~~~~~~~~~~~
#>         └─ Class: <Material>
#>            └─ Object [ID:47] <WD01>
#>               └─ 1: "WD01";        !- Name
#> ── Referred by Others ─────────────────────────────────────────────────────
#> Target(s) is not referred by any other field.

Delete object

$del() will delete current objects specified by object IDs or names. For example, in current model, there is a material named "MAT-CLNG-1" in class Material:NoMass. Let’s see if it has been referred by other objects.

As we can see, MAT-CLNG-1 has been referred by a construction named "CLNG-1".

First, let’s try to direct delete Material MAT-CLNG-1.

We got an error, because directly deleting MAT-CLNG-1 will introduce invalid reference in Construction CLNG-1.

In some cases, you may still want to delete that object. You can achieve this by setting .force to TRUE.

Paste from IDF Editor

Once an IDF file is opened in IDF Editor, you can copy objects by clicking the Copy Obj button in IDF Editor, and use $paste() to insert those objects into current Idf. Note that IDF Editor only exists on Windows, which means that $paste() will also work only on that platform.


$validate() checks if there are errors in current Idf under specified validation level. You can customize what kind of errors to check by changing the level argument. The default validation level is equal to eplusr_option("validate_level").

There are 10 different validation check components in total. Three predefined validation level are included, i.e. "none", "draft" and "final". To get what validation components those levels contain, use level_checks().

In the previous section, we delete Material MAT-CLNG-1.

The final validation level turns all components on. We can just trigger invalid reference checking using custom_validate() function.

As we can see, the invalid reference in construction CLNG-1 is successfully detected.

In this example, we already knows that CLNG-1 is the invalid object. In many cases, we don’t know what that information in advance, we can extract invalid objects for different types directly using $validate(). Below, we extract all objects that have invalid reference errors.

Then we can use $set() to correct them. We can get all possible values for field Outside Layer using $value_possible() method in IdfObject class.

Now let’s change the construction’s Outside Layer to WD10.


You can save your model using $save(). If no path is given, the path of model itself will be used. This may overwrite the current file which has a risk of losing your original file and data. You have to set overwrite to TRUE to confirm the process.

model$save(overwrite = TRUE)


Run and Collect Output

eplusr uses the EnergyPlus command line interface which was introduced since EnergyPlus v8.3.0, which means that $run() only supports models with version higher than v8.3.0.

eplusr will auto-detect already installed EnergyPlus in the standard installation locations. You can get all detected EnergyPlus versions using avail_eplus().

$run() will issue an error if corresponding version of EnergyPlus is not found. If your EnergyPlus was not installed in standard location, you can add that location using use_eplus(). After adding, all models of that version will use this path to call EnergyPlus.


If the needed version of EnergyPlus was not installed, you can use install_eplus() to install it.

install_eplus(ver = 8.8)

$run() will run the current model with specified weather using corresponding version of EnergyPlus. The model and the weather used will be copied to the output directory. An EplusJob object will be returned which provides detailed information of the simulation and methods to collect simulation output. Please see ?EplusJob for details.

Retrieve simulation output

eplusr uses the EnergyPlus SQL output for extracting simulation output. In order to do so, an object in Output:SQLite class with Option Type value of SimpleAndTabular will be automatically created if it does not exists. EplusJob has provided some wrappers that do SQL queries to get report data results, i.e. results from Output:Variable and Output:Meter*. But for Output:Table results, you have to be familiar with the structure of the EnergyPlus SQL output, especially for table “TabularDataWithStrings”. For details, please see “2.20 eplusout.sql”, especially “ TabularData Table” in EnergyPlus “Output Details and Examples” documentation.

$report_data_dict() returns a data.table which contains all information about report data. For details on the meaning of each columns, please see “ ReportDataDictionary Table” in EnergyPlus “Output Details and Examples” documentation.

$report_data() extracts the report data using key values and variable names. Just for demonstration, let’s get the transformer input electric power at 11 a.m for the first day of RunPeriod named SUMMERDAY, tag this simulation as case example, and return all possible output columns.

$tabular_data() extracts all tabular data. For details on the meaning of each columns, please see “ TabularData Table” in EnergyPlus “Output Details and Examples” documentation.

Now let’s get the total site energy per total building area. Note that the value column in the returned data.table is character types, as some table store not just numbers. We need to manually convert it.

Run Parametric Analysis

eplusr provides tools to do parametric simulations which take full advantages of eplusr’s model editing and result collecting functionalities. You can create a parametric job using param_job(), which takes an IDF file or an Idf object as the seed and an EPW file or an Epw object as weather.

param_job() returns a ParametricJob object which provides a prototype of conducting parametric analysis of EnergyPlus simulations. For more details, please see ?param.

Apply measure

$apply_measure() allows to apply a measure to an Idf and create parametric models for simulations. Here, the concept of measure in eplusr is inspired by “measures” in OpenStudio. Basically, a measure is just a function that takes an Idf object and other arguments as input, and returns a modified Idf object as output. Use ... to supply different arguments to that measure.

Let’s create a function that modifies infiltration rate:

The measure set_infil_rate() is pretty simple. First, it gets all objects in class ZoneInfiltration:DesignFlowRate. Then it sets ACH in all zones to the input value.

Now, let’s apply this measure to the seed model with different infiltration rates from 0.0 to 4.0, respectively.

As we can see, 5 models have been created. As we left .names as NULL, each newly created models will be named as a combination of measure name and model number.

Run in parallel and collect results

Now let’s run the parametric job. All simulations will be run in parallel. The number of parallel EnergyPlus processes can be specified using option num_parallel. Now let’s run all simulations and wait them to finish.

After all simulations completed, let’s see the variations of total energy.

case Total Energy (GJ)
set_infil_rate_1 1.33
set_infil_rate_2 1.35
set_infil_rate_3 1.36
set_infil_rate_4 1.38
set_infil_rate_5 1.39