I have the following dataframe, 'A'. I calculate a distance matrix 'B' from it. Then I add that distance matrix 'B' to a list 'C' and view it.
A <- data.frame(x = c(1:10),
y = c(21:30))
B <- dist(A)
C <- list(B)
View(C)
So far so good. No problems, all is well. But once I load either the package "DescTools" or "e1071" and perform the exact same actions, I get an error.
library("e1071")
A <- data.frame(x = c(1:10),
y = c(21:30))
B <- dist(A)
C <- list(B)
View(C)
Error in .Primitive("[")(x, 1:6, , drop = FALSE) : incorrect number of dimensions
However, when I directly call the list, or the distance matrix in the list, I still get a return without error:
C[[1]]
1 2 3 4 5 6 7 8 9
2 1.414214
3 2.828427 1.414214
4 4.242641 2.828427 1.414214
5 5.656854 4.242641 2.828427 1.414214
6 7.071068 5.656854 4.242641 2.828427 1.414214
7 8.485281 7.071068 5.656854 4.242641 2.828427 1.414214
8 9.899495 8.485281 7.071068 5.656854 4.242641 2.828427 1.414214
9 11.313708 9.899495 8.485281 7.071068 5.656854 4.242641 2.828427 1.414214
10 12.727922 11.313708 9.899495 8.485281 7.071068 5.656854 4.242641 2.828427 1.414214
What's also baffling me is that even if I unload the packages with detach(), the error remains.
library("DescTools")
detach("package:DescTools", unload=TRUE)
A <- data.frame(x = c(1:10),
y = c(21:30))
B <- dist(A)
C <- list(B)
View(C)
Once I restart the session, and refrain from loading either package, it works again.
I tested all other packages I use. None cause this behaviour. I loaded the "e1071" package originally to use its kurtosis and skewness function. When I tracked down this error to this particular package, I eventually downloaded the "DescTools" package instead to avoid the error as it offers the same functions. However, it causes the same issue.
Is there some fix for this? Am I being stupid and there is something obvious I'm missing? I'm no programmer/coder/scripter, but usually I can piece together what I need from on here. I found nothing to help me with this though and this error is starting to get frustrating when I try to quickly check my lists. Thanks in advance.