当前位置:网站首页>Select function variable column name in dplyr of R language
Select function variable column name in dplyr of R language
2022-07-04 04:27:00 【Analysis of breeding data】
Background introduction :
R In language , Data frame column names are standardized , Here I want to extract Y2:Y11, Q1:Q5 Such column names , I don't want to write a complete column name ,
Generate a variable name outside, including the above content , such as :
n1 = str_c("Y",2:11)
n1
n2 = str_c("Q",1:5)
n2
And then directly according to n1,n2 Content to extract .
Problem solving
library(dplyr)
dd %>% select(n1,n2) %>% head

With a prefix bug, If there is n1 and n2 Column name of , The above data becomes :
dd$n1 = rnorm(44)
dd$n2 = rnorm(44)
library(dplyr)
dd %>% select(n1,n2) %>% head

obviously , This is not what we want .
Better solution
use
dplyrMediumall_offunction , Use the contents of variables , Instead of the original name of the variable :
dd %>% select(all_of(n1),all_of(n2)) %>% head

This is a more appropriate plan .
Problem solving !
边栏推荐
- Boutique website navigation theme whole station source code WordPress template adaptive mobile terminal
- 苹果CMS仿西瓜视频大气响应式视频模板源码
- MIN_RTO 对话
- Apple CMS imitation watermelon video atmospheric response video template source code
- Leetcode skimming: binary tree 04 (sequence traversal of binary tree)
- R语言中如何查看已安装的R包
- 精品网址导航主题整站源码 wordpress模板 自适应手机端
- ModStartBlog 现代化个人博客系统 v5.2.0 源码下载
- 普源DS1000Z系列数字示波器在通信原理实验中的应用方案
- 干货!基于GAN的稀有样本生成
猜你喜欢

R语言中如何查看已安装的R包

leetcode刷题:二叉树09(二叉树的最小深度)

leetcode刷题:二叉树04(二叉树的层序遍历)

Distributed system: what, why, how

精品网址导航主题整站源码 wordpress模板 自适应手机端

Flink学习6:编程模型

Ppt tutorial, how to save a presentation as a PDF file in PowerPoint?

Imitation of "game bird" source code, mobile game issue evaluation, open service, open test collection, game download website template

tdk-lambda电源主要应用

【微服务|openfeign】@FeignClient详解
随机推荐
陪驾注意事项 这23点要注意!
Graduation project: design seckill e-commerce system
A beautiful API document generation tool
B. All Distinct
VIM mapping command
UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0x98 in position 1093: illegal multibyte sequence
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
C语言双向链表初版
量子力学习题
Unity Resource path
线程常用的方法
Global exposure and roller shutter exposure of industrial cameras
leetcode刷题:二叉树08(N叉树的最大深度)
微信公众号无限回调授权系统源码
Common methods of threads
统计遗传学:第三章,群体遗传
虚拟商品帐号交易平台源码_支持个人二维码收款
One click compilation and deployment of MySQL
Wechat brain competition answer applet_ Support the flow main belt with the latest question bank file
Understand the principle of bytecode enhancement technology through the jvm-sandbox source code