Closed friendly closed 3 weeks ago
With the changes I just pushed, I think I'm now finished with the bordering code. I have to move it into R/latexMatrix.R
and document it, which I'll do soon.
I decided early-on not to propagate labels in matrix operations, but I'm not sure that's the right decision. I think that the rules should be reasonably clear, and it would be necessary to check for incompatible labels, which should be an error. Think, for example, of starting with a data matrix X
with variables as column names and cases as row names. Something like t(X) %*% X
would naturally have variable names for rows and columns. Similarly, cbind(A, B)
would make sense only if A
and B
had the same row names. Maybe there are cases where dim names would be ambiguous but I don't immediately see that. Whether this is worth the effort is another question.
I moved the matrix bordering code to R/latexMatrix.R
and added documentation and a couple of examples.
@friendly I don't see what you mean with border matricies and Eqn. Here's what I get with the latest commit:
W <- latexMatrix(rownames=c("\\alpha_1", "\\alpha_2", "\\alpha_m"),
colnames=c("\\beta_1", "\\beta_2", "\\beta_n"))
W |> Eqn()
Must be a holdover from an earlier version. I just wanted to make sure it was working.
I think this relates to the point I made yesterday that the changes to print.latexMatrix()
weren't yet in R/latexMatrix.R
; they are now.
BTW, I figured out a way to make the adjustments to cell and column-name spacing more flexible by introducing new optional arguments to print.latexMatrix()
that take their default values from a couple of new options()
. I'll upload that to GitHub shortly.
About propagating labels in matrix operations: I tried out matsum()
, called by +
, as a test case, and it was very simple to accommodate labels. See the new file dev/operations-with-names.R
for code and examples. In particular, I only had to add the following lines to matsum.latexMatrix()
:
dimnames <- dimnames(A)
for (M in matrices) {
matlib:::numericDimensions(M)
if (!isTRUE(all.equal(dimnames, dimnames(M)))){
stop("matrix dimension names don't match")
}
}
...
Dimnames(A) <- dimnames
Thoughts?
That does look simple. Should be easy for most of the other operators also, perhaps except for kronecker()
.
That has a make.dimnames
argument, for which the code in .kronecker
is
if (make.dimnames && !(is.null(dnx) && is.null(dny))) {
if (is.null(dnx))
dnx <- vector("list", length(dX))
else if (ld < 0L)
dnx <- c(dnx, vector("list", -ld))
tmp <- which(sapply(dnx, is.null))
dnx[tmp] <- lapply(tmp, function(i) rep.int("", dX[i]))
if (is.null(dny))
dny <- vector("list", length(dY))
else if (ld > 0)
dny <- c(dny, vector("list", ld))
tmp <- which(sapply(dny, is.null))
dny[tmp] <- lapply(tmp, function(i) rep.int("", dY[i]))
k <- length(dim(opobj))
dno <- vector("list", k)
for (i in 1L:k) {
tmp <- outer(dnx[[i]], dny[[i]], FUN = paste, sep = ":")
dno[[i]] <- as.vector(t(tmp))
}
dimnames(opobj) <- dno
}
@philchalmers For Eqn()
, does it make sense to have the default for preview
be controllable by an option, so the default would be
preview = getOption("preview")
In running multiple tests, I found I wanted to turn preview off on some occasions.
Setting preview
globally for testing purposes makes sense to me. I've added an option to do this though the slot is called 'previewEqn'
to match the 'quartoEqn'
form.
I'm moving the discussion of dimnames
and matrix operations to the issue "Bordering a matrix #63."
I'm not sure where we are on this issue, that of finishing our work to release a new version.
Is the bordermatrix topic done enough?
I did notice that our work on simplifying the matrix operators simplified the descriptions in the vignette, but please check this over to see if there is something I missed or something that could be added.
If we're nearly done, I can do the pre-release CRAN tests & preparation for submission
I'm not sure where we are on this issue, that of finishing our work to release a new version.
Is the bordermatrix topic done enough?
That's in the issue "Bordering a matrix," which I think has run its course.
I did notice that our work on simplifying the matrix operators simplified the descriptions in the vignette, but please check this over to see if there is something I missed or something that could be added.
If we're nearly done, I can do the pre-release CRAN tests & preparation for submission
I don't have anything else planned.
I have some small features to add, some of which have appeared in earlier issues, but nothing pressing that would prevent a CRAN release. Agreed that border matrix is flexible enough for PDF/HTMLs now.
I've added dev/Prepare_for_CRAN.R
, which provides more comprehensive pre-CRAN tests than I've used before.
One gotcha (@john-d-fox): What is the correct URL for this paper:
> urlchecker::url_check()
✖ Error: README.md:150:144 404: Not Found
* Fox & Friendly, [_Visualizing Simultaneous Linear Equations, Geometric Vectors, and Least-Squares Regression with the matlib Package for R_](https://socialsciences.mcmaster.ca/jfox/Papers/matlib-useR2016.pdf),
McMaster retired the social-sciences web server. There is no current URL for this paper. I do, of course, have a local copy on my computer (and in various backups). It's not a paper, BTW, but some slides for a conference presentation.
OK, thx. I'll remove that link
All pre-CRAN checks have passed, so I think this is good to go. But I'll wait til next week, in case there are any last minute thoughts.
Ran another devtools::check_win_devel()
and other checks and all still OK. I'm going to release this now.
I've added
dev/Prepare_for_CRAN.R
, which provides more comprehensive pre-CRAN tests than I've used before.One gotcha (@john-d-fox): What is the correct URL for this paper:
> urlchecker::url_check() ✖ Error: README.md:150:144 404: Not Found * Fox & Friendly, [_Visualizing Simultaneous Linear Equations, Geometric Vectors, and Least-Squares Regression with the matlib Package for R_](https://socialsciences.mcmaster.ca/jfox/Papers/matlib-useR2016.pdf),
I found this paper at: https://facsocsci.mcmaster.ca/jfox/Papers/matlib-useR2016.pdf Is this where your stuff now is?
I see that instead of removing the link to the presentation on the package, it was changed to https://facsocsci.mcmaster.ca/jfox/Papers/matlib-useR2016.pdf. I understand that McMaster intends to remove that website. It would be safer to copy the PDF to the GitHub archive and link it there.
OK, safer that way. I'll do that. BTW: There were some very nice examples there!
Added papers/matlib-useR-2016.pdf
to avoid bad URL
DONE!
With the near completion of our work on
latexMatrix()
and friends, I'm thinking it will soon be time to release this as v 1.0.0. To this end, I'll bump the current version to 0.9.95What tasks remain?
latex-equations.Rmd
vignette to illustrate bordered matrices & preview featureEqn()
pick up row/col labels? https://github.com/friendly/matlib/issues/63#issuecomment-2336399238Feel free to add to this list