我想收集用户输入到向量中的字符串,其中一些字符串将是多个单词。我目前正在使用:
terms = scan(strip.white = TRUE, sep = NULL, what = character())
这可行,但是如果用户输入'blue car'
,向量将存储为("blue", "car")
而不是("blue car")
。
我可以通过要求用户输入术语(例如'"blue car"'
用字符串包装)来解决这个问题,但这并不理想。
我已经检查了文档,但看不到任何能解决此问题的方法。有人知道解决方法吗?
非常感谢
如果您更改分隔符,似乎工作正常。
terms = scan(strip.white = TRUE, sep = '\n', what = character())
1: blue
2: car
3: blue cars
4:
Read 3 items
terms
#[1] "blue" "car" "blue cars"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句