Displaying 2 results from an estimated 2 matches for "norm_".
Did you mean:
norm
2008 Jul 14
1
Function to create variables with prefix
...ata.frame, an array of variables, and a prefix
string. It performs a transformation on the variables (e.g. logs and
scales), and creates new variables with the same names as the inputs, but
with the prefix_string prepended.
So, a sample call would look like:
myfunction(mydata, myvariables, "norm_")
And if myvariables contained variables named "var1", "var2", etc., the
function would generate:
mydata$norm_var1
mydata$norm_var2
Thanks,
Moira
[[alternative HTML version deleted]]
2009 Aug 03
2
Scale set of 0 values returns NAN??
...very "Good Thing")
So, on to the question...
I'm scaling data based on groups. I have it working well in a nice
loop. (This WORKS, but if someone has a faster/cleaner way, I'd be
curious.)
#group-wide normailzation
groups <- unique(rawdata$group)
group_names = grep('norm_',names(rawdata))
for(group in groups){
for(name in group_names){
rawdata[rawdata$code==group, name] <-
c(scale(rawdata[rawdata$code==group, name]))
}
}
My problem is that if the particular list of data I'm scoring is all 0,
then scale returns NaN for all of them, s...