Skip to content
Prev 175021 / 398506 Next

the by function

Hey,

I have a dataframe with subjects who have watched films. The variables of
interest are Pixel number and Temperature on the face. For each subject
there are 8 films, for each film for each subject I need to measure the mean
number of pixels then merge this vector with the data frame. I have 

mean.pixels<-as.data.frame(by(Final[,5],Final[,1:2],mean)[1:13,])

where column 5 is the pixels variable and 1 and 2 are subject and film
number respectively. Now I can do this, but the average value of the pixel
is usually around 7000. For some reason the machine has only  calculated a
certain second of the film as having say 500 pixels. I need to use the by
function to calculate the mean pixels but I only want it to consider those
values of the pixel variable that are above 1000.

Does anyone know how I can modify the command I already have to make sure
this happens? Sorry it's a bit confusing but I find it hard to explain.