How to use R-exams package to create a multi-part question? - r-exams

Suppose I had an exam question such as "A car starting from rest accelerates to 26.82 m/s in 3.2 s. Compute the acceleration during this time. How far did the car travel in this time?"
I'm new to R-exams package. In the past I've used MIT's "exam" LaTex package. There, I'd do something like:
\begin{question}
A car starting from rest accelerates to 26.82 m/s in 3.2 s.
\begin{parts}
\part Compute the acceleration during this time.
\part How far did the car travel in this time?
\end{parts}
I've poked around the r-exams.org but don't see any examples of creating such a multipart question.

For combining multiple questions in a single exercise you can use the "cloze" type: http://www.R-exams.org/intro/dynamic/. Some concrete examples are linked from there.
In your case, if you want to use R/LaTeX markup (.Rnw) in the exercise, the question would become:
\begin{question}
A car starting from rest accelerates to 26.82 m/s in 3.2 s.
\begin{answerlist}
\item Compute the acceleration during this time.
\item How far did the car travel in this time?
\end{answerlist}
\end{question}
The corresponding meta-information needs to include something like:
\extype{cloze}
\exclozetype{num|num}
\exsolution{8.38125|42.912}
R/Markdown (.Rmd) would, of course, be possible as well. And both are hopefully straightforward to turn into dynamic exercises where the numbers are sampled randomly. Let us know if you need further help with this.

Related

Format for adding references in R package DESCRIPTION?

I just submitted an R package to CRAN. I got this comment back:
If there are references describing the methods in your package, please add these in the description field of your DESCRIPTION file in the form
authors (year) <doi:...>
authors (year) <arXiv:...>
authors (year, ISBN:...)
or if those are not available: <https:...>
with no space after 'doi:', 'arXiv:', 'https:' and angle brackets for auto-linking.
(If you want to add a title as well please put it in quotes: "Title")
But I thought that the description field is limited to one paragraph, which means you can't include additional text besides the single paragraph in that field. So I was unsure what the exact formatting is for including references in the description field. My guess is below, but this format returns a note stating that the description is malformed.
Description: Text describing the package, blah blah blah.
More text goes here, etc etc etc.
Foo, B., and J. Baz. (1999) <doi:23232/xxxxx.00>
Smith, C. (2021) <https://something.etc/foo>
Note returned when running R CMD check:
checking DESCRIPTION meta-information ... NOTE
Malformed Description field: should contain one or more complete sentences.
This question is related but does not have a satisfactory answer so I am asking again.
I started with Julia Silge's blog post here:
cran <- tools::CRAN_package_db()
desc_with_doi <- grep("doi:", cran$Description, value = TRUE)
Here are some examples:
Given a protein multiple sequence alignment, it is daunting task to assess the effects of substitutions along sequence length. 'aaSEA' package is intended to help researchers to rapidly analyse property changes caused by single, multiple and correlated amino acid substitutions in proteins. Methods for identification of co-evolving positions from multiple sequence alignment are as described in : Pelé et al., (2017) <doi:10.4172/2379-1764.1000250>.
or
Estimate parameters of accumulated damage (load duration) models based on failure time data under a Bayesian framework, using Approximate Bayesian Computation (ABC). Assess long-term reliability under stochastic load profiles. Yang, Zidek, and Wong (2019) <doi:10.1080/00401706.2018.1512900>.
Using a similar filter for "https" shows (unsurprisingly) a lot more generic website links than scholarly references, but e.g.:
Designed for studies where animals tagged with acoustic tags are expected\n to move through receiver arrays. This package combines the advantages of automatic sorting and checking \n of animal movements with the possibility for user intervention on tags that deviate from expected \n behaviour. The three analysis functions (explore(), migration() and residency()) \n allow the users to analyse their data in a systematic way, making it easy to compare results from \n different studies.\n CJS calculations are based on Perry et al. (2012) <https://www.researchgate.net/publication/256443823_Using_mark-recapture_models_to_estimate_survival_from_telemetry_data>.
ArXiv (there are only 24 packages with such links out of 17962 total at present):
Provides functions for model fitting and selection of generalised hypergeometric ensembles of random graphs (gHypEG).\n To learn how to use it, check the vignettes for a quick tutorial.\n Please reference its use as Casiraghi, G., Nanumyan, V. (2019) doi:10.5281/zenodo.2555300\n together with those relevant references from the one listed below.\n The package is based on the research developed at the Chair of Systems Design, ETH Zurich.\n Casiraghi, G., Nanumyan, V., Scholtes, I., Schweitzer, F. (2016) <arXiv:1607.02441>.\n Casiraghi, G., Nanumyan, V., Scholtes, I., Schweitzer, F. (2017) <doi:10.1007/978-3-319-67256-4_11>.\n Casiraghi, G., (2017) <arxiv:1702.02048>\n Casiraghi, G., Nanumyan, V. (2018) <arXiv:1810.06495>.\n Brandenberger, L., Casiraghi, G., Nanumyan, V., Schweitzer, F. (2019) <doi:10.1145/3341161.3342926>\n Casiraghi, G. (2019) <doi:10.1007/s41109-019-0241-1>.

