Michael Pomeroy
2015-Feb-13 17:15 UTC
[R] Error when I attempt to create a list or a data frame
When I try to create a list with three classes of objects: a numeric, boolean, and vector of character data: lst <- list(c(1,2),TRUE,c(?a?,?b?,?c?)) I receive this error: Error: unexpected input in "lst <- list(c(1,2),TRUE,c(?" I receive a similar error when I create a data frame with mixed classes of objects. Thanks ahead of time!
Uwe Ligges
2015-Feb-14 08:14 UTC
[R] Error when I attempt to create a list or a data frame
On 13.02.2015 18:15, Michael Pomeroy wrote:> > When I try to create a list with three classes of objects: a numeric, > boolean, and vector of character data: > lst <- list(c(1,2),TRUE,c(?a?,?b?,?c?)) > > I receive this error: > Error: unexpected input in "lst <- list(c(1,2),TRUE,c(?"Do not use directed quotes. Best, Uwe Ligges> > I receive a similar error when I create a data frame with mixed classes > of objects. > > Thanks ahead of time! > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Hi, It appears that you used left double quotation marks and right double quotation marks in your vector for characters. The first lst assignment is copied from your post and indicates issues. I retyped with doulbe quotation mark and went through fine with the second lst assignment. Unicode for double quotation mark is U+0022 and for left double quotation mark U+201C and right double quotation mark U+201D. Although they look similar but they are not the same in unicode.> lst <- list(c(1,2),TRUE,c(?a?,?b?,?c?))Error: unexpected input in "lst <- list(c(1,2),TRUE,c(?"> lst <- list(c(1,2),TRUE,c("a","b","c")) > lst[[1]] [1] 1 2 [[2]] [1] TRUE [[3]] [1] "a" "b" "c" -- View this message in context: http://r.789695.n4.nabble.com/Error-when-I-attempt-to-create-a-list-or-a-data-frame-tp4703251p4703433.html Sent from the R help mailing list archive at Nabble.com.