Research breakthrough possible @S-Logix pro@slogix.in

Office Address

  • 2nd Floor, #7a, High School Road, Secretariat Colony Ambattur, Chennai-600053 (Landmark: SRM School) Tamil Nadu, India
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to generate Frequency tables in R?

Description

To generate the frequency tables using R programming.

Process

Table() :

   To generate frequency tables

   R Function :table()

ftable() :

  To print the results more attractively.

   R Function :ftable()

Margin :

   To generate marginal frequencies

   R Function :table()

Proportion table:

  To generate tables of proportions

   R Function :table()

Crosstable:

   R Package :gmodels

   To produce crosstabulations model

   R Function :CrossTable()

Sapmle Code

#Frequency and Contingency Tables
#Input
attach(mtcars)
x<-mtcars$mpg
y<-mtcars$hp

#Table Function
tab<-table(x,y)
print(tab)

#ftable
tab_f<-ftable(x,y)
print(tab_f)

#Marginal Frequencies
margin.table(tab,1)
margin.table(tab,2)

#table of Proportion
prop.table(tab_f,1)
prop.table(tab_f,2)

#Cross table Function
library(“gmodels”)

#Simple Input
x1<-c(2,4,2,6,2)
x2<-c(2,4,3,6,3)
CrossTable(x1,x2)

Screenshots
generate Frequency tables in R
Table Function
Frequency and Contingency Tables
print the results more attractively
Proportion table