Hi,
I have a dataframe and want to remove columns from it
that are populated with a similar value (for the total
column) (the variation of that column is 0). Is there an
easier way than to calculate the statistics and then
remove them by hand?
A - runif(100)
B - rep(1,100)
C - rep(2.42,100)
D -
On Thu, May 31, 2012 at 8:27 AM, Johannes Radinger jradin...@gmx.at wrote:
Hi,
I have a dataframe and want to remove columns from it
that are populated with a similar value (for the total
column) (the variation of that column is 0). Is there an
easier way than to calculate the statistics and
Hi Johannes,
Try
df[, !apply(df, 2, function(x) sd(x, na.rm = TRUE) 1e-10)]
HTH,
Jorge.-
On Thu, May 31, 2012 at 9:27 AM, Johannes Radinger wrote:
Hi,
I have a dataframe and want to remove columns from it
that are populated with a similar value (for the total
column) (the variation of
On Thu, May 31, 2012 at 8:52 AM, J Toll jct...@gmail.com wrote:
for (i in seq(ncol(df), 1))
if (length(unique(df[, i])) == 1) {
df[, i] - NULL
}
Here's a similar method employing a more functional approach:
df[, apply(df, 2, function(x) length(unique(x)) 1)]
James
with name B.
I have to think about this
/Johannes
Original-Nachricht
Datum: Thu, 31 May 2012 09:20:27 -0500
Von: J Toll jct...@gmail.com
An: Johannes Radinger jradin...@gmx.at
CC: R-help@r-project.org
Betreff: Re: [R] Remove columns from dataframe based on their statistics
, 31 May 2012 09:20:27 -0500
Von: J Toll jct...@gmail.com
An: Johannes Radinger jradin...@gmx.at
CC: R-help@r-project.org
Betreff: Re: [R] Remove columns from dataframe based on their statistics
On Thu, May 31, 2012 at 8:52 AM, J Toll jct...@gmail.com wrote:
for (i in seq(ncol(df), 1
:52 AM
Subject: Re: [R] Remove columns from dataframe based on their statistics
On Thu, May 31, 2012 at 8:27 AM, Johannes Radinger jradin...@gmx.at wrote:
Hi,
I have a dataframe and want to remove columns from it
that are populated with a similar value (for the total
column) (the variation
7 matches
Mail list logo