Skip to content

Instantly share code, notes, and snippets.

View pjastam's full-sized avatar
💭
Reading The Effect by @NickCH-K

Piet Stam pjastam

💭
Reading The Effect by @NickCH-K
View GitHub Profile
@pjastam
pjastam / README.md
Last active June 18, 2023 10:02
Quarto line endings bug on Windows

Quarto line endings bug on Windows

For cross-platform projects, the recommended setting of Git on Windows is "Checkout Windows-style, commit Unix-style line endings". This means that Git will convert LF to CRLF when checking out text files from a remote repository to your local repository. When committing text files, CRLF will be converted to LF.

However, as freezing files in Quarto is done before the commit, the hashes of the freezed files in the _freeze folder in on Windows are based on the files with CRLF line endings and based on the files with LF line endings on Unix. The consequence is different hashes although the source files are identical. This bug is therefore called: same source different hashes in _freeze/ files from different OS machines #3599.

In my workflow I use RStudio as an IDE on Windows. Therefore, I suffered from this bug too, as I describe in the issue [GitHub Actions fails b/o missing rmarkdown package #5870](https://github

@pjastam
pjastam / README.md
Last active April 16, 2023 08:51
Sum of squares for partitions

Sum of squares for partitions

I wrote R code to define an example dataset with an outcome variable y and two variables x, where x1 defines some partition of the dataset and x2 defines defines some other partition of the dataset. For each partition, I want to calculate the sum of squares of y for all segments of this partition and sum them up to arrive at the total sum of squares (TSS) for that partition.

For each combination of variables x, the original dataset contains multiple observations per unique combination of the variables x. Also, an aggregated dataset is created such that the mean of the outcome variable and number of original observations is calculated for each unique combination of variables x. We compare the results of these two datasets.

I first wrote a function that calculates the TSS for the x1 partition and the TSS for the x2 partition. Then I asked ChatGPT to extend this function for more than two partitions. And it did more than that: it also fixed some errors, introduced some by its

# Source: https://stats.stackexchange.com/questions/494421/how-do-we-visualize-the-decomposition-of-variance-formula-textvary-text
# Parameterization of regression coefficients by Piet Stam, 15-4-2023
# Set parameters
set.seed(12345)
nsim = 100
X = runif(nsim, 40,120)
const = 1
coef.Mean = 0.3
coef.SD = 0.15
@pjastam
pjastam / Regression-Analysis-of-Aggregate-Data-in-R.markdown
Last active April 2, 2023 18:30
Regression Analysis of Aggregate Data in R

Regression Analysis of Aggregate Data in R

These files are a supplement to my blog post about using R for vertical aggregation in data analysis.

@pjastam
pjastam / easy-customizable-css-arrow.markdown
Created September 5, 2022 21:40
Easy customizable CSS arrow

Easy customizable CSS arrow

My use case for this CSS is to have a big arrow at the background of a reveal.js slideshow like so. See all the credits in the Credits section, most notably the pen by @LukyVj gave me a head start.

A Pen by Piet Stam on CodePen.

License.

Verifying that "pjastam.id" is my Blockstack ID. https://explorer.blockstack.org/name/pjastam.id