Incremental nested lists in rmarkdown - r

I've been working in RMarkdown to make some slide sets, and have discovered odd behavior with respect to nested lists and mixing of list types. The following short presentation only works for slide 2. Nested lists are no longer nested and mixing incremental ordered and unordered lists fails entirely. I've tried this with a few different presentation formats, and it actually fails differently for different output types, which was surprising.
Thoughts?
---
title: "Attempt"
output: revealjs::revealjs_presentation
---
## Nested Incremental Lists
> * This
> + kinda works (but is not nested)
## Incremental Ordered Lists
> 1. This
> 2. works
## Broken - Nested mixed lists
> 1. This
> + Does not work

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.

Worked when I gave 2 tabs, so:
1. This
<tab><tab>+ Should work

I was having the same problem and found a solution that worked. When making nested lists without incremental reveal, you need to add four spaces for sub-bullets. When making lists with incremental reveal, you need to add one space after >. So, when making sub-bullets with incremental reveal, you need five spaces between > and - (one for the incremental syntax, and four for the nested list syntax).
So, a regular list with incremental reveal would look like this:
><space>- Point 1
><space>- Point 2
If you want to add sub-bullets, this will not work:
><space>- Point 1
><space><space><space><space>- Sub-bullet
><space>- Point 2
But this will work:
><space>- Point 1
><space><space><space><space><space>- Sub-bullet
><space>- Point 2
Hope this is helpful/readable!

As #Alex mentioned you have to give it 4 spaces. If you don't want to worry about this in the future you can set the tab preset to be 4 spaces. the solution will be
*something
<space><space><space><space>+ Other thing

Related

Unordered lists next to each other. First word of every list are in line

I want to put 4 lists next to each other where the first word of every list are inline with eachother. Not every list has the same amount of items.
I have not tried anything because i don't know what kind of elements i could use to fix this problem, sorry.

List Positioning in itextsharp 5

I didn't find a proper way to position things in itextsharp.
I want Intended lists:
But what actually I have is current list:
If I add another list it appends after the first one but not one the right of current. Is there a way to do this?
List li = new List(List.UNORDERED);
li.SetListSymbol("\u2022");
li.Add("Two");
li.Add("Three");
Well No one answered this query. I found the solution.
We can just have a table with 1 row and 2 columns. Each column will have a list inside. So table cells support the alignment of text. If someone still need help. Comment below

COUNTIF of non-empty and non-blank cells

In Google Sheets I want to count the number of cells in a range (C4:U4) that are non-empty and non-blank. Counting non-empty is easy with COUNTIF. The tricky issue seems to be that I want to treat cells with one or more blank as empty. (My users keep leaving blanks in cells which are not visible and I waste a lot of time cleaning them up.)
=COUNTIF(C4:U4,"<>") treats a cell with one or more blanks as non-empty and counts it. I've also tried =COUNTA(C4:U4) but that suffers from the same problem of counting cells with one or more blanks.
I found a solution in stackoverflow flagged as a solution by 95 people but it doesn't work for cells with blanks.
After much reading I have come up with a fancy formula:
=COUNTIF(FILTER(C4:U4,TRIM(C4:U4)>="-"),"<>")
The idea is that the TRIM removes leading and trailing blanks before FILTER tests the cell to be greater than or equal to a hyphen (the lowest order of printable characters I could find). The FILTER function then returns an array to the COUNTIF function which only contains non-empty and non-blank cells. COUNTIF then tests against "<>"
This works (or at least "seems" to work) but I was wondering if I've missed something really obvious. Surely the problem of hidden blanks is very common and has been around since the dawn of excel and google sheets. there must be a simpler way.
(My first question so apologies for any breaches of forum rules.)
I don't know about Google. But for Excel you could use this array formula for multiple contiguous columns:
=ROWS(A1:B10) * COLUMNS(A1:B10)-(COUNT(IF(ISERROR(CODE(A1:B10)),1,""))+COUNT(IF(CODE(A1:B10)=32,1,"")))
Could try this but I'm not at all sure about it
=SUMPRODUCT(--(trim((substitute(A2:A5,char(160),"")))<>""))
seems in Google Sheets that you've got to put char(160) to match a space entered into a cell?
Seems this is due to a non-breaking space and could possibly apply to Excel also - as explained here - the suggestion is that you could also pass it through the CLEAN function to eliminate invisible characters with codes in range 0-31.
I found another way to do it using:
=ARRAYFORMULA(SUM(IF(TRIM($C4:$U4)<>"",1,0)))
I'm still looking for a simpler way to do it if one is available.
This should work:
=countif(C4:U4,">""")
I found this solution here:
Is COUNTA counting blank (empty) cells in new Google spreadsheets?
Please let me know if it does.
=COLUMNS(C4:U4)-COUNTBLANK(C4:U4)
This will count how many cells are in your range (C4 to U4 = 19 cells), and subtract those that are truly "empty".
Blank spaces will not get counted by COUNTBLANK, despite its name, which should really be COUNTEMPTY.

