Skip to content

Instantly share code, notes, and snippets.

@fxcosta
Last active May 11, 2016 00:31
Show Gist options
  • Save fxcosta/6a265ecb9d3b35a206b9d36fbbc612b8 to your computer and use it in GitHub Desktop.
Save fxcosta/6a265ecb9d3b35a206b9d36fbbc612b8 to your computer and use it in GitHub Desktop.
Simples script em R que exibe histograma de posições sequenciais de uma determinada massa de dados e uma plotagem usando curva gaussiana e curva de densidade
#!/usr/bin/Rscript
emg <- read.csv("emg_s1.csv", header = FALSE, sep = "|", dec = ",")
View(emg)
attach(emg)
par(mfrow = c(4, 5))
for(data in 1:20) {
position <- paste(c("V", data), collapse = "")
header <- paste(c("Histograma de ", position), collapse = "")
hist(emg[[position]], main = header, xlab = header)
}
for(data in 1:5) {
position <- paste(c("V", data), collapse = "")
header <- paste(c("Histograma de ", position), collapse = "")
hist(emg[[position]], main = header, xlab = header, prob = TRUE)
media <- mean(emg[[position]])
desvio <- sd(emg[[position]])
curve(dnorm(x, mean = media, sd = desvio), add=TRUE, col = "red", xlab="Miles Per Gallon")
lines(density(emg[[position]]), col = "blue", xlab="Miles Per Gallon")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment