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.
这是一段简单的代码:
for (i in c("red", "green")) for (j in c("blood", "trees")) { k <- paste(i, j, sep=" ") print(k) } }
我希望它只输出"red blood"和"green trees". 剩余的组合将被丢弃。这可以在循环内完成吗?
"red blood"
"green trees"
你不需要一个循环:
R> paste(c("red","green"), c("blood","trees")) [1] "red blood" "green trees"