Skip to content
Prev 37610 / 63424 Next

Assignment of individual values to data frame columns: intentional or unintentional behavior?

On 2010-08-05 12:14, Ulrike Gr?mping wrote:
This is another example of why it's a good idea to avoid
the '$' notation when fiddling with data frames. Try this:

  sw <- swiss[1:5, 1:4]
  sw[["Fert"]]
  sw[["Fert"]] <- 10

and my preferred version:
  sw[, "Fert"]
  sw[, "Fert"] <- 10

I've never liked partial matching for data frames.

   -Peter Ehlers