Data frame challenge [🇷 for BE/BA]

posted by wligtenberg – The Netherlands, 2016-12-19 15:29 (3477 d 15:57 ago) – Posting: # 16856
Views: 5,871

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,655 posts in 4,993 threads, 1,572 registered users;
379 visitors (0 registered, 379 guests [including 27 identified bots]).
Forum time: 08:26 CEST (Europe/Vienna)

The real struggle is not between the right and the left
but between the party of the thoughtful
and the party of the jerks.    Jimmy Wales

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