Remove the "" around the options. You also have to put it in a sapply, as switch only works on single values. But I wouldn't call this optimal...
elevation.DM <-sapply(Population,switch, CO= 2169, CN = 1121, Ga =500, KO = 2500, Mw = 625, Ng = 300 ) Cheers Joris On Wed, May 26, 2010 at 9:04 PM, Ian Dworkin <idwor...@msu.edu> wrote: > > # Dennis Murphy suggested switch.. I have not gotten it working yet.. > > elevation.DM <- switch(Population, "CO"= 2169, "CN" = 1121, "Ga" = > 500, "KO" = 2500, "Mw" = 625, "Ng" = 300 ) > > > > > > -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent tel : +32 9 264 59 87 joris.m...@ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.