R - How to return full output to the console (without truncation)

Summary

I use RStudio and my console output is truncated. I cannot find how to stop truncation (I tried searching ?options , as well as googling searches for longer than I would like to admit).

the code

 # 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[1] # Assuming first col is a short name [1] "ThisIsAShortName" # However, when I request a longer name, this returns a truncated version >mycolnames[2] # Assuming second col is a really long name [1] "ThisIsA...Long...Name" 

I want to return a non-truncated version of mycolnames[2] (for example, "ThisIsAReallyReallyReallyReallyReallyLongName")

Thanks to everyone.

- EDIT (see below for details) -

I apologize for everyone! Initially, I had a long name "ThisIsAReallyReallyReallyReallyReallyLongName", but the problem only occurred to me with the long name "Translation Service - What Translation Service?". I think I found the problem. ... not truncated, it replaced unknown characters, such as ? and - on . and ...

Customization

I am on Windows 7 64bit, RStudio version 0.98.1091, R version 3.0.1 (2013-05-16) - "Good sport" with the platform: x86_64-w64-mingw32 / x64 (64-bit), I tried to use "Use Git Bash as a wrapper for Git projects."

myfile.csv

 ThisIsAShortName, Translation Service Info - Which translation service? 23143505, Yes 23143614, No 23143324, Yes 

Char Replacement instead of truncating issue

+5
source share
3 answers

This is the expected behavior of read.csv , not the truncation problem in R. When you have spaces and special characters in the column names of the file, read.csv replaces each of them . if you do not specify check.names = FALSE

Here you can see make.names how read.table creates column names.

 nm <- "Translation Service Info - Which translation service?" make.names(nm) # [1] "Translation.Service.Info...Which.translation.service." 

And here is the corresponding line from read.table

 if (check.names) col.names <- make.names(col.names, unique = TRUE) 
+2
source

In RStudio, use the menu:

Tools > Global Options > Code > Display

In the Console section, set the Limit length of lines displayed in console to: to a certain number, much larger than what is currently set.

Click OK.

+3
source

What about:

 options(width=300) 

Does this solve the problem?

+2
source

Source: https://habr.com/ru/post/1209848/


All Articles