Replace data in text

Asked

Viewed 46 times

0

I am working with a text taken from the Gutemberg project. It is a book. I need to mark the beginning of each chapter on a regular basis. In the current format, they are identified only with uppercase Roman numerals. For example:

I Introduction

II Trabalho

I needed him to turn into:

Chapter 2 - Work

Chapter 1 - Introduction

In total there are 160 chapters

I put together a list of Roman numbers from 1 to 160 to be replaced in the text by another list, which would read Chapter 1...Chapter n. But I could not find a role in the R that would help me to make such a replacement

Any tips on how to proceed?

grateful

  • 4

    What is the book? Not all books of the Gutenberg project have chapters numbered with Roman numerals.

  • That’s why I made the list. It’s Dom Casmurro. I want to replace the regular expression so I can search the text Thanks @Ruibarradas!

  • 1

    can you edit the question with a reproducible example? For me, it was not clear.

  • 1

    It would be great if you edited the question to make it clear. Anyway, there are functions in the R, like the roman2int package gtools that convert Roman numerals to integers.

  • Hello I already made the edition! Thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.