Skip to content
Back to formatted view

Raw Message

Message-ID: <20120208105419.16090@gmx.net>
Date: 2012-02-08T10:54:19Z
From: Johannes Radinger
Subject: remove NAs from list collectively

Hi,

I am importing dataframe from an Excel file (xlsx package).
The columns contain acutally measurements for single species and
the column-length is of variable. As it is imported as a dataframe the difference to the "longest" column is filled with NA.
To explain it with an example, my dataframe looks like:

A <- seq(1:10)
B <- c(seq(1:5),rep(NA,5))
C <- c(seq(1:7),rep(NA,3))

df <- data.frame(A,B,C)


Now I'd like to transform that to a list of vectors of different length. Therefore I need to remove the NAs collectively from the single columns...I tried for transforming:

as.list(df)

...but I don't know how can I remove the NAs now? as.list doesn't take na.rm=TRUE argument. Is there any ready function to perform such tasks?
Or is there a better way then to assign the data to a list of vectors with variable length?

/johannes
--