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&feature=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: >> >>

Re: [R] levels

2020-07-17 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&feature=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 ha

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 <- data.frame(name,values,stringsAsFactors=

[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) levels(data$nam

Re: [R] Levels of a factor

2013-07-25 Thread Borja Rivier
D" "F" "G" "H" "J" "K" "L" "M" "N" "O" "P" "Q" > "R" "S" "T" "V" "X" > # [20] "Y" "Z" > > There are times wh

Re: [R] Levels of a factor

2013-07-24 Thread David Carlson
; "P" "Q" "R" "S" "T" "V" "X" # [20] "Y" "Z" There are times when you want to know if certain factor levels do not appear in a subset of the original data. - David L Carls

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 el

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 fa

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 element

[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 <- dataset$Benc

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 fa

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

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 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 that >> were present i

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:

[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

Re: [R] levels of comma separated data

2012-05-25 Thread analys...@hotmail.com
On May 25, 7:23 am, "analys...@hotmail.com" wrote: > On May 25, 4:46 am, Stefan wrote: > > > > > > > analyst41 hotmail.com 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 tha

Re: [R] levels of comma separated data

2012-05-25 Thread analys...@hotmail.com
On May 25, 4:46 am, Stefan wrote: > analyst41 hotmail.com 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. > > > Th

Re: [R] levels of comma separated data

2012-05-25 Thread Stefan
analyst41 hotmail.com 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: d <- d

[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 https:

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

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, a

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

2010-09-04 Thread Greg Snow
ginal Message- > 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, > >

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 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 this list is archived a

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

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

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,

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

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

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

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

[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.s

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 <

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

Re: [R] levels values of cut()

2008-08-09 Thread Stephen Tucker
3.1 - Original 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 l

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

Re: [R] "Levels" error after printing

2008-05-29 Thread Dieter Menne
Gundala Viswanath gmail.com> writes: > > Hi all, > > After running this code (attaches is the input file): > > dat <- read.table("gene_prob.txt", sep = "\t") > n <- length(dat$V1) > print(n) > print(dat$V1) > > I get this print out. > > .. > [8541] LOC552889 GPR15 SLC2A11

[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 0.

Re: [R] levels in dataframes

2008-04-22 Thread Peter Alspach
) # now it is gone B C D 1 1 1 HTH 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] 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 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

[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