[R] how to modify the histogram's frequencies
(Ted Harding)
Ted.Harding at manchester.ac.uk
Sun Apr 27 20:14:43 CEST 2008
On 27-Apr-08 16:41:58, marcelha mukim wrote:
> Hi Sarah:
>
> Thank you very much, but my problem remains. What I want is not
> duplicate the sample, but be able to divide each frequency for
> a factor(specific for each value).For example:
>
> Values 1 2 3 4 5
> Frequency 10 34 56 67 98
> Factor 105 50 60 150 200
>
> Actually Im plotting: plot(Values, Frequency/Factor, type="b").
> But I dont know how to visualize the probability distribution.
> On the hand to modify the "hist" function to include this Factor
> seems to be a daunting task.
>
> any other advise will be welcome
> thank you
> m.
You don't need to go that far! Assuming you need to use hist()
to construct the counts in the first place, you can then modify
the $counts component of what it returns.
Here is an example using uniform random data:
X <- 5*runif(265)
## Have a look at it:
hist(X,breaks=5)
## Now make a histogram with class frequencies divided by the factors:
Factor <- c(105,50,60,150,200)
H <- hist(X,breaks=5,plot=FALSE)
H$counts <- H$counts/Factor
plot(H)
Is that the sort of thing you were after?
Best wishes,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 27-Apr-08 Time: 19:14:39
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list