Sorry typo -- lapply(1:n, function(x) cat(rep("*",x),"\n"))M On Fri, Apr 20, 2012 at 10:45 AM, R. Michael Weylandt <[email protected]> wrote: > R is in the broad family of functional languages -- if your student is > on board with the statistical capabilities of R, he might benefit from > looking at one of the classic tutorials for those while doing the > exercises in R. SICP is a classic, but the syntax doesn't match: maybe > the python version works > http://www-inst.eecs.berkeley.edu/~cs61a/sp12/book/index.html : > alternatively, think Python or think Complexity (both online) provide > another (less difficult) exposition. However, take these options with > a grain of salt: if your student learns R this way, he'll get some bad > R habits that will take a long time to break: I'd highly advise > against any solution that suggests he do the > > * > ** > *** > > puzzle with nested loops: performance in later programming assignments > will be terrible. Better to learn good habits now: lapply(1:n, > function(x) cat(rep("*", n), "\n") > > Alternatively, working through something like Project Euler in R will > require a little more self-starting, but might be more rewarding after > he masters the basics of syntax. (just what's given in a first read > through the standard intro to R document) > > Finally, Matloff's Art of R programming is probably exactly what > you're looking for, but isn't free. > > Hope this helps, (and my strong advice is options 2 or 3) > > Michael > > On Fri, Apr 20, 2012 at 10:05 AM, cgenolin <[email protected]> wrote: >> Thanks for your answer. >> >> Yes, it is quite different from what I am looking for which will be more >> something like : >> >> --- 8< ----- >> >> Exercice 1: wrote a function that compute the surface of a rectangle >> >> Exercice 2: wrote a function that compute factorial n (whithout using the >> function factorial) >> >> Exercice 3: wrote a function, that given a n, will draw a triangle of "*". >> Example with n=5 >> >> * >> ** >> *** >> **** >> ***** >> >> --- 8< ----- >> >> The first exemple is about writing a (very) simple function and returning >> the result ; the second >> need the use of a loop. The third will need two loops (for a beginer). >> >> And so on, on various topic. >> >> Christophe >> >>> Are you familiar with R Inferno? This is a programming-oriented >>> tutorial for R by the statistician Patric Burns. He has generously >>> placed it as a pdf online for free >>> (http://www.burns-stat.com/pages/Tutor/R_inferno.pdf [4]); you could >>> >>> also >>> purchase a copy. Of course this will be more than just a few practice >>> exercises (a lot more, and actually, I'm not sure there are any >>> exercises but you can certainly follow along with the examples). >>> Nonetheless, it may still be right up your alley. There are other >>> resources for learning the programming side of R, but only a few that >>> are as good, and none other free, so far as I know. If this is really >>> different from what you're looking for, you may want to reply with more >>> detail. >>> >>> Hope that helps. -Jeff >>> >>> On 4/20/2012 7:41 AM, cgenolin wrote: >>> >>>> Hi the list, I am looking for some exercices for a PhD student that >>>> start to learn R. He already "read" some tutorial, but now he needs >>>> some practice. He does *not* need to learn any statistical tools ; he >>>> just needs to work on programmation concept. So I am looking for some >>>> exercice sheet that will, for example, focus on : - structuring the >>>> data (data.frame / list / matrix / ...) - using controle syntax (for / >>>> if / while / function) - reading data - ... Any link for this kind of >>>> material? Sincerely Christophe [[alternative HTML version deleted]] >>>> _______________________________________________ >>>> [email protected] [1] mailing list >>>> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching [2] ----- No >>> >>> virus >>>> >>>> found in this message. Checked by AVG - www.avg.com [3] Version: >>>> >>>> 2012.0.1913 / Virus Database: 2411/4948 - Release Date: 04/20/12 >>> >>> >>> _______________________________________________ >>> [email protected] [5] mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching [6] >> >> >> >> >> Links: >> ------ >> [1] mailto:[email protected] >> [2] https://stat.ethz.ch/mailman/listinfo/r-sig-teaching >> [3] http://www.avg.com >> [4] http://www.burns-stat.com/pages/Tutor/R_inferno.pdf >> [5] mailto:[email protected] >> [6] https://stat.ethz.ch/mailman/listinfo/r-sig-teaching >> >> >> _______________________________________________ >> [email protected] mailing list >> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching _______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
