minisciencegirl / studyGroup

http://minisciencegirl.github.io/studyGroup/
Other
43 stars 20 forks source link

Writing your own R packages and objects #14

Closed jstaf closed 9 years ago

jstaf commented 9 years ago

I figured it might be helpful to go over R's control statements/functions, how to create/build/distribute a package, and creating/using custom object types with R's S4 system (better type safety than S3, harder to misuse...).

Some of this is rather advanced stuff, but I've found that writing packages is often a better approach to some projects than writing scripts. Not sure if we can get through this all in one tutorial, but we'll see I guess...

ksamuk commented 9 years ago

This sounds like a great idea, I would be very interested in this!

bkatiemills commented 9 years ago

Don't be afraid to split it into a couple of sessions if need be - it sounds awesome, I am totes in if I am in town!

MaxLev commented 9 years ago

That's an awesome idea Jeff! I don't think it would be possible to cover everything within a single session though; 2-3 sessions sounds more reasonable. I could help you out with the S4 system if needed but probably not before June. People interested in writing their own packages might also be interested into formal automated testing. Hadley Wickham has written the very neat package testthat for that specific purpose.

jkbooth commented 9 years ago

I would be very interested in this too.

minisciencegirl commented 9 years ago

Great idea Jeff! In addition to running it over a couple of instructional sessions, we can also schedule some "work alongs” too if it helps.

On Apr 27, 2015, at 1:53 PM, Bill Mills notifications@github.com wrote:

Don't be afraid to split it into a couple of sessions if need be - it sounds awesome, I am totes in if I am in town!

— Reply to this email directly or view it on GitHub.

jstaf commented 9 years ago

Hah, yeah help with teaching the S4 system could be good. It looks like we're mostly scheduled until June anyways, so waiting until then should work I think.

jstaf commented 9 years ago

Okay I was thinking about doing this on Thursday July 2nd @ 3pm (leaving for a conference soon... that's probably the soonest I'll have time). I also wanted to avoid Canada Day, because I'm betting a lot of people may take the day off.

Here's what I think I will cover:

Although this seems like a lot of stuff, it's actually quite quick to demo and explain. This tutorial should make it much easier to understand the source code for other people's packages you may be using (unless they include C/C++/Java components... need to learn those languages to understand those bits).

bkatiemills commented 9 years ago

hooray! Sounds awesome, looking forward to it!

jstaf commented 9 years ago

Okay, so the lesson is at 3pm tomorrow in Biodiv 224. We are all going to try writing a basic package together! After this lesson you will be able to share/reuse/document your code more easily, and understand how R works a little bit more.

Make sure you have the devtools, roxygen2, knitr, and testthat package (obtainable via install.packages(c("devtools","roxygen2", "testthat", "knitr"))).

Additionally, Mac and Windows users need to follow the instructions listed here in order to be able to build packages from source.

radaniba commented 9 years ago

@BillMills any plans to shift these sessions a bit later during the day ? this is interesting but its hard to commute during working hours :(

@kazi11 any testing suite in R like in python (I don't know any) if yes it could be great to integrate these before wrapping a package no ?

jstaf commented 9 years ago

I'll add testing in using the testthat package. I've updated my above comment to reflect some packages I forgot.

jstaf commented 9 years ago

Here is the link to a demo package that we will re-create tomorrow.

minisciencegirl commented 9 years ago

Hi @radaniba: @BillMills and I have been talking about starting another round of #R lessons and building up the #R Utility Belt (see Issues #29). This session will hopefully start after the software carpentry workshop for the LSI folks. What would be a good time for you? The other option is to start something for BCCA. Do you want to shoot me an email at amy.lee@ubc.ca and we can chat more about this?

minisciencegirl commented 9 years ago

Link to Hadley Wickham's R package book: http://r-pkgs.had.co.nz/

radaniba commented 9 years ago

:+1: This is also useful if Continuous Integration will be discussed http://docs.travis-ci.com/user/languages/r/

@minisciencegirl teams at BCCA are independant of each others, we need an approach that brings people together and I see VanBug as the best way to start things here. I can help by spreading the word, gathering people through internal messaging, but there is a protocol I guess for organizing events here, we can work on this together if you want

jstaf commented 9 years ago

We did not end up making it to the S4 system given time constraints, but perhaps we can cover that later (it mostly comes in useful when you need a new data type for a special function or something). Anyhow, thanks all for coming, and remember to check out the demo package here if you didn't understand something or would like to cover this at your own pace.

Also, we determined at the tutorial that the RStudio Release Preview is definitely the way to go for doing stuff in R. The code checking/extra hotkeys/roxygen2 support, make life much, much easier for pretty much any project.

Anyhow, thanks for coming out and I'll close this thread.