similar to: nchar on factors

Displaying 20 results from an estimated 11000 matches similar to: "nchar on factors"

2009 Sep 02
2
Documentation for is.atomic and is.recursive
The documentation for is.atomic and is.recursive is inconsistent with their behavior in R 2.9.1 Windows. ? is.atomic ???? 'is.atomic' returns 'TRUE' if 'x' is an atomic vector (or 'NULL') ???? and 'FALSE' otherwise. ???? ... ???? 'is.atomic' is true for the atomic vector types ('"logical"', ???? '"integer"',
2009 May 20
2
Class for time of day?
What is the recommended class for time of day (independent of calendar date)? And what is the recommended way to get the time of day from a POSIXct object? (Not a string representation, but a computable representation.) I have looked in the man page for DateTimeClasses, in the Time Series Analysis Task View and in Spector's Data Manipulation book but haven't found these. Clearly I can
2008 Nov 29
2
Using grep() to subset lines of text
I have two vectors, a and b. b is a text file. I want to find in b those elements of a which occur at the beginning of the line in b. I have the following code, but it only returns a value for the first value in a, but I want both. Any ideas please. a = c(2,3) b = NULL b[1] = "aaa 2 aaa" b[2] = "2 aaa" b[3] = "3 aaa" b[4] = "aaa 3 aaa"
2005 Oct 25
1
performance of nchar
Hi, Is nchar function knowingly slow in R? I'm doing some string formatting that requires multiple call to nchar, and nchar seems to be very slow. Experiment 1, pass nchar inside sprintf, and it takes 0.7 seconds > system.time(for (i in 1:10000) + str = sprintf('0005%020d', nchar(op)) + )[3] [1] 0.7 Experiment 2, get the length of op separately using nchar, and then pass
2009 Nov 01
2
Internal error in 'ls' for pathological environments (PR#14035)
nchar(with(list(2),ls())) gives an internal error. This is of course a peculiar call (no names in the list), but the error is not caught cleanly. It is not clear from the documentation whether with(list(2)...) is allowable; if it is not, it should presumably give an error. If it is, then ls shouldn't have problems with the resulting environment. > qq <- with(list(2),ls())
2009 Jun 23
1
Documentation/software inconsistency in `:` and seq
In 2.8.1/Windows: According to ? : Details: For numeric arguments 'from:to' is equivalent to 'seq(from, to)' ... Value: For numeric arguments, a numeric vector. This will be of type 'integer' if 'from' and 'to' are both integers and representable in the integer type, otherwise of type 'numeric'.... The first claim
2009 Feb 17
2
cumsum vs. sum
I recently traced a bug of mine to the fact that cumsum(s)[length(s)] is not always exactly equal to sum(s). For example, x<-1/(12:14) sum(x) - cumsum(x)[3] => 2.8e-17 Floating-point addition is of course not exact, and in particular is not associative, so there are various possible reasons for this. Perhaps sum uses clever summing tricks to get more accurate results? In some
2015 Oct 05
2
Error generated by .Internal(nchar) disappears when debugging
Hi all, I have a puzzling problem related to nchar. In R 3.2.1, the internal nchar gained an extra argument (see https://stat.ethz.ch/pipermail/r-announce/2015/000586.html) I've been testing code using the package copula, and at home I'm still running R 3.2.0 (I know, I know...). When trying the following code, I got an error: > library(copula) > fgmCopula(0.8) Error in
2015 Oct 06
1
Error generated by .Internal(nchar) disappears when debugging
On 05/10/2015 8:25 PM, Matt Dowle wrote: > > On Mon, Oct 5, 2015 at 4:57 PM, Duncan Murdoch <murdoch.duncan at gmail.com > <mailto:murdoch.duncan at gmail.com>> wrote: > > On 05/10/2015 7:24 PM, Matt Dowle wrote: > > Joris Meys <jorismeys <at> gmail.com <http://gmail.com>> writes: > > > >> > >> Hi all,
2015 Oct 07
1
Error generated by .Internal(nchar) disappears when debugging
Malcolm, I tested the code on a clean R 3.2.0 session. Not even in RStudio, just to rule that out. > sessionInfo() R version 3.2.0 (2015-04-16) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 8 x64 (build 9200) locale: [1] LC_COLLATE=English_United Kingdom.1252 [2] LC_CTYPE=English_United Kingdom.1252 [3] LC_MONETARY=English_United Kingdom.1252 [4] LC_NUMERIC=C [5]
2009 Jul 29
3
Object equality for S4 objects
To test two environments for object equality (Lisp EQ), I can use 'identity': > e1 <- environment(local(function()x)) > e2 <- environment(local(function()x)) > identical(e1,e2) # compares object identity [1] FALSE > identical(as.list(e1),as.list(e2)) # compares values as name->value mapping [1] TRUE # (is there a
2009 Mar 09
3
E`<`<rrors in recursive default argument references
Tested in: R version 2.8.1 (2008-12-22) / Windows Recursive default argument references normally give nice clear errors. In the first set of examples, you get the error: Error in ... : promise already under evaluation: recursive default argument reference or earlier problems? (function(a = a) a ) () (function(a = a) c(a) ) () (function(a = a) a[1] ) () (function(a = a)
2009 Feb 10
1
Variable/function namespaces WAS: Bug in subsetting data frame (PR#13515)
On Tue, Feb 10, 2009 at 10:11 AM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote: > Stavros Macrakis wrote: >> On Tue, Feb 10, 2009 at 8:31 AM, Duncan Murdoch <murdoch at stats.uwo.ca>wrote: >>> The evaluator recognizes the context of usage and will get the >>> function for a function call.... >> Can you point me to chapter and verse in the language
2001 Mar 28
2
nchar on data.frames
I don't understand why nchar() gives different string lengths for vectors in a list than it does for vectors in a dataframe. Here's a snippet of code: > temp <- list(text=c("thug","jimbob","apple","thug"),numbers=1:4) > nchar(temp$text) [1] 4 6 5 4 > temp <- data.frame(temp) > nchar(temp$text) [1] 1 1 1 1 Could someone explain
2003 Aug 29
2
length() and nchar()
I would propose to add " See also: `nchar' for counting the number of character in character vectors. " to the helpfile of length(), because it is rather difficult to find nchar() if one has only search terms as "length", "len", "strlen" in mind. Sincerly Wolfram Fischer
2009 Dec 18
2
Vectorized switch
What is the 'idiomatic' way of writing a vectorized switch statement? That is, I would like to write, e.g., vswitch( c('a','x','b','a'), a= 1:4, b=11:14, 100 ) => c(1, 100, 13, 4 ) equivalent to ifelse( c('a','x','b','a') ==
2011 Oct 19
2
Speed difference between df$a[1] and df[1,"a"]
I was surprised to find that df$a[1] is an order of magnitude faster than df[1,"a"]: > df <- data.frame(a=1:10) > system.time(replicate(100000, df$a[3])) user system elapsed 0.36 0.00 0.36 > system.time(replicate(100000, df[3,"a"])) user system elapsed 4.09 0.00 4.09 A priori, I'd have thought that combining the row and column
2015 Apr 24
2
Development version of R: Improved nchar(), nzchar() but changed API
Those of you who track R development closely, will have noticed yesterday's commit of enhanced versions of nchar() and nzchar(). ------------------------------------------------------------------------ r68254 | maechler | 2015-04-23 18:06:37 +0200 (Thu, 23 Apr 2015) | 1 line Changed paths: M doc/NEWS.Rd M src/library/base/R/New-Internal.R M src/library/base/R/zzz.R M
2009 Apr 20
2
The assign(paste(...,i),...) idiom
Judging from the traffic on this mailing list, a lot of R beginners are trying to write things like assign( paste( "myvar", i), ...) where they really should probably be writing myvar[i] <- ... Do we have any idea where this bizarre habit comes from? -s
2009 May 27
1
R Books listing on R-Project
I was wondering what the criteria were for including books on the Books Related to R page <http://www.r-project.org/doc/bib/R-books.html>. (There is no maintainer listed on this page.) In particular, I was wondering why the following two books are not listed: * Andrew Gelman, Jennifer Hill, *Data Analysis Using Regression and Multilevel/Hierarchical Models*. (CRAN package 'arm') *