你提的问题不够详细,正是你想做的事知道。
一般来说,apply
家庭是非常有用的与载体的工作:看到?apply
文档如果从要仅保留> 200
向量的那些元素的数字载体列表那么你可以使用下面的代码:
# list of numeric vectors
my_list <- list(a = c(201, 199, 202),
b = c(9, 203, 188),
c = c(203, 210, 7))
# using the apply family to e.g. calculate a mean
sapply(my_list, mean)
# a b c
# 200.6667 133.3333 140.0000
# same thing but now with explicitely naming the vector i
# using an anonymous function
sapply(my_list, function(i) mean(i))
# a b c
# 200.6667 133.3333 140.0000
# using a anonymous function to select in the vector what we want
sapply(my_list, function(i){ i[i>200] })
# $a
# [1] 201 202
#
# $b
# [1] 203
#
# $c
# [1] 203 210
请让我知道这是否是你想要的
你能提供什么你在'list'?警告基本上告诉你,如果'i'具有比1长的向量,那么只有第一个元素会被使用。这基本上意味着'list'的结构有问题。你可以很容易地使用'l < - list(1:2); (i> l)if(i> 200)print(i)' –
将'str(list)'的输出添加到你的问题中应该会有所帮助。 – Marius