It depends how you stored your missing values. If they are listed as NAs
then
mydataframe$calib <- Count - is.na(stain)*Count
or
mydataframe$calib <- Count*(1 - is.na(stain))
The trick is the boolean 'TRUE' equals 1 in numeric calculations.
--
View this message in context:
http://n4.nabble.c
And here is one more SQL solution. This one uses the window functions
in PostgreSQL and is slightly more compact and even closer to the pure
R version in our prior post. We quote Count so its not regarded as
the reserved word of the same name. Note that if RpgSQL is loaded then
sqldf will automati
Try this ave solution noting that summing Count * (stain == "none")
over each group gives the Count in its stain=="none" row and ave
causes that Count value to be repeated for every row of the group so
we get a vector that can be subtracted from Count:
transform(DF, calib = Count - ave(Count * (st
On Mar 12, 2010, at 5:27 PM, Sam Albers wrote:
Hello all,
I have not been able to find an answer to this problem. I feel like
it might
be so simple though that it might not get a response.
Suppose I have a dataframe like the one I have copied below (minus the
'calib' column). I wish to cre
Hi:
Here's a ddply solution to your problem (package plyr):
library(plyr)
# within group function to apply; assumes that 'none' is first obs in group
# x will be the Count variable in the call...
subt2 <- function(x) x - x[1]
head(df)
rep Count stain
11 1522.0none
21 147.0
Hello,
On Fri, Mar 12, 2010 at 3:27 PM, Sam Albers wrote:
> Hello all,
>
> I have not been able to find an answer to this problem. I feel like it
> might
> be so simple though that it might not get a response.
>
> Suppose I have a dataframe like the one I have copied below (minus the
> 'calib' co
Hello all,
I have not been able to find an answer to this problem. I feel like it might
be so simple though that it might not get a response.
Suppose I have a dataframe like the one I have copied below (minus the
'calib' column). I wish to create a column like calib where I am subtracting
the 'Co
7 matches
Mail list logo