Hi all, Can somebody explain why length("") returns 1 and not 0? How do I test if a given string is the empty string? Thanks, Steffen. [[alternative HTML version deleted]]
Le vendredi 18 novembre 2011 ? 16:09 +0100, Jaensch, Steffen [TIBBE] a ?crit :> Hi all, > > Can somebody explain why length("") returns 1 and not 0?Probably because it contains one element, "".> How do I test if a given string is the empty string?a <- "" a == "" [1] TRUE Seems to be enough to me. ;-) Cheers
On Nov 18, 2011, at 10:09 AM, Jaensch, Steffen [TIBBE] wrote:> Hi all, > > > > Can somebody explain why length("") returns 1 and not 0? How do I test > if a given string is the empty string?character(0) is not the same as "" -- David Winsemius, MD West Hartford, CT
> nchar("")[1] 0 On Friday 18 November 2011 16:09:38 Jaensch, Steffen [TIBBE] wrote:> Hi all, > > > > Can somebody explain why length("") returns 1 and not 0? How do I test > if a given string is the empty string? > > > > Thanks, > > Steffen. > > > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html and provide commented, > minimal, self-contained, reproducible code.
R. Michael Weylandt <michael.weylandt@gmail.com>
2011-Nov-18 15:57 UTC
[R] length of empty string
Because it's a character vector with only one element, which just happens to be empty - sort of like why the cardinality of the set { /O } is one. (/O being my best shot at the empty set symbol in plain text). You might be thinking of nchar(). Michael On Nov 18, 2011, at 10:09 AM, "Jaensch, Steffen [TIBBE]" <SJAENSCH at its.jnj.com> wrote:> Hi all, > > > > Can somebody explain why length("") returns 1 and not 0? How do I test > if a given string is the empty string? > > > > Thanks, > > Steffen. > > > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Possibly Parallel Threads
- unix_primary_group=yes together with vfs objects=acl_xattr not working
- unix_primary_group=yes together with vfs objects=acl_xattr not working
- Cardinality constraint
- constrained optimization
- DEoptim example illustrating use of fnMap parameter for enforcement of cardinality constraints