Re: [R] levels

2020-07-19 Thread Chris Gordon-Smith
There is an interesting item on stringsAsFactors in this useR! 2020 session: https://www.youtube.com/watch?v=X_eDHNVceCU=youtu.be It's about 27 minutes in. Chris Gordon-Smith On 15/07/2020 17:16, Marc Schwartz via R-help wrote: >> On Jul 15, 2020, at 4:31 AM, andy elprama wrote: >> >> Dear

Re: [R] levels

2020-07-18 Thread andy elprama
Thanks, I will check it out. Op za 18 jul. 2020 om 00:47 schreef Chris Gordon-Smith < c.gordonsm...@gmail.com>: > There is an interesting item on stringsAsFactors in this useR! 2020 > session: > > https://www.youtube.com/watch?v=X_eDHNVceCU=youtu.be > > It's about 27 minutes in. > > Chris

Re: [R] levels

2020-07-15 Thread Erin Hodgess
Hi Andy: I just checked in "options", and the following appears: $stringsAsFactors [1] FALSE I think this might be it. You may want to look at options() in R-3.6.1. Thanks, Erin Erin Hodgess, PhD mailto: erinm.hodg...@gmail.com On Wed, Jul 15, 2020 at 9:45 AM andy elprama wrote: >

Re: [R] levels

2020-07-15 Thread Marc Schwartz via R-help
> On Jul 15, 2020, at 4:31 AM, andy elprama wrote: > > Dear R-users, > > Something strange happened within the command "levels" > > R version 3.6.1 > name <- c("a","b","c") > values <- c(1,2,3) > data <- data.frame(name,values) > levels(data$name) > [1] "a" "b" "c" > > R version 4.0 > name

Re: [R] levels

2020-07-15 Thread Jeff Newmiller
Read the NEWS about R4.0.0 [1] (search for stringsAsFactors), or read any of the many announcements in blogs and forums around the Internet. [1] https://cran.r-project.org/doc/manuals/r-release/NEWS.html On July 15, 2020 1:31:06 AM PDT, andy elprama wrote: >Dear R-users, > >Something strange

Re: [R] levels

2020-07-15 Thread Eric Berger
Hi Andy, I believe this is because R 4.0 has changed the default behavior of data.frame(). Prior to 4.0, the default was stringsAsFactors=TRUE. In 4.0, the default is stringsAsFactors=FALSE. If you run your code in R 3.6.1 and change the command to data <-

[R] levels

2020-07-15 Thread andy elprama
Dear R-users, Something strange happened within the command "levels" R version 3.6.1 name <- c("a","b","c") values <- c(1,2,3) data <- data.frame(name,values) levels(data$name) [1] "a" "b" "c" R version 4.0 name <- c("a","b","c") values <- c(1,2,3) data <- data.frame(name,values)

Re: [R] Levels of a factor

2013-07-25 Thread Borja Rivier
...@r-project.org] On Behalf Of Borja Rivier Sent: Wednesday, July 24, 2013 8:25 AM To: r-help@r-project.org Subject: [R] Levels of a factor Hi all, I am having a bit of trouble using the levels() function. I have a factor with many elements, and when I use the function levels() to extract

[R] Levels of a factor

2013-07-24 Thread Borja Rivier
Hi all, I am having a bit of trouble using the levels() function. I have a factor with many elements, and when I use the function levels() to extract the list of unique elements, some of the elements returned are not actually in the factor. For example I would have this: vector -

Re: [R] Levels of a factor

2013-07-24 Thread arun
Hi,  vec1- factor(1:5,levels=1:10)  vec1 #[1] 1 2 3 4 5 #Levels: 1 2 3 4 5 6 7 8 9 10 vec2-droplevels(vec1)  levels(vec2) #[1] 1 2 3 4 5  vec2 #[1] 1 2 3 4 5 #Levels: 1 2 3 4 5 A.K. Hi all, I am having a bit of trouble using the levels() function. I have a factor with many elements, and when

Re: [R] Levels of a factor

