在 R 中,如果列中的字符串是/不是字母,如何插入 TRUE/FALSE 列?

In R, how can I insert a TRUE / FALSE column if strings in columns ARE / ARE NOT alphabetic?

示例数据:
df <- data.frame(noun1 = c("cat","dog"), noun2 = c("apple", "tree"))

  noun1 noun2
1   cat apple
2   dog  tree

如何创建一个新列 df$alpha,使其在第 1 行中显示为 FALSE,在第 2 行中显示为 TRUE

谢谢!

我认为您可以将 is.unsorted() 应用于每一行,尽管您必须先取消列出它(可能)。

 df <- data.frame(noun1 = c("cat","dog"), noun2 = c("apple", "tree"))
 df$alpha <- apply(df,1,function(x) !is.unsorted(unlist(x)))

我通过 apropos("sort") 找到了 is.unsorted()