Re: [R-sig-teaching] Using R in an introductory stats course for non-stat/math majors using Lock5 text

2019-12-03 Thread Randall Pruim
plots), randomization tests, bootstrapping, and run t-tests, chi-square, ANOVA, and regression. I tried using RStudio, but it is still overkill for what I want my students to be able to do. They don't need an IDE. Randall Pruim has kindly made a PDF for using R with Lock5, but that is too much

Re: [R-sig-teaching] Need help to understand the code

2019-06-14 Thread Randall Pruim
Perhaps the original question was only the syntax question about how if() statements work. That has been answered. (But I’ll add a note that omitting { } in this situation is a good way to introduce bugs over time, so I generally avoid doing that.) But in case the question is motivated by the

Re: [R-sig-teaching] R for introductory epidemiology for MPH students--base or with a package or two?

2018-07-02 Thread Randall Pruim
Christopher, It sounds to me like you are the right track to answering your own question. There are certainly packages that make some things much easier (like the tidyverse suite you mention), and in the end you will need to match what you choose to your audience and your goals. So my take

Re: [R-sig-teaching] A second try...

2018-02-20 Thread Randall Pruim
Are you familiar with the learnr package for creating tutorials? That might do much of what you want. Also, checkr (by Danny Kaplan) is in development and will provide a way for you to check work and give feedback. —rjp > On Feb 20, 2018, at 9:40 PM, BRET R LARGET

Re: [R-sig-teaching] Graph Two Series over Time

2015-12-24 Thread Randall Pruim
Steve, This is on the edge of what R-sig-teaching is for (since it isn’t really about teaching). But since I think there are elements of what you are doing that lead students to think that R is terrible, I’ll show you how I might approach things. First a few comments about my solution. 1) I

Re: [R-sig-teaching] subsetting data with the median position

2015-12-22 Thread Randall Pruim
The issue of ties probably has no answer that is best in all situations. Here’s what mosaic::ntiles() does: > x <- c(2,4,8,9,11,11,11,12,15) > rbind(x, ntiles(x, 2)) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] x2489 11 11 11 12 15 111112

Re: [R-sig-teaching] Choice of graphics package

2015-11-28 Thread Randall Pruim
e all this gets called, and with which arguments, I don’t know whether this matters or not. —rjp On Nov 28, 2015, at 1:35 PM, Ista Zahn <istaz...@gmail.com<mailto:istaz...@gmail.com>> wrote: On Nov 28, 2015 12:56 PM, "Randall Pruim" <rpr...@calvin.edu<mailto:r

Re: [R-sig-teaching] count the number of argument of a function

2015-10-20 Thread Randall Pruim
A couple more questions for you: * what type of object do you want created? (A matrix? data frame? something else?) * is there a reason to have 3 named arguments and then … if you are treating them all the same in the end anyway? Seems like that just makes your function less flexible

Re: [R-sig-teaching] count the number of argument of a function

2015-10-20 Thread Randall Pruim
I think perhaps it would be useful if you tipped your hand a bit more about what you are actually trying to do with your function, but I think that this does the immediate task for functions that have … in the argument list. foo <- function(x=1, y=2, z=3, ...) { m <- length(formals()) +

Re: [R-sig-teaching] Read *.xlsx data file into R

2015-09-23 Thread Randall Pruim
Try readxl I’ve found that that package works very well. > On Sep 23, 2015, at 10:02 AM, Steven Stoline wrote: > > Dear All: > > I am having trouble reading an *.xlsx data file into R. > > I tried to install the packages XLSX and readx1, but still did not work. > > Any

Re: [R-sig-teaching] Read *.xlsx data file into R

2015-09-23 Thread Randall Pruim
But be warned that depending on the kinds of data you have, exporting to CSV and then reading in the CSV may or may not give you exactly what you are expecting. So it is safer to use a tool designed to read excel files directly if (a) you can make it work and (b) the tool you are using is good

Re: [R-sig-teaching] introducing R to high school students

2012-04-18 Thread Randall Pruim
A few thoughts. You can do what you want with them. 1) Use R formulas. If you lattice graphics, then lm() and plots have essentially the same syntax and you can make nice connections between the graphs and the analyses. For example, bwplot( weightLoss ~ diet ) or xyplot (weightLoss ~

Re: [R-sig-teaching] Shading the solution of quadratic inequality

2012-02-16 Thread Randall Pruim
I'm not sure exactly what sort of plot was desired, but I'll offer 1.5 possibilities. Currently you can do something like this: require(mosaic) plotFun( x^2 - 4 ~ x , xlim=c(-6,6), col='blue' ) plotFun( (x^2 - 4)/as.numeric(x^2 -4 0) ~ x , xlim=c(-6,-2), add=TRUE, col='blue', lwd=4 ) It

Re: [R-sig-teaching] Shading the solution of quadratic inequality

2012-02-16 Thread Randall Pruim
The xlim=c(-6,-2) is extraneous in the code below. It snuck in from something else I was doing. It doesn't hurt any, but it doesn't do anything either since the plotting limits are inferred from the surrounding plot when add=TRUE is used. On Feb 16, 2012, at 10:07 AM, Randall Pruim

Re: [R-sig-teaching] Example(s) of Biomodal distributions

2012-01-15 Thread Randall Pruim
I recently wrote a function for the mosaic package that makes it easy to generate various kinds of plots of distributions. For example, to plot a Binom(30,.35) distribution, you just use: distPlot(binom,params=list(size=30, prob=.35)) and get the attached plot (if it makes it through to

Re: [R-sig-teaching] Example(s) of Biomodal distributions

2012-01-15 Thread Randall Pruim
I have modified the distPlot() function in the mosaic package so that the following makes the desired plot (as a density histogram): distPlot( binom, params=list(35,.25), groups= y dbinom(qbinom(0.05, 35, .25), 35,.25), kind='hist') The groups argument is used to get the desired shading of

Re: [R-sig-teaching] Plotting the p-value

2011-07-09 Thread Randall Pruim
I just joined this list, and I see in the archives that there have been several answers to this already, but I'll add another one: install.packages(mosaic) example(xpnorm) xpnorm() is a function that behaves much like pnorm() but provides more verbose output and a plot to go with the