Hi Ivan, Thanks for your solution.
Is there any way to remove all possible "Unicode character" that may be present in the array at once? On Mon, Mar 3, 2025 at 12:18 PM Ivan Krylov <ikry...@disroot.org> wrote: > > В Mon, 3 Mar 2025 12:08:43 +0530 > Christofer Bogaso <bogaso.christo...@gmail.com> пишет: > > > dat2 = c("-24.437285333333300", "4.850695000000000", > > "-1.918495666666670", > > > > "2.641818000000000", "6.777527666666670", "3.208084000000000", > > > > "4.193287666666670", "0.378257666666667", "4.658955000000000", > > > > "-9.881474000000000") > > > > Now when I try to convert this data to numeric, I got NA as below > > > > > as.numeric(dat2) > > > > [1] -24.4372853 4.8506950 -1.9184957 2.6418180 6.7775277 > > 3.2080840 > > > > [7] 4.1932877 0.3782577 4.6589550 NA > > There's an invisible Unicode character in there, U+FEFF ZERO WIDTH > NO-BREAK SPACE: > > > dat2 |> tail(1) |> tools::showNonASCII() > 1: <ef><bb><bf>-9.881474000000000 > > Try as.numeric(gsub('\ufeff', '', dat2)). > > -- > Best regards, > Ivan ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.