[datatable-help] Transform characters to numbers and compare

Sergio.pv serpalma.v at gmail.com
Sun Apr 13 21:35:55 CEST 2014


I have a data.frame of two vectors.

df <- data.frame(G1=c("b","a","e","d","c"),
                 G2=c("c","d","e","b","a"))
You can see that both vectors have the same characters, but in diferent
order. I want to convert them into numbers and then compare them.

To compare G2 to G1, G1 must be the reference, so the output will be this:

df2 <- data.frame(G1=c("1","2","3","4","5"),
                 G2=c("5","4","3","1","2"))
Is there a way to do this?, thanks



--
View this message in context: http://r.789695.n4.nabble.com/Transform-characters-to-numbers-and-compare-tp4688708.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list