## Question Authors' Forum

### Programming statistics in R

Programming statistics in R

If not then how much work would this be to add?

Thanks,

Chris

Re: Programming statistics in R

I asked about this and we did a very little investigation about a year ago but then I ran out of free time and got distracted ...  We started by looking at a basic R install to see what configuration options would be useful.  I do remember noting down the --silent option.  There did seem to be potential for creating some resources that our stats students who need to use R but are not programmers could use to at least start finding their feet with it.

Jenny

Re: Programming statistics in R

Just to give you a bit of background to Jenny's answer ...

When Jenny raised the question of R a year or two ago, my first response was that it would be trivial to ask R questions of the simple "write-an-R-function" or "write-an-R-program" variety. I installed R-base on our Jobe server (5 mins work) and we used a Python3 question (with R as the Ace language) to run R. That was easy enough. Here's a possible template:

import subprocess
r_prog = """{{ STUDENT_ANSWER | e('py') }}"""
r_prog += "\n" + """{{TEST.testcode | e('py')}}"""
with open('prog.r', 'w') as fout:
fout.write(r_prog)

cmd = "R --slave --vanilla"
subprocess.call(cmd.split(), stdin=open('prog.r'), universal_newlines=True)


With that question type you can ask questions like the following:

However, as I recall that wasn't the sort of question that Jenny thought the stats lecturers would want to ask their students, who aren't really programmers. So then you get into the much harder issue of "What sort of question to you really want to ask?".

Richard

Re: Programming statistics in R

Thank you both for such swift and helpful replies.

I'm very reassured that CodeRunner can, at least at a technical level, accept R code.  I'm not sure exactly what my colleagues have in mind. We will be running on a server which also has my own STACK question type installed (https://github.com/maths/moodle-qtype_stack) and I think a combination of the normal Moodle questions, STACK and CodeRunner will be an interesting combination of tasks for students which combine mathematical and programming elements.

The 10^6\$ question is always "What sort of question to you really want to ask?".  I'll talk with colleagues about that one...

Chris