[R] help with encrypting a text string in a data.frame
g.rudge at bham.ac.uk
Sun Feb 23 19:53:48 CET 2014
I am trying to encrypt postcodes (zipcodes) which, in my datasets, are
strings with 8 characters, including spaces. By referring to other help
files and other R resources I've built some (clumsy looking) code that turns
a postcode into an output I'm happy with. See below.
#make a character string of the post code in 8 character format
#get it into a string of numbers
#make a 16 digit pin for the key, in this case with a simple set of
#make a encryption key
#encrypt the postcode
#finally convert this to a manageable string
#summary of the outputs
Now, I’ve got a couple of questions about this
Firstly and most importantly if I have a data.frame where one of my columns
contains these postcodes (e.g. df below) how can I run this workflow (or
something slicker, that does the same thing) and put the result into a
column in the data.frame? I’ve tried making a function and I’ve tried
sapply, but been unable to do achieve this.
Secondly there seem to be a lot of steps to get the text string into a
format that the AES command can use, is there a way to make this simpler?
#make a simple data.frame with some sample codes
postcode<-c("AB5 2TG","B1 8AA","TG22 4XB")
Any help gratefully received.
View this message in context: http://r.789695.n4.nabble.com/help-with-encrypting-a-text-string-in-a-data-frame-tp4685716.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help