Incremental nested lists in rmarkdown
Try inserting four leading spaces. From the documentation (emphasis mine):
The four-space rule
A list item may contain multiple paragraphs and other block-level content. However, subsequent paragraphs must be preceded by a blank line and indented four spaces or a tab. The list will look better if the first paragraph is aligned with the rest:
The inconsistency to do with number of tabs may be due to how many spaces are inserted by default by Rstudio.
R Markdown Bullet List with Multiple Levels
For each sub-level instead of one tab, include two:
* unordered list
+ sub-item 1
+ sub-item 2
- sub-sub-item 1
Output:
nested ordered lists in rmarkdown
Cf. the next section of the documentation (my emphasis):
Pandoc also pays attention to the type of list marker used, and to the starting number, and both of these are preserved where possible in the output format.
To get the output you want (all new list should begin at 1.), disable the startnum
extension (source):
---
output:
html_document:
md_extensions: -startnum
---
Incremental sub-bullets in RMarkdown and Beamer
This problem is solved by updating pandoc
. This works using pandoc 2.1.3
I updated my pandoc
at the Terminal with brew install pandoc
, which threw an error suggesting I run brew link --overwrite pandoc
. I did so, and my pandoc version was updated. I recompile the .Rmd
file and the first two but fails to nest cases increment and nest.
How to create an automatic nested list and sub-lists with letters and/or Roman numerals in R-markdown?
Luckily, I have found the answer to my question in another R-Markdown cheatsheet. The point is to put 4 spaces or 2 indents before the sub-list items and 8 spaces or 4 indents before the sub-sub-list items. The following is my code in R-Markdown:
1. What geoms would you use to draw the followings?
a. A line chart
i. `geom_bar()`
i. `geom_line()`
a. A boxplot
i. `geom_boxplot()`
i. box
a. A histogram: `geom_histogram()`
a. An area chart: `geom_area()`
The output is like this:
1. What geoms would you use to draw the followings?
a. A line chart
i. `geom_bar()`
ii. `geom_line()`
b. A boxplot
iii. `geom_boxplot()`
iv. box
c. A histogram: `geom_histogram()`
d. An area chart: `geom_area()`
Creating lists and sub items in R markdown not working any longer?
For everyone that has problems showing simple list, markdown need an Empty line
before a list.
This will not work
* Item 1
* Item 2
* Item 3
The output will look something like this.
This will not work
* Item 1
* Item 2
* Item 3
To fix this;INSERT EMPTY LINE HERE, BEFORE LIST.
* Item 1
* Item 2
* Item 3
should output like this
- Item 1
- Item 2
- Item 3
Processing nested lists in nested for loop
output_sublist
for i = 1
is
#[[1]]
#[1] "a"
#[[2]]
#[1] "b"
For i = 2
, since we don't clear output_sublist
it replaces only the first value and second value remains as it is.
#[[1]]
#[1] "a" "b"
#[[2]]
#[1] "b"
You need to clear output_sublist
after each iteration of i
.
for (i in 1:length(input_variables)) {
output_sublist <- list() #Added a line here to clear output_sublist
input_combination_list[[i]] <- combn(input_variables, i, simplify = FALSE)
for(j in 1:length(input_combination_list[[i]])) {
input_combination_list[[i]][[j]]
output_sublist[[j]] <- input_combination_list[[i]][[j]]
}
output_biglist[[i]] <- output_sublist
}
output_biglist
#[[1]]
#[[1]][[1]]
#[1] "a"
#[[1]][[2]]
#[1] "b"
#[[2]]
#[[2]][[1]]
#[1] "a" "b"
However, as mentioned in the comments we can do this with lapply
as well
lapply(seq_along(input_variables), function(x)
combn(input_variables, x, simplify = FALSE))
#[[1]]
#[[1]][[1]]
#[1] "a"
#[[1]][[2]]
#[1] "b"
#[[2]]
#[[2]][[1]]
#[1] "a" "b"
Related Topics
How to Run a Job Array in R Using the Rscript Command from the Command Line
What Is the "Embracing Operator" '{{ }}'
Ggplot2: How to Reduce Space Between Narrow Width Bars, After Coord_Flip, and Panel Border
Pass String as Name of Attached Data Column Name
How to Get Covariance Matrix for Random Effects (Blups/Conditional Modes) from Lme4
Apply a Function to All Variables Starting with Specific Pattern in R
Numbered Code Chunks in Rmarkdown
How to Bookmark and Restore Dynamically Added Modules
Calculating Prediction Accuracy of a Tree Using Rpart's Predict Method
Let Each Plot in Facet_Grid Have Its Own Y-Axis Value
How to Flatten R Data Frame That Contains Lists
Unzip Password Protected Zip Files in R
Rmarkdown Table with Cells That Have Two Values