我有一些列通过Excel工作表在值中包含$
。
[1] "$5,656.50" "$3,179.20" "$1,391.40" "$2,376.30" "$1,476.80" "$712.30" "$5,327.80"
[8] "$3,642.70" "$1,506.00" "$7,923.70" "$4,782.30" "$1,392.40" "$229.30" "$1,106.90"
[15] "$1,553.30" "$3,492.30" "$4,029.40" "$1,646.70" "$6,013.90" "$19,928.00" "$4,260.60"
此列中有> 10,000行,由于“$”,R会将其作为字符读取。
我试过
gsub( "$", " ", thedata$col.with.dollar.signs)
用空格替换美元符号,但它不起作用。
非常感谢任何其他想法。
答案 0 :(得分:0)
这个可能:
substring(thedata$col.with.dollar.signs, 2)
例如:
vec <- c("$5,656.50", "$3,179.20", "$1,391.40")
substring(vec,2)
#[1] "5,656.50" "3,179.20" "1,391.40"