Hello there,
Let's say I have the following data, how can I search the number of Users per country?
User<-c("B","A", "C", "D","D","A","C","A","D","D","B")
Location<-c("Australia","Japan","Italy","EUA","EUA","Australia","Italy","Japan",
"Australia","Japan","Japan")
Travel<-cbind(User,Location)
summary(Travel)
Travel[grep("D",Travel),]
Travel[grep("C",Travel),]
#Outputs:
summary(Travel)
User Location
A:3 Australia:3
B:2 EUA :2
C:2 Italy :2
D:4 Japan :4
Travel[grep("D",Travel),]
User Location
[1,] "D" "EUA"
[2,] "D" "EUA"
[3,] "D" "Australia"
[4,] "D" "Japan"
Travel[grep("C",Travel),]
User Location
[1,] "C" "Italy"
[2,] "C" "Italy"
As you can see, D was in 4 locations, twice in EUA, also C was twice in Italy, but I need to count only once. The result that I am looking for is something like this:
Country --- Count
Australia -- 3
EUA -------- 1
Italy -------- 1
Japan ------ 1
I am looking for a function (combination of fucntions) since I have too much data to analyse, but any help would be great.
I really appreciate any help.
Regards,
Luiz.