I think it might be up for discussion whether or not
there is a bug in here somewhere.
> mat10 <- matrix(1:6, 3)
> mat10 * 1:12
Error: dims [product 6] do not match the length of object [12]
> data.frame(mat10) * 1:12
X1 X2
1 1 16
2 4 25
3 9 36
> version
_
platform
i386-pc-mingw32
arch
i386
os
mingw32
system i386,
mingw32
status Under development
(unstable)
major
2
minor
9.0
year
2008
month
11
day
22
svn rev
47006
language
R
version.string R version 2.9.0 Under development (unstable) (2008-11-22
r47006)
It seems dangerous to me that there is not at least
a warning in the data frame case. I think I'd prefer
an error like the matrix case.
Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")
markle...@verizon.net wrote:
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 =
c(2,4))
d1 <- data.frame(jet = c(10), feather = c(20))
print(m)
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
______________________________________________
r-h...@r-project.org mailing list
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.
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel