Initial commit.

This commit is contained in:
Filipe Rodrigues 2023-06-04 01:07:39 +01:00
commit 2f1a3be417
4 changed files with 43 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# Output files
output.*

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"cSpell.words": ["ddesemp", "ggplot", "ggsave", "readxl"]
}

BIN
1/econ.xlsx Normal file

Binary file not shown.

38
1/script.R Executable file
View File

@ -0,0 +1,38 @@
#!/bin/env Rscript
# Libraries
library("readxl")
library("ggplot2")
# Read the data
df <- read_xlsx("econ.xlsx")
# Filter for years >= 1971
df <- df[df$tempo >= "1971/01/01", ]
# Create a new data frame with adjusted `ddesemp` and `tpp` columns
ddesemp_mean <- mean(df$ddesemp)
ddesemp_sd <- sd(df$ddesemp)
tpp_mean <- mean(df$tpp)
tpp_sd <- sd(df$tpp)
df_adjusted <- data.frame(
tempo = lapply(df[, c("tempo")], function(tempo) tempo),
ddesemp = lapply(df[, c("ddesemp")], function(ddesemp) {
(ddesemp - ddesemp_mean) / ddesemp_sd
}),
tpp = lapply(df[, c("tpp")], function(tpp) {
(tpp - tpp_mean) / tpp_sd
})
)
# Then plot them and save the output
plot <- ggplot(df_adjusted, aes(x = tempo)) +
geom_line(aes(y = ddesemp, color = "ddesemp")) +
geom_line(aes(y = tpp, color = "tpp"))
ggsave(plot = plot, "output.png")