Peter Chung
Peter Chung

Reputation: 1122

Import an Excel file that has newline \n as string

I have an Excel file and a cell which contains a newline.

1. , : Yes, number of years: ______,\n    : Year at which exposure stopped: _______

After I used the rio package to import the Excel file, I have a double backslash:

 df <- rio::import("excel_file.xlsx")

 print(df[1,])

"1. , : Yes, number of years: ______,\\n    : Year at which exposure stopped: _______" 

I would like to import the string as \n without have to use the gsub/sub function, I tried to change the line into:

1. , : Yes, number of years: ______,'\n'    : Year at which exposure stopped: _______
1. , : Yes, number of years: ______,/n    : Year at which exposure stopped: _______
1. , : Yes, number of years: ______,\\n    : Year at which exposure stopped: _______

but it didn't work.

My desired output is to have \n after running rio::import:

"1. , : Yes, number of years: ______,\n    : Year at which exposure stopped: _______"

Do you have any advice?

Upvotes: 1

Views: 275

Answers (0)

Related Questions