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>
>
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
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
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:
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
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
-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
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
-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
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
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
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
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
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))
14 matches
Mail list logo