dplyr的select助手功能()与复制有何区别? [英] How does dplyr's select helper function everything() differ from copying?

查看:119
本文介绍了dplyr的select助手功能()与复制有何区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  select(iris,everything())

而不是例如只需复制data.frame?

解决方案

寻找对所有内容的引用?选择,他们有一个用于重新排序列的示例:

  #重新排列变量:将变量Species保留在前面
select(iris,Species,everything())

在这种情况下, Species 列移动到第一列,所有列都保留,并且没有列重复。



也可能存在其他用例。


What is the use case for

select(iris, everything())

as opposed to e.g. just copying the data.frame?

解决方案

Looking for references to everything in ?select, they have an example use for reordering columns:

# Reorder variables: keep the variable "Species" in the front
select(iris, Species, everything())

In this case the Species column is moved to the first column, all columns are kept, and no columns are duplicated.

It's possible other use cases exist as well.

这篇关于dplyr的select助手功能()与复制有何区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