search for: droplevels

Displaying 20 results from an estimated 65 matches for "droplevels".

2017 Apr 12
3
"table(droplevels(aq)$Month)" in manual page of droplevels
The last line of the example in droplevels' manual page seems to be incorrect to me. I think it should read: "table(droplevels(aq$Month))". Amazingly (I don't understand) both variants seem to produce the same result (R 3.3.3): --- > aq <- transform(airquality, Month = factor(Month, labels = month.abb[5:9])) > aq...
2017 Apr 12
2
"table(droplevels(aq)$Month)" in manual page of droplevels
...Henric Winell <nilsson.henric at gmail.com> schrieb am 12.04.2017 >>>>> um 15:35 in >> Nachricht <b66fe849-bb8d-f00d-87e5-553f866d57e0 at gmail.com>: >>> On 2017-04-12 14:40, Ulrich Windl wrote: >>> >>>> The last line of the example in droplevels' manual page seems to >>>> be incorrect to me. I think it should read: >>>> "table(droplevels(aq$Month))". Amazingly (I don't understand) >>>> both variants seem to produce the same result (R 3.3.3): --- >>> >>> The manual says...
2017 Apr 13
0
"table(droplevels(aq)$Month)" in manual page of droplevels
...>> 12.04.2017 >>>>> um 15:35 in >>> Nachricht >>> <b66fe849-bb8d-f00d-87e5-553f866d57e0 at gmail.com>: >>>> On 2017-04-12 14:40, Ulrich Windl wrote: >>>> >>>>> The last line of the example in droplevels' manual >>>>> page seems to be incorrect to me. I think it should >>>>> read: "table(droplevels(aq$Month))". Amazingly (I >>>>> don't understand) both variants seem to produce the >>>>> same result (R 3.3....
2017 Apr 12
0
"table(droplevels(aq)$Month)" in manual page of droplevels
...: >>>> Henric Winell <nilsson.henric at gmail.com> schrieb am 12.04.2017 >>>> um 15:35 in > Nachricht <b66fe849-bb8d-f00d-87e5-553f866d57e0 at gmail.com>: >> On 2017-04-12 14:40, Ulrich Windl wrote: >> >>> The last line of the example in droplevels' manual page seems to >>> be incorrect to me. I think it should read: >>> "table(droplevels(aq$Month))". Amazingly (I don't understand) >>> both variants seem to produce the same result (R 3.3.3): --- >> >> The manual says that "The fu...
2012 Feb 13
1
Overwrite S3 methond from base package
Dear all, I am developing a package, which bundles my most frequently used functions. One of those is a modified version of droplevels from the base package (basically, it preserves any contrast function which was used to create the factor, contrast matrices are not kept, for they could be wrong if a level is dropped). In my NAMESPACE file I've the following directives, which should export my methods: S3method(droplevels, fa...
2011 Oct 21
1
droplevels: drops contrasts as well
Dear all, Today I figured out that there is a neat function called droplevels, which, well, drops unused levels in a data frame. I tried the function with some of my data sets and it turned out that not only the unused levels were dropped but also the contrasts I set via "C". I had a look into the code, and this behaviour arises from the fact that droplevels uses s...
2017 May 15
2
[bug] droplevels() also drop object attributes (comment…)
Hi, Just reporting a small bug? not really a big deal, but I don?t think that is intended: droplevels()?also drops all object?s attributes. Example: > > test <- c("hello", "something", "hi") > > test <- factor(test) > > comment(test) <- "this is a test" > > attr(test, "description") <- "this is another test...
2016 Aug 21
1
'droplevels' inappropriate change
In R devel r71124, if 'x' is a factor, droplevels(x) gives factor(x, exclude = NULL) . In R 3.3.1, it gives factor(x) . If a factor 'x' has NA and levels of 'x' doesn't contain NA, factor(x) gives the expected result for droplevels(x) , but factor(x, exclude = NULL) doesn't. As I said in https://stat.ethz.ch/pipermail/r-de...
2017 Jun 06
1
[bug] droplevels() also drop object attributes (comment…)
...16 May 2017 11:01:23 +0200 writes: >>>>> Serge Bibauw <sbibauw at gmail.com> >>>>> on Mon, 15 May 2017 11:59:32 -0400 writes: >> Hi, >> Just reporting a small bug? not really a big deal, but I >> don?t think that is intended: droplevels()?also drops all >> object?s attributes. > Yes. The help page for droplevels (or the simple > definition of 'droplevels.factor') clearly indicate that > the method for factors is really just a call to factor(x, > exclude = *) > and that _is_ q...
2017 May 16
0
[bug] droplevels() also drop object attributes (comment…)
>>>>> Serge Bibauw <sbibauw at gmail.com> >>>>> on Mon, 15 May 2017 11:59:32 -0400 writes: > Hi, > Just reporting a small bug? not really a big deal, but I don?t think that is intended: droplevels()?also drops all object?s attributes. Yes. The help page for droplevels (or the simple definition of 'droplevels.factor') clearly indicate that the method for factors is really just a call to factor(x, exclude = *) and that _is_ quite an important base function whose semantic should no...
2017 Jun 08
0
[bug] droplevels() also drop object attributes (comment…)
...ced, the original contrasts matrix is no longer valid. Example case: x <- factor(c("a", "a", "b", "b", "b"), levels = c("a", "b", "c")) contrasts(x) <- contr.treatment(levels(x), contrasts=FALSE)[, -2, drop=FALSE] droplevels(x) * If function 'factor' is changed, make sure that as.factor(x) and factor(x) is the same for 'x' where is.integer(x) is TRUE. Currently, as.factor(<integer>) is treated specially. * It is possible that names(x) is not attr(x, "names"). For example, 'x' i...
2017 Jun 14
1
[bug] droplevels() also drop object attributes (comment…)
...ent from 'levels<-.factor' that is in package base. However, factor subsetting ('[.factor') knows "contrasts" attribute. -------------------------------------------- On Sat, 10/6/17, Martin Maechler <maechler at stat.math.ethz.ch> wrote: Subject: Re: [Rd] [bug] droplevels() also drop object attributes (comment?) To: "R Development" <R-devel at r-project.org> Cc: "Serge Bibauw" <sbibauw at gmail.com>, "Suharto Anggono" <suharto_anggono Date: Saturday, 10 June, 2017, 5:54 AM >>>>> Suharto Anggono Suharto...
2016 Aug 27
0
'droplevels' inappropriate change
>>>>> Suharto Anggono Suharto Anggono via R-devel <r-devel at r-project.org> >>>>> on Sat, 27 Aug 2016 03:17:32 +0000 writes: > In R devel r71157, 'droplevels' documentation, in "Arguments" section, says this about argument 'exclude'. > passed to factor(); factor levels which should be excluded from the result even if present. Note that this was implicitly NA in R <= 3.3.1 which did drop NA levels even when present in x,...
2016 Aug 27
2
'droplevels' inappropriate change
In R devel r71157, 'droplevels' documentation, in "Arguments" section, says this about argument 'exclude'. passed to factor(); factor levels which should be excluded from the result even if present. Note that this was implicitly NA in R <= 3.3.1 which did drop NA levels even when present in x, contrary...
2013 Jul 24
3
Change values in a dateframe
Hello I have the following problem : The dataframe TEST has multiple lines for a same person because : there are differents values of Nom or differents values of Prenom but the values of Matricule or Sexe or Date.de.naissance are the same. TEST <- structure(list(Matricule = c(66L, 67L, 67L, 68L, 89L, 90L, 90L, 91L, 108L, 108L, 108L), Nom = structure(c(1L, 2L, 2L, 4L, 8L, 5L, 6L, 9L, 3L, 3L,
2012 Apr 16
2
Problems with subset, droplevels and lm: variable lengths differ
...ssing data > Oslo <- Oslo[complete.cases(Oslo),] > nrow(Oslo) [1] 350 > > # delete low frequency litho=="GNEID_O" | "MICSH" > Oslo <- subset(Oslo, !litho %in% c("GNEID_O", "MICSH"), drop=TRUE) > nrow(Oslo) [1] 332 > Oslo<- droplevels(Oslo) > table(Oslo$litho) CAMSED GNEIS_O GNEIS_R MAGM 98 89 32 113 > nrow(Oslo) [1] 332 > mod1 <- lm(cbind("Cu", "Fe", "K", "Mg", "Mn", "P", "Zn") ~ litho + forest + weather, data=Oslo) E...
2016 Sep 13
0
Coercion of 'exclude' in function 'factor' (was 'droplevels' inappropriate change)
...nsider it .. though *after* the '<length-1-array> OP <non-array>' issue has settled a bit. Martin > -------------------------------------------- > On Wed, 31/8/16, Martin Maechler <maechler at stat.math.ethz.ch> wrote: > Subject: Re: [Rd] 'droplevels' inappropriate change > Cc: "Martin Maechler" <maechler at stat.math.ethz.ch> > Date: Wednesday, 31 August, 2016, 2:51 PM >>>>> Martin Maechler <maechler at stat.math.ethz.ch> >>>>> on Sat, 27 Aug 2016 18:55:37 +0200 write...
2016 Sep 02
2
Coercion of 'exclude' in function 'factor' (was 'droplevels' inappropriate change)
...f <- factor(cc) factor(ff,exclude=ff[3]) However, the coercion of 'exclude' has been in function 'factor' in R "forever". -------------------------------------------- On Wed, 31/8/16, Martin Maechler <maechler at stat.math.ethz.ch> wrote: Subject: Re: [Rd] 'droplevels' inappropriate change Cc: "Martin Maechler" <maechler at stat.math.ethz.ch> Date: Wednesday, 31 August, 2016, 2:51 PM >>>>> Martin Maechler <maechler at stat.math.ethz.ch> >>>>> on Sat, 27 Aug 2016 18:55:37 +0200 writes: >>>...
2013 Jul 24
3
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 have this: > vector <- dataset$Benchmark > class(vector) [1] "factor" > length(vector) [1] 35615 > vector2
2012 Sep 19
2
drop zero slots from table?
...0] tab <- sort(tab,decreasing=TRUE) --8<---------------cut here---------------end--------------->8--- all the time. I am wondering if the "drop 0" (and maybe even sort?) can be effected by some magic argument to table() which I fail to discover in the docs? Obviously, I could use droplevels() to avoid 0 counts in the first place, but I do not want to drop the levels in the data. -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://ffii.org http://truepeace.org http://www.memritv.org http://honestreporting.com http://dhimm...