I wrote a short script to create a frequency distribution plot from raw data. The only thing I cannot make right is the x-axis. As you can see below, when the numbers are too long they got written in the e-notation which is difficult to read (also, labels are long enough to be cut out from the picture).
Normally I would use digits = X
but unfortunately this notation cannot be used with the command cut
. Full code is attached. Also, any other advice to make the graph more readable is warmly welcome.
##Paramaters definition
num.bins = 60 #The number of bins you want to be used
w.data = 2 #The column you have the data in
##Data loading
dataset = read.csv(file.choose())
##Calculating frequency
d.min = min(dataset[,w.data])
d.max = max(dataset[,w.data])
breaks = seq(d.min, d.max, by = (d.max-d.min)/num.bins)
d.cut = cut((dataset[,w.data]), breaks, right = FALSE, digits = 6)
d.freq = table(d.cut)
##Plot
plot(d.freq, ylab = 'Frequency', las = 2)