# The _if() variants apply a predicate function (a function that
# returns TRUE or FALSE) to determine the relevant subset of
# columns.
# mutate_if() is particularly useful for transforming variables from
# one type to another
iris %>% mutate_if(is.factor, as.character)
Run Code Online (Sandbox Code Playgroud)
那么如何使用逆形式呢?我想将所有非数字值转换为字符,所以我想到这样做:
iris %>% mutate_if(!is.numeric, as.character)
#> Error in !is.numeric : invalid argument type
Run Code Online (Sandbox Code Playgroud)
但这是行不通的。或者只选择所有非数字变量:
iris %>% select_if(!is.numeric)
#> Error in !is.numeric : invalid argument type
Run Code Online (Sandbox Code Playgroud)
也不行。
如何对,和 等函数使用否定?dplyrmutate_if()select_if() …
有没有办法使用 Windows 上的 R/R Studio 中的命令打开文件资源管理器窗格,也许将路径指定为参数?例如:
open_folder(getwd())
Run Code Online (Sandbox Code Playgroud)
将在工作目录中打开文件资源管理器。它与 的相反choose.dir,是从路径转到文件资源管理器,而不是从文件资源管理器转到路径。这将是在 R Studio 中单击“文件>>更多>>在新窗口中显示文件夹”的命令行版本。
我真的不知道如何编写代码来直接在 Windows 上工作,所以我正在寻找已经实现或可以在 R 内部实现的东西。