Re: [R] Factor levels in training set

2016-06-15 Thread PIKAL Petr
sed to be numeric you can check if they really are by str(df) Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of ch.elahe > via R-help > Sent: Tuesday, June 14, 2016 5:29 PM > To: R-help Mailing List <r-help@r-project.org> >

[R] Factor levels in training set

2016-06-14 Thread ch.elahe via R-help
Hi all, I want to use Supervised Self organizing Maps from Kohonen package for my data. I need to divide my df into training set and test set, but a part of my df contains column with factor levels and I don't know how to bring them into my training set. Currently I use the following command

[R] Factor levels in training set

2016-06-14 Thread ch.elahe via R-help
Hi all, I want to use Supervised Self organizing Maps from Kohonen package for my data. I need to divide my df into training set and test set, but a part of my df contains column with factor levels and I don't know how to bring them into my training set. Currently I use the following command

Re: [R] factor levels numeric values

2015-02-11 Thread JS Huang
Hi, Suppose your data frame is called data and the name of the factor column is named tobeConverted. I have tried this and it worked. Hope this helps. as.numeric(as.character(data$tobeConverted)) -- View this message in context:

[R] factor levels numeric values

2014-11-12 Thread David Studer
Hi everybody, I have another question (to which I could not find an answer in my r-books. I am sure, it's not a great issue, but I simply lack of a good idea how to solve this: One of my variables gets imported as a factor instead of a numeric variable. Now I have a... Factor w/ 63 levels

Re: [R] factor levels numeric values

2014-11-12 Thread Gerrit Eichner
Hello, David, take a look at the beginning of the Warning section of ?factor. Hth -- Gerrit Hi everybody, I have another question (to which I could not find an answer in my r-books. I am sure, it's not a great issue, but I simply lack of a good idea how to solve this: One of my variables

Re: [R] factor levels numeric values

2014-11-12 Thread David L Carlson
-help@r-project.org Subject: Re: [R] factor levels numeric values Hello, David, take a look at the beginning of the Warning section of ?factor. Hth -- Gerrit Hi everybody, I have another question (to which I could not find an answer in my r-books. I am sure, it's not a great issue, but I

Re: [R] factor levels numeric values

2014-11-12 Thread Ivan Calandra
Eichner Sent: Wednesday, November 12, 2014 8:06 AM To: David Studer Cc: r-help@r-project.org Subject: Re: [R] factor levels numeric values Hello, David, take a look at the beginning of the Warning section of ?factor. Hth -- Gerrit Hi everybody, I have another question (to which I could

Re: [R] factor levels numeric values

2014-11-12 Thread Jeff Newmiller
-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gerrit Eichner Sent: Wednesday, November 12, 2014 8:06 AM To: David Studer Cc: r-help@r-project.org Subject: Re: [R] factor levels numeric values Hello, David, take a look

Re: [R] Factor levels.

2007-10-03 Thread Rolf Turner
On 3/10/2007, at 5:48 PM, Peter Dalgaard wrote: Rolf Turner wrote: I have factors with levels ``Unit, Achieved, and Scholarship; I wish to replace these with U, A, and S. So I do fff - factor(fff,labels=c(U,A,S)) This works as long as all of the levels are actually present in

Re: [R] Factor levels.

2007-10-03 Thread Rolf Turner
On 4/10/2007, at 7:50 AM, Peter Dalgaard wrote: Rolf Turner wrote: Does it even work? (What if it is the first or the 2nd level that is absent? Yes it works. What's the problem? To beat it to death: if the second level of fff is absent then fff will consist entirely of 1's

Re: [R] Factor levels.

2007-10-03 Thread Peter Dalgaard
Rolf Turner wrote: P.S. ***Are*** there any risks/dangers in following Christos Hatzis' suggestion of simply doing levels(fff) - c(U,A,S) ??? Not if the levels are right to begin with. Problems only arise if fff somehow becomes a two-level factor, e.g. if you do

[R] Factor levels.

2007-10-02 Thread Rolf Turner
I have factors with levels ``Unit, Achieved, and Scholarship; I wish to replace these with U, A, and S. So I do fff - factor(fff,labels=c(U,A,S)) This works as long as all of the levels are actually present in the factor. But if ``Scholarship'' is absent (as if often is) then I

Re: [R] Factor levels

2007-09-19 Thread Gabor Grothendieck
If you don't know ahead of time how many columns you have and only that they are a mix of numeric and character (to be converted to factor) then you can do this: DF - read.table(textConnection(Input), header = TRUE, as.is = TRUE) f - function(x) if (is.character(x)) factor(x, levels = unique(x))