how to display dataframe data in columns?
how to display dataframe data in columns?
I wish to create a dynamic tables as
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
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
Re: how to display dataframe data in columns?
hi,
i'm afraid i don't quite understand what you mean. could you describe in a bit more detail?
with thanks
i'm afraid i don't quite understand what you mean. could you describe in a bit more detail?
with thanks
Re: how to display dataframe data in columns?
this is my r.yaml code
here is the .b.R code
I want to display value from dataframe into all the columns cells in rowNo1. How to do the forloop? is it use addColumn functions?
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
))
Re: how to display dataframe data in columns?
hi,
taking a look at your code, i can't see anything obviously wrong with it, so i would expect it to work ... if it doesn't work, i assume there's something a bit subtle we're overlooking.
if you commit this module to a github repo, and share the link with us, someone should be able to figure out what's wrong.
cheers
taking a look at your code, i can't see anything obviously wrong with it, so i would expect it to work ... if it doesn't work, i assume there's something a bit subtle we're overlooking.
if you commit this module to a github repo, and share the link with us, someone should be able to figure out what's wrong.
cheers
Re: how to display dataframe data in columns?
do you have an example data set i can use with this?
(most modules won't need to use addColumn() because the .r.yaml file sets up the tables appropriately)
with thanks
(most modules won't need to use addColumn() because the .r.yaml file sets up the tables appropriately)
with thanks
Re: how to display dataframe data in columns?
https://github.com/lerlerchan/FuzzyDelp ... sampleData
Thank you
can setRow ... display data in columns cells? use for loop columns in the dataframe?
Thank you
can setRow ... display data in columns cells? use for loop columns in the dataframe?
Re: how to display dataframe data in columns?
hi,
so the problem is the way you're reading values from the df4 data frame.
this code:
value <- df4$value
description <- df4$description
$value and $description don't exist in df4, and so these will just be assigned NULL.
to read the values from a data frame, you'll probably want to use something like:
df4[rowNumber, columnNumber]
df4[rowNumber, columnName]
df4[i, name]
if you can draw describe what you're hoping the final table looks like, i can probably point you in the right direction. i.e. are you after a table with 2 columns, 5 rows ... the first column contains Item 1, Item 2, Item 3, and the second column contains each of their scores?
jonathon
so the problem is the way you're reading values from the df4 data frame.
this code:
value <- df4$value
description <- df4$description
$value and $description don't exist in df4, and so these will just be assigned NULL.
to read the values from a data frame, you'll probably want to use something like:
df4[rowNumber, columnNumber]
df4[rowNumber, columnName]
df4[i, name]
if you can draw describe what you're hoping the final table looks like, i can probably point you in the right direction. i.e. are you after a table with 2 columns, 5 rows ... the first column contains Item 1, Item 2, Item 3, and the second column contains each of their scores?
jonathon
Re: how to display dataframe data in columns?
https://github.com/lerlerchan/FuzzyDelp ... Output.png
yes. a table with 5 rows and 6 columns
item1 item2 item3 item4 item5
________________________________________
title1 x x x x x #from df2
title2 x x x x x # from df4
title3
title4
yes. a table with 5 rows and 6 columns
item1 item2 item3 item4 item5
________________________________________
title1 x x x x x #from df2
title2 x x x x x # from df4
title3
title4
Re: how to display dataframe data in columns?
still not completely clear to me what you're trying to do, but hopefully this can get you on the right track.
here you can see me populating the 'Fuzzy Score Table' from the data frame.
to achieve this, i add a .init() function beside the .run() function that looks like this:
then inside .run() i go:
hopefully there's enough information here for you to move forward.
your design is a little unusual, in that the number of columns in the table depends on the number of variables ... this is a less common design (the number of rows in a table matching the number of variables is far more common pattern), which is why you need to resort to an .init() function.
let me know if you'd like an invite to our slack group too. you may find that's an easier medium to ask these sorts of questions, etc.
cheers
here you can see me populating the 'Fuzzy Score Table' from the data frame.
to achieve this, i add a .init() function beside the .run() function that looks like this:
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)
}
your design is a little unusual, in that the number of columns in the table depends on the number of variables ... this is a less common design (the number of rows in a table matching the number of variables is far more common pattern), which is why you need to resort to an .init() function.
let me know if you'd like an invite to our slack group too. you may find that's an easier medium to ask these sorts of questions, etc.
cheers