thanks a lot , I think this would work but dont know how to use it with my reactive function. It works as it is right now but not using my reactive function
My function returns the dataframe and it fills up by executing a query
VarPrecio=reactive({
validate(
need(nrow(values$mydata)>0,"")
)
sem4=c((values$mydata[origTable_selected(),107]/values$mydata[origTable_selected(),55])/(values$mydata[origTable_selected(),111]/values$mydata[origTable_selected(),46])-1)
sem3=c((values$mydata[origTable_selected(),108]/values$mydata[origTable_selected(),56])/(values$mydata[origTable_selected(),112]/values$mydata[origTable_selected(),47])-1)
sem2=c((values$mydata[origTable_selected(),109]/values$mydata[origTable_selected(),57])/(values$mydata[origTable_selected(),113]/values$mydata[origTable_selected(),48])-1)
sem1=c((values$mydata[origTable_selected(),110]/values$mydata[origTable_selected(),58])/(values$mydata[origTable_selected(),114]/values$mydata[origTable_selected(),49])-1)
w4=c(((values$mydata[origTable_selected(),107]+values$mydata[origTable_selected(),108]+values$mydata[origTable_selected(),109]+values$mydata[origTable_selected(),110])/
(values$mydata[origTable_selected(),55]+values$mydata[origTable_selected(),56]+values$mydata[origTable_selected(),57]+values$mydata[origTable_selected(),58]))/
((values$mydata[origTable_selected(),111]+values$mydata[origTable_selected(),112]+values$mydata[origTable_selected(),113]+values$mydata[origTable_selected(),114])/
(values$mydata[origTable_selected(),46]+values$mydata[origTable_selected(),47]+values$mydata[origTable_selected(),48]+values$mydata[origTable_selected(),49]))-1)
text_tbl <- data.frame(sem4,sem3,sem2,sem1,w4)
row.names(text_tbl)=c("VarPrecio")
return(text_tbl)
})
library(DT)
data <- matrix(c(0,0.64,-0.76234,0.43,1,19),nrow=3,byrow=T)
datatable(data,options=list(
rowCallback=JS("function( row, data, index ) {
$('td:eq(0)', row).html(data[0] % 1 != 0 | data[0]==0 ? (data[0]*100).toFixed(1) +'%':data[0]);
$('td:eq(1)', row).html(data[1] % 1 != 0 | data[1]==0 ? (data[1]*100).toFixed(1) +'%':data[1]);
}
")))