Peter Dalgaard wrote:
Kevin E. Thorpe wrote:
I'm sure this is simple enough, but an R site search on my subject
terms did suggest a solution. I have a numeric vector with many
values that I wish to create a factor from having only a few levels.
Here is a toy example.
> x <- 1:10
> x <-
fact
Kevin E. Thorpe wrote:
I'm sure this is simple enough, but an R site search on my subject
terms did suggest a solution. I have a numeric vector with many
values that I wish to create a factor from having only a few levels.
Here is a toy example.
> x <- 1:10
> x <-
factor(x,levels=1:10,labels
On Nov 1, 2009, at 3:51 PM, Kevin E. Thorpe wrote:
I'm sure this is simple enough, but an R site search on my subject
terms did suggest a solution. I have a numeric vector with many
values that I wish to create a factor from having only a few levels.
Here is a toy example.
> x <- 1:10
> x <-
Hi Kevin,
Here are two suggestions:
# Combination of levels() and table()
table(levels(x))
# A B C
# 3 3 4
# Or defining a function
mysummary <- function(x) table(levels(x)) # you can easily improve it :-)
mysummary(x)
# A B C
# 3 3 4
HTH,
Jorge
On Sun, Nov 1, 2009 at 3:51 PM, Kevin E. Thorpe
I'm sure this is simple enough, but an R site search on my subject
terms did suggest a solution. I have a numeric vector with many
values that I wish to create a factor from having only a few levels.
Here is a toy example.
> x <- 1:10
> x <-
factor(x,levels=1:10,labels=c("A","A","A","B","B","B"
5 matches
Mail list logo