How to avoid space while reading .txt file

久未见 提交于 2019-12-12 03:29:00

问题


I am trying to read a file which has a column of + and - but apparently associated with a space after that. In anyway I read (read.csv or read.table or read_excel that file I pick up the space after.

For example:

df = data.frame(x = c('a', 'b', 'c'), y = c('+ ', "- ", "+ "))
df
  x  y
1 a + 
2 b - 
3 c + 

Now, is there a way to specifically instruct not to pick up space after the value in read.csv or read_excel

Or is there a way to clean up the spaces after reading into a dataframe?

来源:https://stackoverflow.com/questions/43433491/how-to-avoid-space-while-reading-txt-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!