Data frame challenge [🇷 for BE/BA]

posted by wligtenberg – The Netherlands, 2016-12-19 15:29 (2656 d 08:03 ago) – Posting: # 16856
Views: 3,899

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
22,957 posts in 4,819 threads, 1,636 registered users;
87 visitors (0 registered, 87 guests [including 7 identified bots]).
Forum time: 23:32 CET (Europe/Vienna)

Nothing shows a lack of mathematical education more
than an overly precise calculation.    Carl Friedrich Gauß

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