简体   繁体   中英

How to work around NAs introduced by coercion in R?

participated in the review for their constructive contributions, and to the international organizations. He urged them to continue to show solidarity with C™te dÕIvoire. In closing, he said that, more than ever, C™te dÕIvoire needed their support in order to attain its objectives ahead of 2020. 

*II. Conclusions and/or recommendations*
127. The recommendations listed below enjoy the support of C™te dÕIvoire: 
127.1 Consider the accession to core human rights instruments (Lesotho); and to other main international human rights treaties that it is not yet a party to (Philippines); 
127.2 Make efforts towards the ratification of the OP-CAT (Chile); 
127.3 Ratify the OP-CAT (Ghana, Tunisia), as recommended previously in 2009 (Czech Republic) and take policy measures to prevent torture and ill-treatment (Estonia);

This is my text, and I want to extract everything after, II. Conclusions and/or recommendations I have tried the following;

x <- substring(text, first = "II. Conclusions and/or recommendations\n")

But Im getting the NAs introduced by coercion. what do I do to make it better?

text <- "participated in the review for their constructive contributions, and to the international organizations. He urged them to continue to show solidarity with C™te dÕIvoire. In closing, he said that, more than ever, C™te dÕIvoire needed their support in order to attain its objectives ahead of 2020. 

*II. Conclusions and/or recommendations*
127. The recommendations listed below enjoy the support of C™te dÕIvoire: 
127.1 Consider the accession to core human rights instruments (Lesotho); and to other main international human rights treaties that it is not yet a party to (Philippines); 
127.2 Make efforts towards the ratification of the OP-CAT (Chile); 
127.3 Ratify the OP-CAT (Ghana, Tunisia), as recommended previously in 2009 (Czech Republic) and take policy measures to prevent torture and ill-treatment (Estonia);"

Use this:

substring(text, regexpr("II.", text))

Or by giving start position as an integer:

substring(text, 300)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM