Organize data in excel

Asked

Viewed 126 times

2

I have a file with 59 observations and with 93 variables in Excel file and turned to .csv. to create the table in R, however my 93 variables appear in the same column. How do I make them appear apart?

3 answers

2

Try to rotate the command

read.table(file="nomedoarquivo.csv", header=T, sep=",") 

This command will work if your file has columns named. If the columns are not named, replace the header=T argument with header=F.

1

Read straight from Excel using the package readxl

read_excel("arquivo.xlsx")

You can still use the argument sheet if your spreadsheet has multiple tabs. Read the help using ?read_excel. And before all this don’t forget to install the package: install.packages("readxl").

Direct reading excel has the advantage of already reading numbers, dates and strings correctly without you having to save the .csv.

1

If you saved . csv from an excel in English, you must use read.csv2. In relation to read.csv, it changes because it uses sep = ";" and dec = ",", which is the non-American standard.

It’s worth using too stringsAsFactors = FALSE to avoid clutter with non-numeric columns:

read.csv2("arquivo.csv", stringsAsFacotrs = FALSE)

Browser other questions tagged

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