0

I have a csv file which has a lot of text in one of the columns and I when I read it into R, the full text is not present in the column. How can I read a csv file and preserve all of the information in the text column? Here's an example of the problem:

x1 <- rnorm(2)
x2 <- c("This is a really long string and when I run read.csv the full text doesn't appear",
        "This is a really long string and when I run read.csv the full text doesn't appear")
x3 <- rnorm(2)
df <- data.frame(x1,x2,x3)
write.csv(df,"df.csv")
df <- read.csv("df.csv")
pd441
  • 2,644
  • 9
  • 30
  • 41
  • I cannot reproduce this. The column contains the whole text for me. – ottlngr Aug 03 '17 at 15:16
  • How exactly are you checking that all the data is in the column? I'm guessing it's really there but however you are "checking" is not right. – MrFlick Aug 03 '17 at 15:17
  • I think you get confused by checking column `x2` in the R studio Viewer, where you can't see the whole text. However, the whole text is there. – AntoniosK Aug 03 '17 at 15:17
  • I just copied and pasted, ran your code and it works fine: `df[1,3] [1] This is a really long string and when I run read.csv the full text doesn't appear Levels: This is a really long string and when I run read.csv the full text doesn't appear` – sconfluentus Aug 03 '17 at 15:17
  • OK, it seems that in my example the whole text is actually there, However, as @MrFlick pointed out, it doesn't appear in rstudio viewer. HOWEVER, with my real data that I'm working on, the entire information does not appear and it is 'truncated'. – pd441 Aug 03 '17 at 15:20

0 Answers0