【方法】 n_distinct(v.x)
【補足】 library(dplyr)が必要
#テスト用データフレームを作成
v.x <- c(1,2,3,4)
v.x1 <- c("x","a","a","a")
v.x2 <- c("11","11","11","11")
df.x <- data.frame(id = v.x, name = v.x1, num = v.x2)
df.x
> df.x id name num 1 1 x 11 2 2 a 11 3 3 a 11 4 4 a 11 >
df.x %>%
summarize(id_u = n_distinct(id),name_u = n_distinct(name),num_u = n_distinct(num))
> df.x %>% + summarize(id_u = n_distinct(id),name_u = n_distinct(name),num_u = n_distinct(num)) id_u name_u num_u 1 4 2 1
R ユニークデータを抽出する
http://mototeds.blogspot.jp/2015/07/r.html