Skip to content

Help on R Functionality & Histogram

2 messages · Shivi82, Boris Steipe

#
Hello Experts, 
I have couple of questions on the analysis I am creating.
1) How does R adopt to changes. The case I have here is that the excel I
have started initially had to be modified because the data I had was on
hourly basis ranging from 0 to 23 hours. After Changes 0 was modified to 24
in hours. Now do I need to recall this excel again in R using read.csv
syntax or is there another way to do so i.e. a kind of reload option
2) I am creating a histogram. I need on x axis 24 hours to be displayed
separately as 0,1,2, and thereon. However it only shows till 20 which makes
the look awkward. Also all l need to resize the labels and if possible
inside the bars. It used the below code, axis fonts have changed but labels
give an error with this code

Code:- hist(aaa$Hours,main="Hourly Weight",xlab = "Time",breaks = 25,col =
"yellow",ylim = c(0,9000),
     labels=TRUE, cex.axis=0.6,cex.label=0.6)

Kindly advice on the both the questions. Thanks. 






--
View this message in context: http://r.789695.n4.nabble.com/Help-on-R-Functionality-Histogram-tp4707887.html
Sent from the R help mailing list archive at Nabble.com.
#
Don't use Nabble when posting to the R-Help forum.

Responses inline.
On May 29, 2015, at 7:54 AM, Shivi82 <shivibhatia at ymail.com> wrote:

            
No. Reload the data by rerunning your script.
The very understandable warning message you must have got with that call tells you that there is no such argument "cex.label".

hist() calls plot.histogram() which internally calls text() to write the labels. text() has an argument "cex", but even if you supply it to hist(), it is not passed to text() via the function body of plot.histogram(). You could modify plot.histogram but the more immediate solution is to set labels = FALSE, and explicitly use text() to write your labels. Try something like

x <- hist(aaa$Hours,
     main="Hourly Weight",
     xlab = "Time",
     breaks = 25,
     col = "yellow",
     ylim = c(0,9000),
     labels=FALSE,
     cex.axis=0.6)
     
text(x$mids, x$counts * 1.05, labels = x$counts, cex=0.5)



B.