I am working with the 'mtcars' data-set:

```                   mpg cyl disp  hp drat    wt  qsec vs am gear carb
Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1```

I want to find out the number of frequency of unique values for the 'cyl' column, i.e, number of occurences of each value.

May 18, 2018 39,227 views

## 3 answers to this question.

+1 vote

```table(mtcars\$cyl)

4  6  8
11  7 14```

• 4,620 points
how to visualize it so that it will that particular element along with it's frequency

You can use plyr module. It will give you the frequency count. You can see the below example.

```> library("plyr")
> count(mtcars, 'gear')
gear freq
1    3   15
2    4   12
3    5    5```
+1 vote

Try this,

lapply(mtcars,function(x){ length(unique(x))})

answered Aug 20, 2019 by anonymous
• 32,930 points
+1 vote

Hi,

You can use plyr module. It will give you the frequency count. You can see the below example.

```> library("plyr")
> count(mtcars, 'gear')
gear freq
1    3   15
2    4   12
3    5    5```
• 95,180 points

## Counting the frequency of user activities - R

Within a data frame (see below), I ...READ MORE

## How to write a custom function which will replace all the missing values in a vector with the mean of values in R?

Consider this vector: a<-c(1,2,3,NA,4,5,NA,NA) Write the function to impute ...READ MORE

## Change the order of legend values in a plot in R

@prardhana, Use scale_fill/color/size_discrete/contin....(labels = c()). compare both to see ...READ MORE

## Show count of unique values for each value in the field in dataframe

Hi, Use below r code. For one field, you ...READ MORE

+1 vote

## How to convert a list of vectors with various length into a Data.Frame?

We can easily use this command as.data.frame(lapply(d1, "length< ...READ MORE

## In data frame how to spilt strings into values?

You can do this using dplyr and ...READ MORE

## How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE