I am trying to send a mail via mailr and it working fine. For sending a small table of 5 lines - I am using HTML format and it is working fine too.
I am using htmlTable package - the only disadvantage as of now is that I am not able to control the width of the column or the gap between the columns. Is there a possible way to control this.
I tried the kable and kableExtra package but the output is coming without any css formatting - a very plan HTML, however the Viewer in Rstudio is showing great but mail comes in without any formatting.
Even tried the formattable, it ok to somextent, but some CSS lookwise are getting removed in mailr - but is working for me, but lacks column size control here too.
Please advice on how to add column gaps/widths in htmlPackage or get the desired html formatting in mail using kable/kableExtra. or any knowledge sharing would be appreciated too.
You can use tableHTML for this (which is the package you tagged!!). As a small example, the argument widths controls the widths of the columns:
library(tableHTML)
mtcars[1:4, 1:5] %>%
tableHTML(widths = rep(100, 6))
You can pretty much add any kind of (other) CSS you want into the table by using the add_css_column function for columns (or any other add_css_ function for other parts of the table). There is a detailed explanation on the vignette.
Related
I would like to know if a DT::datatable output object's columns can be automatically adjusted inside a Shiny App? This seems like a very popular interface but I can't seem to do a simple manual column size adjustment, like the Rhandsontable, with the following call
hot_cols(manualColumnResize = TRUE)
If there is an option to do this via JavaScript I'll take that as well, as I've already search for how to do this with pure R syntax to no avail. Thanks.
Ok, I understand now, not from DT, but you could use {DataEditR} package instead.
I am new to R, and despite searching the forums I have been unable to find a solution to indenting code within both the Source window and Document Outline (Ctrl+Shift+O).
An example is shown below.
Ideally, I would want the code to function as below when pressing Alt+O
This function does seem to be implemented in some fashion as you get the indented code with functions but this is less than ideal.
# Section 1 -----------------------------------------------------------
function(x) {
# Section 1A ===========================================================
}
Has anyone found a work-around to implement this?
Not a fix but a workaround:
Any whitespace after a "." is included in the heading, so a "." followed by a tab or space can be used to create indented headers preceded by a ".".
# Section title ---------------------------------------------------------------
# . Subsection A --------------------------------------------------------------
# . . A.1 ---------------------------------------------------------------------
Would still be nice to see this implemented the way it is in R markdown, but in the mean time might make it easier to navigate scripts using sub-headers.
Screenshot of example script using dot-tab to indent headers
For what it's worth, this sort of nested indent is implemented for Markdown sections (for e.g. R Markdown documents), e.g.
However, this sort of nested is not implemented for sections in plain R scripts. You might consider filing this as a feature request for the RStudio team.
Thanks #Foztarz I posted this as an issue about a year ago on the GitHub. They claimed it was a worthy enhancement but they keep pushing it to the next version of RStudio lol. My work-around was similar. I used Alt codes to insert symbols I found a bit more visually appealing over .
# ▬ Section A ------
# ▐ ▬ Section A.1-----------
Here's what it looks like inside RStudio
Two additions:
Box-drawing characters look much better than the characters mentioned in https://stackoverflow.com/a/63812437/13776976 #Patricks answer
From RStudio 1.4 on, you can indicate sub-sections by additional '#' at the start of the line, see RStudio How To Article
I used skimr package for descriptive table. On using View() function it is showing a very-very long table, 600 rows.
Skimr was just released on CRAN and the new version has a functionskim_to_list and one skim_to_wide that give you the results in two different wide versions. Use these instead of skim() e.g. skim_to_wide(iris).
What you are seeing is the default skim object. Another option you have is to use dplyr or other approach to put the data into the format you want.
I'm new to making tables in R and using html. I have R on two different laptops, and when working on one of the computers, when I use htmlTable, xtable, etc, a table appears in the viewer on the ride side of RStudio. However, on the other computer, no table displays in the viewer but html code appears in the console. Is there another package I need to render the html? I'm not using Markdown or anything, I just want to see simple tables using htmlTable in the viewer instead of the code.
I'm not sure how to make this reproducible, so I'm hoping someone knows the answer. On the computer that shows the actual table in the viewer, all I do is load the htmlTable package, and it works.
What am I missing? Is it related to my computer's settings, version of RStudio, etc?
It was a bug. While I used
if(!code) htmltools::html_print(out_html) else out_html
as #hrbrmstr suggested in the comments, it seems the fix was among Changes for 1.10 so it is now (v. 1.11.1) possible to just
output <- matrix(1:4,ncol=2,
dimnames = list(list("Row 1", "Row 2"),
list("Column 1", "Column 2")))
print(htmlTable::htmlTable(output,useViewer=TRUE))
and I can simply use useViewer=!code in my wrapper functions. Note you can also do
print(htmlTable::htmlTable(output,useViewer=utils::browseURL))
as the documentation suggests.
This is my first time using R so this is about as basic of a question as they come.
I am making a presentation using markdown (ioslides). I want to do something very simple which is to put something in superscript. According to the manual, the syntax is the following:
Lower bound = α^Full – K^ - α^Full^
The first time I tried running this, I got a pop-up screen with some options. Too quickly, I pressed enter and inadvertently chose something. Now the syntax won't run and I can't figure out what I did to undo it.
Can someone help? Thank you in advance.
Markdown allows HTML to be used if necessary, so you should be able to use the HTML sup tag.