-
Notifications
You must be signed in to change notification settings - Fork 1
/
test workshop 4.R
71 lines (45 loc) · 918 Bytes
/
test workshop 4.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# test workshop 4
library(tidyverse)
mtcars
df <- data.frame(abc = 1, xyz = "a")
a <- df$x
class(a)
b <- df[ , "xyz"]
class(b)
c <- df[ , c("abc", "xyz")]
class(c)
var <- "abc"
df$var #doesn't work
df[[var]]
#q4
annoying <- tibble(
`1` = 1:10,
`2` = `1` * 2 + rnorm(length(`1`))
)
annoying
annoying$`1`
annoying$1
annoying[ ,1]
annoying[ ,`1`]
ggplot(annoying) +
geom_point(aes(x = `1`, y = `2`))
annoying2 <- annoying %>%
mutate(`3` = `1` * `2`)
annoying2b <- annoying %>%
mutate(`3` = 1 * 2)
annoying2 %>%
rename(one = `1`,
two = `2`,
three = `3`)
?enframe
a <- 1
a
class(a)
enframe(a)
??tibble.print
# Data import ####
dir.create("data")
download.file("https://raw.githubusercontent.com/hadley/r4ds/master/data/heights.csv", "data/heights.csv")
heights <- read_csv("data/heights.csv")
read_csv("a,b\n1,2\na,b")
str(parse_logical(c("TRUE", "FALSE", "NA")))