[R] R programming

John Kane jrkrideau at inbox.com
Sat May 23 16:15:06 CEST 2015


Read R-help. :) Seriously, you will see all kinds of problems and questions. Some of the simpler ones you can try yourself and see how your approach matches other peoples. 

Google around for some R blogs and see if you find any that are useful. https://learnr.wordpress.com/ might be useful. IIRC there is a mixture of real intro and very sophisticated material there.

Think of something simple exercise or analysis that you would normally do in Matlab or even in a spreadsheet and see how easily you can translate this to R. If needed think more of what you would expect students in first year to be doing if you are a TA and duplicate it in R. 

A great intro to R, in my opinion is Dan Navarro's book (available as a pdf at my last look) but I suspect from your point of view not so good as he is a psychologist and is writing for them. http://health.adelaide.edu.au/psychology/ccs/docs/lsr/lsr-0.3.pdf

With your educational background An Introduction to R may be a good read but, as a non-techie, my normal advise is not to read it right away. It is a fantastic reference and repays reading after a few weeks into R but it is IMHO emphatically NOT an introduction in the same way that the Navarro book is. (I am now changing my name and entering a witness protection program).

Learn as much as possible about the various basic data structures in R.  As someone said use str() a lot.  Here is an example why. Just copy and paste:
dat1  <- structure(list(aa = structure(1:10, .Label = c("1", "2", "3", 
"4", "5", "6", "7", "8", "9", "10"), class = "factor"), bb = c(10L, 
9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L)), .Names = c("aa", "bb"), row.names = c(NA, 
-10L), class = "data.frame")

dat2  <-  structure(list(aa = 1:10, bb = c(10L, 9L, 8L, 7L, 6L, 5L, 4L, 
3L, 2L, 1L)), .Names = c("aa", "bb"), row.names = c(NA, -10L), class = "data.frame")

dat1
dat2  # looks a lot like dat1 :)


with(dat1, aa*bb)
with(dat2 , aa*bb)

str(dat1)
str(dat2)


BTW dat1 and dat2 are in dput() format which is the preferred way to supply data to the R-help list.  It provides a perfect copy of the data as it sits on your machine and avoids little problems like we see in dat1 vs dat2 if other readers are loading data on their machines.

If the course has not already recommended this, get a good dedicatd R text editor or IDE.  Everyone has their own, but some popular ones seem to be Tinn-R, EMACS, RStudio, and there are many others.

John Kane
Kingston ON Canada

PS: Don't post in HTML. it mangles code.


> -----Original Message-----
> From: varun1220 at gmail.com
> Sent: Fri, 22 May 2015 19:01:12 -0400
> To: r-help at r-project.org
> Subject: [R] R programming
> 
> Hello there,
> 
> I wanted to learn R programming over this summer hence I registered for
> the
> R programming course on Coursera. I understood most part of the lecture
> but
> I'm having a hard time with the assignments.
> 
> Till now I can write small functions such as calculating mean of a vector
> or an array. I can also use arguments such as lapply, sapply, rbind etc.
> 
> I am not very handy with coding in R. I get completely stuck.
> 
> What should I do to learn gradually?
> 
> Can anyone tell me what to do step by step. I'm an average student
> pursuing
> my masters in Engineering Management at UNC Charlotte.
> 
> 	[[alternative HTML version deleted]]
>

____________________________________________________________
Publish your photos in seconds for FREE
TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if4



More information about the R-help mailing list