Skip to content

Commit

Permalink
Adding assignments solutions for course "pogRomcy Danych" about data
Browse files Browse the repository at this point in the history
science and R.
  • Loading branch information
afronski committed Apr 11, 2015
1 parent 8fdf8cf commit d7d1a05
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions pogromcy-danych/assignments/1_4.R
@@ -0,0 +1 @@
wynik <- sqrt((2+517)*1.23)
10 changes: 10 additions & 0 deletions pogromcy-danych/assignments/1_5.R
@@ -0,0 +1,10 @@
# Text file:
auta2012 <- read.table(file="http://biecek.pl/MOOC/dane/auta2012mini.csv",
sep=";", dec=",", header=TRUE)

# Excela file:
library(gdata)
auta2012 <- read.xls("http://biecek.pl/MOOC/dane/auta2012mini.xls", sheet=1)

# RDA file (it loads whole workspace, with variables):
load(url("http://biecek.pl/MOOC/dane/auta2012mini.rda"))
10 changes: 10 additions & 0 deletions pogromcy-danych/assignments/1_6.R
@@ -0,0 +1,10 @@
# Text file:
write.table(koty_ptaki, file="dane_o_kotach.csv", sep=",", dec=".")

# Excela file:
library(xlsx)
write.xls(koty_ptaki, file="koty_ptaki.xlsx", sheetName="New Sheet")

# RDA file:
save(koty_ptaki, file="koty_ptaki.rda")
load("koty_ptaki.rda")
12 changes: 12 additions & 0 deletions pogromcy-danych/assignments/1_7.1.R
@@ -0,0 +1,12 @@
# 10 following letters:
c('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')
letters[1:10]

# Odd numbers starting from 3:
seq(3, 21, 2)

# Selected numbers from LETTERS:
LETTERS[c(5, 10, 15, 20, 25)]

# Reversed LETTERS:
LETTERS[26:1]
18 changes: 18 additions & 0 deletions pogromcy-danych/assignments/1_7.2.R
@@ -0,0 +1,18 @@
# All besides falcons:
koty_ptaki[-(11:12), ]
koty_ptaki[c(1:10, 13), ]

# Only cats:
koty_ptaki[1:7, ]
koty_ptaki[koty_ptaki$druzyna == "Kot", ]

# Only two columns:
koty_ptaki[, c("waga", "predkosc")]
koty_ptaki[, c(2, 4)]

# All besides last column:
koty_ptaki[, 1:6]
koty_ptaki[, -7]

# Lightweight animals:
koty_ptaki[koty_ptaki$waga < 100, 1:4]

0 comments on commit d7d1a05

Please sign in to comment.