Displaying 1 result from an estimated 1 matches for "removedata".
Did you mean:
remotedata
2007 Dec 15
1
modify a data.frame within a function
...y 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 Evolu...