.subset2(x,i,精确=精确)中的错误:递归索引在级别2上失败 [英] Error in .subset2(x, i, exact = exact) : recursive indexing failed at level 2

查看:269
本文介绍了.subset2(x,i,精确=精确)中的错误:递归索引在级别2上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试将我的教育变量从18个等级的因子重新编码为7个等级的因子,范围从无资格-GCSE DG,GCSE A * -C- A等级-本科-研究生-其他.

I am trying to recode my education variable from a factor with 18 levels to a factor with 7 levels,ranging from no qualification - GCSE D-G, GCSE A*-C- A Level -Undergraduate -Postgraduate - other.

bes[[bes$education]]%>% recode('No qualification' = 'no qualification',
                               'GCSE D-G, CSE grades 2-5, O level D-E' = 'GCSE D-G',
                               'Youth training certificate, skill seekers' = 'GCSE D-G',
                               'Clerical and commercial qualifications'= 'GCSE D-G',
                               'GCSE A*-C, CSE grade 1, O level grade A-C'  = 'GCSE A*-C',
                               'Scottish Standard grades, Ordinary bands' = 'GCSE A*-C',
                               'Recognised trade apprenticeship' = 'GCSE A*-C',
                               'City&Guilds level 1, NVQ/SVQ 1 and equivalent' = 'GCSE A*-C',
                                 'A level or equivalent '= 'A level',
                               'Scottish Higher or equivalent'= 'A level',
                               'City&Guilds level 2, NVQ/SVQ 2 and equivalent'= 'A level',
                               'HNC/HND, City&Guilds level 4, NVQ/SVQ 4/5'= 'A level',
                               'ONC/OND, City&Guilds level 3, NVQ/SVQ 3'= 'A level',
                               'Univ/poly diploma'= 'Undergraduate',
                               'First degree'= 'Undergraduate',
                               'Nursing qualification'= 'Undergraduate',
                               'Teaching qualification'= 'Undergraduate',
                               'Postgraduate degree'  = 'Postgrad',
                               'Other technical, professional or higher qualification' = "Other")

我在执行此操作时遇到了麻烦,并且不断收到错误消息.我已经尝试过使用ifelse函数以及base r和dplyr和plyr软件包中的各种其他函数,但我似乎还是做不到.

I am having trouble doing so and I keep on getting error messages. I have tried using the ifelse function and various other functions both from base r and dplyr and plyr packages and I still can't seem to do it.

推荐答案

第一个命令的语法错误.代替 bes [[bes $ education]] ,使用 bes $ education .方括号 [[]] 与列数和带有名称的 $ 符号一起使用.是 [[]] $ ,但不是两者.

Syntax of the first command is wrong. Instead of bes[[bes$education]] use bes$education. Square brackets [[]] are to be used with numbers of columns and $ symbol with their names. It's either [[]] or $ but not both.

这篇关于.subset2(x,i,精确=精确)中的错误:递归索引在级别2上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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