Bioequivalence and Bioavailability Forum

Main page Policy/Terms of Use Abbreviations Latest Posts

 Log-in |  Register |  Search

Back to the forum  Query: 2018-05-28 01:24 CEST (UTC+2h)

Data frame challenge [R for BE/BA]

posted by ElMaestro - Denmark, 2016-12-17 19:40  - Posting: # 16850
Views: 2,448

Hi all,

I am struggling with import of a data from a file having a structure like:

Now, I would like R to understand that
1. we are not dealing with factors, the data frame is a series of numeric vectors.
2. Whenever we encounter something non-numeric such as Apple and Banana we will set it to zero.

So I have this solution:
A=read.table("SomeFile.csv", header=T)
for (i in 1:ncol(A))

A is now effectively a matrix, or we can as.matrix or matrix it directly.
And although it works, it is painfully unreadable and it also throws warnings (coercion).

I am looking for a solution that is much more readable and not throwing warnings (and we are not going to discuss suppression of warnings, please, it sends shivers down my spine to do it). Regarding readability: I am fine with a solution that takes more coding/more lines, so this is not a competition in doing a lot of stuff in a single line. Single line = more elegance, to some = less readbility to a simpleton like me.

Can anyone help here?

Many thanks.

“A ten-year, double-blind study from the Mayo Clinic concluded that even in late stages of dementia, the last to go is the lobe of the brain in charge of cafeteria layout.” (Serge Storms/Tim Dorsey).

Best regards,

- Bootstrapping is a relatively new hobby of mine. I am only 30 years late to the party.

Complete thread:

Back to the forum Activity
 Mix view
Bioequivalence and Bioavailability Forum |  Admin contact
18,295 posts in 3,890 threads, 1,165 registered users;
7 users online (0 registered, 7 guests).

To know that we know what we know,
and to know that we do not know what we do not know,
that is true knowledge.    Nicolaus Copernicus

BEBAC Ing. Helmut Schütz