Re: [R] select data

2012-05-14 Thread S Ellison
> From: David L Carlson [dcarl...@tamu.edu] >This overwrites the data so you might want to create a copy first. > > example <- data.frame(V1=c(3, -1), V2=c(-2, 4), V3=c(4, 1)) > tf <- ifelse(example<0, TRUE, FALSE) > example[tf] <- NA > apply(example, 1,

Re: [R] select data

2012-05-14 Thread David L Carlson
This overwrites the data so you might want to create a copy first. example <- data.frame(V1=c(3, -1), V2=c(-2, 4), V3=c(4, 1)) tf <- ifelse(example<0, TRUE, FALSE) example[tf] <- NA apply(example, 1, mean, na.rm=TRUE) -- David L Carlson Associate Profes

Re: [R] select data

2012-05-14 Thread Andrea Sica
Thank you all. Really! I have used the following function: apply(dfrm, 1, function(x) mean(x[x>=0]) ) Someone of you even gave me a few interesting explanations about why to use it. Still thank you all. Andrea On Mon, May 14, 2012 at 6:52 PM, David Winsemius wrote: > > On May 14, 2012, at 12:

Re: [R] select data

2012-05-14 Thread David Winsemius
On May 14, 2012, at 12:32 PM, Andrea Sica wrote: Dear all, I am sure it won't be difficult for you!! I need to calculate the average among variables for the single units of my dataset. But, while doing it, I need to do not consider some values. To better explain, think like there are two un

Re: [R] select data

2012-05-14 Thread R. Michael Weylandt
This was actually discussed about a week and a half ago with many good solutions offered, but I think the most idiomatic would be something like this: apply(dataset, 1, function(x) mean(x[x>0])) The reasons I like it: i) It uses the apply function to do the same operation row-wise (that's what t

Re: [R] select data for boxplot

2011-01-10 Thread Peter Ehlers
On 2011-01-10 07:38, David A. wrote: Dear list, havig the following matrix "Value" "Class" 13.001 12.801 11.781 11.702 11.612 11.952 11.552 12.403 11.401 12.271 12.493 11.394 11.804 12.393 12.723 12.183 11.643 11.504 12.81