Week 1: Background, Getting Started, and Nuts & Bolts
En esta seccin del curso, bsicamente fue la introduccin a la programacin en R. Durante esta parte se manejaron los temas ms basicos, tales como Instalar R en nuestro ordenador as como configuraciones bsicas necesarias para poder usar R. Despus de esto en el curso muestran un poco de la historia de R. Para finalizar esta parte del curso nos muestran como vamos a asignar variables con datos, a su vez estos pueden tomar distintos tipos de datos u objetos tales como matrices, vectores o datos logicos, esto con el fin de saber manipular y declarar las variables como ms nos sirva. Sin dejar atrs el hecho de que en esta parte del curso aprendimos a manera de introduccin como programarlos en R para usarlos con el fin que deseemos. Cabe destacar que al finalizar esta parte del curso tambien aprendimos a subconfigurar R o mejor dicho a manejar el tipo de datos con ciertos operadores para que nos sea fcil interactuar con el programa.
Quiz 1
Week 2: Programming with R
En la segunda semana de R aprendimos a declarar o mejor dicho a programar ciclos bsicos con estructuras que ya conocemos como ciclos if-else, while loops y for loops, esto se me hizo algo sencillo ya que en mi caso me fue muy parecido a programar en c++, sin dejar atrs que tambin vimos como crear funciones y algo que se considera importante: manejar tiempo y fechas en R. De igual manera algo que considero bastante importante en esta seccin del curso fue como utilizar y mandar a llamar la paquetera ya existente dentro del mismo R.
Quiz 2
Cdigo programado para Quiz 2
##Question 1 cube <- function(x, n) { x^3 } cube(3) > cube <- function(x, n) { + x^3 +} > cube(3) [1] 27 ##Question 2 x <- 1:10 if(x > 5) { x <- 0 } ##Question 3 f <- function(x) { g <- function(y) { y+z } ##Question4 x <- 5 y <- if(x < 3) { NA } else { 10 } ##Question 5 h <- function(x, y = NULL, d = 3L) { z <- cbind(x, d) if(!is.null(y)) z <- z + y else z <- z + f g <- x + y / z if(d == 3L) return(g) g <- g + 10 g
} z <- 4 x + g(x) }
Week 3: Loop Functions and Debugging
Quiz 3
Codigo programado para el Quiz 3
##Question 1 library(datasets) data(iris) #A description of the dataset can be found by running ?iris #There will be an object called 'iris' in your workspace. In this dataset, what is the mean of 'Sepal.Length' for the species virginica? (Please only enter the numeric result and nothing else.) mean(iris$Sepal.Length [iris$Species=="virginica"],na.rm=TRUE) ##Question 2 apply(iris[, 1:4], 2, mean) ##Question 3 library(datasets) data(mtcars) #There will be an object names 'mtcars' in your workspace. You can find some information about the dataset by running ?mtcars #How can one calculate the average miles per gallon (mpg) by number of cylinders in the car (cyl)? split(mtcars, mtcars$cyl) sapply(split(mtcars$mpg, mtcars$cyl), mean) #Question 4 tapply(mtcars$hp, mtcars$cyl, mean) 209.21429 - 82.63636 #Question 5 #If you run debug(ls)what happens when you next call the 'ls' function? Debug(ls)