textstat_keyness 不计算

问题描述

我见过 similar questions,但其他线程中的解决方案都没有对我有'names' attribute must be the same length as the vector

这是我的数据“d”的快照

Answer ID   Created Date    Is this an ongoing case (duplicate)?    CSS:    Case Number:    Date:   Referral Source:    If otthey,Please Specify   City Council Staff Name:    City Council Staff Phone Number:    Referral Type:  Have you completed two attempts with no response by Agent?  If otthey,Please Specify   Attempt Contact 1 Name: Attempt Contact 1 Date: Attempted to Contact 1: Attempt Contact 2 Name: Attempt Contact 2 Date: Attempted to Contact 2: May we proceed? First Name: Last Name:  Address:    City:   State:  Zip Las chapas: Phone Number:   Age:    Head of Household disabled: Full-Time Student:  Gross Annual Income ($):    Total Household Members:    Income Level:   Race:   Ethnicity of Household: Does your family have a female Head of Household?   Do you certify that the demographic and income information you provided is complete and accurate? Thank you.    Gender: Marital Status: Education Level:    Head of Household a Veteran:    Head of Household Senior:   Preferred Language: Limited English Proficiency Status: Household Experiencing Domestic Violence:   Household Receives SAHA or Bexar County Voucthey:   Council district:   Rural Area Status:  Email:  Referral Outcome/Impact:    Resources Provided (check all that apply):  Referral Status:    Self-Certification Form:    Brief Description of Referral:  Resolution:
1   6/6/1966 16:06  No  Bobby Gomez     6/6/1966    Department Administrators/Staff                                                     Adam    The First       NYC NY      555-594-5548                                            Male                    English Household is Not Limited English Proficient No  No      Household Does Not Live in a Rural Area     Property Quote Provided     Agent provided resources - Loop Closed on Referral      Regarding stadium and contraction   Spoke with party. Provided via e-mail to party the Center for disease Control stadium and extension information.
336 5/5/1955 10:25      Jason Kidd  15901001    5/5/1955    otthey  online submission           Ttheyapy    Yes     Selena  5/5/1955    No Answer (Left Message)    Selena  5/5/1955            Selena                      555-5762926                                                                                     mind_ya-bizness@thanks.com                  CSS received assignment party seeking Ttheyapy on selling home  CSS attempted to contact applicant to no avail,a voice message was left. CSS emailed party requesting contact to discuss they situation.
337 5/5/1955 11:00      Jason Kidd  15901002    5/5/1955    otthey  online submission           otthey      utility quote                               Michael GoodBerry   222 Yepers Ave  NYC     NY  05587   555-570-5631                                            Female                  English Household is Not Limited English Proficient         district 5  Household Does Not Live in a Rural Area         Community Agencies (otthey resources),DHS Utilities           CSS received email assignment to contact party seeking Ttheyapy CSS contacted party who stated they was seeking financial quote to pay a property tax lien payment arrangement. CSS referred party to DHS for utility quote as the financial therapy quote would not be able to assist.
338 5/5/1955 11:07      Jason Kidd  15901003    5/5/1955    otthey  online submission           Property Quote          NBA Youngboy    5/5/1955    Phone disconnected                  NBA Youngboy                    555-546-5424                                                                                                            CSS received email assignment to contact party due to inquiry for information on lease and moving   CSS made an attempt,phone was busy; reverified number again was busy-disconnected
339 5/5/1955 11:18      Jason Kidd  15901004    5/5/1955    Department Administrators/Staff             Property Quote          Randy Savage    5/5/1955    No Answer (Left Message)                    Randy   Savage                  555-582-5600                                                                                                            CSS received email assignment to contact Agent in regards to contraction process.  Savage works for the Midwest INC..   CSS attempted contact to no avail,a voice message was left for Agent.

我设置了我的数据...

   #2 for resolution,what was done by staff.
resolution_corp = corpus(d,text_field = 'Resolution:')

#Then we create the data term matrix / data feature matrix and simultaneously format
#the text for the problem description

dtm_problem <-
  dfm(
    problem_corp,tolower = T,stem = T,remove = c(stopwords('en'),'stated','also','due to','regarding','email','call'),remove_punct = T,)
#Remove less common words
#Check what came out#
textstat_frequency(dtm_problem,n = 20)
#
#### Step 3 Analysis ####


#Then we create the data term matrix / data feature matrix and simultaneously format
#the text for the problem description

dtm_resolution <-
  dfm(
    resolution_corp,'call','can','need'),)


textstat_frequency(dtm_resolution,n = 30)

#We can trim down both corpi
#Here trimming both down to words that appear at least 10 times.
dtm_problem = dfm_trim(dtm_problem,min_termfreq = 10)
dtm_resolution = dfm_trim(dtm_resolution,min_termfreq = 10)
#### Step 3 Analysis ####

#The sparsity is talking about what% of the cells contain the value 0.;
#higher  %  reflects a lot of unique words per cell
dtm_problem
dtm_resolution

以上所有作品

然后我遇到问题的地方是尝试将 Jason Kidd 的回应与其他组的关键性进行比较。特别是 textstat_keyness 对我不起作用

子集似乎有效。

dtm_jksub <- subset.matrix(dtm_resolution,dtm_resolution$"CSS:" == "Jason Kidd")
dtm_bgsub <- subset.matrix(dtm_resolution,dtm_resolution$"CSS:" == "Bobby Gomez")

#### This is not working####
dtm_resolution_cssk = dfm_group(dtm_resolution,"CSS:")
length(dtm_resolution)
length(dtm_jksub)
summary(dtm_resolution$"CSS:")
length(dtm_resolution$"Answer ID")
ts <- textstat_keyness(dtm_jksub,target = "Jason Kidd")[1]
docnames(dtm_jksub)
head(ts,20)    ## view first 20 results


"Error in textstat_keyness.dfm(dtm_jksub,dtm_resolution) : 
  target must be numeric,character or logical"

textstat_keyness 的任何变化都没有对我每次都产生相同的错误

ts <- textstat_keyness(dtm_resolution,dtm_jksub)
ts <- textstat_keyness(dtm_resolution,target = dtm_jksub)
ts <- textstat_keyness(dtm_resolution,target = "Jason Kidd")

"Error in textstat_keyness.dfm(dtm_resolution,target = "Jason Kidd") : 
  target not found in docnames(x)"

之前还有一个关于尺寸不匹配的错误,但我尝试了很多事情,我不记得我是怎么得到这个错误的。

对于附加上下文,我试图遵循本指南https://github.com/ccs-amsterdam/r-course-material/blob/master/tutorials/R_text_3_quanteda.md

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...