Consumption of Baltic herring in Finland: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(code copied)
 
(initiation and answer codes added and debugged)
Line 8: Line 8:


== Answer ==
== Answer ==
<rcode embed=1 graphics=1>
# This is code Op_en7403/answer on page [[Consumption of Baltic herring in Finland]]
library(OpasnetUtils)
library(ggplot2)
objects.latest("Op_en6007", code_name = "answer") # OpasnetUtils/Drafts
objects.latest("Op_en7403", code_name = "amount") # [[Consumption of Baltic herring in Finland]]
amount <- EvalOutput(amount)
amount$Age_group <- cut(as.numeric(as.character(amount$Ikä)), c(0, 20, 65, 80), include.lowest = TRUE)
ggplot(amount@output, aes(x = amountResult, colour = Age_group)) + stat_ecdf(size = 2) +
  facet_wrap( ~ Sukupuoli) + scale_x_log10() + theme_gray(base_size = 24) +
  labs(
title = "Baltic herring consumption by sex and age",
colour = "Age group",
x = "Consumption (g/d)",
y = "Cumulative probability distribution"
  )
</rcode>


== Rationale ==
== Rationale ==
Line 15: Line 35:
=== Calculations ===
=== Calculations ===


<rcode name="amount" label="Initiate amount (for developers only)">
<rcode name="amount" label="Initiate amount (for developers only)" embed=1>
#This code is ##/amount on page [[Consumption of Baltic herring in Finland]]
#This code is Op_en7403/amount on page [[Consumption of Baltic herring in Finland]]
library(OpasnetUtils)
library(OpasnetUtils)


Line 72: Line 92:


# lyhyt = lyhyt lista yksilökohtaisia määrittelyjä eli vain välttämättömät.
# lyhyt = lyhyt lista yksilökohtaisia määrittelyjä eli vain välttämättömät.
lyhyt <- silakka[c("Age", "Ikä", "Hedelm", "Sukupuoli", "Rivi", "Maakunta")]  
lyhyt <- silakka[c("Age", "Ikä", "Hedelm", "Sukupuoli", "Rivi", "Maakunta", "Rannikko")]  


kokoaik <- Ovariable("kokoaik", data = data.frame(
kokoaik <- Ovariable("kokoaik", data = data.frame(
Line 187: Line 207:
out <- out + kouluruokailut * annos * into / 91
out <- out + kouluruokailut * annos * into / 91


# Muutetaan Age ja Maakunta epävarmaksi eli ei-marginaaliksi
# Muutetaan Age ja Maakunta epävarmaksi eli ei-marginaaliksi
out@marginal[colnames(out@output) %in% c("Age", "Maakunta")] <- FALSE  
colnames(out@output)[colnames(out@output) == "Ikä"] <- "Ikä"
# Sukupuoli ja Hedelm pidetään indekseinä koska niiden mukaan arvottiin
out@marginal[colnames(out@output) %in% c("Age", "Ikä", "Maakunta", "Rannikko")] <- FALSE  
out <- unkeep(out, cols = c("Rivi", "Ikä", "Arvo"), prevresults = TRUE, sources = TRUE)
# Sukupuoli ja Hedelm pidetään indekseinä koska niiden mukaan arvottiin
out <- unkeep(out, cols = c("Rivi", "Arvo"), prevresults = TRUE, sources = TRUE)


result(out)[result(out) == 0] <- 0.01 # Ei jätetä nollia saantiin
result(out)[result(out) == 0] <- 0.01 # Ei jätetä nollia saantiin
Line 216: Line 237:
"kouluruokailut",
"kouluruokailut",
"annos",
"annos",
"into"
"into",
"amount"
)
)
cat("Objects kokoaik,
cat("Objects
kokoaik,
silakoita,
silakoita,
silakanpaino,
silakanpaino,
Line 227: Line 250:
kouluruokailut,
kouluruokailut,
annos,
annos,
into
into,
amount
stored,\n")
stored,\n")


</rcode>
</rcode>

Revision as of 23:28, 19 October 2015



Consumption of Baltic herring in Finland describes Baltic herring consumption by age, sex, and district.

Question

What is the Baltic herring consumption in Finland in different subgroups?

Answer

+ Show code

Rationale

Answer is based on an interview to random 2042 individuals in Finland in 2003.

Calculations

+ Show code