Entering edit mode
Hi all,
I have data frame (probe_int) as:
col1 col2 col3 ...
12,1 11,2 12,1 ...
10,1 11,1 11,2 ...
....
I want to separate the data into two matrix by comma like:
matrix1 (probe_int_s):
col1 col2 col3 ...
12 11 12 ...
10 11 11 ...
...
matrix2 (probe_int_b):
col1 col2 col3 ...
1 2 1 ...
1 1 2 ...
....
My code:
for(i in 1:nrow(probe_int)){
for(j in 1:ncol(probe_int)){
temp<-strsplit(as.character(probe_int[i,j]),",")
probe_int_s[i,j]<-as.numeric(temp[[1]][1])
probe_int_b[i,j]<-as.numeric(temp[[1]][2])
}
}
Is there any clean and grace methods to do that? Thanks.
Yours sincerely,
Jianhong Ou
jianhong.ou@umassmed.edu<mailto:jianhong.ou@umassmed.edu>
[[alternative HTML version deleted]]