
1) Is it possible to display a dataframe data in dynamic table?
2) can we loop through the column and dataframe?
Currently, I am trying to learn from https://github.com/arcaldwell49/SimplyAgree. I am able to display the data in rows.
Thank you
Code: Select all
- name: scoreTable
title: Fuzzy Score Table
type: Table
rows: 4
columns:
- name: var
title: ''
type: text
- name: varScore
title: ''
type: number
Code: Select all
table1 <- self$results$scoreTable
# Assuming you have a dataframe called 'dataframe' with the data you want to display
# Initialize an empty list to store the values
rows <- list()
# Loop through each row of the dataframe
for (i in 1:nrow(df4)) {
# Extract the values from the dataframe
value <- df4$value[i]
description <- df4$description[i]
# Append the values to the 'rows' list
rows[[i]] <- list(
var = description,
varDconstruct = value
)
}
# Loop through the 'rows' list and set each row in the table
for (i in 1:length(rows)) {
table1$setRow(rowNo = i, values = rows[[i]])
}
#output the calculated Info into dcTable
table2 <- self$results$dcTable
#row1 = value d construct
table2$setRow(rowNo=1, values=list(
var = "Value d construct",
varDconstruct = dConstruct
))
#row2 = result percentage
table2$setRow(rowNo=2, values=list(
var = "%o f expert consesnsus for construct",
varDconstruct = perCentageDCon
))
Code: Select all
.init = function() {
table1 <- self$results$scoreTable
for (name in self$options$deps) {
table1$addColumn(name, title=name)
}
},
Code: Select all
for (rowNo in seq_len(nrow(rounded_dataframe))) {
if (rowNo > table1$rowCount)
break()
values <- as.list(rounded_dataframe[rowNo,])
table1$setRow(rowNo=rowNo, values)
}