Message-ID: <1353766067479-4650646.post@n4.nabble.com>
Date: 2012-11-24T14:07:47Z
From: Marcel Curlin
Subject: Performing operations only on selected data
I spent some time on this simple question, also searched the forum,
eventually hacked my way to an ugly solution for my particular problem but I
would like to improve my coding:
I have data of the form:
df <- expand.grid(group=c('copper', 'zinc', 'aluminum', 'nickel'),
condition1=c(1:4))
I would like to add a new data column "condition2", with values equal to the
value of condition1 plus a random number from 0-1 (uniform distribution) if
the value of condition1 is < 1, or just condition1 if the value of
condition1 is > 1. More generally, my interest is in manipulating the values
of condition1 if they meet one or more criteria, or keeping the values the
same otherwise. Thanks for any thoughts!
--
View this message in context: http://r.789695.n4.nabble.com/Performing-operations-only-on-selected-data-tp4650646.html
Sent from the R help mailing list archive at Nabble.com.