Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
fn <- function(D, e) { for(i in 1:nrow(D)) { if(D[i,1] == e) { print("y") } } } fn(events, "a")
問題:eventsは 2 行 n 列の行列です。の代わりに"a"を渡したい場合、状態を確認するにはどうすればよいc("a","b","c")ですか?eif(D[i,1]==e)
events
"a"
c("a","b","c")
e
if(D[i,1]==e)
これは簡単です:
if any((D[i, 1] %in% e))