Why does R produce an extra space at the start of the first expression's result, but there is no such extra space at the start of the second expression's result? I am using R 2.13.1.
> 20:30
[1] 20 21 22 23 24 25 26 27 28 29 30
> 20:24
[1] 20 21 22 23 24
gsub() function is used to remove the space by removing the space in the given string.
Find Whitespace Using Regular Expressions in Java The most common regex character to find whitespaces are \s and \s+ . The difference between these regex characters is that \s represents a single whitespace character while \s+ represents multiple whitespaces in a string.
String result = str. trim(); The trim() method will remove both leading and trailing whitespace from a string and return the result.
Use the . strip() method to remove whitespace and characters from the beginning and the end of a string. Use the . lstrip() method to remove whitespace and characters only from the beginning of a string.
Given the encouraging comments, reposted as an answer.
OMG R is a total FAIL! Run away! :-)
Seriously, try 1:50
amd then 1:1000
.
It appears to be deliberate, to get the [1]
tag on the first line of output to be right-justified with the [24]
(or whatever value is the wrap on your console) tag on the second line of output. Josh O'Brien went further and observed a double-indent when indices went up to 3 digits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With