<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Please don't cross-post:</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><a href="http://stackoverflow.com/questions/23047280/transform-characters-to-numbers">http://stackoverflow.com/questions/23047280/transform-characters-to-numbers</a></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <div id="bloop_sign_1397418184358636800" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">Arun</div></div> <div style="color:black"><br>From: <span style="color:black">Sergio.pv</span> <a href="mailto:serpalma.v@gmail.com">serpalma.v@gmail.com</a><br>Reply: <span style="color:black">Sergio.pv</span> <a href="mailto:serpalma.v@gmail.com">serpalma.v@gmail.com</a><br>Date: <span style="color:black">April 13, 2014 at 9:36:35 PM</span><br>To: <span style="color:black">datatable-help@lists.r-forge.r-project.org</span> <a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>Subject: <span style="color:black"> [datatable-help] Transform characters to numbers and compare <br></span></div><br> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>I have a data.frame of two vectors.
<br>
<br>df <- data.frame(G1=c("b","a","e","d","c"),
<br>                 G2=c("c","d","e","b","a"))
<br>You can see that both vectors have the same characters, but in diferent
<br>order. I want to convert them into numbers and then compare them.
<br>
<br>To compare G2 to G1, G1 must be the reference, so the output will be this:
<br>
<br>df2 <- data.frame(G1=c("1","2","3","4","5"),
<br>                 G2=c("5","4","3","1","2"))
<br>Is there a way to do this?, thanks
<br>
<br>
<br>
<br>--
<br>View this message in context: http://r.789695.n4.nabble.com/Transform-characters-to-numbers-and-compare-tp4688708.html
<br>Sent from the datatable-help mailing list archive at Nabble.com.
<br>_______________________________________________
<br>datatable-help mailing list
<br>datatable-help@lists.r-forge.r-project.org
<br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
<br></div></div></span></blockquote></body></html>