Randomized order of exercises in Canvas via R/exams

I use the R package exams to create quizzes that are administered through the learning management system Canvas. I would like to randomize the order of exercises. Suppose I have 2 exercises A and B. From each exercise we draw 100 realizations, 1, ..., 100. I would like to create exams consisting of one random A exercise and one random B exercise in random order, i.e., of the following form: {A(2), B(10)}, {B(20), A(60)}, etc.
I am aware that you can use R/exams to generate PDF exams in this form (see: Different orders of questions in exams2pdf() from R/exams). However, I cannot find how to do the same for Canvas using the exams2canvas() function.
At the moment this feature is not available in exams2canvas() and I'm not sure whether it can be implemented. (Should anyone reading this have insights about whether/how this could be achieved, please let me know.)
Conceptually, there is an important difference between those exams2xyz() interfaces that produce a single file per exam (notably, exams2pdf() and exams2nops()) and those that produce a collection for learning management systems (like exams2moodle(), exams2canvas(), exams2blackboard(), and exams2openolat()). The former assure that the 1st replication from A and B are together in one exam - and potentially their order can be randomized. Analogously, for the 2nd and 3rd replication, etc. In the exports for learning management systems this is not easily possible.
Instead, the exports for the different learning management systems produce one "pool" or "section" of 100 exercises for A, and another pool/section of 100 exercises for B. For each exam the learning management system then samples one exercise from the A pool/section and one exercise from the B pool/section. So far, this is what you are looking for.
However, additionally shuffling or randomizing the order of the sections is available in some learning management systems but (to the best of my knowledge) not in all. Notably, OpenOLAT based on the QTI 2.1 format has an option for this. But for systems based on QTI 1.2 (rather than 2.1) like Canvas I did not see any way of including this feature.

RadViz & survey/permutation matrix plots in R

