Coursera-Johns Jopkins R Programming
-
Upload
carlos-andres-flores-urtecho -
Category
Documents
-
view
20 -
download
1
description
Transcript of Coursera-Johns Jopkins R Programming
![Page 1: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/1.jpg)
Curso R-Coursera
Johns Jopkins University
14 DE MARZO DE 2016
![Page 2: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/2.jpg)
Week 1: Background, Getting Started, and Nuts & BoltsEn esta sección del curso, básicamente fue la introducción a la programación en R. Durante esta
parte se manejaron los temas más basicos, tales como Instalar R en nuestro ordenador así como
configuraciones básicas necesarias para poder usar R. Después 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 más nos sirva. Sin dejar atrás el
hecho de que en esta parte del curso aprendimos a manera de introducción 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 fácil interactuar con el
programa.
Quiz 1
![Page 3: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/3.jpg)
![Page 4: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/4.jpg)
![Page 5: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/5.jpg)
![Page 6: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/6.jpg)
![Page 7: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/7.jpg)
Week 2: Programming with REn la segunda semana de R aprendimos a declarar o mejor dicho a programar ciclos básicos 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 atrás que también
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 sección del curso fue como utilizar y
mandar a llamar la “paquetería” ya existente dentro del mismo R.
Quiz 2
![Page 8: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/8.jpg)
![Page 9: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/9.jpg)
![Page 10: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/10.jpg)
Código 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 2x <- 1:10if(x > 5) { x <- 0}
##Question 3
f <- function(x) { g <- function(y) { y + z }
##Question4
x <- 5y <- 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
![Page 11: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/11.jpg)
}
z <- 4 x + g(x)}
Week 3: Loop Functions and Debugging
Quiz 3
![Page 12: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/12.jpg)
![Page 13: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/13.jpg)
Codigo programado para el Quiz 3##Question 1library(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 2apply(iris[, 1:4], 2, mean)
##Question 3library(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 4tapply(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)
![Page 14: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/14.jpg)
Week 4: Simulation & Profiling
Quiz 4:
![Page 15: Coursera-Johns Jopkins R Programming](https://reader030.fdocuments.in/reader030/viewer/2022020222/577c7d481a28abe0549e2400/html5/thumbnails/15.jpg)