GithubHelp home page GithubHelp logo

wurmlab / sbc361-programming-in-r Goto Github PK

View Code? Open in Web Editor NEW
4.0 12.0 11.0 874 KB

QMUL's programming in R course

Home Page: https://wurmlab.github.io/SBC361-programming-in-R/practical1.html

CSS 54.57% R 37.65% HTML 5.86% Ruby 1.66% JavaScript 0.26%
practicals r programming educational-materials

sbc361-programming-in-r's Introduction

Programming in R

This is part of QMUL's year 3 SBC361 Research Methods and Communication II course.

There are generally 3 practicals:

  • Introduction to R and Regular expressions
  • functions and for loops
  • practice exercises

Put any public file in the "public" folder.

Practicals are now organised by year. Each year has a relevant README.

Contributors

Yannick Wurm, Rodrigo Pracana, Bruno Vieira, Bob Verity.

sbc361-programming-in-r's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sbc361-programming-in-r's Issues

Prac2: function with multiple arguments

Q3 (additional_hours) is confusing because it is asking from an arbitrary action (adding an arbitrary number of hours to the output of time_converter).

An alternative is to ask the students to create the reverse of time_converter:

hours_to_seconds <- function(hours, minutes, seconds) {
  total_ hours <- hours + minutes/60 + seconds/3600
  return(total_ hours)
}

We could also update the name of time_converter to something more descriptive (e.g. hours_minutes_seconds).

Question_31_32_Practical1 explanations

I have made some changes/suggestions to Question_31_32_Practical1.md in 930592a However some work is still needed. This includes:

  • please reorder so that "x" is first, then repl, then pattern (as the pattern is the only thing changing it should be easy to see that that is the only thing changing)
  • please test all of them (I wrote things from memory and so havnett tested any of them) - you may need to adjust so they work.
  • put the "two step" versions before the 1 step versions
  • when creating a temp variable, subsequently delete it
  • rewrite the last one without the confusing \w and \s. Better to be more specific. Similarly, don't use 'sub'. Finally, avoid "*" in favor of "+"

practical 1: Confusion between logical and regular expressions

"Q30. How many reptile names (genus or species) contain a lowercase "o" or an uppercase "E"?
Hint - you will have to combine your knowledge of regular expressions with your knowledge of logical expressions to answer this one!"

This could be asking students to use logical expression, although they have not been taught to use grepl:

grepl("o", x) | grepl("E", x)

On the other hand, this could be asking students to use regular expression "alternation", which the practical does not explain, and which in my mind differs from traditional logical expressions:

grep("(o|E)", x)  # Possibility 1
grep("[oE]", x)  # Possibility 2

practical1.md

A few things noticed today (i'm sure you will also have found things that should be addressed before friday):

  • When they are subsetting the puromycin table, the subset() approach is preferred. It should thus come before the confusing [,] approach
  • When calling a function such as subset, we should name the arguments, e.g. subset(x = puromycin_data, subset = conc < rate)

prac3

On 2017-Oct-23, at 20:19, Yannick Wurm [email protected] wrote:

"The second half of this session will be the exam"

"For example, ACCTAGGT is a palindromic DNA sequence as its complement is TGGATCCA." - not quite.
(we shouldn't use the word "as" in general because it is ambiguious)

http://wurmlab.github.io/SBC361-programming-in-R/ButterflySample.csv"
butterfly_ref_url <-
"http://wurmlab.github.io/SBC361-programming-in-R/ButterflyReference.csv"

--> better to do everything in lowercase with '_' delimiter

urveys in two locations (A and B

--> what are they?

ignore.case = T
--> TRUE

Exam Reminders....

You are allowed to use the internet and your class notes during the exam, but you are not allowed to use chat or forums to ask for answers and you are not allowed to copy off one another.
-> I think that they will not be allowed anything other than QMPlus.

header = T)

--> TRUE

Q8: They were already imported

I don't think we should mention if as it should be unnecesasry

@MartinezRuiz-Carlos

practical 2: need feedback on nested loop example

It is an example in Nested loop paragraph:

coffee_drinks <- c("latte", "cappuccino", "espresso", "flat white", "cortado")
coffee_places <- c("Infusion", "Ground", "Sugar Cube", "Foxcroft & Ginger", "Sweet")

for (the_drink in 1:length(coffee_drinks)) {
  for (the_place in 1:length(coffee_places)) {
    print(paste("I'd like a", coffee_drinks[the_drink], "from", coffee_places[the_place]))
  }
}

Does it represent what we wanted?

Practical 0

Broken formatting -
screen shot 2017-10-11 at 4 36 33 pm

Possibly incomplete example -
screen shot 2017-10-11 at 4 45 23 pm

Possibly confusing -
screen shot 2017-10-11 at 4 41 30 pm

practical 2 question 14

This question is quite difficult for someone who has just only learned what a for loop is. It is difficult to understand why you would need a nested for loop, and why you would need an extra index.

practical 2 and 3

Examples with matrices want to become data frames - because this allows subsetting by columns.

Practical 2 question 16

This question asks to generate the reverse complement of a sequence using "gsub". Using "gsub" is quite dangerous in this question. A better solution is to use "match", despite this not being the point of the exercise:

sequence <- "ATTACGACGCGATTCCCGGTTAATCGAATTCCCA"

# Complement of each nucleotide
dna_code               <- c("A","C","G","T")
complement_code <- c("T","G", "C","A")

# Complement of sequence
comp_seq <- complement_code[match(sequence, dna_code)]

# Reverse
rev_comp <- rev(rev_comp)

# paste together
rev_comp <- paste(rev_comp, collapse = "")

plot

of bank balance wants to replaced with ggplot
(just give example command)

prac 2

helianthus data is giving 404

Question Intro 4 in Practical 3

This questions needs to be changed or removed, as it is quite pointless and confusing. This needs to be done after the exam happens, the 2nd November 2018

Todos for 2017

  • "intro" is something they should already know. Name it practical0. Keep regex as practical1
  • @EmelineAurore identified a few places with issues. Please identify them more clearly here and/or directly resolve them BEFORE other assistants work through the practicals
  • put our css on it.
  • shift URLs to this year's verison

prac2 q1

  • "before evaluating" the R code -> "before testing"
  • q2 fields -> rows
  • q3: should be more complex.
  • delete "The general construct of a"
  • rename "my_first_function" to something relevant
  • (don't worry too much about the computation in the middle) -> (floor() is R's built-in function function for rounding down to the closest whole number)
  • "run it on the numbers 5, 50000, and 10000000 seconds" -> use relevant examples for testing (0, 3600, another)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.