it's the first time I've used the model.matrix command on R. I'm posting the code from an example found in a book:
model.matrix(~., data)
I don't understand what ~. is.
Looking on the internet I saw that the first argument would be "an object of an appropriate class" but I don't understand what ~. is.
The dot means all columns in your data.frame not otherwise mentioned.
Running a few examples with the iris dataset shows this pretty well.
You could forgo the
.syntax and spell it out. I think this is a better approach since in this case a reader does not need to know what the columns inirisare. You can just tell what our model will include. It also has the side effect of preventing you from including something accidentally.Another resource on making these model matrices that I have used is this article: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7873980/. It's specific for RNA seq, but the model matrices can be used for any similar style of comparison/model.