Wednesday, January 7, 2015

Frequency Table

Here is the data from Google search of continents (all figures in millions):
North America,577
South America,453
Europe,1840
Asia,1510
Africa,1620

We use the concatenation operator to create the data set:

> continents <- c(rep("North America",577),
+                 rep("South America",453),
+                 rep("Europe",1840),
+                 rep("Asia",1510),
+                 rep("Africa",1620))

Next, we use the table function to create the frequencies.

> table(continents)

Following is the output:


But, the frequencies are not ordered according to the magnitude. We can easily do that with sort function: