Skip to contents

The .tidydf should be grouped as needed.

Usage

S_units_from_tidy(
  .tidydf,
  Product = "Product",
  Unit = "Unit",
  S_units = "S_units"
)

Arguments

.tidydf

the data frame from which an S_units matrix is to be formed

Product

the name of the Product column in .tidydf. Default is "Product".

Unit

the name of the Unit column in .tidydf. Default is "Unit".

S_units

the name of the S_units column to be added to .tidydf. Default is "S_unit".

Value

a data frame containing grouping variables and a new S_unit column

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
library(matsindf)
library(Recca)
UKEnergy2000tidy %>%
  group_by("Country", "Year", "Energy.type", "Last.stage") %>%
  S_units_from_tidy()
#>   "Country" "Year" "Energy.type" "Last.stage"
#> 1   Country   Year   Energy.type   Last.stage
#>                                                                                                                                                                                                                                                                                                      S_units
#> 1 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1