I have tried a few proposed solution in here. But it was not working for my case.
I have a code, here:
a <- read.table("Whirr_127.csv", header=T, sep=",", row.names=1) # task assignment / people vs task
b <- read.table("Files_Whirr_127.csv", header=T, sep=",", row.names=1) #task vs files
a
b
#calc cr , cr = ta * tf * transpose(ta)
cr <- as.matrix(a) %*% (as.matrix(b) %*% as.matrix(t(b)) %*% as.matrix(t(a)))
cr
#set value to 1, to initialize table
cr[cr>=1]<-1
cr
#identify diagonal matrix, set to zero
cr<-as.matrix(0,ncol=ncol(cr),nrow=nrow(cr))
cr<-diag(cr,x=0)
I want to set diagonal value as zero. It seems the code used in the last two lines are not working for my case.
Also, I would like to used the file name in a, and saved it as AB_Files_Whirr_127.csv
I tried to use
write.csv(cr,file = paste("CR_", a,".csv")
but, nothing appear in my directory.
sample output for cr:
Adrian Cole Alison Wong Andrei Savu Bruno Dumon Edward J. Yoon Eugene Koontz Jakob Homan Kelvin Kakugawa Kirk True Lars George Soren Macbeth Stu Hood
Adrian Cole 0 0 0 0 0 0 0 0 0 0 0 0
Alison Wong 0 0 0 0 0 0 0 0 0 0 0 0
Andrei Savu 0 0 1 0 0 0 0 0 0 1 1 0
Bruno Dumon 0 0 0 0 0 0 0 0 0 0 0 0
Edward J. Yoon 0 0 0 0 0 0 0 0 0 0 0 0
Eugene Koontz 0 0 0 0 0 0 0 0 0 0 0 0
Jakob Homan 0 0 0 0 0 0 0 0 0 0 0 0
Kelvin Kakugawa 0 0 0 0 0 0 0 0 0 0 0 0
Kirk True 0 0 0 0 0 0 0 0 0 0 0 0
Lars George 0 0 1 0 0 0 0 0 0 1 1 0
Soren Macbeth 0 0 1 0 0 0 0 0 0 1 1 0
Stu Hood 0 0 0 0 0 0 0 0 0 0 0 0
Tibor Kiss 0 0 0 0 0 0 0 0 0 0 0 0
Tom White 0 0 1 0 0 0 0 0 0 1 1 0
Unassigned 0 0 0 0 0 0 0 0 0 0 0 0
Tibor Kiss Tom White Unassigned
Adrian Cole 0 0 0
Alison Wong 0 0 0
Andrei Savu 0 1 0
Bruno Dumon 0 0 0
Edward J. Yoon 0 0 0
Eugene Koontz 0 0 0
Jakob Homan 0 0 0
Kelvin Kakugawa 0 0 0
Kirk True 0 0 0
Lars George 0 1 0
Soren Macbeth 0 1 0
Stu Hood 0 0 0
Tibor Kiss 0 0 0
Tom White 0 1 0
Unassigned 0 0 0
acannot be used in the name of the output file as it is not a character variable, it is a data frame.The syntax of the
diagline tends to look funny to new R users, but it is actually just an alternate syntax to call the assignment functiondiag<-, i.e.diag(x) <- 0is interpreted asdiag<-(x, 0).Update: Multiple files
If you want to repeat the above for multiple paired files you can do this.