2013-07-24 Thread David Winsemius
On Jul 24, 2013, at 6:25 AM, Borja Rivier wrote: Hi all, I am having a bit of trouble using the levels() function. I have a factor with many elements, and when I use the function levels() to extract the list of unique elements, some of the elements returned are not actually in the factor.

Re: [R] Levels of a factor

2013-07-24 Thread David Winsemius
On Jul 24, 2013, at 11:35 AM, David Winsemius wrote: On Jul 24, 2013, at 6:25 AM, Borja Rivier wrote: Hi all, I am having a bit of trouble using the levels() function. I have a factor with many elements, and when I use the function levels() to extract the list of unique elements, some

Re: [R] Levels of a factor

2013-07-24 Thread David Carlson
-project.org Subject: [R] Levels of a factor Hi all, I am having a bit of trouble using the levels() function. I have a factor with many elements, and when I use the function levels() to extract the list of unique elements, some of the elements returned are not actually in the factor. For example I would

[R] Levels and labels in factor

2013-04-10 Thread chong shiauyun
Hi R users, I have a imputed dataset of undefinedundefined cycles which I generated using StAta version undefinedundefined. Then I imported my data from Stata into R and I used a loop to run Mclust package in R. My observation starts with ID=2 (ID=1 has been excluded from the sample) and ends

Re: [R] Levels and labels in factor

2013-04-10 Thread Blaser Nello
Perhaps write.dta(..., convert.factors=string) might help. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of chong shiauyun Sent: Mittwoch, 10. April 2013 10:01 To: r-help@r-project.org Subject: [R] Levels and labels in factor Hi R

Re: [R] Levels in new data fed to SVM

2013-01-10 Thread Uwe Ligges
On 08.01.2013 21:14, Claus O'Rourke wrote: Hi all, I've encountered an issue using svm (e1071) in the specific case of supplying new data which may not have the full range of levels that were present in the training data. I've constructed this really primitive example to illustrate the point:

Re: [R] Levels in new data fed to SVM

2013-01-10 Thread Claus O'Rourke
Thanks for clarifying! On Thu, Jan 10, 2013 at 12:47 PM, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: On 08.01.2013 21:14, Claus O'Rourke wrote: Hi all, I've encountered an issue using svm (e1071) in the specific case of supplying new data which may not have the full range of levels

[R] Levels in new data fed to SVM

