-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
347 lines (347 loc) · 11.2 KB
/
.Rhistory
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
x <- c(1,2,3,NA,4,5,6)
rm(cube, make.power, square, test)
criteria <- x>3
criteria
which(criteria)
?which
x[criteria]
x[which(criteria)]
?w
?c
c(1,2,3,4,5)
12345
x[[]][[]][[]][[]][[]][[]][[[]]][[[[[]]]]]
install.packages("RMySQL")
library(RMySQL)
?dbConnect
remove.packages(RMySQL)
remove.packages("RMySQL")
?dbConnect
install.packages("RMySQL")
library(RMySQL)
ucscDb <- dbConnect(MySQL(),user="genome",host="genome-mysql.cse.ucsc.edu")
result <- dbGetQuery(ucscDb, "show databases;"); dbDisconnect(ucscDb);
result
rm(ucscDb)
r.version.string
?r.version
??r.version
r.string.version
?r.string
detach(RMySQL)
detach("package:RMySQL", unload=TRUE)
library(swirl)
swirl()
library(tidyr)
students
?gather
gather(students, sex, count, -grade)
students2
res <- gather(students2, sex_class, count, -grade)
res
?separate()
?separate
separate(data=res, col=sex_class, into=c("sex","class"))
submit()
students3
submit()
?spread
submit()
extract_numeric("class5")
submit()
students4
submit()
passed
failed
mutate(passed, status, "passed")
?mutate
mutate(passed, status="passed")
passed <- mutate(passed, status="passed")
failed <- mutate(failed, status="failed")
bind_rows <- (passed, failed)
bind_rows(passed, failed)
sat
submit()
install.packages("httr")
install.packages("httpuv")
library(httr)
library(httpuv)
myapp <- oauth_app("github", "1e284e4e35d198bbc097", "86128a0a57f6185a6af8003f6d3b544cf114deee")
install.packages("Rcpp")
remove.packages("Rcpp")
install.packages("Rcpp")
library(httr)
library(httpuv)
myapp <- oauth_app("github", "1e284e4e35d198bbc097", "86128a0a57f6185a6af8003f6d3b544cf114deee")
github_token <- oauth2.0_token(oauth_endpoints("github"), myapp)
rm(failed, gradebook)
rm(passed, res, result, sat, student_info)
rm(students, students2, students3, students4, criteria, x)
gtoken <- config(token=github_token)
req <- GET("https://api.github.com/rate_limit", gtoken)
stop_for_status(req)
content(req)
install.packages(c("codetools", "manipulate"))
?required
?require
con <- url("http://biostat.jhsph.edu/~jleek/contact.html")
htmlCode <- readLines(con)
close(con)
head(htmlCode)
nchar(htmlCode[10])
nchar(htmlCode[20])
nchar(htmlCode[30])
nchar(htmlCode[100])
getwd()
dir()
fileURL <- "https://d396qusza40orc.cloudfront.net/getdata%2Fwksst8110.for "
fileURL <- "https://d396qusza40orc.cloudfront.net/getdata%2Fwksst8110.for"
download.file(fileURL, destfile="q5.for")
??fixed
q6 <- read.fwf("q5.for", 4, skip = 3)
head(q6)
q6 <- read.fwf("q5.for", c(9,4,4,4,4,4,4,4,4), skip = 3)
head(q6)
q6 <- read.fwf("q5.for", c(9,4,4,4,4,4,4,4,4), skip = 3, header=TRUE)
q6 <- read.fwf("q5.for", c(14,4,4,5,4,4,5,4,4,5,4,4), skip = 3)
head(q6)
str(q6)
q6 <- read.fwf("q5.for", c(14,4,4,5,4,4,5,4,4,5,4,4), skip = 3, stringsAsFactors=FALSE)
str(q6)
head(q6)
q6[2,2]
q6 <- read.fwf("q5.for", c(15,4,4,5,4,4,5,4,4,5,4,4), skip = 3, stringsAsFactors=FALSE)
head(q6)
q6 <- read.fwf("q5.for", c(10,-5,4,4,5,4,4,5,4,4,5,4,4), skip = 3, stringsAsFactors=FALSE)
head(q6)
q6 <- read.fwf("q5.for", c(-1,9,-5,4,4,-5,4,4,-5,4,4,-5,4,4), skip = 3, stringsAsFactors=FALSE)
head(q6)
q6 <- read.fwf("q5.for", c(-1,9,-5,4,4,-5,4,4,-5,4,4,-5,4,4), skip = 3, stringsAsFactors=FALSE, headers=T)
q6 <- read.fwf("q5.for", c(-1,9,-5,4,4,-5,4,4,-5,4,4,-5,4,4), skip = 3, stringsAsFactors=FALSE, header=T)
q6[1,1]
q6 <- read.fwf("q5.for", c(-1,9,-5,4,4,-5,4,4,-5,4,4,-5,4,4), skip = 4, stringsAsFactors=FALSE)
head(q6)
sum(q6$V4)
sum(q6$v4, q6$v9)
sum(q6$V4, q6$V9)
sum(as.numeric(q6$V4), as.numeric(q6$V9)
)
q6$V4 <- as.numeric(q6$V4)
q6$V9 <- as.numeric(q6$V9)
sum(q6$V4)
sum(q6$V9)
tail(q6)
?detach
detach(RCurl)
detach(package:Rcurl)
detach(package:RCurl)
detach(package:bitops)
?require
install.packages(c("codetools", "manipulate", "mgcv"))
install.packages("httr")
install.package("httpuv")
install.packages("httpuv")
rm(list=ls())
library()
install.packages("manipulate")
?inner_join
?grepl
setwd("C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project")
setwd("C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset")
x <- read.table("features.txt")
head(x)
?duplicated
sum(duplicated(x[,2]))
table(x[,2])
dim(table(x[,2]))
anyDuplicated(x[,2])
set <- "test"
paste(set,"/X_",set,".txt",sep="")
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
head(testData[,5],n=3)
head(testData[,1:5],n=3)
set = "test"
set %in% c("test","train")
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
?file.exists
file.exists("features.txt")
files <- c("test/X_test.txt","test/y_test.txt","test/subject_test.txt",
"train/X_train.txt","train/y_train.txt","train/subject_train.txt"
"features.txt","activity_labels.txt")
files <- c("test/X_test.txt","test/y_test.txt","test/subject_test.txt",
"train/X_train.txt","train/y_train.txt","train/subject_train.txt",
"features.txt","activity_labels.txt")
?lapply
lapply(file,file.exists)
lapply(files,file.exists)
sapply(files,file.exists)
res <- sapply(files,file.exists)
dim(res)
class(res)
all(res)
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
source('~/.active-rstudio-document')
feat <- read.table("features.txt")[,2]
length(feat)
feat <- read.table("features.txt", strings.As.Factors=F)[,2]
?read.table
feat <- read.table("features.txt", stringsAsFactors=F)[,2]
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
rm(analyze)
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
View(testData)
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
compile()
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
compile()
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
identical(names(testData),names(trainData))
data <- rbind(testData,trainData)
2947+7352
summary(data[,1:3])
?grepl
names(data)
names(data)[3]
feat <- read.table("features.txt")[,2]
head(feat)
names(testData)[3]
feat <- read.table("features.txt", stringsAsFactors=F)[,2]
names(testData)[3:] <- feat
names(testData)[3:563] <- feat
names(testData)[3]
names(trainData)[3:563] <- feat
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
identical(names(testData),names(trainData))
names(testData)[3]
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
names(testData)[1:3]
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
names(testData)[1:3]
x <- read.table("test/X_test.txt")
names(x) <- feat
names(x)[3]
x <- read.table("test/X_test.txt", col.names=feat)
names(x)[3]
?as.name
x <- read.table("test/X_test.txt", col.names=as.name(feat))
as.name(feat)
?read.table
sapply(feat,as.name)[1:5]
feats <- sapply(feat,as.name)
?sapply
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
names(testData)[3]
names(testData)[1:5]
feats <- lapply(feat,as.name)
feats[1:3]
?as.vector
as.vector(feats)[1:5]
?read.table
feats <- sapply(feat,as.char)
feats <- sapply(feat,as.chr)
?as.ch
??as.char
feats <- sapply(feat,as.character)
feats[1:5]
feats <- names(feats)
?as.names
?as.name
?apply
feats <- apply(feat,1,as.name)
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
?make.names
feats <- make.names(feat)
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
names(testData)[1:4]
test <- names(data)[3:8]
test
test <- names(data)[3:6,23,43]
test <- names(data)[c(3:6,23,43)]
test
?grepl
grepl("mean",test)
grepl(c("mean","std"),test)
?sub
sub(".","",test[1])
sub("...","",test[1])
sub("[[:punct:]]","",test[1])
sub("[^[:alnum:]]","",test[1])
class(test[1])
sub("[[:punct:]]","",feat[1:3])
sub("[^[:alnum:]]","",feat[1:3])
gsub("[[:punct:]]","",feat[1:3])
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
names(testData)[1:5]
test <- names(testData)[3:8]
grepl("mean",test)
test
grepl("mean|std",test)
sum(grepl("mean|std",names(testData)))
sum(grepl("mean|std",names(testData),ignore.case=TRUE))
?intersect
test <- testData[,grepl("mean|std",names(testData),ignore.case=TRUE)]
rm(list=ls())
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/UCI HAR Dataset/run_analysis.R')
30*6*86
30*6
rm(msData)
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/run_analysis.R')
setwd("..")
getwd()
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/run_analysis.R')
library(reshape2)
install.packages("reshape2")
library(reshape2)
?melt
head(msData[,1:5])
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/run_analysis.R')
head(msData[,1:5])
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/run_analysis.R')
rm(features,activityLabels,loadFiles,checkFiles,testData,trainData,fullData)
head(msData[,1:5])
names(msData)[87]
names(msData)
source('~/.active-rstudio-document')
names(fullData)[1:5]
head(fullData[,1:5])
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/run_analysis.R')
names(msData)
table(msData$Subject,msData$Activity)
msData[msData$Subject==1 & msData$Activity=="SITTING",3]
dataMelt <- melt(msData,id=c("Subject","Activity"),measure.vars=names(msData)[3:88])
head(dataMelt)
cast <- dcast(dataMelt,activity~variable)
cast <- dcast(dataMelt,Activity~variable)
cast <- dcast(dataMelt,Activity~variable, mean)
head(cast)
?dcast
cast <- dcast(dataMelt,Subject+Activity~variable, mean)
head(cast[,1:5])
?write.table
write.table(cast,file="results.txt")
test <- read.table("results.txt",header=TRUE)
head(test[,1:5])
x=c(1,2,3,4,5)
write.table(x,file="results.txt")
test <- read.table("results.txt",header=TRUE)
rm(list=ls())
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/run_analysis.R')
search()
if(!("package:reshape2" %in% search())){
library(reshape2)
}
if(("package:reshape2" %in% search())){
library(reshape2)
}
?library
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/run_analysis.R')
?do.call
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/run_analysis.R')
rm(result)
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/run_analysis.R')
write.table(results,"results.txt",row.name=FALSE)
print("Result file exported as results.txt")
rm(features,activityLabels,loadFiles,checkFiles,testData,
trainData,fullData,msData,dataMelt)
print("Workspace cleaned up.")
source('C:/Users/ryan.summe/OneDrive/Coursera/Data Science/Getting and Cleaning Data/Project/run_analysis.R')