Skip to content

Commit cb5a122

Browse files
author
Benjamin Chan
committed
Save dataset as tab-delimited text file
1 parent d1d2547 commit cb5a122

File tree

7 files changed

+11924
-40
lines changed

7 files changed

+11924
-40
lines changed

Project/DatasetHumanActivityRecognitionUsingSmartphones.txt

Lines changed: 11881 additions & 0 deletions
Large diffs are not rendered by default.

Project/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@ Parameters for the project
3030
Steps to reproduce this project
3131
-------------------------------
3232

33-
1. Run R script `run_analysis.r`. It calls the R Markdown file, `run_analysis.Rmd`, which contains the bulk of the code.
34-
2. Copy the *Codebook* section from the resulting `run_analysis.md` file to a new file, `codebook.md`. This step is not automated.
33+
1. Open the R script `run_analysis.r` using a text editor.
34+
2. Change the parameter of the `setwd` function call to the working directory/folder (i.e., the folder where these the R script file is saved).
35+
3. Run the R script `run_analysis.r`. It calls the R Markdown file, `run_analysis.Rmd`, which contains the bulk of the code.
36+
4. Copy the *Codebook* section from the resulting `run_analysis.md` file to a new file, `codebook.md`. This step is not automated and must be manually done using a text editor.

Project/project.RData

-5.12 MB
Binary file not shown.

Project/run_analysis.Rmd

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,6 @@ dtTidy <- dt[, list(count = .N, average = mean(value)), by=key(dt)]
264264
```
265265

266266

267-
Save to file
268-
------------
269-
270-
Save data table objects to an RData file.
271-
272-
```{r save}
273-
f <- file.path(path, "project.RData")
274-
save(dt, dtTidy, file=f)
275-
```
276-
277267
--------------------------------------------------------------------------------
278268

279269
Codebook
@@ -331,3 +321,13 @@ List all possible combinations of features
331321
```{r}
332322
dtTidy[, .N, by=c(names(dtTidy)[grep("^feat", names(dtTidy))])]
333323
```
324+
325+
Save to file
326+
------------
327+
328+
Save data table objects to an txt file called `DatasetHumanActivityRecognitionUsingSmartphones.txt`.
329+
330+
```{r save}
331+
f <- file.path(path, "DatasetHumanActivityRecognitionUsingSmartphones.txt")
332+
write.table(dtTidy, f, quote=FALSE, sep="\t", row.names=FALSE)
333+
```

Project/run_analysis.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
<body>
192192
<h1>run_analysis</h1>
193193

194-
<p>Last updated 2014-04-12 11:27:46 using R version 3.0.2 (2013-09-25).</p>
194+
<p>Last updated 2014-04-14 10:18:19 using R version 3.0.2 (2013-09-25).</p>
195195

196196
<h2>Instructions for project</h2>
197197

@@ -239,7 +239,7 @@ <h2>Preliminaries</h2>
239239
path
240240
</code></pre>
241241

242-
<pre><code>## [1] &quot;C:/Users/Ben/Documents/GitHub repositories/GettingAndCleaningData/Project&quot;
242+
<pre><code>## [1] &quot;C:/Users/chanb/Documents/Repositories/Coursera/GettingAndCleaningData/Project&quot;
243243
</code></pre>
244244

245245
<h2>Get the data</h2>
@@ -299,7 +299,7 @@ <h2>Get the data</h2>
299299
## [28] &quot;train/y_train.txt&quot;
300300
</code></pre>
301301

302-
<p><strong>See the <code>README.txt</code> file in C:/Users/Ben/Documents/GitHub repositories/GettingAndCleaningData/Project for detailed information on the dataset.</strong></p>
302+
<p><strong>See the <code>README.txt</code> file in C:/Users/chanb/Documents/Repositories/Coursera/GettingAndCleaningData/Project for detailed information on the dataset.</strong></p>
303303

304304
<p>For the purposes of this project, the files in the <code>Inertial Signals</code> folders are not used.</p>
305305

@@ -481,19 +481,11 @@ <h2>Create a tidy data set</h2>
481481
dtTidy &lt;- dt[, list(count = .N, average = mean(value)), by = key(dt)]
482482
</code></pre>
483483

484-
<h2>Save to file</h2>
485-
486-
<p>Save data table objects to an RData file.</p>
487-
488-
<pre><code class="r">f &lt;- file.path(path, &quot;project.RData&quot;)
489-
save(dt, dtTidy, file = f)
490-
</code></pre>
491-
492484
<hr/>
493485

494486
<h1>Codebook</h1>
495487

496-
<p>Codebook was generated on 2014-04-12 11:28:24 during the same process that generated the dataset. See <code>run_analysis.md</code> or <code>run_analysis.html</code> for details on dataset creation.</p>
488+
<p>Codebook was generated on 2014-04-14 10:18:52 during the same process that generated the dataset. See <code>run_analysis.md</code> or <code>run_analysis.html</code> for details on dataset creation.</p>
497489

498490
<h2>Variable list and descriptions</h2>
499491

@@ -782,6 +774,14 @@ <h2>List all possible combinations of features</h2>
782774
## featVariable featAxis N
783775
</code></pre>
784776

777+
<h2>Save to file</h2>
778+
779+
<p>Save data table objects to an txt file called <code>DatasetHumanActivityRecognitionUsingSmartphones.txt</code>.</p>
780+
781+
<pre><code class="r">f &lt;- file.path(path, &quot;DatasetHumanActivityRecognitionUsingSmartphones.txt&quot;)
782+
write.table(dtTidy, f, quote = FALSE, sep = &quot;\t&quot;, row.names = FALSE)
783+
</code></pre>
784+
785785
</body>
786786

787787
</html>

Project/run_analysis.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
run_analysis
22
============
3-
Last updated 2014-04-12 11:27:46 using R version 3.0.2 (2013-09-25).
3+
Last updated 2014-04-14 10:18:19 using R version 3.0.2 (2013-09-25).
44

55

66
Instructions for project
@@ -55,7 +55,7 @@ path
5555
```
5656

