mankojag
mankojag

Reputation: 71

Cannot assemble COIN object, due to column names and indicator codes not matching with makeCOIN(IndData) in COINr6 R package

This question concerns the package COINr6 for R, used for composite indicator construction.

I am encountering a problem when assembling my COIN. The error when calling KULI <- assemble(IndData = data, IndMeta = metadata, AggMeta = aggmeta)

is:

Error in makeCOIN(IndData) : 
  Indicator codes in metadata table and indicator table are not the same. Please correct.

Although, I believe the Indicator code in my metadata table and the indicator codes in the data match exactly, because:

> metadata$IndCode
 [1] "UnitName"                 "UnitCode"                 "income"                   "no_households"           
 [5] "maori_pr"                 "dampness"                 "no_intersections_in_100m" "station_dist"            
 [9] "bus_dist"                 "ev_dist"                  "conv_st_dist"             "petrol_st_dist"          
[13] "biking_len_100m"          "second_dist"              "primary_dist"             "childcare_dist"          
[17] "cinemas_dist"             "galleries_dist"           "libraries_dist"           "museum_dist"             
[21] "theatre_dist"             "bigpark_dist"             "smallpark_dist"           "chemists_dist"           
[25] "dentist_dist"             "supermarket_dist"         "x_lon"                    "x_lat"

And

> colnames(data)
 [1] "UnitName"                 "UnitCode"                 "income"                   "no_households"           
 [5] "maori_pr"                 "dampness"                 "no_intersections_in_100m" "station_dist"            
 [9] "bus_dist"                 "ev_dist"                  "conv_st_dist"             "petrol_st_dist"          
[13] "biking_len_100m"          "second_dist"              "primary_dist"             "childcare_dist"          
[17] "cinemas_dist"             "galleries_dist"           "libraries_dist"           "museum_dist"             
[21] "theatre_dist"             "bigpark_dist"             "smallpark_dist"           "chemists_dist"           
[25] "dentist_dist"             "supermarket_dist"         "x_lon"                    "x_lat"

And to confirm:

> colnames(data)==metadata$IndCode
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[23] TRUE TRUE TRUE TRUE TRUE TRUE

So very clearly all the columns of my indicators match the IndCode column in the metadata, so I really do not know how to fix this problem.

I would really appreciate it if you could help me understand what I’m doing wrong. Thanks!

Upvotes: 0

Views: 44

Answers (1)

mankojag
mankojag

Reputation: 71

The problem was that I shouldn't include the UnitName and UnitCode in the indicator metadata, also needed to take out the x_ variables from IndMeta.

Upvotes: 0

Related Questions