What is the problem and / or difference between reading a file in .txt
and .xlsx
in R?
Strictly speaking, none. Both are valid ways of storing data for analysis, as well as .csv
, .sav
and .dat
are also. The only way to use .xlsx
is almost necessarily to require a spreadsheet editor to view the files, whereas the .txt
format can be read for almost any program installed on the computer.
Reading in .xlsx
Can I have more problems than in .txt
during an analysis?
If you read both files correctly, you should not experience problems during data analysis.
A friend asked me to do everything in .txt
because it's better but I did not understand why.
See the first answer I gave. Also, it may just be his personal preference. In particular, I prefer .txt
and .csv
files because I can read them directly on the terminal, without needing additional programs. Besides, of course, the disk space occupied by files .txt
is smaller than the space occupied by files .xlsx
(although in the present day this is not so relevant).
Another detail is that I have a .xlsx file with 4 tabs and when I rename the tab in the script it continues reading the previous one. Is this due to being Excel?
I can not answer this question because I do not have your code available. So, I can not figure out what could be wrong with it or even the .xlsx
file to read. What I can say is that I use something similar to the code below when working with people who use Excel and this code, when adapted to the needs of each analysis, works very well, even in .xlsx
files with more than one sheet. I just change the parameter sheet=1
to sheet=2
in order to read a different sheet. I do not call them by name, but by the position inside the file .xlsx
.
library(readxl)
read_excel("arquivo.xlsx", sheet=1, col_names=TRUE)
read_excel("arquivo.xlsx", sheet=2, col_names=TRUE)
Note that it is necessary to install the readxl
package before running the above commands.