Created
January 23, 2018 07:22
-
-
Save Xsmael/48c778015eeca97a15488e012be96d8e to your computer and use it in GitHub Desktop.
R workshop - morning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("ok") | |
a= 5 | |
b=10 | |
print(a+b) | |
x <- 4L | |
20 -> y | |
print(class(x)) | |
print(class(y)) | |
#vectors collection of same data types 'C' or 'v' is used to create vector | |
apple <- c("red", "green", "yellow") | |
print(apple) | |
print(apple[1]) | |
#lists - collection of dissimilar data types variable | |
l <- list(1,2,3,"abc",12.5, c('x','y','z')) | |
print(class(l)) | |
print(class(apple)) | |
#matrix | |
M= matrix( c(2,2,2,3,3,4,4,4,3), nrow=3, ncol = 3, byrow= FALSE) | |
print(M) | |
#array | |
a <- array(c("green","yellow"), dim= c(3,3,2)) #3D array 3x3x2 | |
print(a) | |
#data frame | |
BMI <- data.frame( | |
gender= c("male", "female", "male"), | |
height= c(102,120,180), | |
weight= c(65,82,55), | |
age= c(28,32,65) | |
) | |
print(BMI) | |
install.packages("MASS") | |
library(mass) | |
Pima.te | |
Pima.tr | |
merged.Pima <- merge(x= Pima.te, y= Pima.tr, | |
by.x = c("bp", "bmi"), | |
by.y = c("bp", "bmi") | |
) | |
# TESt 1 | |
f1 <- data.frame( | |
state = c("alabama", "alaska", "arizona", "arkansas", "Califorinia", "colorado","connecticut","delaware"), | |
region = c("S","W","w","s","w","w","NE","S") | |
) | |
print(f1) | |
f2 <- data.frame( | |
stat = c("alabama", "alaska", "arizona", "arkansas", "Califorinia", "colorado","connecticut"), | |
population = c(95200,12000,50000,125000,805000,350000,725000) | |
) | |
print(f2) | |
f3 <- merge(f1, f2) | |
print(f3) | |
nrow(f1) | |
ncol(f1) | |
str(f3) | |
summary(f1) | |
############################### | |
install.packages("downloader") | |
library(downloader) | |
install.packages("dplyr") | |
library(dplyr) | |
url <- "https://raw.githubusercontent.com/genomicsclass/dagdata/master/inst/extdata/msleep_ggplot2.csv" | |
filename <- "msleep_ggplot2.csv" | |
if (!file.exists(filename)) download(url,filename) | |
msleep <- read.csv("msleep_ggplot2.csv") | |
#head(msleep) | |
#summary(msleep) | |
sleepData= select(msleep, name, sleep_total, sleep_rem, awake, brainwt) | |
sleepData= select(msleep, -name, -vore, -genus) | |
sleepData= select(msleep, order:sleep_total) | |
sleepData= select(msleep, starts_with("sleep")) | |
filter(sleepData, sleep_total>=16) | |
head(sleepData) | |
msleep %>% filter(sleep_total >16) | |
msleep %>% filter(sleep_total >16, sleep_rem >1.8) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.telerik.com/blogs/creating-your-first-cross-platform-native-app-with-nativescript