kalori {ddp}R Documentation

Calory calculation

Description

This function calculates the total calory of each responden.

Usage

kalori(data, output = "all")

Arguments

data

A data set of (n x 218) (see Details).

output

A desirable output, the default is "all" (see Details).

Details

The data set is an n x 218 data frame. The first column is the name of the respondent. The rest columns are types of food. The type of food can be listed as in the data simulation (see in the data example of simulasi or vignette("ddp")).

The output argument has "all" as the default, meaning that all of the calories are yielded. They are energy, protein, fat, and carbohydrate. Single calory can be produced by writing the output argument with "protein" for the calory of protein, for example. The possible inputs for output argument are "all", "energi", "protein", "lemak" for fat, and "karbohidrat".

Value

Function returns a matrix of n x 4 for "all" and n x 1 for other "output" arguments.

Author(s)

Weksi Budiaji
Contact: budiaji@untirta.ac.id

References

BKP, Kementan. 2017. Aplikasi Harmonisasi Analisis PPH Data Susenas 2017. Badan Ketahanan Pangan Kementrian Pertanian.

Examples

#data simulation of 10 person
set.seed(2020)
n <- 10
matsim <- matrix(0, n, 218)
datsim <- as.data.frame(matsim)
datsim$V1 <- LETTERS[1:n]

#calory for boiled rice
datsim$V2 <- rnorm(n, 200, 50)
#calory for boiled egg
datsim$V73 <- rnorm(n, 60, 5)
#calory for fresh milk
datsim$V79 <- rnorm(n, 100, 10)
#calory for tomato
datsim$V93 <- rnorm(n, 19, 2)
#caloty for pineapple
datsim$V134 <- rnorm(n, 20, 2)

kalori(datsim)


[Package ddp version 0.0.3 Index]