unique length of combinations

0 votes
hi i am working with mtcars data , if mpg=21.0 and cyl=4 ,i want to find how many times the same combination repeated int he data set. i want its frequency
Dec 24, 2018 in Data Analytics by anonymous
39 views

2 answers to this question.

0 votes

Hello.

You can use the count method of the plyr package to get the frequency. Example:

install.packages('plyr')
library(plyr)
count(mtcars, mpg)
answered Dec 26, 2018 by Karuna
0 votes

Try this:

sum(mtcars$mpg == 21.0 & mtcars$cyl == 4, na.rm = TRUE)
answered Dec 26, 2018 by Omkar
• 67,660 points

Related Questions In Data Analytics

+1 vote
1 answer

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

answered Apr 4, 2018 in Data Analytics by DeepCoder786
• 1,720 points
131 views
0 votes
1 answer

Find length of string in R

You can try nchar > nchar("fast") [1] 4 > set.seed(10) > ...READ MORE

answered Apr 17, 2018 in Data Analytics by DataKing99
• 8,130 points
51 views
0 votes
2 answers

Counting the frequency of unique values - R

Try this, lapply(mtcars,function(x){ length(unique(x))}) READ MORE

answered Aug 20 in Data Analytics by anonymous
• 31,840 points
5,304 views
0 votes
1 answer

Manage length of field values

Hi, Use str_pad() function to format the length ...READ MORE

answered Oct 23 in Data Analytics by Cherukuri
• 31,840 points
20 views
+1 vote
3 answers

Integration of Google Collaboratory with github

You can use SSH protocol to connect ...READ MORE

answered Aug 7, 2018 in Data Analytics by Kalgi
• 42,540 points
1,229 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
200 views
+1 vote
2 answers

Custom Function to replace missing values in a vector with the mean of values

Try this. lapply(a,function(x){ifelse(is.na(x),mean(a,na.rm = TRUE) ...READ MORE

answered Aug 14 in Data Analytics by anonymous
101 views
0 votes
1 answer

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

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

answered Aug 21 in Data Analytics by anonymous
• 31,840 points
54 views
+1 vote
3 answers

Problem with installation of Wordcloud in anaconda

Using Anaconda Python 3.6 version For Windows ...READ MORE

answered Aug 7, 2018 in Data Analytics by Priyaj
• 56,940 points
4,156 views