https://github.com/cran/plotKML
Tip revision: 7e79f0094a9ff898febe51089ecf40eb542c523e authored by Tomislav Hengl on 09 March 2020, 21:40:02 UTC
version 0.6-1
version 0.6-1
Tip revision: 7e79f00
attributes.R
.df2htmltable <- function(x, fix.enc = TRUE, columns = TRUE) {
# if the user passed in TRUE, then we want all of the columns
if(class(columns) == 'logical'){
columns <- 1:ncol(x) # use all columns from the dataframe row
}
else{ # otherwise, keep only requested columns
x <- x[, columns]
}
# fix encoding:
if(fix.enc==TRUE){
x <- data.frame(lapply(x, iconv, to = "UTF8"))
}
# get selected table data:
att.names <- sapply(names(x), function(i) { paste('<span style="font-weight: bold; color: #000000; padding: 3px;">', as.character(i), '</span>: ', sep = '') } )
att.values <- as.vector(t(sapply(x, function(i) { paste('<span style="color: #000000; padding:3px;">', as.character(i), '</span><br>', sep = '') })))
# combine by interleaving:
att <- matrix(paste(att.names, att.values, sep="\n"), ncol=length(names(x)), byrow=TRUE)
html.table <- apply(att, 1, paste, collapse="\n")
return(html.table)
}
# end of script;