Folks, I have a very basic question. The solution eludes me perhaps because of my own lack of creativity. I am not attaching a fully reproducible session because the issue may well be becuase of the way the data file is, and the data file is large (and I don't know whether I can legally distribute it). If people can suggest things that might be wrong in my data or the way that I am reading it, I would be most grateful. I get the following error message in the session quoted at the end of this email: / not meaningful for factors in: Ops.factor(BookValuePS, Price) As you can see in that some session, I check that the two vectors being divided are numeric. I also check that the divisor is not 0 at any index. I also believe that this is not because of the NA's in the data. My question is, what are other "problems" that can cause the / operator to not be meaningful? I did try some simple examples to try to get the same error. However, I am not sure how to put the same NA's that one gets from read.table() into a vector:> a <- c(1, 2, 3, NA); > a[1] 1 2 3 NA> b <- c( 1, 2, 3, 4); > c <- b / a; > b[1] 1 2 3 4> a <- c(1, 2, 3, ); > c <- b/a;Warning message: longer object length is not a multiple of shorter object length in: b/a ******** Quoted Session below ******** > explainPriceSimplified <- read.table("combinedClean.csv", + sep = ",", header=TRUE);> attach(explainPriceSimplified); > summary(explainPriceSimplified);Symbol Date Price EPS BookValuePS XL : 98 Min. :19870630 22 : 61 Min. :-1.401e+05 Min. :-6.901e+05 ZION : 97 1st Qu.:19910930 26.5 : 61 1st Qu.: 4.650e-01 1st Qu.: 3.892e+00 YRCW : 72 Median :19960331 27.5 : 58 Median : 1.060e+00 Median : 7.882e+00 AA : 71 Mean :19957688 30 : 58 Mean :-1.534e+01 Mean : 1.515e+02 ABS : 71 3rd Qu.:20001231 25 : 56 3rd Qu.: 1.890e+00 3rd Qu.: 1.444e+01 ABT : 71 Max. :20041231 (Other):29561 Max. : 5.309e+03 Max. : 3.366e+06 (Other):29624 NA's : 249 NA's : 2.460e+02 NA's : 4.760e+02 FiscalQuarterRep F12MRet 2004/2F: 482 Min. :-100.00 2003/4F: 471 1st Qu.: -8.82 2004/1F: 470 Median : 10.57 2004/3F: 470 Mean : 13.36 2003/3F: 464 3rd Qu.: 31.12 2003/2F: 463 Max. :4700.00 (Other):27284 NA's : 463.00> mode(Price)[1] "numeric"> mode(EPS)[1] "numeric"> mode(BookValuePS)[1] "numeric"> BP <- BookValuePS / Price ;Warning message: / not meaningful for factors in: Ops.factor(BookValuePS, Price)> which(Price==0)numeric(0)>-- -- Vivek Satsangi Student, Rochester, NY USA
But factors are numeric: mode(factor(1:3)) # numeric so the numerator or denominator are likely a factor. Try using str and class rather than mode to investigate this. On 1/15/06, Vivek Satsangi <vivek.satsangi at gmail.com> wrote:> Folks, > I have a very basic question. The solution eludes me perhaps because > of my own lack of creativity. I am not attaching a fully reproducible > session because the issue may well be becuase of the way the data file > is, and the data file is large (and I don't know whether I can legally > distribute it). If people can suggest things that might be wrong in my > data or the way that I am reading it, I would be most grateful. > > I get the following error message in the session quoted at the end of > this email: > / not meaningful for factors in: Ops.factor(BookValuePS, Price) > > As you can see in that some session, I check that the two vectors > being divided are numeric. I also check that the divisor is not 0 at > any index. I also believe that this is not because of the NA's in the > data. My question is, what are other "problems" that can cause the / > operator to not be meaningful? > > I did try some simple examples to try to get the same error. However, > I am not sure how to put the same NA's that one gets from > read.table() into a vector: > > a <- c(1, 2, 3, NA); > > a > [1] 1 2 3 NA > > b <- c( 1, 2, 3, 4); > > c <- b / a; > > b > [1] 1 2 3 4 > > a <- c(1, 2, 3, ); > > c <- b/a; > Warning message: > longer object length > is not a multiple of shorter object length in: b/a > > > ******** Quoted Session below ******** > > explainPriceSimplified <- read.table("combinedClean.csv", > + sep = ",", header=TRUE); > > attach(explainPriceSimplified); > > summary(explainPriceSimplified); > Symbol Date Price EPS > BookValuePS > XL : 98 Min. :19870630 22 : 61 Min. :-1.401e+05 > Min. :-6.901e+05 > ZION : 97 1st Qu.:19910930 26.5 : 61 1st Qu.: 4.650e-01 > 1st Qu.: 3.892e+00 > YRCW : 72 Median :19960331 27.5 : 58 Median : 1.060e+00 > Median : 7.882e+00 > AA : 71 Mean :19957688 30 : 58 Mean :-1.534e+01 > Mean : 1.515e+02 > ABS : 71 3rd Qu.:20001231 25 : 56 3rd Qu.: 1.890e+00 > 3rd Qu.: 1.444e+01 > ABT : 71 Max. :20041231 (Other):29561 Max. : 5.309e+03 > Max. : 3.366e+06 > (Other):29624 NA's : 249 NA's : 2.460e+02 > NA's : 4.760e+02 > FiscalQuarterRep F12MRet > 2004/2F: 482 Min. :-100.00 > 2003/4F: 471 1st Qu.: -8.82 > 2004/1F: 470 Median : 10.57 > 2004/3F: 470 Mean : 13.36 > 2003/3F: 464 3rd Qu.: 31.12 > 2003/2F: 463 Max. :4700.00 > (Other):27284 NA's : 463.00 > > mode(Price) > [1] "numeric" > > mode(EPS) > [1] "numeric" > > mode(BookValuePS) > [1] "numeric" > > BP <- BookValuePS / Price ; > Warning message: > / not meaningful for factors in: Ops.factor(BookValuePS, Price) > > which(Price==0) > numeric(0) > > > > > -- > -- Vivek Satsangi > Student, Rochester, NY USA > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
The mode of a factor is numeric, so your test does not do what you think it does. is.numeric() is the recommended test of a vector being numeric. I have no idea where you got the idea that mode() was a useful test (perhaps you could give us the reference you used), but it rather rarely is (typeof is usually more informative).>From the summary quoted, Price is clearly a factor. Test it withis.factor. On Sun, 15 Jan 2006, Vivek Satsangi wrote:> Folks, > I have a very basic question. The solution eludes me perhaps because > of my own lack of creativity. I am not attaching a fully reproducible > session because the issue may well be becuase of the way the data file > is, and the data file is large (and I don't know whether I can legally > distribute it). If people can suggest things that might be wrong in my > data or the way that I am reading it, I would be most grateful. > > I get the following error message in the session quoted at the end of > this email: > / not meaningful for factors in: Ops.factor(BookValuePS, Price) > > As you can see in that some session, I check that the two vectors > being divided are numeric.(see the request above for your reference here)> I also check that the divisor is not 0 at any index. I also believe that > this is not because of the NA's in the data. My question is, what are > other "problems" that can cause the / operator to not be meaningful?Why not test for factor, since that is what the very helpful error message told you the problem was?> I did try some simple examples to try to get the same error. However, > I am not sure how to put the same NA's that one gets from > read.table() into a vector: >> a <- c(1, 2, 3, NA); >> a > [1] 1 2 3 NA >> b <- c( 1, 2, 3, 4); >> c <- b / a; >> b > [1] 1 2 3 4 >> a <- c(1, 2, 3, ); >> c <- b/a; > Warning message: > longer object length > is not a multiple of shorter object length in: b/a > > > ******** Quoted Session below ******** > > explainPriceSimplified <- read.table("combinedClean.csv", > + sep = ",", header=TRUE); >> attach(explainPriceSimplified); >> summary(explainPriceSimplified); > Symbol Date Price EPS > BookValuePS > XL : 98 Min. :19870630 22 : 61 Min. :-1.401e+05 > Min. :-6.901e+05 > ZION : 97 1st Qu.:19910930 26.5 : 61 1st Qu.: 4.650e-01 > 1st Qu.: 3.892e+00 > YRCW : 72 Median :19960331 27.5 : 58 Median : 1.060e+00 > Median : 7.882e+00 > AA : 71 Mean :19957688 30 : 58 Mean :-1.534e+01 > Mean : 1.515e+02 > ABS : 71 3rd Qu.:20001231 25 : 56 3rd Qu.: 1.890e+00 > 3rd Qu.: 1.444e+01 > ABT : 71 Max. :20041231 (Other):29561 Max. : 5.309e+03 > Max. : 3.366e+06 > (Other):29624 NA's : 249 NA's : 2.460e+02 > NA's : 4.760e+02 > FiscalQuarterRep F12MRet > 2004/2F: 482 Min. :-100.00 > 2003/4F: 471 1st Qu.: -8.82 > 2004/1F: 470 Median : 10.57 > 2004/3F: 470 Mean : 13.36 > 2003/3F: 464 3rd Qu.: 31.12 > 2003/2F: 463 Max. :4700.00 > (Other):27284 NA's : 463.00 >> mode(Price) > [1] "numeric" >> mode(EPS) > [1] "numeric" >> mode(BookValuePS) > [1] "numeric" >> BP <- BookValuePS / Price ; > Warning message: > / not meaningful for factors in: Ops.factor(BookValuePS, Price) >> which(Price==0) > numeric(0)-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Hi there, This will sound very stupid because I just started using R but I see you had similar problems. I just loaded a very large dataset (2950*6602) from csv into R. The format is ticker=row, date=column. Every time I want to compute basic operations, R returns "In Ops.factor: not meaningful for factors" I believe it is because R does not read the data as numbers but I am not sure. Can anybody help? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124697.html Sent from the R help mailing list archive at Nabble.com.
On May 3, 2010, at 6:22 PM, vincent.deluard wrote:> > Hi there, > > This will sound very stupid because I just started using R but I see > you had > similar problems. > > I just loaded a very large dataset (2950*6602) from csv into R. The > format > is ticker=row, date=column.Not a particularly precise description of what is in the data.> Every time I want to compute basic operations, R returns "In > Ops.factor: not > meaningful for factors"Code .... we want to see code. All of it.> > I believe it is because R does not read the data as numbersProbably true. Were they dates or numbers?> but I am not > sure. Can anybody help?I generally read in my data with read.table( ,,,,, as.is=TRUE, stringsAsFactors=FALSE, ....) and then convert the columns that I know should be numeric with as.numeric. If all of your columns should have been numeric, you might use the colClasses argument, perhaps along these lines: rd.obj <- read.csv(file="something", colClasses= rep("numeric", <number-of-columns>) ) -- David Winsemius, MD West Hartford, CT
Hi David, Thanks for the prompt answer. In this file, I have cut the data to the first 15 columns. Here is the code: t2 <- read.csv(''Test2.csv'', sep=",", header=TRUE)> Test2[2,2][1] 18.72 1994 Levels: 0.24 0.33 0.49 0.53 0.65 0.67 0.72 0.76 0.88 0.9 0.94 ... 98.88> Test2[2,2]+1[1] NA Warning message: In Ops.factor(Test2[2, 2], 1) : + not meaningful for factors The funny thing is that the same commands work normally for a shorter matrix – just the 1st 6 rows and columns. Which led me to think it had to do with the blank cells. But typing : Test2 <- read.csv(''Test2.csv'', sep=",", header=TRUE, na.strings=" ") does not help. Your help is infinitely appreciated. -------------------------------------------- Vincent Deluard <mailto:Vincent.Deluard@TrimTabs.com> Vincent.Deluard@TrimTabs.com Global Equity Strategist, CFA Charter Award Pending TrimTabs Investment Research 40 Wall Street, 28th Floor New York, NY 10005 Phone: (+1) 646-512-5616 From: David Winsemius [via R] [mailto:ml-node+2124710-750256529-90534@n4.nabble.com] Sent: Monday, May 03, 2010 6:35 PM To: vincent.deluard Subject: Re: / Operator not meaningful for factors On May 3, 2010, at 6:22 PM, vincent.deluard wrote:> > Hi there, > > This will sound very stupid because I just started using R but I see > you had > similar problems. > > I just loaded a very large dataset (2950*6602) from csv into R. The > format > is ticker=row, date=column.Not a particularly precise description of what is in the data.> Every time I want to compute basic operations, R returns "In > Ops.factor: not > meaningful for factors"Code .... we want to see code. All of it.> > I believe it is because R does not read the data as numbersProbably true. Were they dates or numbers?> but I am not > sure. Can anybody help?I generally read in my data with read.table( ,,,,, as.is=TRUE, stringsAsFactors=FALSE, ....) and then convert the columns that I know should be numeric with as.numeric. If all of your columns should have been numeric, you might use the colClasses argument, perhaps along these lines: rd.obj <- read.csv(file="something", colClasses= rep("numeric", <number-of-columns>) ) -- David Winsemius, MD West Hartford, CT ______________________________________________ [hidden email] 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. _____ View message @ http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124710.html To unsubscribe from Re: / Operator not meaningful for factors, click < (link removed) AwNTU4Mzk3> here. -- View this message in context: http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124747.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]]
Check you input data. You have some non-numeric characters in columns where you are expecting numerics. The parameter is stringsAsFactors=FALSE You had it spelt wrong. After reading in your data, do the conversion to numeric and then examine which locations contain NA; this will point you to the problem line in your input. Also if you use 'colClasses', I think it will error the offending line. On Mon, May 3, 2010 at 7:21 PM, vincent.deluard < vincent.deluard@trimtabs.com> wrote:> > Hi John, > > > > Thanks for responding so quickly. > > > > So I tried: > > > > Test2[1:3,1:3]) > > 'data.frame': 3 obs. of 3 variables: > > $ Date : Factor w/ 2480 levels "A UN Equity",..: 1033 2396 613 > > $ X4.20.2010: Factor w/ 1994 levels "0.24","0.33",..: 953 497 1814 > > $ X4.19.2010: Factor w/ 1957 levels "0.24","0.33",..: 933 486 1779 > > > > But I am not sure how to interpret it. > > > > The stringAsFactors = False option did not work either. > > > > > Test2 <- read.table('Test2.csv', sep=",", header=TRUE, > stringAsFactors=FALSE) > > Error in read.table("Test2.csv", sep = ",", header = TRUE, stringAsFactors > = FALSE) : > > unused argument(s) (stringAsFactors = FALSE) > > > > If you want to look at it, I attach a section of my data. > > > > Right now if I type: > > > Test2[2,2]+1 > > Which should return 19.72 > > > > I get > > [1] NA > > Warning message: > > In Ops.factor(Test2[2, 2], 1) : + not meaningful for factors > > > > Your help is SO appreciated! > > > > -------------------------------------------- > > Vincent Deluard > > <mailto:Vincent.Deluard@TrimTabs.com> Vincent.Deluard@TrimTabs.com > > Global Equity Strategist, CFA Charter Award Pending > > TrimTabs Investment Research > > 40 Wall Street, 28th Floor > > New York, NY 10005 > > Phone: (+1) 646-512-5616 > > > > From: John Kane-2 [via R] [mailto: > ml-node+2124731-1168690456-90534@n4.nabble.com<ml-node%2B2124731-1168690456-90534@n4.nabble.com> > ] > Sent: Monday, May 03, 2010 6:51 PM > To: vincent.deluard > Subject: Re: / Operator not meaningful for factors > > > > I think that you are correct. R has the annoying habit of converting > character data to factors when you don't want it > to while it is importing data. This is because the in the option > "stringsAsFactors" is set to TRUE for some weird > historical reasons. > > Try the command str(insert name of data) and see what happens. It should > show you which columns of data are being > treated as factors. > > You can convert the back to character or to numeric. See the FAQ Part 7 > "How do I convert factors to numeric? " or you > can use the String as options command in the read.table to FALSE > > Something like this should work, I think, but it's not tested > read.table("C:/rdata/trees.csv", stringsAsFactors=FALSE) > > > > > > --- On Mon, 5/3/10, vincent.deluard <[hidden email]> wrote: > > > > From: vincent.deluard <[hidden email]> > > Subject: Re: [R] / Operator not meaningful for factors > > To: [hidden email] > > Received: Monday, May 3, 2010, 6:22 PM > > > > Hi there, > > > > This will sound very stupid because I just started using R > > but I see you had > > similar problems. > > > > I just loaded a very large dataset (2950*6602) from csv > > into R. The format > > is ticker=row, date=column. > > Every time I want to compute basic operations, R returns > > "In Ops.factor: not > > meaningful for factors" > > > > I believe it is because R does not read the data as numbers > > but I am not > > sure. Can anybody help? > > > > Thanks! > > -- > > View this message in context: > http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124697.html > > Sent from the R help mailing list archive at Nabble.com. > > > > ______________________________________________ > > [hidden email] > > mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > > and provide commented, minimal, self-contained, > > reproducible code. > > > > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > > > > _____ > > View message @ > http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124731.html > To unsubscribe from Re: / Operator not meaningful for factors, click > < (link removed) > AwNTU4Mzk3> here. > > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124759.html > Sent from the R help mailing list archive at Nabble.com. > > [[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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]]
Hi "Katya Mauff" <Katya.Mauff at uct.ac.za> napsal dne 04.05.2010 09:53:49:> another way to do it (if you are still having problems) is to use sapply > (yourdataname,data.class) after you've read it in, which will tell youthe> data class of each of your variables (factor, numeric etc). You can then> change your factor variables to numeric by typing yourdataname > $variablename=as.numeric(yourdataname$variablename).You can not!!!!! When you do it you will get numeric **representation** of factor levels.> x<-rnorm(5) > x[1] -1.1550254 -0.4578429 -0.6089007 -1.7378599 0.1297853> x.f<-factor(x) > x.f[1] -1.15502538070463 -0.457842907389024 -0.608900689299125 -1.73785992416606 [5] 0.129785271221269 5 Levels: -1.73785992416606 -1.15502538070463 ... 0.129785271221269> as.numeric(x.f)[1] 2 4 3 1 5>Regards Petr> > >>> Petr PIKAL <petr.pikal at precheza.cz> 2010/05/04 09:38 AM >>> > Hi > > r-help-bounces at r-project.org napsal dne 04.05.2010 00:50:00: > > > I think that you are correct. R has the annoying habit of converting> > character data to factors when you don't want it to while it is > importing > > data. This is because the in the option "stringsAsFactors" is set to > TRUE for > > some weird historical reasons. > > It is a matter of opinion. I consider it quite useful feature. If I seeby> > str(some.data) or summary(data0 that numeric columns are factors I know > something is wrong with input. > > and when I want to use ggplot, xyplot or just plot my data withdifferent> colours/sizes/pchs/.... it is quite easy to use as.numeric(my.factor) to> get numeric representation of levels. > > Finally you can easily change labels, concatenate levels and so on. > > Just my 2 cents. > > Regards > Petr > > > > > > > Try the command str(insert name of data) and see what happens. It > should show > > you which columns of data are being treated as factors. > > > > You can convert the back to character or to numeric. See the FAQ Part7> "How > > do I convert factors to numeric? " or you can use the String asoptions> > command in the read.table to FALSE > > > > Something like this should work, I think, but it's not tested > > read.table("C:/rdata/trees.csv", stringsAsFactors=FALSE) > > > > > > > > > > > > --- On Mon, 5/3/10, vincent.deluard <vincent.deluard at trimtabs.com> > wrote: > > > > > From: vincent.deluard <vincent.deluard at trimtabs.com> > > > Subject: Re: [R] / Operator not meaningful for factors > > > To: r-help at r-project.org > > > Received: Monday, May 3, 2010, 6:22 PM > > > > > > Hi there, > > > > > > This will sound very stupid because I just started using R > > > but I see you had > > > similar problems. > > > > > > I just loaded a very large dataset (2950*6602) from csv > > > into R. The format > > > is ticker=row, date=column. > > > Every time I want to compute basic operations, R returns > > > "In Ops.factor: not > > > meaningful for factors" > > > > > > I believe it is because R does not read the data as numbers > > > but I am not > > > sure. Can anybody help? > > > > > > Thanks! > > > -- > > > View this message in context: > http://r.789695.n4.nabble.com/Operator-not- > > meaningful-for-factors-tp791563p2124697.html > > > Sent from the R help mailing list archive at Nabble.com. > > > > > > ______________________________________________ > > > R-help at 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. > > > > > > > ______________________________________________ > > R-help at 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. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.>______________________________________________________________________________________________> UNIVERSITY OF CAPE TOWN > This e-mail is subject to the UCT ICT policies and e-mail disclaimerpublished> on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/or> obtainable from +27 21 650 4500. This e-mail is intended only for theperson> (s) to whom it is addressed. If the e-mail has reached you in error,please> notify the author. If you are not the intended recipient of the e-mailyou may> not use, disclose, copy, redirect or print the content. If this e-mailis not> related to the business of UCT it is sent by the sender in the sender's > individual capacity. >
Hi Yes, it is also possible. I usually use as.numeric(as.character(some.factor.which can.be.transformed.to.numeric)) Regards Petr "Katya Mauff" <Katya.Mauff at uct.ac.za> napsal dne 04.05.2010 10:42:20:> apologies-try something like this: > > x<-rnorm(5) > > x > [1] 0.9128818 1.5615704 -1.2319878 -1.8689400 -1.2931785 > > x.f<-factor(x) > > x.f > [1] 0.912881849717846 1.56157044807315 -1.2319877852522-1.8689399737313> -1.29317849983031 > Levels: -1.8689399737313 -1.29317849983031 -1.23198778525220.912881849717846> 1.56157044807315 > > y=as.numeric(levels(x.f))[x.f] > > y > [1] 0.9128818 1.5615704 -1.2319878 -1.8689400 -1.2931785 > > > > > > >>> Petr PIKAL <petr.pikal at precheza.cz> 2010/05/04 10:12 AM >>> > > > x<-rnorm(5) > > x > [1] -1.1550254 -0.4578429 -0.6089007 -1.7378599 0.1297853 > > x.f<-factor(x) > > x.f > [1] -1.15502538070463 -0.457842907389024 -0.608900689299125 > -1.73785992416606 > [5] 0.129785271221269 > 5 Levels: -1.73785992416606 -1.15502538070463 ... 0.129785271221269 > > as.numeric(x.f) > [1] 2 4 3 1 5 > >______________________________________________________________________________________________> UNIVERSITY OF CAPE TOWN > This e-mail is subject to the UCT ICT policies and e-mail disclaimerpublished> on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/or> obtainable from +27 21 650 4500. This e-mail is intended only for theperson> (s) to whom it is addressed. If the e-mail has reached you in error,please> notify the author. If you are not the intended recipient of the e-mailyou may> not use, disclose, copy, redirect or print the content. If this e-mailis not> related to the business of UCT it is sent by the sender in the sender's > individual capacity. >