> I have a vector of numbers ranging form 20 to 500. The numbers represent > days since a starting point. The list is not consecutive, some numbers > skipped and some numbers duplicated. I know day 1 was a Monday. I want to > use this vector in a lm but I need to factor by day. I'm wondering how to > assign "Monday" to 22,29,36,..., Tuesday to 23,30,37,... etc...
Here is one way to do it: # make some sample data foo <- c(22,29,23,37) # convert to factor of weekdays foo<- factor(foo %% 7, levels=1:7, labels=c('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')) foo cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan Maximus-von-Imhof-Forum 3 85354 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/ ______________________________________________ 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.