vendredi 27 février 2015

split a string by the last patterns

I have some data like this:



vtab = read.table(textConnection("uid=123455,ou=usuarios,ou=gm,dc=intra,dc=planej,dc=gov,dc=de
uid=123456,ou=bsa,dc=plant,dc=gov,dc=de
uid=123457,ou=reg,ou=regfns,dc=sero,dc=gov,dc=de
uid=123458,ou=reg,ou=regbhe,dc=sero,dc=gov,dc=de
uid=123459,ou=sede,ou=regbsa,dc=sero,dc=gov,dc=de
uid=123450,ou=reg,ou=regbhe,dc=sero,dc=gov,dc=de"))


I would like split this data. Firstly split the data in two groups including just the uid= number and the third last description in dc=. Like thus:



[,1] [,2]
[1,] "123455" "plant"
[2,] "123456" "planej"
[3,] "123457" "sero"
[4,] "123458" "sero"
[5,] "123459" "sero"


Any helps are enjoyed :-)


Aucun commentaire:

Enregistrer un commentaire