Is there a way to optimize code that is going through edge activity matrix, to get rid of all of the (-)Inf values?
To see how long this works: onlineNet sample data set.
(~/network-app/server.R)
edges acitivity matrix
connectionsIdx <- get.edge.activity(data, as.spellList = TRUE)[c("onset", "terminus", "tail", "head")]
for (i in 1:nrow(connectionsIdx))
{
# remove onset -infitiy values
if (connectionsIdx[i,]$onset == -Inf)
connectionsIdx[i,]$onset <-
max(nodesActivity[which(nodesActivity$vertex.id == connectionsIdx[i,]$tail),]$onset,
nodesActivity[which(nodesActivity$vertex.id == connectionsIdx[i,]$head),]$onset)
# remove terminus infitiy values
if (connectionsIdx[i,]$terminus == Inf)
connectionsIdx[i,]$terminus <-
min(nodesActivity[which(nodesActivity$vertex.id == connectionsIdx[i,]$tail),]$terminus,
nodesActivity[which(nodesActivity$vertex.id == connectionsIdx[i,]$head),]$terminus)
# decrement indexes as javascript counts from 0, not 1
connectionsIdx[i,]$tail <- connectionsIdx[i,]$tail - 1
connectionsIdx[i,]$head <- connectionsIdx[i,]$head - 1
}
Is there a way to optimize code that is going through edge activity matrix, to get rid of all of the (-)Inf values? To see how long this works: onlineNet sample data set. (~/network-app/server.R)
edges acitivity matrix