Hello all,
I'm trying to modify a single column of a data frame to remove randomly half of
the values. I want to do it within a function, but can not assign the modified
column back into the data frame. It was easy and successful without a function,
so I suspect the problem is the call of the single column within the function.
removedata<-function(datafull,var.removed)
{
attach(datafull)
NArandom<-rnorm(n=length(var.removed), mean=0, sd=1)
for (i in 1:length(var.removed))
if(NArandom[i]>0)
var.removed[i]<-"NA"
datamiss<<-datafull
detach(datafull)
}
-- Yuval Sapir, PhDResearcherInstitute of Evolution, Haifa UniversityHaifa,
Israel 3190â
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.