5757
```
58-
## [1] "C:/Users/Ben/Documents/GitHub repositories/GettingAndCleaningData/Project"
58+
## [1] "C:/Users/chanb/Documents/Repositories/Coursera/GettingAndCleaningData/Project"
5959
```
6060

6161

@@ -128,7 +128,7 @@ list.files(pathIn, recursive = TRUE)
128128
```
129129

130130

131-
**See the `README.txt` file in C:/Users/Ben/Documents/GitHub repositories/GettingAndCleaningData/Project for detailed information on the dataset.**
131+
**See the `README.txt` file in C:/Users/chanb/Documents/Repositories/Coursera/GettingAndCleaningData/Project for detailed information on the dataset.**
132132

133133
For the purposes of this project, the files in the `Inertial Signals` folders are not used.
134134

@@ -385,23 +385,11 @@ dtTidy <- dt[, list(count = .N, average = mean(value)), by = key(dt)]
385385

386386

387387

388-
Save to file
389-
------------
390-
391-
Save data table objects to an RData file.
392-
393-
394-
```r
395-
f <- file.path(path, "project.RData")
396-
save(dt, dtTidy, file = f)
397-
```
398-
399-
400388
--------------------------------------------------------------------------------
401389

402390
Codebook
403391
========
404-
Codebook was generated on 2014-04-12 11:28:24 during the same process that generated the dataset. See `run_analysis.md` or `run_analysis.html` for details on dataset creation.
392+
Codebook was generated on 2014-04-14 10:18:52 during the same process that generated the dataset. See `run_analysis.md` or `run_analysis.html` for details on dataset creation.
405393

406394
Variable list and descriptions
407395
------------------------------
@@ -677,3 +665,15 @@ dtTidy[, .N, by = c(names(dtTidy)[grep("^feat", names(dtTidy))])]
677665
## featVariable featAxis N
678666
```
679667

668+
669+
Save to file
670+
------------
671+
672+
Save data table objects to an txt file called `DatasetHumanActivityRecognitionUsingSmartphones.txt`.
673+
674+
675+
```r
676+
f <- file.path(path, "DatasetHumanActivityRecognitionUsingSmartphones.txt")
677+
write.table(dtTidy, f, quote = FALSE, sep = "\t", row.names = FALSE)
678+
```
679+

Project/run_analysis.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require(knitr)
22
require(markdown)
3+
setwd("~/Repositories/Coursera/GettingAndCleaningData/Project")
34
knit("run_analysis.Rmd", encoding="ISO8859-1")
45
markdownToHTML("run_analysis.md", "run_analysis.html")

0 commit comments

Comments
 (0)