[R] Dealing with special characters at end of line in file

David L Carlson dc@rl@on @ending from t@mu@edu
Sat Dec 15 16:40:08 CET 2018


Each of the backslashes need to be escaped with a backslash:

> ctxt <- "In  Alvarez Cabral street by no. 105.\\000"
> sub("\\\\000", "", ctxt)
[1] "In  Alvarez Cabral street by no. 105."

-------------------------------------------------------
David L. Carlson
Department of Anthropology
Texas A&M University

-----Original Message-----
From: R-help [mailto:r-help-bounces using r-project.org] On Behalf Of J C Nash
Sent: Saturday, December 15, 2018 9:32 AM
To: r-help <r-help using R-project.org>
Subject: [R] Dealing with special characters at end of line in file

I am trying to fix up some image files (jpg) that have comments in them.
Unfortunately, many have had extra special characters encoded.

rdjpgcom, called from an R script, returns a comment e.g.,

"In  Alvarez Cabral street by no. 105.\\000"

I want to get rid of "\\000", but sub seems
to be giving trouble.

> sub("\\000", "", ctxt)
[1] "In  Alvarez Cabral street by no. 105.\\0"

Anyone know how to resolve this?

JN

______________________________________________
R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list