[R] odd behavior of numeric()
Why does: > numeric(0.2*25) return [1] 0 0 0 0 0 but > numeric((1-0.8)*25) returns [1] 0 0 0 0 [running version 3.2.0] [Apologies if this has been asked before - it's a hard question to find specific search terms for] Thanks, Scott __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Symbolic equations to R code?
Ista, On the one hand I'd like it to be as flexible as possible so the students could really come up with whatever they like. On the other hand, restricting their choices probably would make it easier to do the backend. The goal would be to get them to realize that the apparatus of hypothesis testing (when done via simulation/randomization techniques) doesn't depend on what the statistic is. The flow of steps is the same whether the statistic is a mean, variance, or their own kooky thing. Obviously this isn't the end of the story - what the statistic is actually describing is also a crucial component to interpreting the results of a hypothesis test, but I think it teaches an important pedagogical point about where statistics come from and that if they find themselves in a situation in the future where they need to make up their own, then that is perfectly okay. So they could make up ones like: arctan( (max({x})^2)/ (min({x})^2) )-3), max({x})-min({x}), sum from i to n of (x_i - 25th%ile({x}) )^3) [that might be tricky to write in a standard equation editor] none of these is hard to write in R, but translating from an equation editor might be. Perhaps the best solution is (as Alan suggests below) to write a Shiny function builder myself so that I can control the whole process and make sure that they can't enter anything that would break the backend. Or to have them learn the rudiments of writing equations in R so that it bypasses the whole process. Thanks, Scott On 11/19/14 1:52 PM, Ista Zahn wrote: Hi Scott, Can you give a couple of examples of the equations you have in mind along with how those should be translated to R? Thanks, Ista __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Symbolic equations to R code?
David, Thanks for your reply and suggestions of packages - let me clarify what I am looking for: The web editor you pointed out is the sort of equation editor I'm looking for and I had seen others like this.Let's say I use that one (step 1) and then have Latex code (step 2). Step (3) would be converting the Latex into an R function automatically. That's the key package. In searching for Latex and R there seem to be lots of ways to embed R code into Latex but not to translate Latex into R. As far as R commander, I do indeed know about that and am not looking for an R GUI for my students. They are not going be learning R in the class. As far as I know, R commander can't do steps 1-3, but please let me know if I am wrong. After students use the interface in step (1), the software in steps (2) and (3) would be for my benefit, to programmatically translate the equations of 150+ students into R code. Thanks, Scott __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Symbolic equations to R code?
I'm looking for a package that would take a mathematical function written in symbolic notation and convert it into R code. What I have in mind would be something like the following: 1) Have a GUI (e.g. something like Microsoft Word equation editor, but computer readable) to produce an equation so that it would look just like it would if you were writing it on paper 2) Have some way to translate the GUI into some markup language (perhaps this would be in a non-R application) 3) Have code that translates the markup into an R function. My motivation is that I teach an intro stats class that uses randomization techniques. I would like for the students to be able to make up their own statistics and then simulate null distributions or estimate bootstrap confidence intervals using them. I'd prefer to make it as easy as possible for them to enter the formula for their statistics into the computer, and I think that will be easier if it looks from their end just like it would if they were writing it on paper. After they submit the equation, I would have an RStudio shiny applet take care of the rest. Any suggestions for R packages that could do this or pieces of it would be very much appreciated. Thanks, Scott __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.