How to add two sub-columns in one (Concat) using datatable (DT) in R Markdown/Shiny?

How to add two sub-columns in one (Concat) using datatable (DT) in R Markdown/Shiny?

bharath222bharath222 Posts: 3Questions: 1Answers: 0
edited October 2018 in Free community support
I would like to see two columns in one using DT package. 

Example:

              Score
Count of scores  Sum of scores


I am  rendering the table from Markdown: 

renderDataTable({  
  DT::datatable(


I would appreciate any help.

Thanks.

Answers

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    You would use the row parameter of columns.render to access different data in the row.

    Kevin

  • bharath222bharath222 Posts: 3Questions: 1Answers: 0
    edited October 2018

    Hi,

    Thank you for letting me know. I was not able to create the reprex in R so I have created in Excel and pasted here. Please let me know if you don't understand. (see below image)

    `

    `

    This is how I wanted to create a table in R Markdown using datatable package. Is it possible to do that? or is there any other package to create a table exactly the same.

    Thanks.

  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    edited October 2018

    Hi @bharath222 ,

    From that image, it looks like a normal table, with a double row header - the top row with a colspan, and the second without. If so, this example here should help,

    Cheers,

    Colin

  • bharath222bharath222 Posts: 3Questions: 1Answers: 0

    Thank you for the link. I am able to get it.

This discussion has been closed.