mirror of
https://github.com/Zenithsiz/ist-pe-proj.git
synced 2026-02-03 05:57:12 +00:00
Initial commit.
This commit is contained in:
commit
2f1a3be417
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# Output files
|
||||
output.*
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"cSpell.words": ["ddesemp", "ggplot", "ggsave", "readxl"]
|
||||
}
|
||||
BIN
1/econ.xlsx
Normal file
BIN
1/econ.xlsx
Normal file
Binary file not shown.
38
1/script.R
Executable file
38
1/script.R
Executable 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")
|
||||
Loading…
x
Reference in New Issue
Block a user