Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Frequency distribution with custom format data

Tags:

r

I need help with a R plot, with a data format I have not worked with before. Please help if you know.

NUMBER   FREQUENCY
10          1  
11          1  
12          3  
10          45   
11          2  
12          3  

i need a bar plot with numbers on X axis (continuous, not bins in histogram) and frequency on Y, but combined. like

10     46  
11     3  
12     6  

it seems simple enough, but i have 10,000 rows and large numbers in real data so I am looking for a good solution in R without doing it manually.

like image 654
user1873707 Avatar asked Dec 03 '12 20:12

user1873707


People also ask

What are the 3 types of frequency distributions?

Cumulative frequency distribution. Relative frequency distribution. Relative cumulative frequency distribution.

Can Excel create frequency distribution?

To create Frequency Distribution in Excel, we must have Data Analysis Toolpak, which we can activate from the Add-Ins option available in the Developer menu tab. Once it is activated, select the Histogram from Data Analysis, and select the data we want to project.


1 Answers

What about:

##tapply splits dd$FREQ by dd$NUM and "sums" them
barplot(tapply(dd$FREQUENCY, dd$NUMBER, sum))

to get:

enter image description here


Read in your data:

dd = read.table(textConnection("NUMBER   FREQUENCY
10          1  
11          1  
12          3  
10          45   
11          2  
12          3"), header=TRUE)  
like image 144
csgillespie Avatar answered Sep 25 '22 16:09

csgillespie