Data frame challenge [🇷 for BE/BA]

posted by wligtenberg – The Netherlands, 2016-12-19 15:29 (3105 d 03:44 ago) – Posting: # 16856
Views: 4,844

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,424 posts in 4,927 threads, 1,674 registered users;
42 visitors (0 registered, 42 guests [including 13 identified bots]).
Forum time: 20:13 CEST (Europe/Vienna)

Complex, statistically improbable things are by their nature
more difficult to explain than
simple, statistically probable things.    Richard Dawkins

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