Replacing a symbol in a .txt file

Alright, I've been given a program that requires me to take a .txt file of varying symbols in rows and columns that would look like this.
..........00
...0....0000
...000000000
0000.....000
............
..#########.
..#...#####.
......#####.
...00000....
and using command arguments to specify row and column, requires me to select a symbol and replace that symbol with an asterisk. The problem i have with this is that it then requires me to recur up, down, left, and right any of the same symbol and change those into an asterisk.
As i understand it, if i were to enter "1 2" into my argument list it would change the above text into.
**********00
***0....0000
***000000000
0000.....000
............
..#########.
..#...#####.
......#####.
...00000....
While selecting the specified character itself isn't a problem, how do i have any similar, adjacent symbols change and then the ones next to those. I have looked around but can't find any information and as my teacher has had a different subs for the last 3 weeks, i havent had a chance to clarify my questions with them. I've been told that recursion can be used, but my actual experience using recursion is limited. Any suggestions or links i can follow to get a better idea on what to do? Would it make sense to add a recursive method that takes the coordinates given adds and subtracts from the row and column respectively to check if the symbol is the same and repeats?
Load in char by char, row by row, into a 2D array of characters. That'll make it a lot easier to move up and down and left and right, all you need to do is move one of the array indexes.
You can also take advantage of recursion. Make a function that changes all adjacent matching characters, and then call that same function on all adjacent matching characters.

How to select all elements of a list at a particular nested Level?

Or put it differently: How can I use the [[ operator in a nested list?
You can consider this as a follow-up question on this one, when I asked how to determine the depth level of a list. I got some decent answers from #Spacedman and #flodel who both suggested recursive functions. Both solutions where quite similar and worked for me.
However I haven't figured out yet what to do with the information I get from these functions. Let's say I have a list nested at level i and I want to get back a list that contains all i-th level elements, like this:
myList$firstLevel$secondLevel$thirdLevel$fourthLevel
# fourthLevel contains 5 data.frames and thirdLevel has
# three elements
How can I get back all 15 data.frames from mylist?
I am trying to use e.g.
lapply(mylist,"[[",2)
but obviously I just get the second element of all list elements at the first level.
EDIT: I found the following in the help of extract respectivel ?"[[" but can't really wrap my head around it so far:
"[[ can be applied recursively to lists, so that if the single index i is a vector of length p, alist[[i]] is equivalent to alist[[i1]]...[[ip]] providing all but the final indexing results in a list."
EDIT:
Don't want to end up nesting loops like this.
o <- list()
i=1
for (i in 1:2){
o[[i]] <- mylist[[c(i,1,1,1)]]
}
I found the answer in the meantime. Can't say say I did it on my own. This
link gives an elaborate explanation how to use another (complex) recursive function to linearize the whole nested list wad.
What's really nice about the solution provided by Akhil S. Behl: it deals with the fact that data.frames are lists too and recursing can stop before data.frames. It turned out that this was one of my major problems before.

Resources