We just need the indexing of the table to be able to run:
table -> tag_attr(table[,2], align = "right")
This would add the attribute "align = 'right'" to all td elements in the second column of the table.
I think the table should be indexed only in the tbody not the thead like a normal data.frame is indexed. I'm however not sure what the best design would be to handle the tfoot. Perhaps tfoot is also outside of the standard indexing unless you specifically call that row with table$tfoot?
Note that instead of table$content[[2]] we should have table$content$tfoot and instead of table$content[[3]] we should have table$content$tbody
## Add align right to all cells
for(i in seq_len(length(table$content[[3]]$content))) {
for(j in seq_len(length(table$content[[3]]$content[[i]]$content))) {
table$content[[3]]$content[[i]]$content[[j]] <- tag_attr(table$content[[3]]$content[[i]]$content[[j]], align = "right")
}
}
## Remove align right from all cells
for(i in seq_len(length(table$content[[3]]$content))) {
for(j in seq_len(length(table$content[[3]]$content[[i]]$content))) {
table$content[[3]]$content[[i]]$content[[j]] <- tag_attr(table$content[[3]]$content[[i]]$content[[j]], align = NULL)
}
}
## Add it to just the second column
for(i in seq_len(length(table$content[[3]]$content))) {
table$content[[3]]$content[[i]]$content[[2]] <- tag_attr(table$content[[3]]$content[[i]]$content[[2]], align = "right")
}
## Add alignment to the tfoot
for(j in seq_len(length(table$content[[2]]$content$content))) {
table$content[[2]]$content$content[[j]] <- tag_attr(table$content[[2]]$content$content[[j]], align = "right")
}
Nice, it looks like we are almost there.... Now I just have to remove code from SVAMAP :) I have been looking through some of the functionality that is in SVAMAP and consider that it could be the package that just deploys pages so contains a functions that are essential to to spatial data manipulation and the deploy code for each page. So it is fluid and gets frequently updated based on needs of pages that are being designed. Then we need a 3rd package that just builds the mapping .js script that will be injected as a script item with hlt and the lines of .json that will also be injected as a script item with 'hlt'. This 3rd package should have a name like webmapping or leaflet something or r2leaflet.... there are already at least two others on CRAN :)
Two examples of what I am building today in svamap and we like to replace the code that generates everything inside:
view-source:http://www.sva.se/Maps/Kvarka_table/kvarka_table.html
view-source:http://www.sva.se/Maps/CWD/table.html
Both tables also include styles in the
@stewid We are almost solving the table http://www.sva.se/Maps/CWD/table.html now like this:
We just need the indexing of the table to be able to run:
This would add the attribute "align = 'right'" to all
td
elements in the second column of the table.I think the table should be indexed only in the
tbody
not thethead
like a normal data.frame is indexed. I'm however not sure what the best design would be to handle thetfoot
. Perhapstfoot
is also outside of the standard indexing unless you specifically call that row withtable$tfoot
?Here we also add the alignment:
Note that instead of
table$content[[2]]
we should havetable$content$tfoot
and instead oftable$content[[3]]
we should havetable$content$tbody
@trosendal Does it work if you change
to
nope
I have made some refactoring, could you please try
I get the alignment in tfoot. However, the cells in tfoot are now
<th>
where they should be<td>
Found the problem with
<th>
, try againNice, it looks like we are almost there.... Now I just have to remove code from SVAMAP :) I have been looking through some of the functionality that is in SVAMAP and consider that it could be the package that just deploys pages so contains a functions that are essential to to spatial data manipulation and the deploy code for each page. So it is fluid and gets frequently updated based on needs of pages that are being designed. Then we need a 3rd package that just builds the mapping .js script that will be injected as a script item with
hlt
and the lines of .json that will also be injected as a script item with 'hlt'. This 3rd package should have a name likewebmapping
orleaflet something
orr2leaflet
.... there are already at least two others on CRAN :)Impletmentation of example2: https://github.com/SVA-SE/svamap/blob/master/inst/deploy_scripts/CWD_table2.R
Implementation of example 1 in lines 174 to the end
https://github.com/SVA-SE/svamap/blob/master/inst/deploy_scripts/kvarka_table2.R