Difference between revisions of "Tools/rstudio"

From Open Food Facts wiki
Jump to navigation Jump to search
(Created page with "Rstudio is a tool do do statistical analysis on data. == Recipe == The tool can be used to find the recipe of products. === Steps === Create the product data, e.g: product...")
 
Line 5: Line 5:
  
 
=== Steps ===
 
=== Steps ===
 +
We use the order as found on packaging, i.e. fat, sat. fat, carbs, sugar, fiber, proteins, salt).
 +
 
Create the product data, e.g:
 
Create the product data, e.g:
 
  product <- c(58.0, 6.4, 6.4, 4.2, 8.5, 0.01)
 
  product <- c(58.0, 6.4, 6.4, 4.2, 8.5, 0.01)
 +
 +
Create the individual ingredients, eg.:
 +
walnuts <- c(67.3, 6.45, 6.88, 3, 6.7, 13.3, 0.1)
 +
 +
Create the ingredients, e.g.:
 +
ingredients <- c(walnuts, hazelnuts, cashews, almonds)
 +
 +
Create the array for 4 ingredients, e.g.:
 +
Z <-array(ingredients, dim=c(7,4))
 +
 +
Fit:
 +
lsFit <- lm(y~Z)
 +
 +
Fit with no intercept:
 +
lsFitZero <- lm(y~Z +0)

Revision as of 13:40, 31 January 2025

Rstudio is a tool do do statistical analysis on data.

Recipe

The tool can be used to find the recipe of products.

Steps

We use the order as found on packaging, i.e. fat, sat. fat, carbs, sugar, fiber, proteins, salt).

Create the product data, e.g:

product <- c(58.0, 6.4, 6.4, 4.2, 8.5, 0.01)

Create the individual ingredients, eg.:

walnuts <- c(67.3, 6.45, 6.88, 3, 6.7, 13.3, 0.1)

Create the ingredients, e.g.:

ingredients <- c(walnuts, hazelnuts, cashews, almonds)

Create the array for 4 ingredients, e.g.:

Z <-array(ingredients, dim=c(7,4))

Fit:

lsFit <- lm(y~Z)

Fit with no intercept:

lsFitZero <- lm(y~Z +0)