我不是想解决任何特定问题,而是试图学习R并理解其逻辑否定运算符“!”记录http://stat.ethz.ch/R-manual/R-devel/library/base/html/Logic.html页逻辑否定运算符“!”如何作品
上,结合=使用时,它为我的作品,在表现形式,例如:
1 != 2
TRUE
但我不能完全理解这种操作的独立应用程序。例如,我可以使用它来选择没有特定名称的列表元素。这里是我试图做到这一点,但没有奏效:
vector1 <- 1:5 # just making vector of 5 numbers
vector2 <- 5:1 # same vector backwards
list <- list(Forward=vector1, Backwards=vector2) # producing list with two elements
x = "Forward"
list[!x]
我的输出是:
Error in !x : invalid argument type
会明白在哪里我的逻辑在这种情况下出现问题的任何提示,有什么其他的好除了!= case外,该运算符的用法。
谢谢! 谢尔盖
乔兰,非常感谢澄清和解释,现在对我来说都是有意义的。 – 2013-04-22 23:06:10