R tools gageRR response input not clear - r

I am interested in using the gageRR function in one of my projects offered by r tools.
In the following code:
gdo = gageRRDesign(3,10, 2, randomize = FALSE)
y = c(23,22,22,22,22,25,23,22,23,22,20,22,22,22,24,25,27,28,23,24,23,24,24,22,
22,22,24,23,22,24,20,20,25,24,22,24,21,20,21,22,21,22,21,21,24,27,25,27,
23,22,25,23,23,22,22,23,25,21,24,23)
response(gdo) = y
gdo = gageRR(gdo, tolerance = 5)
summary(gdo)
plot(gdo)
How should i organize my data to input to y? There seems to be no explanation for this online.
Ps sorry for not giving proper code format for the code as this option is not available on stackoverflow on my phone.

Related

Changing STARTS for mplusModeler in R

I'm trying to up the number of starting values in Mplus when I pass objects through the program using the mplusModeler package in R, specifically the mplusObject function. Is there a way to specify the number of starts (e.g., 100 10) instead of the defaults? Or is this something I can only do in Mplus and there's no way to do this from R?
I figured it out!
You add the command to the ANALYSIS section of the input. For example:
lpa_model <- mplusObject(
TITLE = "3-Class LPA;",
VARIABLE = "USEVARIABLES = x01-x15;
CLASSES=c(3);",
ANALYSIS = "ESTIMATOR = MLR;
TYPE = MIXTURE;
STARTS=100 10;",
MODEL = " [code continues...]

How to add answer specific feedback to dist3.Rmd?

I'm looking at the dist3.Rmd example template from here: http://www.R-exams.org/templates/dist3/. The solution markdown is the general feedback provided after submission. I want to create feedback.
Solution
========
The distance $d$ of $p$ and $q$ is given by
$d^2 = (p_1 - q_1)^2 + (p_2 - q_2)^2$ (Pythagorean formula).
Hence $d = \sqrt{(p_1 - q_1)^2 + (p_2 - q_2)^2} =
\sqrt{(`r p[1]` - `r q[1]`)^2 + (`r p[2]` - `r q[2]`)^2}
= `r round(sol, digits = 3)`$.
\
```{r distplot, echo = FALSE, results = "hide", fig.path = "", fig.cap = ""}
par(mar = c(4, 4, 1, 1))
plot(0, type = "n", xlim = c(0, 6), ylim = c(0, 6), xlab = "x", ylab = "y")
grid(col = "slategray")
points(rbind(p, q), pch = 19)
text(rbind(p, q), c("p", "q"), pos = c(2, 4))
lines(rbind(p, q))
lines(c(p[1], p[1], q[1]), c(p[2], q[2], q[2]), lty = 2)
```
If the answer choice is correct, I'd like the general feedback to popup and if the answer is wrong, I'd like for the pythagorean formula and the image prompt to show up but not the calculation. How can I accomplish this?
Given your jargon about "general feedback" I assume this is related to Moodle and the exams2moodle() interface in R/exams.
I tried to find out whether the feature you describe can be specified using Moodle XML format but was not successful. So at the moment this is certainly not possible in R/exams and I'm not sure whether it would be possible in Moodle XML. If anyone is aware of a solution in Moodle XML, I would be interested and could check whether it would be possible to add this to exams2moodle().
Update: Following the discussion in the comments with #ArvindMurali I briefly discuss here how it is possible to include images in the specific feedback from the "solution list". However, I still don't see how to separate specific and general feedback between different iterations of answering the question.
If you make a copy of dist3.Rmd to, say, dist4.Rmd you just need to modify two lines. In the options for the r distplot code chunk in line 35, add fig.show = "hide". And in the r solutionlist chunk in line 46 replace the answerlist(...) command with:
answerlist(ifelse(sc$solutions,
"This is correct!",
"This is not correct, please consider: <br/> ![](distplot-1.png)"),
markup = "markdown")
For preparing this for Moodle you then need to use pluginfile = FALSE so that the image is really embedded directly into the specific feedback (rather than via Moodle's plugin file declaration).
set.seed(1)
exams2moodle("dist4.Rmd", pluginfile = FALSE)
Then, the specific feedback for each incorrect item will display the plot from the r distplot chunk.
The formatting is not great but it works - so far so good.
The problem is that in addition to this specific feedback, the general feedback will also be displayed at the end - always, as far as I can see. If there were a way to delay this in Moodle, then I could check whether it is possible to interface this in R/exams.

How to implement sample_ and sbm() functions in the newer versions of igraph in R?

I have a line of code that used to work perfectly:
sbm_2 <- sample_(sbm(n = 200,pref.matrix = diag(0.2, 2) + 0.2, block.sizes = c(100, 100)),vertex_attr("true_block" ,rep(1:2, each = 100)) )
However, ever since igraph updated itself, this coding hasn't been working anymore and I am really not sure how to reconstruct it according to the new rules. The sbm function above is a stochastic block model with a sample_ function on the outside. Does anyone have any ideas how to convert the above so that it works in igraph again?

Why can't the pdf file created by gage (a R packge) be opened

I am trying to use Gage package implemented in R to analyze my RNA-seq data. I followed the tutorial and got my data.kegg.p file and I used the following script to generate the heatmap for the top gene set
for (gs in rownames(data.kegg.p$greater)[1]) {
outname = gsub(" |:|/", "_", substr(gs, 10, 100))
geneData(genes = kegg.gs[[gs]], exprs = essData, ref = 1,
samp = 2, outname = outname, txt = T, heatmap = T,
Colv = F, Rowv = F, dendrogram = "none", limit = 3, scatterplot = T)
}
I did get a pdf file named "NOD-like_receptor_signaling_pathway.geneData.heatmap.pdf", but when I open this file with acrobat reader or photoshop, it gives the error information that this file has been disrupted and cannot be recovered. Could anyone help check this file (https://www.dropbox.com/s/wrsml6n1pbrztnm/NOD-like_receptor_signaling_pathway.geneData.heatmap.pdf?dl=0) to see whether it is really disrupted and is it possible to find a way to recover it?
I also attached the R workspace file (https://www.dropbox.com/s/6n5m9x5hyk38ff1/A549.RData?dl=0). The object "a4" is the data with the format ready for gage analysis. It contains the data of the reference sample (nc) the treated sample (a549). It can be accepted by gage for analysis but generate the heatmap pdf file which cannot be opened (above). Would you mind helping me check whether these data can be properly used to generated the correct gage result?
Best regards.
I'm running into a similar problem myself. Not 100% sure but I think this problem occurs when there is no heatmap to plot. In my case, I was doing as.group comparison with ref and sample selections. I think the software treats this circumstance as a sample n of 1 and can't really show a differential heatmap. When I tried using 1ongroup setting, I was able to visualize the pdf file.

How can I extract values from graph in R?

As you know, Our country is famous for the popular music industry, named "K-POP".
Recently, the 'tuneR' package to analyze 'wav.file' was released in R.
So I want to know any tendency of the K-POP musics and cluster them by using this package.
In analysis, I got a graph to show the notes of a music file (see example below)
My problem is that I don't know how can I extract the peak value's notes from this graph (those circled in blue)
Please let me know some methods if you know any functions to resolve this problem in R.
library("tuneR")
transcribeMusic <- function(wavFile, widthSample = 4096, expNotes = NULL)
{
perioWav <- periodogram(wavFile, width = widthSample)
freqWav <- FF(perioWav)
noteWav <- noteFromFF(freqWav)
melodyplot(perioWav, observed = noteWav, expected = expNotes, plotenergy = FALSE)
}
songHlp <- readMP3("Beenzino.mp3")
testSound_stereo <- extractWave(songHlp, from = 0, to = 12, xunit = "time")
testSound <- mono(testSound_stereo, "both")
transcribeMusic(testSound)

Resources