stata2r / stata2r.github.io

Stata -> R guide
https://stata2r.github.io
88 stars 19 forks source link

Add note to bottom of section #6

Closed grantmcdermott closed 2 years ago

grantmcdermott commented 2 years ago

@kylebutts is there a way to add a (short) text block below a section? This would be useful for adding some additional context or qualifying text. E.g. In the current collapse section we don't use na.rm=TRUE anywhere because it's not necessary. But I can imagine this tripping up some Stata users in RL, so a short note would be helpful.

EDIT: Obvs doesn't have to be at the bottom. Just looking for some way to add text that isn't a header (maybe italics?) and lives outside of the two-column code chunks.

kylebutts commented 2 years ago

Yeah, you can make a notes.txt file similar to commands.txt like this:

data_cleaning
cat_id
text to include...

And I'll make it work in the helpers.R file

grantmcdermott commented 2 years ago

great, thanks

grantmcdermott commented 2 years ago

Hmmm. I don't seem to be able to get this working. Do you mind pushing an example using this text for the collapse section.

Note: In R, any missing (i.e. "NA") values will propagate during aggregating functions. If you have NA values in your real-life dataset — we don't in this example dataset — you probably want to add , na.rm=TRUE to remove these on the fly. E.g. mean(var1, na.rm=TRUE) or lapply(.SD, mean, na.rm=TRUE).

kylebutts commented 2 years ago

It shouldn't work, I haven't written any code to extract those and place them in the correct spot in the HTML code :-) But put the notes there and they will be included after that!