60 likes | 153 Views
http://www.sciencedaily.com/releases/2008/09/080902143245.htm. Topic #4 – input/output . 1. Input Set working directory Read a script Read a text file 2. Output Write a text file. http://www.sciencedaily.com/releases/2008/09/080902143245.htm. Topic #4 – input/output . 1. Input
E N D
http://www.sciencedaily.com/releases/2008/09/080902143245.htmhttp://www.sciencedaily.com/releases/2008/09/080902143245.htm Topic #4 – input/output • 1. Input • Set working directory • Read a script • Read a text file • 2. Output • Write a text file
http://www.sciencedaily.com/releases/2008/09/080902143245.htmhttp://www.sciencedaily.com/releases/2008/09/080902143245.htm Topic #4 – input/output • 1. Input • Set working directory • Method #1 • file > change dir... • Method #2 • file.path should look like ... setwd(file.path) “C://...//”
http://www.sciencedaily.com/releases/2008/09/080902143245.htmhttp://www.sciencedaily.com/releases/2008/09/080902143245.htm Topic #4 – input/output • 1. Input • Set working directory • Method #1 • [ file > change dir... ]
http://www.sciencedaily.com/releases/2008/09/080902143245.htmhttp://www.sciencedaily.com/releases/2008/09/080902143245.htm Topic #4 – input/output • 1. Input • Read a script • file.path should be specified similar to setwd( ) source(file.path)
http://www.sciencedaily.com/releases/2008/09/080902143245.htmhttp://www.sciencedaily.com/releases/2008/09/080902143245.htm Topic #4 – input/output • 1. Input • Read a text file • Options • Header – can save column names at top of file • Separator – can change the character that separates values DATA = read.table(file = file.path , ...)
http://www.sciencedaily.com/releases/2008/09/080902143245.htmhttp://www.sciencedaily.com/releases/2008/09/080902143245.htm Topic #4 – input/output • 2. Output • Write a text file write.table(Data, file = file.path , ...)