Difference between revisions of "Central product classification"
From Testiwiki
(code seems to work now) |
(some description of CPC added) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Life cycle assessment]] | [[Category:Life cycle assessment]] | ||
+ | [[Category:Contains R code]] | ||
{{variable|moderator=Jouni}} | {{variable|moderator=Jouni}} | ||
Line 8: | Line 9: | ||
== Answer == | == Answer == | ||
− | <rcode> | + | {{attack|#|Something wrong with the first-level codes (there is a leading zero although should not be). This was corrected, but is there more problems with the data?|--[[User:Jouni|Jouni]] ([[User talk:Jouni|talk]]) 23:05, 27 December 2013 (EET)}} |
+ | |||
+ | <rcode name="answer" label="Show classification levels 1-2" embed=1> | ||
library(OpasnetUtils) | library(OpasnetUtils) | ||
− | |||
− | objects. | + | objects.latest("Op_en5914", code_name = "initiate") |
+ | |||
+ | CPC <- EvalOutput(CPC) | ||
+ | |||
+ | oprint(CPC@output[CPC@output$CPC.level < 3 , ]) | ||
+ | |||
+ | oprint(head(CPC@output)) | ||
+ | |||
+ | </rcode> | ||
+ | |||
+ | |||
+ | <rcode name="subclasses" label="Show lower classification levels" embed=1 variables=" | ||
+ | name:class|description:Which class do you want to see in detail?|type:text|default:011 | ||
+ | "> | ||
+ | library(OpasnetUtils) | ||
+ | |||
+ | objects.latest("Op_en5914", code_name = "initiate") | ||
+ | |||
+ | CPC <- EvalOutput(CPC) | ||
+ | |||
+ | oprint(CPC@output[regexpr(class, CPC@output$CPC.code) == 1 , ]) | ||
− | |||
</rcode> | </rcode> | ||
== Rationale == | == Rationale == | ||
− | UN CPC version 2 seems to be an optimal choice. | + | UN CPC version 2 seems to be an optimal choice. It contains a hierarchical system for products, 4408 rows in total. It is organised in five hierarchical levels. It is based on ten categories at the top level, numbered from 0 to 9: |
[http://unstats.un.org/unsd/cr/registry/cpc-2.asp] | [http://unstats.un.org/unsd/cr/registry/cpc-2.asp] | ||
[http://unstats.un.org/unsd/cr/registry/regdntransfer.asp?f=130] | [http://unstats.un.org/unsd/cr/registry/regdntransfer.asp?f=130] | ||
+ | * Agriculture, forestry and fishery products | ||
+ | * Ores and minerals; electricity, gas and water | ||
+ | * Food products, beverages and tobacco; textiles, apparel and leather products | ||
+ | * Other transportable goods, except metal products, machinery and equipment | ||
+ | * Metal products, machinery and equipment | ||
+ | * Constructions and construction services | ||
+ | * Distributive trade services; accommodation, food and beverage serving services; transport services; and electricity, gas and water distribution services | ||
+ | * Financial and related services; real estate services; and rental and leasing services | ||
+ | * Business and production services | ||
+ | * Community, social and personal services | ||
=== Dependencies === | === Dependencies === | ||
Line 27: | Line 58: | ||
===Calculations=== | ===Calculations=== | ||
− | <rcode name=" | + | <rcode name="initiate" label="Initiate variable" embed=1> |
library(OpasnetUtils) | library(OpasnetUtils) | ||
− | |||
− | CPC <- | + | dat <- opbase.data("Op_en5914") |
− | CPC | + | dat$CPC.name <- dat$Result |
− | objects. | + | temp <- levels(dat$CPC.name) |
+ | temp <- gsub("\r", "", temp) | ||
+ | levels(dat$CPC.name) <- temp | ||
+ | dat$Result <- 1 | ||
+ | temp2 <- as.character(levels(dat$CPC.code)[dat$CPC.code]) | ||
+ | temp2[c(318, 416, 1016, 1734)] <- c("1", "2", "3", "4") | ||
+ | dat$CPC.code <- as.factor(temp2) | ||
+ | dat$CPC.level <- nchar(temp2) | ||
+ | |||
+ | CPC <- Ovariable("CPC", data = dat) | ||
+ | |||
+ | objects.store(CPC) | ||
cat("Ovariable CPC created.\n") | cat("Ovariable CPC created.\n") | ||
− | |||
− | |||
</rcode> | </rcode> |
Latest revision as of 13:09, 13 March 2014
This page is a variable.
The page identifier is Op_en5914 |
---|
Moderator:Jouni (see all) |
Give your opinion to the peer rating of the content of this page. |
Upload data
|
Contents
Question
What is a good classification system for products?
Answer
⇤#: Something wrong with the first-level codes (there is a leading zero although should not be). This was corrected, but is there more problems with the data? --Jouni (talk) 23:05, 27 December 2013 (EET)
Rationale
UN CPC version 2 seems to be an optimal choice. It contains a hierarchical system for products, 4408 rows in total. It is organised in five hierarchical levels. It is based on ten categories at the top level, numbered from 0 to 9: [1] [2]
- Agriculture, forestry and fishery products
- Ores and minerals; electricity, gas and water
- Food products, beverages and tobacco; textiles, apparel and leather products
- Other transportable goods, except metal products, machinery and equipment
- Metal products, machinery and equipment
- Constructions and construction services
- Distributive trade services; accommodation, food and beverage serving services; transport services; and electricity, gas and water distribution services
- Financial and related services; real estate services; and rental and leasing services
- Business and production services
- Community, social and personal services
Dependencies
Calculations
See also
Keywords
References
Related files
<mfanonymousfilelist></mfanonymousfilelist>