Re: [R] Factor levels in training set

2016-06-15 Thread PIKAL Petr
upposed 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 > Subject: [R

[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 fo

[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: http://r.789695.n4.nabble.com/factor-levels-numeric-values

Re: [R] factor levels > numeric values

2014-11-12 Thread Jeff Newmiller
ent of Anthropology >Texas A&M University >College Station, TX 77840-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-he

Re: [R] factor levels > numeric values

2014-11-12 Thread Ivan Calandra
rrit 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 que

Re: [R] factor levels > numeric values

2014-11-12 Thread David L Carlson
c: 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 not find an answer in my r-books. > I am

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 variable

[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 "0","0

Re: [R] Factor levels.

2007-10-03 Thread Peter Dalgaard
Peter Dalgaard wrote: > 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 s

Re: [R] Factor levels.

2007-10-03 Thread Rolf Turner
On 4/10/2007, at 8:29 AM, Peter Dalgaard wrote: > 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 onl

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 yo

Re: [R] Factor levels.

2007-10-03 Thread Christos Hatzis
verride this behavior, you will have to deal with the sorting problem, as Peter suggested. -Christos > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Rolf Turner > Sent: Wednesday, October 03, 2007 4:12 PM > To: Peter Dalgaard > Cc: r

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

Re: [R] Factor levels.

2007-10-03 Thread Peter Dalgaard
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 and 3's, > and so c("U","A","S")[fff] wil

Re: [R] Factor levels.

2007-10-03 Thread Rolf Turner
On 3/10/2007, at 5:10 PM, Christos Hatzis wrote: > Would > > levels(fff) <- c("A","S","U") > > not work? Well, not quite. This would scramble the levels. The levels of the original fff are c("Unit","Achieved","Scholarship") --- i.e. they are ***not*** in alphabetical order

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

Re: [R] Factor levels.

2007-10-02 Thread Ted Harding
On 03-Oct-07 04:57:33, 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-02 Thread Peter Dalgaard
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 the > factor. But if ``

Re: [R] Factor levels.

2007-10-02 Thread Christos Hatzis
Would levels(fff) <- c("A","S","U") not work? Can you send an example? -Christos > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Rolf Turner > Sent: Wednesday, October 03, 2007 12:58 AM > To: r-h

[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 of

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))

Re: [R] Factor levels

2007-09-19 Thread Sébastien
Hi Gabor, I am coming back to you about the method you described to me a month ago to define the level order during a read.table call. I initially thought that I would need to apply the 'unique' function on a single column of my dataset, so I only used it after the read.table step (to make my l