a=as.matrix(a)
a=a %>% replace_na("NA")
rror in stop_vctrs()
:
! Can't convert replace
to match type of data
<double[,13]>.
Run rlang:last_error()
to see where the error occurred.
Backtrace:
<fn>
()replace_na用于替换data中的na值,作为参数传入data时,要用一个数字,而不能用字符类型。
如:
library(tidyr)
a=c(3,5,NA,0)
a=as.matrix(a)
a=a %>% replace_na(0.1)
a