나는 당신의 예를 재현했다 생각하지 않았다, 그래서 당신이 게시 된 것을 포함 할 수 그것을 편집하지만, 이름이 일치 할 경우 나도 몰라 :
txtvec <- structure(list(`'511' ` = "MR Smith: Mr Speaker, I like the spirit in which we are agreeing on this. The administration of FUFA is present here. FUFA could be used as a conduit, but the intention of what hon. Beti Kamya brought up and what hon. Rose Namayanja has said was okufuwa - just giving a token of appreciation to the players who achieved this.\"",
`'513' ` = "MR Gordon: Thank you very much, Mr Speaker. FUFA is an organisation and the players are the ones who got the cup for us. To promote motivation in all activities, not only football, you should remunerate people who have done well. In this case, we have heard about FUFA with their problems. They have not paid water bills and they can take this money to pay the water bills. If we agree that this money is supposed to go to the players and the coaches, then when it goes there they would know the amount and they will sit among themselves and distribute according to what we will have given. (Applause) I thank you.\"",
`'515' ` = "MR Catalano: Mr Speaker, I want to give information to my dear colleagues. The spirit is very good but you must be mindful that the administration of FUFA is what has made this happen. The money to the players. That indicates to you that FUFA is very trustworthy. This is not the old FUFA we are talking about.\""), .Names = c("'511'\t",
"'513'\t", "'515'\t"))
을 그래서 그것은 단지 문제 나 정규 표현식을 실행하고 그 결과를 도표화하면 다음과 같습니다.
> table(sapply(txtvec, function(x) sub("(^MR.+)\\:.+", "\\1", x)))
#MR Catalano MR Gordon MR Smith
1 1 1
이름이 원래 구조에없는 것으로 나타났습니다. 이러한 쉽게 할 수 있을까 (이 코드를 사용할 수 있습니다 줄에 80 자와 포장 장치에 차지하는
txtvec <- c("\"511\"\t\"\nMR Smith: Mr Speaker, I like the spirit in which we are agreeing on this. The administration of FUFA is present here. FUFA could be used as a conduit, but the intention of what hon. Beti Kamya brought up and what hon. Rose Namayanja has said was okufuwa - just giving a token of appreciation to the players who achieved this.\"",
"\"513\"\t\"\nMR Gordon: Thank you very much, Mr Speaker. FUFA is an organisation and the players are the ones who got the cup for us. To promote motivation in all activities, not only football, you should remunerate people who have done well. In this case, we have heard about FUFA with their problems. They have not paid water bills and they can take this money to pay the water bills. If we agree that this money is supposed to go to the players and the coaches, then when it goes there they would know the amount and they will sit among themselves and distribute according to what we will have given. (Applause) I thank you.\"",
"\"515\"\t\"\nMR Catalano: Mr Speaker, I want to give information to my dear colleagues. The spirit is very good but you must be mindful that the administration of FUFA is what has made this happen. The money to the players. That indicates to you that FUFA is very trustworthy. This is not the old FUFA we are talking about.\""
)
table(sapply(txtvec, function(x) sub(".+\\n(MR.+)\\:.+", "\\1", x)))
#MR Catalano MR Gordon MR Smith
# 1 1 1
는 "선"의 수를 계산하려면 다음이 익명의 벡터 다른 버전과 약간 수정 된 정규식) 함수로 변환 :
sapply(txtvec, function(tt) 1+nchar(tt) %/% 80)
#[1] 5 8 4
줄을 구하기 위해선 아무것도 얻을 수 없습니다 (countLines, length (count.fields()도 작동하지 않습니다). 나는 문자 수를 얻기 위해 nchar()을 사용했고 단어 수를 얻을 수있다 : sapply (gregexpr ("\\ W +", statement), function (x) sum (x> 0)) + 1 각 문장은 Mr. Smith/Gordon/Catalano가 전달한 것. 최악의 경우 양식화 된 변환을 사용할 수 있습니다. 한 줄에 10-12 단어로 가정하면 단어를 세 어서 나눌 수 있지만 조금 더 형식적인 것이 있는지 궁금해하고 있습니다. –
이전 질문 및 답변에 무엇이 잘못 되었습니까? http://stackoverflow.com/questions/15326689/how-to-count-text-lines-in-r – Arun