In hyperSpec.Rmd faux_cell is repeatedly overwritten
In the course of working on #223 I noticed that chondro is repeatedly overwritten as the vignette progresses. Wouldn't it be better to assign the result to something like chondro.tmp <- to avoid modifying the modifications repeatedly? I'm a little surprised it behaves well.
I saw similar issues in several vignettes. It seemed a bit vulnerable, as some modifications in code may create mismatches between the results of code and narration. In some places mismatches were already present.
I think we may distinguish the flow of the data analysis ("narration") from "side notes" about solving thematically related issues that are however, not following the central line of the narration.
- Along the flow of the data analysis, IMHO the object should be overwritten. After all, that's usual and it is what variables are for: containing values that change over the course of a program.
This would refer to the vignettes that give data analysis examples, i.e. chondro, laser, flu.
For vignette hyperSpec part of the secret for behaving is that
- at least at some points the modified
chondroobject is deleted, so we move back to the version provided by the package.
Here, replacing by a temporary copy would be good. - some changes redo the preprocessing in vignette chondro and are needed for later parts.
But you are right: this is likely confusing for readers.
I'm thinking that we may want to further break the vignette into parts: keep vignette hyperSpec focused on a description of how hyperSpec objects behave and have separate vignettes for "spectroscopic tasks", e.g. correcting the wavelength axis (and we anyways already have the topic "baseline correction")
I may not have been completely clear. We have code that looks like this in the vignette:
chondro <- modify(chondro) # 1
...
chondro <- modify(chondro) # 2
...
chondro <- modify(chondro) # 3
My point is that only # 1 is using chondro, the others use an increasingly modifed chondro. If a user is interested in the line marked # 2 and executes it (and just it, nothing that comes before it) on their own local machine, they will not get the same result as seen in the vignette. This could be alleviated by assigning the result to chondro2 or chondro.tmp or anything. Just have to be careful in a particular section if chondro.tmp is then plotted or further processed we need to plot(chondro.tmp) etc.
@cbeleites By "narration" I meant "text that describes plots and other results produced by R code".
For workflow demonstration vignettes, I agree, that this is acceptable. But for vignettes, that demonstrate separate pieces of functionality, this does not seem convenient. Because if code in one section changes, it affects everything bellow.
@bryanhanson Does it seem that this behavior could result in some issues in hyperSpec.Rmd when functions are removed from hyperSpec to other packages?
or
chondro.tmp
On code style: I'd prefer using dots only in the function names of S3 methods and using underscores instead of dots in all other object names in the examples/vignettes. (E.g., → chondro_tmp).
I updated the title of this issue as chondro is replaced by faux_cell in the vignette.