Skip to content
Prev 388512 / 398513 Next

problem for strsplit function

Thanks Bert,
I'm reading some books now. But it takes me a while to get familiar R.

Best,
Kai On Friday, July 9, 2021, 03:06:11 PM PDT, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:

        
On 09/07/2021 5:51 p.m., Jeff Newmiller wrote:
I would also object to v3 (below) as "extracting" a column from d. 
"d[2]" doesn't extract anything, it "subsets" the data frame, so the 
result is a data frame, not what you get when you extract something from 
a data frame.

People don't realize that "x <- 1:10; y <- x[[3]]" is perfectly legal. 
That extracts the 3rd element (the number 3).? The problem is that R has 
no way to represent a scalar number, only a vector of numbers, so x[[3]] 
gets promoted to a vector containing that number when it is returned and 
assigned to y.

Lists are vectors of R objects, so if x is a list, x[[3]] is something 
that can be returned, and it is different from x[3].

Duncan Murdoch
______________________________________________
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.