[R] Help on R Functionality & Histogram
sarah.goslee at gmail.com
Fri May 29 14:50:48 CEST 2015
On Fri, May 29, 2015 at 7:53 AM, Shivi82 <shivibhatia at ymail.com> wrote:
> 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
Using read.csv() is the reload option. R has no automatic interface to
> 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)
The most understandable approach is to break it down into chunks:
Create the histogram.
Add a custom axis.
Add custom labels.
# using fake data
aaa <- data.frame(Hours = sample(1:24, 10000, replace=TRUE))
aaa.hist <- hist(aaa$Hours, main="Hourly Weight", xlab = "Time",
breaks = seq(0, 24), col = "yellow", ylim = c(0,9000), cex.axis=0.6,
axis(1, (0:23)+.5, 1:24, cex.axis=.6)
text((0:23)+.5, aaa.hist$counts-150, aaa.hist$counts, cex=.6)
More information about the R-help