Data frame challenge [🇷 for BE/BA]

posted by wligtenberg – The Netherlands, 2016-12-19 15:29 (2975 d 08:13 ago) – Posting: # 16856
Views: 4,517

I am a fan of the data.table package. So my answer would be this:

library(data.table)
a <- fread("./test.csv", colClasses = "character")
a <- a[, lapply(.SD, as.numeric)]
a <- a[, lapply(.SD, function(x){ifelse(is.na(x), 0, x)})]


You need to do it in two steps, else the class stays character.

Complete thread:

UA Flag
Activity
 Admin contact
23,379 posts in 4,913 threads, 1,661 registered users;
250 visitors (0 registered, 250 guests [including 21 identified bots]).
Forum time: 23:42 CET (Europe/Vienna)

Science is what you know.
Philosophy is what you don’t know.    Bertrand Russell

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5