BoutMouse
BoutMouse

Reputation: 11

How to bind Binary Rating Matrices with different columns?

I'm currently working with the package *recommenderlab *and have run into some memory issues because I work with a lot of data. The problem lies in the creation of the matrices, so I thought I could solve this by using a function, that merges small matrices together to one big matrix.

S1 <- S1 %>% 
  select(SessionID, material_number) %>% 
  mutate(value = 1) %>% 
  spread(material_number,value, fill = 0) %>% 
  select(-SessionID) %>% 
  as.matrix() %>% 
  as("binaryRatingMatrix")
S2 <- S2 %>% 
  select(SessionID, material_number) %>% 
  mutate(value = 1) %>% 
  spread(material_number,value) %>% 
  select(-SessionID) %>% 
  as.matrix() %>% 
  as("binaryRatingMatrix")

Now I want to somehow bind these 2 matrices. Is this possible and do you have some ideas? I tried so many different approaches and run in many errors... If you have any creative other ideas to fight the memory issues, I will look forward to discuss these with you :)

That is the link to the package/class: https://github.com/cran/recommenderlab/blob/master/R/binaryRatingMatrix.R

Tried to write and use functions that bind matrices together but ran in class issues I don't understand.

Error with rbind.fill.matrix(S1@data,S2@data): Error in as.vector(data) : no method for coercing this S4 class to a vector

Upvotes: 1

Views: 24

Answers (0)

Related Questions