I'm currently working on a brief presentation for a graduate class in multivariate data analysis. It's on methods of displaying multivariate data (for human comprehension), and of the six methods we're supposed to present on, I've taken on radial visualization plots (specifically the type referred to as "RadViz") and survey plots (which are a variety of permutation matrix visualization, or so I've been led to understand from my research). While I have been able to find sufficient resources on the uses of these visualization methods, as well as their benefits/drawbacks, I'm coming up with problems finding code to implement them in R.
I have located two user-written functions that will do survey plots and radial visualization in R. These appear to part of the package "dprep", which has since been discontinued from CRAN--and try as I might, I cannot seem to get it to install as a package when I download the older version from the archive. Additionally, all of this code is now six years and several versions out of data, and I am hesitant to recommend it to classmates if it may become completely unusable at some point.
I suppose what I'm asking is if there is any easier or cleaner way--possibly as part of an existing package--to implement these visualizations in R, or if my only option is using the above (very old) code to do it. I'm aware of solutions in other programming languages (Python) as well as other pieces of software (Orange, VisuLab), but since the class is primarily based around using R, I'd like to be able to present in it if I can.
Sounds like we need to teach you to search. The google pathway is always available but for R functionality it sometimes is not sufficiently specific if the topic name is commonly used for other concepts. I often pair the search term with 'rproject'
https://www.google.com/search?q=radviz&ie=utf-8&oe=utf-8#q=radviz+rproject
Brings up:
http://www.cs.uml.edu/~phoffman/Radviz/readme.txt # R interface to C-implementation
... as well as many others but it would take some effort to sort through to find R-specific implementation.
I have many successes using the findFn-function in the sos package:
install.packages("sos")
library(sos)
Originally I thought this was just the ordinary radar chart but seems it might be something different.
> findFn("Radial Coordinate Visualization")
found 12 matches; retrieving 1 page
Downloaded 4 links in 3 packages.
The search on Radviz only brings up a single item, radviz2d, whose help page links to a surveyplot function in the same package 'dprep'. The term 'radial' alone brought up a large number, possibly unmanageable:
> findFn("radial plots")
found 456 matches; retrieving 20 pages, 400 matches.
2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
Those terms deliver a somewhat more manageable number. Radar plots or spider plots are generally being used for discrete variables, but radial coordinate visualization appears to be a method of projecting multivariate associations on a two-dimensional domain. The 'circular' package also deals with display and statistics on continuous variables.
From the CRAN Archive I downloaded and unpackaed version 2.1 of radviz: dprep_2.1.tar.gz:
source('~/Downloads/dprep/R/radviz2d.R', chdir = TRUE)
mmnorm <-
function (data,minval=0,maxval=1)
{
d=dim(data)
c=class(data)
cnames=colnames(data)
classes=data[,d[2]]
data=data[,-d[2]]
minvect=apply(data,2,min)
maxvect=apply(data,2,max)
rangevect=maxvect-minvect
zdata=scale(data,center=minvect,scale=rangevect)
newminvect=rep(minval,d[2]-1)
newmaxvect=rep(maxval,d[2]-1)
newrangevect=newmaxvect-newminvect
zdata2=scale(zdata,center=FALSE,scale=(1/newrangevect))
zdata3=zdata2+newminvect
zdata3=cbind(zdata3,classes)
if (c=="data.frame") zdata3=as.data.frame(zdata3)
colnames(zdata3)=cnames
return(zdata3)
}
load("/Users/davidwinsemius/Downloads/dprep/data/my.iris.rda")
radviz2d(my.iris,"Iris")
The package also has several other functions including survey plot that are available in R, so they do not need to be compile. There is a compiled function in the package which I have not investigated.
I have released a new version of dprep. Edgar Acuna

process spot images R pa

I have a SPOT image (bands 1 to 4) in DN and I need to transform them to reflectance values. Does anyone know any package in R that can help with that?
Thank you all..
Nora
It would be interesting to know the application of SPOT images you are planning. Atmospheric and radiometric Correction may be unnecessary in a number of circumstances.
There is no specific package for dealing with SPOT image but you could adapt functions provided by landsat package.
There are good references dealing with SPOT application and raw DN transformation to accommodate atmospheric and radiometric corrections. I'd say that Song et al 2001 is a fundamental reading but see Clark dissertation.
You'll find the Spot reference tables, similar to those available for Landsat.
Let us know if you found a solution.

Random number analysis

Given a series of randomly generated data how can I figure out how random it actually is? Is R-lang a good tool for this matlab? What other questions can can these tools answer about randomly generated data? Is there another tool better for this?
The DieHarder test battery by Robert G. Brown --- which reimplements and extends the old DIEHARD by Marsaglia et al -- has been wrapped into the R package RDieHarder which you could start with.
Note that RDieHarder versions need their particular matching DieHarder releases -- and we're not there yet for the most recent development version of the latter.
Edit Also, for the subset of cryptographioic tests, the NIST suite (which is included in DieHarder) should be appropriate as that is what it was designed for.
First you need to decide what kind of randomness you're testing for. Do you have in mind a uniform distribution inside some range? That's usually what people have in mind, though you may have some other flavor of randomness such as a normal distribution.
Once you have a candidate distribution, you can test the goodness of fit to that distribution. The Kolmogorov-Smirnov test is a good general-purpose test. I believe it's called ks.test in R. But I also believe it assumes distinct values, so that could be a problem if you're sampling from such a small range of values that the same value appears more than once.
S. Lott mentioned Knuth's Seminumerical Algorithms in the comments. That book has a good introduction to the chi-squared test and the Kolmogorov-Smirnov tests for goodness of fit.
If you do suspect you have uniform random values, the DIEHARD test that Dirk Eddelbuettel mentioned is a standard test.
According to Wikipedia (Randomness):
The central idea is that a string of
bits is random if and only if it is
shorter than any computer program that
can produce that string (Kolmogorov
randomness) — this means that random
strings are those that cannot be
compressed.
Therefore, given the random stream of numbers, save it to a file, and compress it using your favorite tool (zip, rar, ...). The compression ratio can be interpreted as measure of randomness... Even better, I would use it as a relative score to compare the randomness of two data series.
I recommend reading Chapter 10 of Beautiful Testing: Testing a Random Number Generator. It's a little more approachable than most texts on the topic. Maybe, if we're nice, the author of that chapter, John Cook, might stop by and give his input.
There's as always a toolbox for it.
For theory, the above mentioned reference by Knuth is useful and to link Amro's response, there is work by Li & Vitanyi which relates here.
link text

Resources