[R] odd behavior when multiplying data frame by an element

markleeds at verizon.net markleeds at verizon.net
Sat Dec 13 02:52:18 CET 2008

could someone explain what is happening below ? I was trying to solve a 
related question on the list and then , as I was solving it,
I was getting strange answers and then I noticed below. It's obviously 
not a bug but I don't get it. Thanks.

m <- data.frame(class = c("birds", "planes"), feather = c(1,3), jet = 
d1 <- data.frame(jet = c(10), feather = c(20))

m[,-1]*2       # THIS IS FINE
m[,"jet"]*2     # THIS IS FINE

print(d1["jet"]) # THIS IS FINE
m[,"jet"]*d1["jet"] # THIS IS ODD

More information about the R-help mailing list