logo
down
shadow

Table format and output in R


Table format and output in R

By : user2955055
Date : November 22 2020, 10:33 AM
it helps some times Can anyone give me any hints on how to output this table in R (link)? for example, how to bold the first line, add a dotted line , and make a double title for the table. I prefer R markdown, rft is also OK , I am trying to avoid Latex . Thank you so much!! , Here is one way using the htmlTable package
code :
install.packages('devtools')
devtools::install_github('gforge/htmlTable')
out <- 
  structure(c("37(34%)", "1 (Ref)", "1 (Ref)", "1 (Ref)", "1 (Ref)", 
              "1 (Ref)", "45(23%)", "0.68 (0.63, 0.73)", "0.38 (0.32, 0.44)", 
              "0.21 (0.17, 0.28)", "0.08 (0.05, 0.13)", "0.05 (0.02, 0.11)", 
              "", "0.03", "0.04", "0.03", "0.02", "0.02", "110(34%)", "0.68 (0.65, 0.71)", 
              "0.38 (0.34, 0.42)", "0.21 (0.18, 0.25)", "0.08 (0.06, 0.11)", 
              "0.05 (0.03, 0.08)", "", "0.03", "0.04", "0.03", "0.02", "0.02"
  ), 
  .Dim = c(6L, 5L), 
  .Dimnames = list(NULL, c("r", "hr", "p", "hr", "p")))

## format rows/cols
colnames(out) <- c('(n = ***)','HR (92% CI)','P','HR (92% CI)','P')
rownames(out) <- c('PD No (%)','None','Age','Age (<60 vs > 60)',
                   '&emsp;Age > 60','&emsp;Age < 60')

## add padding row called subset
out <- rbind(out[1:4, ], 'Subsets:' = '', out[5:6, ])

## bolding rownames
rownames(out) <- sprintf('<b>%s</b>', rownames(out))

## table column headers (with line breaks (<br />))
cgroup <- c('', 'R + C<br />(n = ***)', 'R + S<br />(n = ***)')

# zzz <- `rownames<-`(out, NULL)

library(htmlTable)
htmlTable(out, rowlabel = 'Adjustment<sup>&dagger;</sup>', 
          ctable = TRUE, align = 'ccccc',
          ## number of columns that each cgroup label spans:
          n.cgroup = c(1, 2, 2), cgroup = cgroup,
          ## insert two table spanning sections:
          tspanner = c('',''),  # no labels
          n.tspanner = c(4, 3), # number of rows to span (must sum to nrow(out))
#           css.tspanner.sep = "border-bottom: 1px dotted grey;",
          caption = "Table 1: Hazard ratios and <i>p</i> values of two models and
                     something something.", 
          tfoot = '<font size=1><sup>&dagger;</sup>Some note.</font>')


Share : facebook icon twitter icon
format powershell output to like table format

format powershell output to like table format


By : ALI MIRZA
Date : March 29 2020, 07:55 AM
Any of those help Hard to even start helping, because current code simply won't work... ($spListItem is... what? foreach uses $item, can we assume you are using it?). Also: we have very little to no information about type of this items, it looks like some dictionary object... Anyway, I would try:
code :
$items | ForEach-Object {
    # assume $items is array of dictionary objects...
    New-Object PSObject -Property $_
} | Format-Table ID, Name, Department, Telephone
Format the output of a hash table in Powershell to output to one line

Format the output of a hash table in Powershell to output to one line


By : Tien Nguyen
Date : March 29 2020, 07:55 AM
I wish this help you You can iterate over the keys of a hash table, and then in the loop lookup the values. By using the pipeline you don't need an intermediate collection:
code :
($hashErr.Keys | foreach { "$_ $($hashErr[$_])" }) -join "|"
How to get table format output with sql query for a given table

How to get table format output with sql query for a given table


By : Adeoye Fatai-puma
Date : March 29 2020, 07:55 AM
Hope this helps Can you please help me to get the query to get the below output table? , Here is the answer -
code :
select * 
from
(
select S,T,C as Cd
from  Data
) as src
pivot(
Sum(Cd)--Max gives the same output too.
For T in ([a],[b],[c],[d])
) as pvt
Format output file from a bash script into HTML table format

Format output file from a bash script into HTML table format


