Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

Counting unique combination of columns in a data frame for each country

$
0
0

@Ashis wrote:

Hi,

below is my data frame... I want to count the medals for each country (denoted in NOC column)..
Since there are team events (here every row corresponds to one athlete) i have to count unique event medals.

SO I am trying to count Combination of Event, Event_gender, Medal with following code.

y= ddply(data1_2000 , .(NOC), function(df) count(df[,c("Event","Event_gender","Medal") ]))

I also tried
z= sqldf("select NOC,COUNT(distinct Event,Event_gender,Medal) as MedalCount from data1_2000 group by NOC")

here am getting an error :
Error in sqliteSendQuery(con, statement, bind.data) :
error in statement: wrong number of arguments to function COUNT()

But am not getting the desired result.

please suggest somethng.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles