[R-sig-teaching] reversing the scoring of some columns
Robert Baer
rbaer at atsu.edu
Thu Mar 16 16:07:09 CET 2017
On 3/16/2017 9:04 AM, Nicholas Horton wrote:
> Joel Schwartz wrote:
>
> Cc: r-sig-teaching at r-project.org
> Subject: Re: [R-sig-teaching] Reverse the scoring of some Columns of a
> Data Set
> Message-ID: <05A396B0-2AD4-4AD1-A27A-A9F9730BFC59 at joelschwartz.com>
> Content-Type: text/plain; charset=utf-8
>
> If your data frame is called df then you can reverse the scoring by doing df$x1 = rev(df$x1).
>
> To do multiple columns, you can do:
>
> df[ , paste0(?x?,1:3)] = lapply(df[ , paste0(?x?,1:3)], rev)
>
>
> MY RESPONSE: Wow: that's a neat (but somewhat obfuscated) solution. I make R and R programming a component of my upper level stats courses, but it's hard for me to imagine teaching all of the idioms that are embedded within it. Are there cleaner ways to proceed? How can we prepare students to be able to undertake wrangling of this sort?
Of course, I share your concern as I'm sure do many others.
I have no quick answer, but what I've learned by doing this for a while
is to pick and choose the most important idioms, and repeat them over
and over in the context of class demo's with the students working along
with me. I frequently express my own awe that you can achieve such
things (even if it seems a bit incomprehensible - have fun with the
process of learning/teaching idioms!). The use of RStudio with its
"history tab" has revolutionized the ability of new students to take on
these idioms faster, because they can get a second look at the detailed
syntax as they did it during class.
Demo problems shouldn't be about R itself. In my case, I make the
problems relevant to my biomedical science students goals. The other
thing I typically do, is to store an "idiom containing" solution to a
sample problem in a common place (for example Blackboard or the network
fileserver) where students can find the idiomatic detail to copy from as
they solve their own problems.
Many of the students leave the course not QUITE ready to TEACH someone
else or to DO idiom-containing problems by themselves in the wild, but
I'm gratified by how much they remember as they start to work on
analyzing their own thesis data. Even the idioms come back quickly if
they were "learned" in a context of relevant, discipline-specific
problem solving.
I guess my answer is about as insightful as, "Monkey see; Monkey do".
Sorry about that...
>
> Just my $0.02,
>
> Nick
>
> _______________________________________________
> R-sig-teaching at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
--
--
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A T Still University of Health Sciences
800 W. Jefferson St
Kirksville, MO 63501
660-626-2321 Department
660-626-2965 FAX
More information about the R-sig-teaching
mailing list