By : Sai Dantu
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I have a script that gets data from multiple sources and I want to format its output to HTML table format.
code :
$ awk 'BEGIN{print "Envirnoment  BackEndVersion DBVersion  EventName  Status  Schema" } NF==1{env=$0; t=1; next;} t==1{t++; be=$3; next;} t==2{t++; db=$3; next;} t==3{printf "%s %s %s %s\n", env, be, db, $0; env="#";be="#";db="#";}' <input_file | column -t | tr '#' ' '

Envirnoment      BackEndVersion  DBVersion  EventName  Status    Schema
grid-dev         6.0             10         swap       DISABLED  dev_1
                                            busy       DISABLED  dev_1
grid-test        7.0             11         swap       ENABLED   test_1
                                            busy       ENABLED   test_1
grid-staging     6.0             10         swap       DISABLED  staging_1
                                            busy       DISABLED  staging_1
grid-production  5.0             9          swap       ENABLED   prod
                                            busy       ENABLES   prod
JSON output different from the output of format table

JSON output different from the output of format table


By : EggceptionDev
Date : March 29 2020, 07:55 AM
With these it helps The solution to this problem is by using Select-Object instead of Format-Table
code :
Get-Process | Group-Object -Property ProcessName |
    Select-Object Name, @{n='Mem';
        e={(($_.Group|Measure-Object WorkingSet -Sum).Sum / 1KB)}} |
    ConvertTo-Json
Related Posts Related Posts :
  • get first entries in rows of list?
  • Conditionally removing rows from a matrix in R
  • Using a loop to find P(-1.5<Y<1.5) for a range of sample sizes
  • R-Count and list the maximum count row by row
  • Include Iverson Bracket in R documentation
  • update a data frame and environment in R
  • How to write dynamic cumulative multiple in R
  • format time using as.POSIX in R
  • Change the class of multiple columns
  • Remove period and spaces within column headings nested in a list of data frames
  • R: error message --- package error: "functionName" not resolved from current namespace
  • labels with geom_text ggplot2
  • Passing mongodb ISODate in R
  • Importing "csv" file with multiple-character separator to R?
  • Change row names of a table obtained from a lm regression using xtable function
  • R language iterate over R object
  • How do you delete the header in a dataframe?
  • Re coding in R using complicated statement
  • accumulating functions and closures in R
  • How do you combine two columns into a new column in a dataframe made of two or more different csv files?
  • Twitter authentication fails
  • Summing Values of One Vector Conditional on Values of Another Vector
  • draw cube into 3D scatterplot in RGL
  • lme4 translate formula to code in 3-level model
  • How to draw single axis plot in R
  • Combine geom_tile() and facet_grid/facet_wrap and remove space between tiles (ggplot2)
  • Use snpStats with R version 3.0.1
  • Makefile gives strange error while compiling markdown file into .docx file
  • How to determine whether a points lies in an ellipse
  • Summarize data already grouped in r
  • Is the bigvis package for R not available for R version 3.0.1?
  • Operator overloading in R reference classes
  • How to enable user to switch between ggplot2 and gVis graphs in R Shiny?
  • Is there an easy way to separate categorical vs continuous variables into two dataset in R
  • Correct previous year by id within R
  • Installation of rdyncall package for R
  • ggplot2 plot that evaluates the percentage and mean of a third variable at intersecting points
  • Error Handling with Lapply
  • data.table - split multiple columns
  • How to compute the overall mean for several files in R?
  • R: Graph Plotting: Subscripts in the legend like LaTeX
  • Restructuring data in R
  • Distance of pointsfrom cluster centers after K means clustering
  • R incorrect value of date function
  • Package "Imports" not loading in R development package
  • r - run a user defined function several times by taking column elements as parameters
  • Create input$selection to subset data AND radiobuttons to choose plot type in Shiny
  • Generate crosstabulations from dataframe of categorical variables in survey
  • Restructure output of R summary function
  • New behavior in data.table? .N / something with `by` (calculate proportion)
  • search certain number vector in R
  • R version doesn't support quartz graphic device - RStudio won't plot
  • Referencing a function parameter in R
  • How to synchronize signals using a cross-correlation and FFT in R?
  • Plotting coefficients and corresponding confidence intervals
  • passing expressions to curve() within a function
  • More effective merging of matched column with duplicates in data.table
  • Easy way to export multiple data.frame to multiple Excel worksheets
  • R Foreach Iterator - Walkforward
  • Restructuring data and duplicating rows in R
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org