Re: [R] how to modify the histogram's frequencies

From: Ted Harding <Ted.Harding_at_manchester.ac.uk>
Date: Sun, 27 Apr 2008 19:14:43 +0100 (BST)


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 ------------------------------

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 27 Apr 2008 - 18:17:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 27 Apr 2008 - 18:30:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive