Greetings List, I'm having some trouble with the use of the names function in a formula. Below is an example of something that works (i.e first line), and the second line is the same formula which doesn't. I want to be able to reference the column of the dataC table so I can run the variogram iteratively with a loop.
> v<-variogram(A1~1,loc=~x+y, dataC) > v<-variogram(names(dataC[3])~1,loc=~x+y, dataC) Error in model.frame(formula, rownames, variables, varnames, extras, extranames, : invalid variable type Where dataC looks like: x y A1 A2 A3 1 514030 4793587 0.0 7.9 0.1 2 517995 4792516 5.8 5.1 0.0 3 514232 4792210 0.0 6.5 0.0 I though initially that it might need some escape character if quotes are added, and tried the following, but it looks ok. > names(dataC[3]) [1] "A1" > mode(names(dataC[3])) [1] "character" > v<-variogram(as.character(names(dataC[3]))~1,loc=~x+y, dataC) Error in model.frame(formula, rownames, variables, varnames, extras, extranames, : invalid variable type > v<-variogram(as.formula((names(dataC[3]))~1),loc=~x+y, dataC) Error in model.frame(formula, rownames, variables, varnames, extras, extranames, : invalid variable type I'd greatly appreciate any suggestions for fixing this. Thanks again, femke [[alternative HTML version deleted]] ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html