{"size":{"Width":450,"Height":824},"appearance":{"background":null,"padding":14,"font":{"family":"Courier New","size":10.0,"bold":false,"italic":false,"underline":false,"strikeout":false,"color":"rgb(0,72,168)"},"border":{"on":true,"size":0.0,"style":"solid","color":"#666"},"text":{"wrap":false,"hAlign":"left","vAlign":"top"}},"outputType":"TEXT","widgetState":null,"wikiPageTitle":null,"outputs":{"text":"function(x)\n{ \n # Lookups for coloring cells and fonts\n require(RColorBrewer)\n cell.colors = colorRampPalette(brewer.pal(9,\"Blues\"))(101)\n font.colors = c(rep(\"blue\", 60), rep(\"white\", 41))\n\n # Scaling the data to be on [1, 2, ..., 101], for the lookups\n min.x <- min(x)\n max.x <- max(x)\n scaled.x = round((x - min(x)) / (max(x) - min(x)) * 100, 0) + 1\n\n # Writing the cells styles\n n.rows = nrow(x)\n n.columns = ncol(x)\n rows = rep(1:n.rows, rep(n.columns, n.rows))\n columns = rep(1:n.columns, n.rows)\n x.lookups = as.numeric(t(scaled.x))\n cells.styles = paste0('td.cell', rows, columns, ' {background-color: ', cell.colors[x.lookups], '; color: ', font.colors[x.lookups] ,';}')\n cell.styles = paste0(cells.styles, collapse = \"\\n\")\n \n # Creating the table\n columns.headers = paste0('<th>', c(\"\", dimnames(x)[[2]]) ,'</th>')\n tble = paste0(columns.headers, collapse = \"\\n\")\n row.headers = paste0('<th>', c(dimnames(x)[[1]]) ,'</th>')\n print('row.headers')\n print(row.headers)\n for (row in 1:n.rows)\n {\n row.cells = paste0('<td class = \"border cell', row, 1:n.columns, '\">', x[row,],'</td>')\n print('row.cells')\n print(row.cells)\n tble = paste0(tble, '<tr>', row.headers[row], paste(row.cells, collapse = '\\n'), '</tr>')\n }\n # Assembling the HTML\n html = paste0('<!DOCTYPE html>\n <html>\n <head>\n <style>\n table, th, td {border-collapse: collapse; }\n th, td {padding: 5px; text-align: center; font-family: arial; font-size: 8pt}\n td.border {border: 1px solid grey; }',' td.cell11 {background-color: #F7FBFF; color: blue;}',\n cell.styles, '\n </style>\n </head>\n <body>\n <table style=\"width:100%\">', tble, '\n </table>\n </body>\n </html>')\n rhtmlMetro::Box(text = html, text.as.html = TRUE)\n}\n","warning":""},"secondsTaken":0.2187948,"updated":"2018-11-02T05:49:27.6650557Z","lastUpdatedMessage":null,"executedCode":"MyHeatmap <- function(x)\n{ \n # Lookups for coloring cells and fonts\n require(RColorBrewer)\n cell.colors = colorRampPalette(brewer.pal(9,\"Blues\"))(101)\n font.colors = c(rep(\"blue\", 60), rep(\"white\", 41))\n\n # Scaling the data to be on [1, 2, ..., 101], for the lookups\n min.x <- min(x)\n max.x <- max(x)\n scaled.x = round((x - min(x)) / (max(x) - min(x)) * 100, 0) + 1\n\n # Writing the cells styles\n n.rows = nrow(x)\n n.columns = ncol(x)\n rows = rep(1:n.rows, rep(n.columns, n.rows))\n columns = rep(1:n.columns, n.rows)\n x.lookups = as.numeric(t(scaled.x))\n cells.styles = paste0('td.cell', rows, columns, ' {background-color: ', cell.colors[x.lookups], '; color: ', font.colors[x.lookups] ,';}')\n cell.styles = paste0(cells.styles, collapse = \"\\n\")\n \n # Creating the table\n columns.headers = paste0('<th>', c(\"\", dimnames(x)[[2]]) ,'</th>')\n tble = paste0(columns.headers, collapse = \"\\n\")\n row.headers = paste0('<th>', c(dimnames(x)[[1]]) ,'</th>')\n print('row.headers')\n print(row.headers)\n for (row in 1:n.rows)\n {\n row.cells = paste0('<td class = \"border cell', row, 1:n.columns, '\">', x[row,],'</td>')\n print('row.cells')\n print(row.cells)\n tble = paste0(tble, '<tr>', row.headers[row], paste(row.cells, collapse = '\\n'), '</tr>')\n }\n # Assembling the HTML\n html = paste0('<!DOCTYPE html>\n <html>\n <head>\n <style>\n table, th, td {border-collapse: collapse; }\n th, td {padding: 5px; text-align: center; font-family: arial; font-size: 8pt}\n td.border {border: 1px solid grey; }',' td.cell11 {background-color: #F7FBFF; color: blue;}',\n cell.styles, '\n </style>\n </head>\n <body>\n <table style=\"width:100%\">', tble, '\n </table>\n </body>\n </html>')\n rhtmlMetro::Box(text = html, text.as.html = TRUE)\n}","lastSavedCode":null,"highlightedCodeSpans":[],"tableTransformations":"<TabularTransformer>\r\n <TabularTransform type=\"Truncation\" truncationHeaderType=\"Column\" />\r\n <TabularTransform />\r\n</TabularTransformer>","tabularFilteringOptions":null,"hasGuiControls":false,"calculating":"Idle","showDebug":false,"layout":"CodeOnly","vSplit":0.25,"hSplit":0.45,"updateWarnings":true,"updateMode":"Automatic","warnSlow":true,"Options":{"debugconsole":false,"codeposition":"CodeOnly","splitH":0.45,"splitV":0.25,"update warnings":true,"updating":"Automatic","warn slow":true}}