2013-01-08 Thread Claus O'Rourke
Hi all, I've encountered an issue using svm (e1071) in the specific case of supplying new data which may not have the full range of levels that were present in the training data. I've constructed this really primitive example to illustrate the point: library(e1071) training.data - data.frame(x

Re: [R] levels of comma separated data

2012-05-25 Thread Stefan
analyst41 at hotmail.com analyst41 at hotmail.com writes: I have a data set that has some comma separated strings in each row. I'd like to create a vector consisting of all distinct strings that occur. The number of strings in each row may vary. Thanks for any help. # # # Some data:

Re: [R] levels of comma separated data

2012-05-25 Thread analys...@hotmail.com
On May 25, 4:46 am, Stefan ste...@inizio.se wrote: analyst41 at hotmail.com analyst41 at hotmail.com writes: I have a data set that has some comma separated strings in each row. I'd like to create a vector consisting of all distinct strings that occur.  The number of strings in each

Re: [R] levels of comma separated data

2012-05-25 Thread analys...@hotmail.com
On May 25, 7:23 am, analys...@hotmail.com analys...@hotmail.com wrote: On May 25, 4:46 am, Stefan ste...@inizio.se wrote: analyst41 at hotmail.com analyst41 at hotmail.com writes: I have a data set that has some comma separated strings in each row. I'd like to create a vector

[R] levels of comma separated data

2012-05-24 Thread analys...@hotmail.com
I have a data set that has some comma separated strings in each row. I'd like to create a vector consisting of all distinct strings that occur. The number of strings in each row may vary. Thanks for any help. __ R-help@r-project.org mailing list

[R] Levels of interaction terms between numeric and factor in glm

2010-10-21 Thread achilles tsoumanis
Hello everyone, I have been working on a model to describe the counts of a certain event. I use glm function with Poisson family and log link. the model is: model-glm(event~week+year+week:var1+year:var1+year:var2, family=poisson), where week and season are factor variables with 52 and 7

Re: [R] Levels in returned data.frame after subset

2010-09-05 Thread Ulrik Stervbo
Thanks for the replies! Obviously I must have used to wrong search terms - sorry. @greg: I care about the levels after the subset, because if they are not dropped, then they still appear in the subsequent heatmap I make with ggplot (with my read data-set of course). Admittedly I am quite green,

[R] Levels in returned data.frame after subset

2010-09-04 Thread Ulrik Stervbo
Dear List, When I subset a data.frame, the levels are not re-adjusted (see example). Why is this? Am I missing out on some basic stuff here? Thanks Ulrik m - data.frame(gender = c(M, M,F), ht = c(172, 186.5, 165), wt = c(91,99, 74)) dim(m) [1] 3 3 levels(m$gender) [1] F M s - subset(m,

Re: [R] Levels in returned data.frame after subset

2010-09-04 Thread Ista Zahn
Hi Ulrik On Sat, Sep 4, 2010 at 12:52 PM, Ulrik Stervbo ulrik.ster...@gmail.com wrote: Dear List, When I subset a data.frame, the levels are not re-adjusted (see example). Why is this? Am I missing out on some basic stuff here? Only that this issue has come up many times before, and that

Re: [R] Levels in returned data.frame after subset

2010-09-04 Thread Greg Snow
- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Ulrik Stervbo Sent: Saturday, September 04, 2010 6:53 AM To: r-help@r-project.org Subject: [R] Levels in returned data.frame after subset Dear List, When I subset a data.frame, the levels are not re

[R] levels update

2008-12-05 Thread Antje
Hello, I hope this question is not too stupid. I would like to know how to update levels after subsetting data from a data.frame. df - data.frame(factor(c(a,a,c,b,b)), c(4,5,6,7,8), c(9,1,2,3,4)) names(df) - c(X1,X2,X3) my.sub - subset(df, X1 == a | X1 == b) levels(my.sub$X1) # still gives

Re: [R] levels update

2008-12-05 Thread jim holtman
try this: df - data.frame(factor(c(a,a,c,b,b)), c(4,5,6,7,8), c(9,1,2,3,4)) names(df) - c(X1,X2,X3) my.sub - subset(df, X1 == a | X1 == b) levels(my.sub$X1) [1] a b c my.sub$X1 - factor(my.sub$X1) levels(my.sub$X1) [1] a b On Fri, Dec 5, 2008 at 7:50 AM, Antje [EMAIL PROTECTED] wrote:

Re: [R] levels update

2008-12-05 Thread Erich Neuwirth
I do the following for a subsetted dataframe: cleanfactors - function(mydf){ outdf-mydf for (i in 1:dim(mydf)[2]){ if (is.factor(mydf[,i])) outdf[,i]-factor(mydf[,i]) } outdf } Antje wrote: Hello, I hope this question is not too stupid. I would like to know how to update levels

Re: [R] levels update

2008-12-05 Thread hadley wickham
On Fri, Dec 5, 2008 at 6:50 AM, Antje [EMAIL PROTECTED] wrote: Hello, I hope this question is not too stupid. I would like to know how to update levels after subsetting data from a data.frame. df - data.frame(factor(c(a,a,c,b,b)), c(4,5,6,7,8), c(9,1,2,3,4)) names(df) - c(X1,X2,X3) my.sub

Re: [R] levels update

2008-12-05 Thread Prof Brian Ripley
On Fri, 5 Dec 2008, jim holtman wrote: try this: df - data.frame(factor(c(a,a,c,b,b)), c(4,5,6,7,8), c(9,1,2,3,4)) names(df) - c(X1,X2,X3) my.sub - subset(df, X1 == a | X1 == b) levels(my.sub$X1) [1] a b c my.sub$X1 - factor(my.sub$X1) I find my.sub$X1 - my.sub$X1[drop=TRUE] a lot more

Re: [R] levels update

2008-12-05 Thread Antje
Thanks a lot!!! the drop thing was exactly what I was looking for (I already used it some time ago but forgot about it). Thanks to everybody else too. Antje Prof Brian Ripley schrieb: On Fri, 5 Dec 2008, jim holtman wrote: try this: df - data.frame(factor(c(a,a,c,b,b)), c(4,5,6,7,8),

Re: [R] levels update

2008-12-05 Thread Richard . Cotton
I hope this question is not too stupid. I would like to know how to update levels after subsetting data from a data.frame. df - data.frame(factor(c(a,a,c,b,b)), c(4,5,6,7,8), c(9,1,2,3,4)) names(df) - c(X1,X2,X3) my.sub - subset(df, X1 == a | X1 == b) levels(my.sub$X1) # still

[R] levels values of cut()

2008-08-09 Thread baptiste auguie
Dear list, I have the following example, from which I am hoping to retrieve numeric values of the factor levels (that is, without the brackets): x - seq(1, 15, length=100) y - sin(x) my.cuts - cut(which(abs(y) 1e-1), 3) levels(my.cuts) hist() does not suit me for this, as it does not

Re: [R] levels values of cut()

2008-08-09 Thread Stephen Tucker
Message From: baptiste auguie [EMAIL PROTECTED] To: r-help@r-project.org Sent: Saturday, August 9, 2008 1:51:01 AM Subject: [R] levels values of cut() Dear list, I have the following example, from which I am hoping to retrieve numeric values of the factor levels (that is, without the brackets

Re: [R] levels values of cut()

2008-08-09 Thread Prof Brian Ripley
On Sat, 9 Aug 2008, baptiste auguie wrote: Dear list, I have the following example, from which I am hoping to retrieve numeric values of the factor levels (that is, without the brackets): x - seq(1, 15, length=100) y - sin(x) my.cuts - cut(which(abs(y) 1e-1), 3) levels(my.cuts) hist()

Re: [R] levels values of cut()

2008-08-09 Thread baptiste auguie
Thank you all for the precious tips. For memory I've made the following wrapper function for this. I wonder whether a short note on these regular expressions could be useful on the help page of cut(). cutIntervals - function(x, ...){ dotArgs - unlist(c(...)) if( any(names(dotArgs)

Re: [R] levels values of cut()

2008-08-09 Thread Prof Brian Ripley
On Sat, 9 Aug 2008, baptiste auguie wrote: Thank you all for the precious tips. For memory I've made the following wrapper function for this. I wonder whether a short note on these regular expressions could be useful on the help page of cut(). Already there in R-devel cutIntervals

[R] Levels error after printing

2008-05-28 Thread Gundala Viswanath
Hi all, After running this code: __BEGIN__ dat - read.table(gene_prob.txt, sep = \t) n - length(dat$V1) print(n) print(dat$V1) __END__ With this input in gene_prob.txt __INPUT__ HFE 0.00107517988586552 NF1 0.000744355305599206 PML 0.000661649160532628 TCF30.000661649160532628 NF2

[R] levels in dataframes

2008-04-22 Thread Georg Ehret
Dear R community, I wish to ask a short question concerning factor-data in dataframes: When I subset the data and get rid of all data for one level, I still retain the level name (obtained by levels(dataframe$variablename) ). Is there a convenient way to get rid of the levels for which all

Re: [R] levels in dataframes

2008-04-22 Thread Peter Alspach
Peter Alspach -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Georg Ehret Sent: Wednesday, 23 April 2008 8:58 a.m. To: r-help Subject: [R] levels in dataframes Dear R community, I wish to ask a short question concerning factor-data

Re: [R] levels() function for a vector

2008-03-11 Thread Richard Pearson
Karen levels returns the levels attribute of a variable, and a vector has no such attribute. This is usually used with a factor, e.g. temp - c(3, 5, 5, NA) levels(factor(temp)) [1] 3 5 Best wishes Richard Chang Liu wrote: Hello: I'm trying to use levels function, but I don't know

[R] levels() function for a vector

2008-03-10 Thread Chang Liu
Hello: I'm trying to use levels function, but I don't know why it's returning NULL. For example: temp[1] 3 5 5 NA levels(temp)NULL Also, I've tried: list(temp)[[1]][1] 3 5 5 NA levels(list(temp))NULL Is there a specific requirement on the parameter? Karen