title: Merging data frames on a specific key in R/Stripping asterisks from Column
body: <p>Hey guys I need help merging in R and here is a reproducible sample of my code which I will explain.</p>
  
  <p>My issue I'm running into is certain guys in the fixedstats df are hall of famers and therefor they have asterisks in their name. I want to clean that so I can join them to the draft database and grab their draft year. When I do so with the code I'm running into an error that gives me:</p>
  
  <p><em>Error in order(Player = list("Tariq Abdul-Wahad", "Shareef Abdur-Rahim",  : 
    unimplemented type 'list' in 'orderVector1'</em></p>
  
  <p><strong>How do you guys recommend I go about stripping the asterisks from the columns in order to properly join the two data frames on the Player Key?</strong> Thanks in Advance. </p>
  
  <p>Code:</p>
  
  <pre><code>library(htmltab)
  library(sqldf)
  library(plyr)
  library(readr)
  
  stats0 &lt;- ""
  draftbank0 &lt;- ""
  
  for (i in 20003:2017){
  
    url &lt;- paste0("http://www.basketball-reference.com/leagues/NBA_",i,"_advanced.html")
    stats &lt;- htmltab(doc = url, which = 1, header = 1, stringsasfactors = FALSE)
    stats$year &lt;- i
  
    stats0 &lt;- rbind(stats0,stats)
  
    stats0[rowSums(is.na(stats0)) != ncol(stats0),]
  
  }
  
  
  colnames(stats0) &lt;- c("Rank",
                    "Player",
                    "Pos",
                    "Age",
                    "Tm",
                    "G",
                    "MP",
                    "PER",
                    "TSp",
                    "ThreePAr",
                    "FTr",
                    "ORBp",
                    "DRBp",
                    "TRBp",
                    "ASTp",
                    "STLp",
                    "BLKp",
                    "TOVp",
                    "USGp",
                    "Null", #comment out null if needed
                    "OWS",
                    "DWS",
                    "WS", 
                    "WS48",
                    "Null2", #comment out null if needed
                    "OBPM",
                    "DBPM",
                    "BPM",
                    "VORP",
                    "Year")
  
  fixedstats &lt;- sqldf("SELECT Rank, Player, Pos, Age, Tm, G, MP, PER, TSp, ThreePAr, FTr, ORBp, DRBp, TRBp, ASTp, STLp, BLKp, TOVp, 
                  USGp, OWS, DWS, WS, WS48, OBPM, DBPM, BPM, VORP, Year FROM stats0 WHERE player != 'Player'")
  
  fixedstats &lt;- fixedstats[-1,]
  
  
  
  for (i in 1980:2016){
  
  
    url2 &lt;- paste0("http://www.draftexpress.com/nba-mock-history/",i,"/all/all/")
    draftbank &lt;- htmltab(doc = url2, which = 1, header = 1, stringsasfactors = FALSE)
  
  
    draftbank0 &lt;- rbind(draftbank0,draftbank)
  
  
  }
  
  
  
  colnames(draftbank0) &lt;- c("Draft_Year", 
                        "Pick",
                        "Null1",
                        "Player",
                        "Null2",
                        "Position",
                        "Age",    
                        "Height",
                        "Weight",
                        "Wingspan",
                        "Points", 
                        "Rebounds",   
                        "Assists",
                        "PER", 
                        "Null3",  
                        "League",
                        "EWA")
  
  draftbankfinal &lt;- sqldf("SELECT Player, Position, Age, Height, Wingspan, Draft_Year FROM draftbank0")
  
  draftbankfinal &lt;- draftbank0[-1,]
  
  
  
  #Multiple drafts appendix getting rid of guys with similar names
  draftbankfinal&lt;-draftbankfinal[!(draftbankfinal$Player=="Corey Brewer" &amp;  draftbankfinal$Draft_Year==1998),]
  draftbankfinal&lt;-draftbankfinal[!(draftbankfinal$Player=="Patrick Ewing" &amp; draftbankfinal$Draft_Year==1985),]
  draftbankfinal&lt;-draftbankfinal[!(draftbankfinal$Player=="Charles Smith" &amp; draftbankfinal$Draft_Year==1988),]
  draftbankfinal&lt;-draftbankfinal[!(draftbankfinal$Player=="Ray McCallum" &amp; draftbankfinal$Draft_Year==1983),]
  draftbankfinal&lt;-draftbankfinal[!(draftbankfinal$Player=="James Anderson" &amp; draftbankfinal$Draft_Year==1985),]
  draftbankfinal&lt;-draftbankfinal[!(draftbankfinal$Player=="Ken Johnson" &amp; draftbankfinal$Draft_Year==1985),]
  draftbankfinal&lt;-draftbankfinal[!(draftbankfinal$Player=="Dee Brown" &amp; draftbankfinal$Draft_Year==1990),]
  
  
  
  
  
  fixedstats$Player &lt;- lapply(fixedstats$Player, sub, pattern = "[*]", replacement = "")
  fixedstats$Player &lt;- lapply(fixedstats$Player, sub, pattern = "[']", replacement = "")
  
  fixedstats$Player &lt;- ifelse(fixedstats$Player == 'Jermaine ONeal', 'Jermaine O\'Neal', fixedstats$Player)
  fixedstats$Player &lt;- ifelse(fixedstats$Player == 'J.J Obrien', 'J.J O\'Brien', fixedstats$Player)
  fixedstats$Player &lt;- ifelse(fixedstats$Player == 'Johnny OBryant', 'Johnny O\'Bryant', fixedstats$Player)
  fixedstats$Player &lt;- ifelse(fixedstats$Player == 'Patrick OBryant', 'Patrick O\'Bryant', fixedstats$Player)
  fixedstats$Player &lt;- ifelse(fixedstats$Player == 'Shaquille ONeal', 'Shaquille O\'Neal', fixedstats$Player)
  
  fixedstats$Player &lt;- as.vector(fixedstats$Player)
  draftbankfinal$Player &lt;- as.vector(draftbankfinal$Player)
  
  
  
  
  df &lt;- merge(x = fixedstats, y = draftbankfinal, by = "Player", all.x = TRUE)
  df2 &lt;- df[c(1,3:5,22,28:29,32:35)]
  </code></pre>