I have two character lists the first one is A
> mode(A)
[1] "character"
> length(A)
[1] 300
> dim(A)
[1] 150 2
the A is something like this
> head(A)
[,1] [,2]
[1,] "000001" "601166"
[2,] "000027" "600582"
[3,] "000027" "600783"
[4,] "000027" "601088"
[5,] "000166" "000728"
[6,] "000333" "600519"
The second list is B which has 1000 elements
> length(B)
[1] 1000
> dim(B)
NULL
also each element of B has the below characteristics
> mode(B[[1]])
[1] "character"
> length(B[[1]])
[1] 300
> dim(B[[1]])
[1] 150 2
the B[[1]]
is
> head(B[[1]])
[,1] [,2]
[1,] "000001" "601818"
[2,] "000027" "600362"
[3,] "000027" "600827"
[4,] "000166" "601099"
[5,] "000333" "002304"
[6,] "000333" "601318"
I want to count of the frequency of the pairs of A's rows such as
"000001" "601166"
in each element of B
such as
B[[1]]
I tried this code but couldn't get the result
Match<-list()
for(i in 1:1000){Match[[i]]<-match(as.data.frame(t(A)),as.data.frame(t(B[[i]])), nomatch=0)}
I found the solution for it, I just need to add stringsAsFactors = FALSE
in the code.
The correct code is
M<-list()
for (i in 1:1000) {M[[i]]<-match(as.data.frame(t(A), stringsAsFactors = FALSE),as.data.frame(t(B[[i]]), stringsAsFactors = FALSE), nomatch=0)}
any other suggestion to improve it will be appreciated.