unable to replace white space in R
I am pasting below output of my head command of a BSE stock data column which I use for R programming practice. I googled and tried almost every trick but I am not able to clear white spaces at the end of these values. It seems that all the strings have fixed width of 12 and after characters I see white space which I am unable to remove.
not sure if this will paste in exact same way(e.g. i see a lot of white space after word HDFC in its double quotes) but no technique helped me get rid of those trailing whitespaces.
Base R, without regex:
trimws
stands for "trim white space".
You should be able to fix this with sub
and a regular expression.
Details:
So the sub statement will identify any string of whitespace characters at the end of the string and replace it with the empty string.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.