Converting Gene Symbol to Ensembl ID in R
You can use the standard annotation package for humans (you can also use biomaRt, but it can be more confusing, see below):

library("org.Hs.eg.db") # remember to install it if you don't have it already
symbols &lt;- mapIds(org.Hs.eg.db, keys = ensemblsIDS, keytype = "ENSEMBL", column="SYMBOL")


The ensemblsIDS should be a character vector: c("ENSG001", "ENSG002", ..)

The solution with biomaRt:

library("biomaRt")
ensembl = useMart("ensembl",dataset="hsapiens_gene_ensembl")
getBM(attributes='hgnc_symbol', 
      filters = 'ensembl_gene_id', 
      values = ensemblsIDS, 
      mart = ensembl)