Hi Kai,
Thank you so much for your input, highly appreciated. We tried it out but it is still showing us the same error. Do you - or anyone else - have an idea what part of our code/ google spreadsheet is incorrect?
Our initial beginning of the code was:
install.packages("magrittr")
library(magrittr)
install.packages("dplyr")
library(dplyr)
We tried out the following
magrittr::describe
dplyr::describe
Please notice our original code in the following. Maybe somebody can find the issue and show us what we did wrong:
install.packages("magrittr")
library(magrittr)
install.packages("dplyr")
library(dplyr)
cat1id <- vector(mode = 'list', length = 20)
cat1rate <- vector(mode = 'list', length = 20)
cat2id <- vector(mode = 'list', length = 20)
cat2rate <- vector(mode = 'list', length = 20)
for(i in 1:20)
{
cat1id[i] <- get(paste("f_id_", i, sep = ""))
cat1rate[i] <- get(paste("f_rate_", i, sep = ""))
cat2id[i] <- get(paste("v_id_", i, sep = ""))
cat2rate[i] <- get(paste("v_rate_", i, sep = ""))
}
cat1 = data.frame(unlist(cat1id), unlist(cat1rate))
names(cat1) = c("id", "rate")
cat2 = data.frame(unlist(cat2id), unlist(cat2rate))
names(cat2) = c("id", "rate")
matchlist<-expand.grid(c1=1:20,c2=1:20,stringsAsFactors=F)
matchlist$c1id<-cat1$id[matchlist$c1]
matchlist$c1rate<-cat1$rate[matchlist$c1]
matchlist$c2id<-cat2$id[matchlist$c2]
matchlist$c2rate<-cat2$rate[matchlist$c2]
matchlist$ratediff<-abs(matchlist$c2rate-matchlist$c1rate)
oppnearscorematch<-data.frame(c1id=rep(NA,20),c2id=rep(NA,20),stringsAsFactors=F)
for(i in 1:20){
currmatch<-matchlist[which.min(matchlist$ratediff),]
currmatch<-currmatch[sample(1:nrow(currmatch),1),]
matchlist%<>%filter(c1id!=currmatch$c1id & c2id!=currmatch$c2id)
oppnearscorematch$c1id[i]<-currmatch$c1id
oppnearscorematch$c2id[i]<-currmatch$c2id
}
oppnearscorematch$c1rate<-cat1$rate[match(oppnearscorematch$c1id,cat1$id)]
oppnearscorematch$c2rate<-cat2$rate[match(oppnearscorematch$c2id,cat2$id)]
oppnearscorematch$ratediff<-abs(oppnearscorematch$c2rate-oppnearscorematch$c1rate)
oppnearscorematch <- oppnearscorematch[sample(1:10), ]
Best,
Lucca