2
I made a histogram in the R but I noticed that the axis has an error, it orders -0 as being greater than -2 and does not follow the sequence, as follows in the picture.
I tried to filter it in the database I generated but when I classify it from the smallest number to the largest it continues like this, have you ever been through something like this? Can you help me?
library("reader")
library("lubridate")
library("zoo")
install.packages("dplyr")
install.packages("data.table")
install.packages("ggplot2")
install.packages("zoo")
setwd("C:/Users/Giovanni/Desktop")
dados_ibov <- read.csv('treinosr/Ibovespa_datah.csv',header = TRUE, sep = ",")
data.frame(dados_ibov)
freq <- table(dados_ibov$Var.)
barplot(freq, ylab="Frequência", xlab = "Retornos diários do Ibovespa")
as requested:
dput(head(freq, 20))
structure(c(`-0,00%` = 4L, `-0,01%` = 9L, `-0,02%` = 6L, `-0,03%` = 4L,
`-0,04%` = 9L, `-0,05%` = 9L, `-0,06%` = 10L, `-0,07%` = 6L,
`-0,08%` = 13L, `-0,09%` = 4L, `-0,10%` = 8L, `-0,11%` = 9L,
`-0,12%` = 6L, `-0,13%` = 9L, `-0,14%` = 11L, `-0,15%` = 4L,
`-0,16%` = 8L, `-0,17%` = 6L, `-0,18%` = 10L, `-0,19%` = 5L),
.Dim = 20L, .Dimnames = list(
dado = c("-0,00%", "-0,01%", "-0,02%", "-0,03%", "-0,04%",
"-0,05%", "-0,06%", "-0,07%", "-0,08%", "-0,09%", "-0,10%",
"-0,11%", "-0,12%", "-0,13%", "-0,14%", "-0,15%", "-0,16%",
"-0,17%", "-0,18%", "-0,19%")), class = "table")
Maybe
i <- order(as.numeric(names(freq))); barplot(freq[i])
.– Rui Barradas
have the database link used? can I test here.
– Brewerton Santos
Can you please, edit the question with the departure of
dput(freq)
or, if the base is too large,dput(head(freq, 20))
? If decimals are commas, these values must have been read as"factor"
. Are you sure the column separator issep = ","
? Andread.csv
already has a data.frame as output, the next statement does nothing.– Rui Barradas
https://br.investing.com/indices/bovespa-historical-data this is the basis used, I took the variation of the last 10 years to plot the last line that is of daily variation Breweron.
– Giovanni Chiodini Dos Santos
Rui, that’s right, the variations are commas, and the program understands positive number the negative and orders considering "-0.0%" less than "-2.0%" for example.
– Giovanni Chiodini Dos Santos
I tried to put the.Numeric but it returns random values, I don’t understand!
– Giovanni Chiodini Dos Santos