library(biomaRt)
ensembl=useMart("ENSEMBL_MART_SNP",
                dataset="hsapiens_snp")

#Make a vector of search terms found on the biomart website
phenotypes <- c('Arsenic metabolism','Hypermanganesemia with dystonia polycythemia and cirrhosis','Lead levels in blood')

#Make a variable for your attributes you want to download
att1 <- c('refsnp_id','minor_allele','minor_allele_freq','phenotype_name',
          'phenotype_description','clinical_significance',
          'associated_variant_risk_allele','p_value','validated')

#Run biomart search with settings listed above
searchResults <-getBM(att1,
                      'phenotype_description',
                      values=phenotypes, mart=ensembl)

#Use unique and length functions to count unique rsids
#In this example searchResults is 79 rows, but there are only 76 
#unique rsids in the refsnp_id column
length(unique(searchResults$refsnp_id))
## [1] 76