search for: stringsasfactor

Displaying 20 results from an estimated 977 matches for "stringsasfactor".

Did you mean: stringsasfactors
2020 Apr 13
2
stringsAsFactors
...the `val <- FALSE` patch a few hours ago by Martin, the line after should also be changed - if(!is.logical(val) || is.na(val) || length(val) != 1L) + if(!is.logical(val) || length(val) != 1L || is.na(val)) ## Consider Sys.setenv("_R_CHECK_LENGTH_1_LOGIC2_" = "TRUE") options(stringsAsFactors = c(TRUE, FALSE)) default.stringsAsFactors() # correct error message On Mon, 13 Apr 2020 at 18:02, Martin Maechler <maechler at stat.math.ethz.ch> wrote: > > >>>>> Duncan Murdoch > >>>>> on Sun, 12 Apr 2020 08:57:14 -0400 writes: > > &gt...
2019 Mar 12
3
as.data.frame.table() does not recognize default.stringsAsFactors()
Reporting a possible inconsistency or bug in handling stringsAsFactors in as.data.frame.table() Here is a simple test > options()$stringsAsFactors [1] TRUE > x<-c("a","b","c","a","b") > d<-as.data.frame(table(x)) > d x Freq 1 a 2 2 b 2 3 c 1 > class(d$x) [1] "factor" > d2...
2020 Apr 12
3
stringsAsFactors
The NEWS for R 4.0.0 says "R now uses a stringsAsFactors = FALSE default, and hence by default no longer converts strings to factors in calls to data.frame() and read.table()." This seems to have been implemented by setting options(stringsAsFactors = FALSE) in the main R profile. However, setting options(stringsAsFactors = NULL) reverts to t...
2016 Feb 19
4
should `data` respect default.stringsAsFactors()?
Hi Peter, Sorry if I was not clear. Perhaps an example will make my point: > data(iris) > class(iris$Species) [1] "factor" > write.table(iris,'data/myiris.tab') > data(myiris) > class(myiris$Species) [1] "factor" > rm(myiris) > options(stringsAsFactors = FALSE) > data(myiris) > class(myiris$Species) [1] "factor" > myiris<-read.table("data/myiris.tab",header=TRUE) > class(myiris$Species) [1] "character" I am surprised to find that in the above setting the global option stringsAsFactors = FALSE does...
2016 Feb 18
2
should `data` respect default.stringsAsFactors()?
Hiya, Probably been debated elsewhere.... I note that R's `data` function does not respect default.stringsAsFactors By my lights, it should, especially as it is documented to call read.table, which DOES respect. Oh, but: http://r.789695.n4.nabble.com/stringsAsFactors-FALSE-tp921891p921893.html Compelling. I have to agree. So, I change my mind. By my lights, `data` should then be documented to NOT re...
2020 Apr 13
0
stringsAsFactors
...; Martin, the line after should also be changed > - if(!is.logical(val) || is.na(val) || length(val) != 1L) > + if(!is.logical(val) || length(val) != 1L || is.na(val)) > ## Consider > Sys.setenv("_R_CHECK_LENGTH_1_LOGIC2_" = "TRUE") > options(stringsAsFactors = c(TRUE, FALSE)) In R-devel and R 4.0.0 alpha/beta, you have > options(stringsAsFactors = c(TRUE, FALSE)) Error in options(stringsAsFactors = c(TRUE, FALSE)) : invalid value for 'stringsAsFactors' > default.stringsAsFactors() # correct error message Note that the defaul...
2020 Apr 13
1
stringsAsFactors
Hello, I also want to report 2 missed cases of stringsAsFactors=TRUE in base: 1. grid.expand() still uses hard stringsAsFactors=TRUE in its arguments. 2. as.data.frame.table() also keeps factors after conversion from table. >>>>>> Duncan Murdoch >>>>>> on Sun, 12 Apr 2020 08:57:14 -0400 writes: > > > The NE...
2009 Jun 25
2
stringsAsFactors has no impact in expand.grid()?
Hi I have the feeling, that the argument stringsAsFactors has no impact in the function expand.grid: a <- c("PR", "NC", "A2", "BS") b <- c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125) class(expand.grid(css, fscs, stringsAsFactors=FALSE)[[1]]) [1] "factor" class(expand.grid(css, fscs, stringsAsFactors=TRU...
2019 Mar 14
0
as.data.frame.table() does not recognize default.stringsAsFactors()
...ent_ of the matrix that is being converted, and it seems much more reasonable to follow the same path as for other character data. -pd > On 12 Mar 2019, at 21:39 , Mychaleckyj, Josyf C (jcm6t) <jcm6t at virginia.edu> wrote: > > Reporting a possible inconsistency or bug in handling stringsAsFactors in as.data.frame.table() > > Here is a simple test > >> options()$stringsAsFactors > [1] TRUE >> x<-c("a","b","c","a","b") >> d<-as.data.frame(table(x)) >> d > x Freq > 1 a 2 > 2 b 2 >...
2016 Feb 19
2
should `data` respect default.stringsAsFactors()?
Aha... Hadn't noticed that stringsAsFactors only works via as.is in read.table. Yes, the doc should probably be fixed. The code probably not -- packages loading different data sets depending on user options is an even worse idea than hav?ng the option in the first place... (I don't mean having the possibility, I mean the default.strin...
2009 May 18
2
stringsAsFactors param in expand.grid not working
Hi all, I've (tried) to look through the bug tracker, and gmane-search the R list to see if this has been mentioned before, and it looks like it hasn't. According to the R 2.9.0 release notes[1], the expand.grid function should now take a stringsAsFactor=LOGICAL argument which controls whether or not the function coerces strings as factors. While the parameter is indeed in the function, a quick examination of the function's source shows that the value of this argument is never checked, and all strings are converted to factors as a matter of...
2009 May 18
2
stringsAsFactors param in expand.grid not working
Hi all, I've (tried) to look through the bug tracker, and gmane-search the R list to see if this has been mentioned before, and it looks like it hasn't. According to the R 2.9.0 release notes[1], the expand.grid function should now take a stringsAsFactor=LOGICAL argument which controls whether or not the function coerces strings as factors. While the parameter is indeed in the function, a quick examination of the function's source shows that the value of this argument is never checked, and all strings are converted to factors as a matter of...
2008 Nov 17
2
stringsAsFactors = FALSE
Hi all, I love the option to not automatically convert strings into factors, but there are three places that the current option doesn't work where I think it should: options(stringsAsFactors = FALSE) str(expand.grid(letters)) str(type.convert(letters)) df <- read.fwf(textConnection(paste(letters,collapse="\n")), 1) str(df) I think type.convert and read.fwf can be fixed by giving them a stringsAsFactors argument and then using asis = !stringsAsFactors (like read.table)....
2011 Feb 28
2
converting the string columns in a data.frame to factors?
Dear All, I'm not sure if I understand the parameter stringsAsFactors correctly. I'm trying to convert the string columns in aframe1 to factors. But it seems stringsAsFactors=T in as.data.frame() doesn't do anything. Could anybody let know what is the correct way to converting strings to factors? > aframe1=data.frame(x=LETTERS[1:10], y=LETTERS[1:10], str...
2016 Feb 19
0
should `data` respect default.stringsAsFactors()?
...clear. Perhaps an example will make my point: > >> data(iris) >> class(iris$Species) > [1] "factor" >> write.table(iris,'data/myiris.tab') >> data(myiris) >> class(myiris$Species) > [1] "factor" >> rm(myiris) >> options(stringsAsFactors = FALSE) >> data(myiris) >> class(myiris$Species) > [1] "factor" >> myiris<-read.table("data/myiris.tab",header=TRUE) >> class(myiris$Species) > [1] "character" > > I am surprised to find that in the above > setting...
2016 Feb 19
0
should `data` respect default.stringsAsFactors()?
Hi, > Aha... Hadn't noticed that stringsAsFactors only works via as.is in read.table. > > Yes, the doc should probably be fixed. The code probably not Agreed. Is someone on-list authorized and willing to make the documentation change? I suppose I could learn what it takes to be a "player", but for such a trivial fix, it p...
2010 Jan 22
4
Inconsistency in as.data.frame.table for stringsAsFactors
I noticed that in as.data.frame.table, the stringsAsFactors argument defaults to TRUE, whereas in the other as.data.frame methods, it defaults to default.stringsAsFactors(). The documentation and implementation agree on this, so this is not a bug. However, I was wondering if this disparity was intended or if it might be some sort of unintentional oversig...
2017 Jul 08
2
Factor vs character in a data.frame vs vector
Thanks Marc. It never occurred to me that I would need a ""stringsAsFactors" expression in a data.frame.? I could have sworn I never did before when mocking up some data but clearly I was wrong or there has been a change in R v. 3.4.1 which seems unlikely. On Friday, July 7, 2017, 10:37:29 AM EDT, Marc Schwartz <marc_schwartz at me.com> wrote: > On Jul 7...
2013 Feb 11
2
stringsAsFactors
...e for which Helmert contrasts are proper so guess what the default contrast option was? (I think there are only a few data sets in the world for which Helmert makes sense, however, and R eventually changed the default.) For character variables that should not be factors such as a street adress stringsAsFactors can be a real PITA, and I expect that people's preference for the option depends almost entirely on how often these arise in their own work. As long as there is an option that can be overridden I'm okay. Yes, I'd prefer FALSE as the default, partly because the current value is a t...
2008 Oct 16
2
Saving results of Kruskal Walis test
Hello, I am running Kruskal-Walis test in R. When I try to save results using write.table it gives me the following error : Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : cannot coerce class "htest" into a data.frame The overall code is as follows : >data_file = read.table("~/DATA.dir/data_file.txt", header=T) >attach(data_file) >data_file.out <- krukal.test(data_file) >write.table(data_file.out, &quot...