@rythur @data_science What's odd is that, between the two different ways of making a list element null, one leaves the null in the list, while the other removes it and shortens the list.
@peterdrake @data_science Now I definitely see it! That is odd. The culprit could be a single element replacement versus a vector replacement, in that the latter used concatenate and the former didn't? Perhaps a single element call to NULL has special properties for some other reason. I like how you approach languages! You're looking for the interesting. I usually just pick a project that needs it and force myself to learn the language quickly, with the interesting with time.
@rythur @data_science Well, I'm looking for the rules, and things like this stick out.
If you like that sort of thing, you'll love Gary Bernhardt's Wat video:
@peterdrake @data_science It had never occurred to me that this might be what computer science was: the rules. We all learn these languages for different reasons and in different ways, and that's great. Keep the rules coming! I like this stuff. Oh, and I'll scope the guy soon. Bed time, finally!
@peterdrake Assigning NULL is the way you delete something in a list (like a column from a data frame)
> mtcars <- mtcars
> ncol(mtcars)
[1] 11
> mtcars$mpg <- NULL
> ncol(mtcars)
[1] 10
If you want to keep the length, you should assign NULL as a list.
> rm(mtcars)
> mtcars <- mtcars
> ncol(mtcars)
[1] 11
> mtcars$mpg <- list(NULL)
> ncol(mtcars)
[1] 11
@hhmacedo Yeah, I got that. It just strikes me as odd that these things behave differently. I would expect
v[1:3] <- list(1, NULL, 3)
to behave just like:
v[1] <- 1
v[2] <- NULL
v[3] <- 3
@peterdrake For every rule, there is an exception ๐
@peterdrake @data_science I use NULL as a temporary place holder within functions when I want behavior like this. Based on what I've learned, this makes sense for the Language. Is it odd to use NULL in this way for a programming language? R also has NA and NaN, which may reflect the expected behavior more quickly.