Comparing the two lists [R]

I have two fairly long lists (both are 232,000 lines). When I try to perform an analysis using both parameters, R gives me an error that some elements in one list are not in the other (to run certain code, both lists must be exactly the same). I did the following to try to decrypt this:

#In Both
both <- varss %in% varsg
length(both)

#What is in Both
int <- intersect(varss,varsg)
length(int)

#What is different in varss
difs <- setdiff(varss,varsg)
length(difs)

#What is different in varsg
difg <- setdiff(varsg,varss)
length(difg)

I think I have the correct code, but my problem is that the results from the above code do not bring what I need. For example, for both <- varss %in% varsgI get only one FALSE. Do both of my lists have to be in a specific class for this to work? I tried data.frame, listand character. Not sure if something important needs to be used, for example function.

, SNP ( )

Edit:

readRDS() , . varss[1:10,] :

 [1] rs41531144 rs41323649 exm2263307 rs41528348 exm2216184 rs3901846 
 [7] exm2216185 exm2216186 exm2216191 exm2216198
232334 Levels: exm1000006 exm1000025 exm1000032 exm1000038 ... rs9990343

RData , , ...

varsg[1:10,]:

 [1] exm2268640 exm41      exm1916089 exm44      exm46      exm47     
 [7] exm51      exm53      exm55      exm56     
232334 Levels: exm1000006 exm1000025 exm1000032 exm1000038 ... rs999943 
+4
1

, , data.frames, :

varss <- list(a = 1:8)
varsg <- list(a = 2:9)

both <- varss %in% varsg
both
# [1] FALSE

#What is in Both
int <- intersect(varss,varsg)
int
# list()

#What is different in varss
difs <- setdiff(varss,varsg)
difs
# [[1]]
# [1] 1 2 3 4 5 6 7 8

#What is different in varsg
difg <- setdiff(varsg,varss)
difg
# [[1]]
# [1] 2 3 4 5 6 7 8 9

, :

varss <- unlist(varss)
varsg <- unlist(varsg)
+5

Source: https://habr.com/ru/post/1538494/


All Articles