I am trying to get a binary matrix but first I need to replace multiple string columns to binary values (0 and 1). I tried to get it in R and python but the code didn't work. I was wondering if someone could help me.
I have a matrix of 29,584 rows x 982 columns, similar like:
G X4646466.555 X564737373.455 X737347474.56
0 add bp_ggfgfgg
1 fgr bb_jhfjfjf bpp_fhfhfhf bb_jfjfjf
2 dfr
3 tth bb_jdjfjdd
4 dee bp_djdjdd
5 ee bp_dhsdhdh
6 ff bb_hfhfhf bpp_dfhdhdhd
...
For each column that start with X, there are various string values. These values start in bb_, bpp_ and bp_. In addition, there are missing data (in blank). I would like to replace with 1 all the string values from each column that start witn X (or all columns except G) and to replace with 0 the missing data from the columns that start with X.
pythonor inR?