I have a list of multiple data frames (called prep1). Each data frame has the following format(only the first 6 rows shown)
player1 player2 win1 win2
1 a12TTT.pdf a21.pdf 0 1
2 a12TTT.pdf B11.pdf 1 0
3 a12TTT.pdf B12.pdf 1 1
4 a12TTT.pdf B24.pdf 0 2
5 a12TTT.pdf B4.pdf 0 1
6 a12TTT.pdf B8.pdf 0 1
I want to model the data using function BTm from BradleyTerry2 package .
With a single data frame the function is
BTm(cbind(win1,win2), player1, player2, data= your.data.frame.name)
I try to do the same but on all dataframes from the list at once using sapply and passing all the arguments from BTm instead of ..... in the sapply arguments (the documentation says: ... optional arguments to FUN).
sapply (prep1, BTm, cbind(win1, win2), player1, player2, data = prep1)
It gets me the following error Error in FUN(X[[i]], ...) : object 'player2' not found
I get the same error if I use lapply
.
I do not know how to pass all the arguments correctly. Can you please help?