Frequency percentage distribution histogram with R


 
Thread Tools Search this Thread
Top Forums Programming Frequency percentage distribution histogram with R
# 1  
Old 03-10-2015
Frequency percentage distribution histogram with R

I am new to R and would like to calculate the percentage frequency distribution of h1 and h2. How can I combine h1 and h2 in one plot? I tried the following code.

Code:
 h1=c(5.18,4.61,3.30,7.58,3.00,3.80,1.95,2.67,2.77,2.73,2.33,3.36,3.50,1.91,4.25,3.87,2.86,2.26,2.00,3.86,3.33,3.59,4.00)
h2=c(2.1,2.1,2.6,2,3.6,2,2.7,1.8,3.1,3.9,3.8,2.6,1.9,2.6,2.1,3.9,2.7,1.8,2.1,2.3,2.2,2.6,1.8,2.3,2.3,3.7,3.3,1.9,2.4,2.6,2.4,3.4,2.4,2.2,1.8,2.1,2,1.2,3.9,1.9,3.4,2,2.2,2.3,2.6,2,3,1.8,1.6,1.5,2.6,3.2,2.3)
h = hist(h1)
h$density = h$counts/sum(h$counts)*100
plot(h, freq=F, ylab='Percentage')

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generating histogram

Hi, I have 2 files with similar structure - reference and test that I would like to BIN both and generate the comparison. input files structure is: a 3 b 10 c 3 d 7 e 1 f 4 g 9 h 6 I would like the output to be (lets say both reference and test are the file above - no diff) BIN ... (3 Replies)
Discussion started by: yan1
3 Replies

2. Shell Programming and Scripting

awk Sort 2d histogram output from min(X,Y) to max(X,Y)

I've got Gnuplot-format 2D histogram data output which looks as follows. 6.5 -1.25 10.2804 6.5404 -1.25 10.4907 6.58081 -1.25 10.8087 6.62121 -1.25 10.4686 6.66162 -1.25 10.506 6.70202 -1.25 10.3084 6.74242 -1.25 9.68256 6.78283 -1.25 9.41229 6.82323 -1.25 9.43078 6.86364 -1.25 9.62408... (1 Reply)
Discussion started by: chrisjorg
1 Replies

3. UNIX for Dummies Questions & Answers

Help with xmgrace histogram

Hi All, I am new to Grace and would like to plot histograms. My input files have one column for frequencies and another column for distances, for example: 1 2.6 4 2.7 5 2.8 2 3.9 2 4.0 4 4.7 4 4.8 4 4.9 ... I want to plot a histogram ranging from 0 to 10 with... (0 Replies)
Discussion started by: sxiong
0 Replies

4. Shell Programming and Scripting

awk for histogram

I have a single file that looks like this: 1.62816 1.62816 0.86941 0.86941 0.731465 0.731465 1.03174 1.03174 0.769444 0.769444 0.981181 0.981181 1.14681 1.14681 1.00511 1.00511 1.20385 1.20385 (2 Replies)
Discussion started by: kayak
2 Replies

5. Shell Programming and Scripting

AWK counting interval / histogram data

My data looks like this: frame phi psi 0 68.466774 -58.170494 1 75.128593 -51.646816 2 76.083946 -64.300102 3 77.578056 -76.464218 4 63.180199 -76.067680 5 77.203979 -58.560757 6 66.574913 -60.000214 7 73.218269 -70.978203 8 70.956879 -76.096558 9 65.538872 -76.716568... (19 Replies)
Discussion started by: chrisjorg
19 Replies

6. UNIX for Dummies Questions & Answers

histogram or counter

Dear all, I have numerous dat files (a.dat, b.dat...) containing 500 numeric values each. I would like to count them, based on their range and obtain a histogram or a counter. INPUT: a.dat 1.3 2.16 0.34 ...... b.dat 1.54 0.94 3.13 ..... ... (2 Replies)
Discussion started by: chen.xiao.po
2 Replies

7. UNIX for Dummies Questions & Answers

gnuplot easy histogram

hello experts, I have been trying to plot a histogram of a data like; -54 -56 -43 -65 -67 -78 ... I have 156.000 rows of these kind of values between 0 and -100. I just want to make x axis takes values 5 spacing in between like; -100 -95 -90 .............. 0 And I want y... (4 Replies)
Discussion started by: enes71
4 Replies

8. UNIX for Dummies Questions & Answers

Gnuplot - Histogram Fitting

Hi I am trying to fit my histogram data with a gaussian model and am encountering two problems: 1. I can't seem to fit the histogram data with a model fit y(x) 'bin.txt' using 2:xtic(1) via a,b,c (error: need 2 to 7 using specs) 2. Even when I manually guess the correct parameters for my fit and... (1 Reply)
Discussion started by: goffinj
1 Replies

9. UNIX for Dummies Questions & Answers

percentage

How to calculate percentage of two values in unix. (5 Replies)
Discussion started by: venkatesht
5 Replies

10. Solaris

out of frequency

:cool: after installing solaris 10 5/08/09 directory the computer rebooting then the massage "out of frequency" appear.i want a solution first second my main board is GA-MA780G UD3H (14 Replies)
Discussion started by: medo2008
14 Replies
Login or Register to Ask a Question
pnmhistmap(1)						      General Commands Manual						     pnmhistmap(1)

NAME
pnmhistmap - draw a histogram for a PGM or PPM file SYNOPSIS
pnmhistmap [-black] [-white] [-max N] [-verbose] [pnmfile] DESCRIPTION
Reads a portable anymap as input, although bitmap (PBM) input produces an error message and no image. Produces an image showing a his- togram of the color (or gray) values in the input. A graymap (PGM) input produces a bitmap output. A pixmap (PPM) input produces pixmap output with three overlaid histograms: a red one for the red input, a green one for the green input, and a blue one for the blue input. The output is fixed in size: 256 pixels wide by 200 pixels high. OPTIONS
-black Ignores the count of black pixels when scaling the histogram. -white Ignores the count of white pixels when scaling the histogram. The -black and -white options, which can be used seperately or together, are useful for images with a large percentage of pixels whose value is zero or 255, which can cause the remaining histogram data to become unreadbaly small. Note that, for pixmap inputs, these options apply to all colors; if, for example, the input has a large number of bright-red areas, you will probably want to use the -white option. -max N Force the scaling of the histogram to use N as the largest-count value. This is useful for inputs with a large percentage of sin- gle-color pixels which are not black or white. -verbose Report the progress of making the histogram, including the largest-count value used to scale the output. All flags can be abbreviated to their shortest unique prefix. BUGS
Assumes maxval is always 255. Images with a smaller maxval will only use the lower-value side of the histogram. This can be overcome either by piping the input through "pnmdepth 255" or by cutting and scaling the lower-value side of the histogram. Neither is a particu- larly elegant solution. Should allow the output size to be specified. SEE ALSO
pgmhist(1), ppmhist(1), pgm(5), ppm(5) AUTHOR
Wilson H. Bent. Jr. (whb@usc.edu). 25 October 1993 pnmhistmap(1)