I'm using RStudio and my output on the Console gets truncated. I can't find how to stop the truncation (I tried searching
# Load File
>myfile <- read.csv(file="C:\\Users\\wliu\\Desktop\\myfile.csv",
sep=",", header=TRUE, stringsAsFactors=FALSE, skip=2)
# Get my column names
>mycolnames <- colnames(myfile)
# When I request a shorter name, this returns the full name
>mycolnames # Assuming first col is a short name
# However, when I request a longer name, this returns a truncated version
>mycolnames # Assuming second col is a really long name
ThisIsAShortName, Translation Service Info - Which translation service?
This is expected behavior by
read.csv, not a truncation problem in R. When you have spaces and special characters in the column names of a file,
read.csv replaces each of them with a
. unless you specify
check.names = FALSE
Here's a glimpse at
make.names, which is how
read.table produces the column names.
nm <- "Translation Service Info - Which translation service?" make.names(nm) #  "Translation.Service.Info...Which.translation.service."
And here's the relevant line from
if (check.names) col.names <- make.names(col.names, unique = TRUE)