0

I am trying to import a dataset from Excel and all of my titles for the columns in excel are formatted as text. When I import them to R they become doubles and I cant covert the data into longframe because of it. I'm not sure why as I've imported other seemingly identical files wihtout issue but now I cant import anything without half of the names being considered "double" while others are considered "character"

I can only figure out how to change them by manually changing each column to character as I import

Rebecca
  • 1
  • 1
  • What command do you use to import the data? – Andre Wildberg Oct 27 '22 at 19:53
  • I have tried to both write out the script as "library(readxl) DW75 <- read_excel("~/Downloads/75dw.xlsx", sheet = "Sheet2") View(DW75)" as well as using R-studios import from excel function – Rebecca Oct 27 '22 at 19:57
  • you could try manually changing using df$name <- as.character(df$name) or df$name <- as.factor(df$name) – hachiko Oct 27 '22 at 19:58
  • If there are any letters or non-digit characters in your data, R may interpret that as a character field. You can convert many cols to numeric at once, though, like this: https://stackoverflow.com/questions/22772279/converting-multiple-columns-from-character-to-numeric-format-in-r – Ben Oct 27 '22 at 20:00
  • did you check to see how those columns or cells (for the headers) are formatted in Excel? – Ido Sarig Oct 27 '22 at 20:00
  • Also see if this may help https://stackoverflow.com/questions/31633891/specifying-column-types-when-importing-xlsx-data-to-r-with-package-readxl/34015430#34015430 – Andre Wildberg Oct 27 '22 at 20:02
  • There is a `col_types` argument to `read_excel` where you can specify "text". But it would help to see some data so we can figure out why this is happening. – neilfws Oct 27 '22 at 21:03

0 Answers0