[R] Transform a list of multiple to a data.frame which I want

Yao He heyao at nibs.ac.cn
Sun Feb 1 13:53:23 CET 2015


Dear all:

	I have a list like that,which is a standard str_locate_all() function (stringr package) output:
$K
   start end
$GSEGTCSCSSK
   start end
[1,]     6   6
[2,]     8   8
$GFSTTCPAHVDDLTPEQVLDGDVNELMDVVLHHVPEAK
   start end
[1,]     6   6
$LVECIGQELIFLLPNK
   start end
[1,]     4   4
$NFK
   start end
$HR
   start end
$AYASLFR
   start end

I want to transform this list like that:

ID   start.1  start.2 
K   NA	NA
GSEGTCSCSSK 6 8
GFSTTCPAHVDDLTPEQVLDGDVNELMDVVLHHVPEAK 6 NA
LVECIGQELIFLLPNK 4 NA
NFK NA NA
HR NA NA
AYASLFR NA NA

I have already tried to use t() , lapply() but I think it is hard to handle the NA value and different rows in every matrix 

Thanks in advance



More information about the R-help mailing list