4
I’m filling the following data into the R to generate a bar chart:
structure(c(5483L, 28034L, 7995L, 5199L, 6785L, 7452L, 7692L), .Dim = 7L, .Dimnames = structure(list(c("dom", "qua", "qui", "sáb", "seg", "sex", "ter")), .Names = ""), class = "table")
I’m generating the following chart:
coresBasicas <- c(1:7)
DataDeAcessoPlot<- barplot(table(DataDeAcesso[,4]),
main = "Exibições de Páginas por Dias da Semana",
ylim = c(0,30000),
xlab="Dias da Semana",
col = coresBasicas,
ylab="Exibições de Páginas",
cex.axis = 0.6,
#cex.names = 0.6,
las=1
)
text(x=DataDeAcessoPlot, y=table(DataDeAcesso[,4]), label=table(DataDeAcesso[,4]), pos = 3, xpd=NA)
I would like to know how to organize the columns of the graphic in the following order: gift, mon, ter, qua, qui, fri, Sáb. Thanks from now on!
I can’t seem to... After executing the code to assign the variable y the organized days of the week, the next command to assign to the error DDA, with the following message:
Error in
[.data frame.(DataDeAcesso, order(order(y))) : 
 undefined columns selected
I have tried to specify the column that corresponds to the days of the week (column 4) but still does not give...– Fábio Junio Alves Sousa
trial
DDA <- DataDeAcesso[order(order(y)),]
– Rafael Cunha
It didn’t work... when I executed the command
DDA <- DataDeAcesso[order(order(y)),]
the DDA data frame is only 7 lines. From what I understand, I would use the y variable to sort the days of the week, which are inDataDeAcesso[,4]
if I do not specify column 4 at some point, how the lines will be arranged?– Fábio Junio Alves Sousa
@Fábiojunioalvessousa It is better to edit the question and post the output of
dput(DataDeAcesso)
. So we can see how this variable is structured.– Rui Barradas
@Noisy Now I understand and it worked! I took the
dput(table(DataDeAcesso[,4])
and stored in a new variableDiasDaSemanaEmFormatoValue
, this new variable is not in Data Frame format hence the commandDDA <- DiasDaSemanaEmFormatoValue[order(order(y)),]
gave right! Thank you very much!!!– Fábio Junio Alves Sousa
@Fábiojunioalvessousa I’m glad it worked out. Note: when I read your code I found a little strange so many calls to
table
. Are you sure they are (all) necessary?– Rui Barradas
Yes because with this function I get the frequency of the data. I have a database with 60000 lines, one of the attributes is this of date, which I converted it to the format YYYY-MM-DD to then obtain the day of the week for each day, then for me to know the frequency of the days of the week in 60000 lines, I use the function
table()
.– Fábio Junio Alves Sousa