Color Cells in Rstudio - r

I have a dataframe that I've imported from a csv. In a free text section the following was included which caused the cell in Rstudio to highlight Red:
<P><FONT style="BACKGROUND-COLOR: #ff0000">SP#12. Notified 7/9. Ending 7/29.</FONT></P>
<P>boa bin 7-24-2014</P>
<P>This is an amendment to ALT252143. We are adding habitable basement square footage to Unit 1. </P>
<P><FONT style="BACKGROUND-COLOR: #ff0000">PAID NOMINAL FEE ONLY</FONT></P>
I know that the "BACKGROUND-COLOR: #ff0000"bit is what is causing this but I can't find exactly how to reproduce this. Any ideas? The class of the vector is character. I'm using the preview version of Rstudio, not sure if that will make a difference.

Related

How to wrap text automatically in a Mermaid flowchart node?

Is there a way to set a max width for text within a Mermaid flowchart node, such that it automatically wraps?
For example - how would I get the first graph to look like the second graph, without painstakingly inserting manual line breaks:
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.14.0/mermaid.min.js"></script>
<div class="mermaid">
flowchart TD
A{Is it Friday midday UTC?} -- Yes --> B(Check out Daft Punk's new single 'Get Lucky' if you have the chance. Sound of the summer.)
A -- No --> C(Never mind then)
</div>
<h2>Desired output</h2>
<div class="mermaid">
flowchart TD
A{Is it Friday</br>midday UTC?} -- Yes --> B(Check out Daft Punk's new single</br>'Get Lucky' if you have the chance.</br>Sound of the summer.)
A -- No --> C(Never mind then)
</div>
I have a suspicion the solution will be a single line of CSS but I don't know what it is.

Folding selected text

I like that in Atom text editor, you can hide code blocks to get a better overview. This is called Folding and is described here. There it says:
Finally, you can fold arbitrary sections of your code or text by making a selection and then typing Alt+Ctrl+F or choosing "Fold Selection" in the Command Palette.
I would like to make use of this, but it doesn't work for me. (I select a section of my code, then press the combination Alt+Ctrl+F, but nothing happens.) My operating system is Linux Mint 20.2 and the Atom version is 1.58.0.
I am looking for a fix or for a different method to fold selected text.
My use-case right now would be to fold Python docstrings. So if someone knows how to accomplish only that in Atom, you would also help me.
Although I did not find out why the hotkey doesn't work, I found a solution that fits my needs. The Atom package custom-folds adds the functionality to define regions that may be folded.
After installing custom-folds, I added the lines #<editor-folds and #</editor-fold> at the beginning and end of the docstring, respectively:
def average(a, b):
#<editor-fold
"""
Return the mean value of inputs a and b
"""
#</editor-fold>
return (a+b)/2
The commands #<editor-fold and #</editor-fold> are recognized and highlighted; also, a dropdown arrow appears where the code region can be folded or unfolded.

What's with the odd font used by spammers? How do they do it?

The screenshot below is from my Gmail spam folder. Notice that some of the email from and subject lines look normal, while many of them appear to use some sort of serif font:
I'm a web developer, and from poking around, there's no CSS font declarations that are causing this to happen. The only hint is that the inspection panel for the "ZippyLoan ." sender shows that the fonts being used are not just Google's typical Roboto, but also "Cambria Math" (despite there being no corresponding "Cambria Math" CSS font declaration):
In fact, it seems that the font definition is somehow built-in to the text, since it even maintains the same appearance in plain-Jane Windows Notepad:
Actually, here, I think it works anywhere... play around with it yourself it you'd like:
𝒁𝒊𝒑𝒑𝒚𝑳𝒐𝒂𝒏 .
𝗜𝗻𝘁𝗿𝗼𝗱𝘂𝗰𝗶𝗻𝗴 𝗟𝗔𝗦𝗜𝗞 𝘀𝘁𝗮𝗿𝘁𝗶𝗻𝗴 𝗮𝘁 $𝟮𝟮𝟬 𝗽𝗲𝗿 𝗲𝘆𝗲!
❤️𝑾𝒆𝒍𝒄𝒐𝒎𝒆 𝒕𝒐 𝒂 𝑪𝒐𝒖𝒓𝒕𝒆𝒔𝒚 $50 𝑪𝑽𝑺/𝒑𝒉𝒂𝒓𝒎𝒂𝒄𝒚® 𝒄𝒉𝒂𝒓𝒈𝒆 𝒄𝒂𝒓𝒅 (𝒀𝒐𝒖𝒓 𝒑𝒓𝒆𝒇𝒆𝒓𝒓𝒆𝒅 𝒄𝒖𝒔𝒕𝒐𝒎𝒆𝒓 𝒏𝒖𝒎𝒃𝒆𝒓 𝒘𝒂𝒔 𝒔𝒆𝒍𝒆𝒄𝒕𝒆𝒅)
Whiskey Tango Foxtrot. O.o
It's not a different font - it's the same font, just using odd code points. For example, the 𝒁 in 𝒁𝒊𝒑𝒑𝒚𝑳𝒐𝒂𝒏 has a code point of 119937:
console.log('𝒁'.codePointAt());
which corresponds to:
𝒁 mathematical bold italic capital z 0352201 119937 0x1D481 𝒁
There are many such odd code points that can be used. It's not ASCII.
In contrast, the standard capital Z has a code point of 90:
console.log('Z'.charCodeAt());

Atom Hydrogen: How is "run cell" used?

How is the "run cell" syntax in Hydrogen for Atom used? I placed multiple
# %%
tags throughout my code following the official manual here, but when I press Shift+Enter in between any two of the tags, it still only executes that line, not the entire cell block. I also tried the other syntax formats the manual describes, but none of them execute the whole cell.
A-C-enter hydrogen:run-cell
A-S-enter hydrogen:run-cell-and-move-down
https://github.com/nteract/hydrogen/issues/304

XPath to extract text after br tags in R

How to extract text after the br tags in the following lines:
<div id='population'>
The Snow Leopard Survival Strategy (McCarthy <em>et al.</em> 2003, Table
II) compiled national snow leopard population estimates, updating the work
of Fox (1994). Many of the estimates are acknowledged to be rough and out
of date, but the total estimated population is 4,080-6,590, as follows:<br>
<br>
Afghanistan: 100-200?<br>
Bhutan: 100-200?<br>
China: 2,000-2,500<br>
India: 200-600<br>
Kazakhstan: 180-200<br>
Kyrgyzstan: 150-500<br>
Mongolia: 500-1,000<br>
Nepal: 300-500<br>
Pakistan: 200-420<br>
Russia: 150-200<br>
Tajikistan: 180-220<br>
Uzbekistan: 20-50
</div>
I got as far as:
xpathSApply(h, '//div[#id="population"]', xmlValue)
but I'm stuck now...
It helps if you realize text is a node too. All text in the div than follows <br/>'s can be retrieved by:
//div[#id="population"]/text()[preceding-sibling::br]
Technically, between <br/> tags would mean:
//div[#id="population"]/text()[preceding-sibling::br and following-sibling::br]
... but I guess that's not what you want at this point.

Resources