# ignore this fiddly bit knitr::opts_chunk$set(comment=NA)
YOUR ANSWER HERE
setwd()
but specify a path to something that doesn't exist? YOUR ANSWER HERE
setwd("..")
do? Are there any circumstances where this command fails? Try a few paths with ..
as one of the folders (not just on its own). What is ..
? What is ../..
? How about .
?YOUR ANS....oh you know what to do.
Change working directories to TextAnalysisWithR
(wherever you unzipped it). Inside this unzipped set of folders, there is a folder called plainText
. With TextAnalysisWithR
as your working directory, how do you change to this directory with:
(a) one use of setwd
?
(b) two successive uses of setwd
?
(c) a single use of setwd
but with a different path specification?
To check your results, use getwd()
and see if it returns a path ending in plainText
.
Because it is tricky to match file systems, type your answers in the following code block, which is not evaluated by R:
# one use of setwd # two uses of setwd # one use of setwd, redux
x <- 10 print(x * 2) x <- 2 * x print(x)
Why doesn't the last line print 10
?
x
.# enter your R code, repeated several times, here # enter your R code, repeated several times, here
Speculate: Is the same thing possible without using x
?
five <- 2 + 2 5 <- 2 + 2
Write down variable names and types needed to store the following information. Remember that R variables are always vectors. Note when a multiple-element vector will be needed; just make up fake data.
For example: to store the information about whether the most recent winner of the Booker Prize is a U.K. citizen, one needs a single-element logical vector, so note this as follows:
last_booker_uk <- F # logical
On the other hand, to store the information about whether each of the Booker winners were from what Paul Gilroy calls "Brit-town," we would need a multiple vector:
booker_uk <- c(T, T, F) # and so on. logical: one element for each year
the titles of all the novels written by Georgette Heyer
the complete text of Moby-Dick (how many elements?)
the complete text of Moby-Dick, with formatting information
the gender of all the Nobel laureates in literature
the number of copies of Beloved held in each library in New Jersey
the total sales of The Lord of the Rings in each year since publication
the dates of publication of each serial installment of Great Expectations
the titles of Shakespeare's plays and their genres in the First Folio
the names of 8 modernist poets and the number of times each one appeared in the same issue of Poetry as each of the others
bonus: the image currently appearing on your monitor
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.