Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 3: error occurs when reading spam. #41

Open
zerodel opened this issue Jun 15, 2016 · 3 comments
Open

Chapter 3: error occurs when reading spam. #41

zerodel opened this issue Jun 15, 2016 · 3 comments

Comments

@zerodel
Copy link

zerodel commented Jun 15, 2016

the code are running from Rstudio with R 3.3.0 under osx 10.11

issue 1:

line 48 in email_classify.R:

geom_hline(aes(yintercept = c(10,30)), linetype = 2)

yintercept need to be put outside aes function , like this :

geom_hline(yintercept = c(10,30), linetype = 2)

issue 2:

error occurs when reading msg by sapply at line 139-140 ..

all.spam <- sapply(spam.docs,
function(p) get.msg(file.path(spam.path, p)))

here is the traceback

Error in seq.default(which(text == "")[1] + 1, length(text), 1) :
'from' cannot be NA, NaN or infinite
7 stop("'from' cannot be NA, NaN or infinite")
6 seq.default(which(text == "")[1] + 1, length(text), 1)
5 seq(which(text == "")[1] + 1, length(text), 1)
4 get.msg(file.path(spam.path, p))
3 FUN(X[[i]], ...)
2 lapply(X = X, FUN = FUN, ...)
1 sapply(spam.docs, function(p) get.msg(file.path(spam.path, p)))

seems some file does not have a blank line

@xialu4820723
Copy link

Yeah, I have met the same problem.

@tjmahr
Copy link

tjmahr commented Aug 14, 2016

Make sure that the "cmds" file is not in the vector of files being read.

spam_docs <- dir(spam_path, full.names = TRUE)
all_spam <- sapply(spam_docs, function(p) get_msg(p))
#> Error in seq.default(which(text == "")[1] + 1, length(text), 1) : 
#>  'from' cannot be NA, NaN or infinite In addition: Warning message:
#> In readLines(path) :
#>   incomplete final line found on './/03- Classification/data/spam/00136.faa39d8e816c70f23b4bb8758d8a74f0'

spam_docs <- dir(spam_path, full.names = TRUE)
spam_docs <- spam_docs[which(basename(spam_docs) != "cmds")]
all_spam <- sapply(spam_docs, function(p) get_msg(p))
#> Warning message:
#> In readLines(path) :
#>   incomplete final line found on './/03-Classification/data/spam/00136.faa39d8e816c70f23b4bb8758d8a74f0'

@pmargreff
Copy link

The same here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants