percentage frequency distribution of two datasets on the same plot
1
0
Entering edit mode
9.1 years ago

I would like to calculate the percentage frequency distribution of h1 and h2. How can I combine h1 and h2 on the same plot? The length of the vectors are different in h1 and h2. I tried the following code. it gives the plot for h1 only. your suggestions would be appreciated!!

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$percentage = h$counts/sum(h$counts)*100
plot(h, freq=F, xlab=
'Proteins', ylab='Percentage')

R • 2.3k views
ADD COMMENT
0
Entering edit mode
9.1 years ago
Mo ▴ 920

@ayyappadas342 you can use par(new=TRUE) if you want to plot both on the same plot

ADD COMMENT
0
Entering edit mode

Mostafa Thank you for your answer.Where do I have to add par(new=TRUE)

ADD REPLY
0
Entering edit mode

@ayyappadas342 between the plots , it says hold on so that you can plot another plot on an existed one! for example plot(x,y); par(new=TRUE); plot(x,y)

in case you are calling someone , it is better you call it with a correct name so that s/he will see your comment. You should have written @Mo and not Mostafa . that is why I did not see your comment

ADD REPLY

Login before adding your answer.

Traffic: 1770 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6