Grouping columns together in R formattable -


apologies if question trivial, formattable documentation has me confused on issue.

my data take shape of:

source <- c("c", "p") name <- c("name1", "name2") n <- c(1234567, 4567890) <- c(12345, 67890) ratea <- / n  deltaa <- c(na, (ratea[1] / ratea[2]) - 1)  df <- data.frame(source, name, n, a, ratea, deltaa) df    source  name       n        ratea  deltaa 1      c name1 1234567 12345 0.009999      na 2      p name2 4567890 67890 0.014862 -0.3272 

there many more columns in actual data, repeating {a, ratea, deltaa} structure several more letters in alphabet. issue grouping columns in formattable command. is:

for {source, name} -> no format change {n, a} -> comma format no digits after decimal {ratea, deltaa} -> percentages 2 digits after decimal (i.e., first value in ratea "0.99%") 

but, grouping columns not easy i'd like. based on formattable documentation tried

result <- formattable(df, list(   area(col = c(n, a)) ~ comma(digits = 0),   area(col = c(ratea, deltaa)) ~ percent(digits = 2) )) 

but error. how group of columns want in comma format vs columns want in percent format? na value in "delta" column messing me up?


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -