0

I have a vector,

Marks : 10 10 10 20 20 20 20 20 30 30 10 10 40 40 40 40 50 50 50 50.

I need to find its frequency distribution. I can get it using the command :

    marks<- c(10,10,10,20,20,20,20,20,30,30,10,10,40,40,40,40,50,50,50,50)
    marks1<- cbind(table(marks))

This is the output

Now, when i check the structure of table marks 1, it is only 1 column and not 2. So,how would I convert this table into a matix or a datframe and assign attributes so that the output has two columns like this:

Marks Freq.
10     5
20     5
30     2
40     4
50     4

Is there any way to convert the table's row names into a column itself while converting the table into a matrix/datframe?

Most of the answers I found here are about converting a table ( with predefined column names) to matrix/datframe.

Shubham Pujan
  • 210
  • 2
  • 7
  • `marks1 = as.data.frame(table(marks))` – Gregory Demin Aug 27 '17 at 11:21
  • @GregoryDemin Ah, yes. Thank you. I was trying all types of complex commands.This works just fine.No need to use the `cbind` command as well. I was also able to assign column names using `colnames(marks1)`. – Shubham Pujan Aug 28 '17 at 12:09

0 Answers0