Displaying 20 results from an estimated 20000 matches similar to: "How to use 'switch' with strings containing spaces?"
2012 Nov 21
3
Problems understanding use of regular expression (in gsub) for manipulating currency
Hello,
After reading help file, various threads on this board, and other online tutorials, I've attempted to use gsub (using Perl-like syntax) to change a currency string into something that can be converted to numeric type using only one regular expression. Can anybody point out my error? Note that
> x <- "\"$ 1,200,300,400.50\""
Tried the following in an
2012 Mar 30
1
How to use access results of gregexpr in data frames
Hello,
I'm trying to figure out how to find the index of the second occurrence of "/" in a string (which happens to represent a date) within a data frame column.
I've used the following code successfully to find the first instance of "/".
dframe <- data.frame(date=c("5/14/2011", "4/7/2011"))
dframe$x1 <- regexpr("/", dframe[, 1])
2011 Jun 09
3
How to subset based on column name that is a number ?
Hi,
I have a data frame with column names "1", "2", "3", ... and I'd like to extract
a subset based on the values in the first column. None of the methods I tried
worked (below).
x <- subset(dframe, 1 = = "My Text")
x <- subset(dframe, "1" = = "My Text")
x <- subset(dframe, names(dframe)[1] = = "My Text")
Q
2012 Dec 15
1
How to limit string size when displaying data frames?
Hello,
Is there a way to set the maximum width of character columns when printing a data frame?
I've looked into print(), format(), and options() and have been unsuccessful.
For example, I'd like to achieve the results below without having to modify the data itself.
> x <- data.frame(c1=rnorm(5), c2="ABCDEFGHIJKLMNOPQRSTUVWXYZ")
> x
c1 c2
1
2012 Aug 27
2
Inexplicably different results using subset vs bracket notation on logical variable
Hi,
Would anyone have any idea as to why I would obtain completely different results when subsetting using the subset function vs bracket notation?
I have a data frame with 65 variables and 4382 rows. When I use execute the following subset command I get the correct results (125 rows)
> subset(df, Renewal==TRUE, 1:2)
However, I tried to obtain the same results with bracket notation as
2011 Sep 14
1
Can 'mosaic' be used with a continuous variable?
Hello,
I'm wondering if the 'mosaic' plot of the vcd package (or any other function for that matter) can be used with a continuous variable that should be represented via various categorical variables. All the documentation I've read lead me to believe that it only works with counts of categories.
Alternatively, I've thought of first creating a contingency table where the
2007 Mar 28
2
RV: By sentence
Hi dear listers
Do you know how to made a mean by one or more categorical variables?
I can do that quite easy on SAS by in R I just can't do it E.g.
Some fishes
Sex Lenght
male 15
fema 20
fema 17
fema 19
male 18
So the idea is mean(Lenght) by sex, in order to have sex: Male
mean=XX Sex: Fema mean=YY
In this case is quite easy to do it by a loop, but I have a huge DB
so is not an
2004 Oct 03
1
[wolfgang@rohdewald.de: Bug#274700: flac: --export-vc-to should quote strings containing spaces]
----- Forwarded message from Wolfgang Rohdewald <wolfgang@rohdewald.de> -----
Date: Sun, 03 Oct 2004 19:24:38 +0200
From: Wolfgang Rohdewald <wolfgang@rohdewald.de>
Resent-From: Wolfgang Rohdewald <wolfgang@rohdewald.de>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: Bug#274700: flac: --export-vc-to should quote strings containing spaces
Package: flac
2005 Aug 11
2
Converting strings with internal delimiters into lists
Hi UserRs,
I know that there has to be an easy way to do this in
R (probably easy enough that once someone clues me in
I'll smack myself on the forehead for not figuring it
out myself), but my searches on my own have not
yielded any hints.
I have many fields in my dataset that participants
entered as "free lists" - i.e., the field constitutes
a varying number of names each
2007 Aug 28
5
sql query over local tables
Hi i have to table with IDs in each one.
I want to make a join (as in sql) by the ID. Is any way to use the RODBC
package (or other) in local tables (not a access, mysql, sql, etc. ) and
made the join?
Thanks in advance
2020 Apr 22
2
parse data wrong for R 4.0. raw strings
This seems like a bug to me:
code <- 'x <- r"(hello, "world")"'
getParseData(parse(text = code))
#> line1 col1 line2 col2 id parent token terminal text
#> 7 1 1 1 24 7 0 expr FALSE
#> 1 1 1 1 1 1 3 SYMBOL TRUE x
#> 3 1 1 1 1 3 7 expr
2006 Dec 11
2
Switch and integer
I searched the help list and the manual, but I do not find my mistake.
Switch is working with character , with integer, but not in the third
example
Regards Knut
count1 <- 0
test
2001 Nov 09
2
confused by switch() and the letter E
I can't get switch() to work as expected with the letter 'E'. The following example from help works just fine.
> ccc <- c("b","QQ","a","A","bb")
> for(ch in ccc) cat(ch,":",switch(ch, a=1, b=2:3), "\n")
b : 2 3
QQ :
a : 1
A :
bb :
Now I replace "a=1" with "E=1"
2020 Apr 22
1
[External] parse data wrong for R 4.0. raw strings
I don't know, maybe it would make sense to keep the whole expression,
that's the text of the tag after all.
Also, if we don't keep the whole expression, then it is not a valid
string literal any more, because it does not have quoting.
I can try to look into a patch. This is for 4.1 I believe, so in some
sense it is not urgent?
Gabor
On Wed, Apr 22, 2020 at 3:31 PM <luke-tierney
2009 Nov 25
1
Question R's parser : - parsing "x=\n 1"
Hello
I was reading the source main/src/gram.y and had one question, how does R parse
x =
1
According the grammar:
prog : END_OF_INPUT { return 0; }
| '\n' { return xxvalue(NULL,2,NULL); }
| expr_or_assign '\n' { return xxvalue($1,3,&@1); }
| expr_or_assign ';' { return xxvalue($1,4,&@1); }
| error { YYABORT; }
;
So this should be of the 3rd
2014 Mar 21
1
Memcheck: error in a switch using getGraphicsEvent
Hi the list,
One of my package has an (other) error detected by memtest that I do not manage to understand.
Here is the message that I get from Memtest
--- 8< ----------------
> try(choice(cld1))
Error in switch(EXPR = choix, Up = { : EXPR must be a length 1 vector
--- 8< ----------------
The choice function does call the choiceChangeParam function, which is:
--- 8<
2007 Aug 28
1
Age-Length key with kimura algorith
Se ha borrado un texto insertado con un juego de caracteres sin especificar...
Nombre: no disponible
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070828/6641b572/attachment.pl
2011 Sep 01
1
parser does not catch strings without closing quote
Shouldn't the parser complain about unfinished strings in files?
It doesn't and will tack on a newline if there isn't one there.
> withOption <- function(optionList, expr) {
+ oldOption <- options(optionList)
+ on.exit(options(oldOption))
+ expr
+ }
> cat(file=tf<-tempfile(), "\"string without closing quote\n")
> p <-
2007 Apr 08
2
Plot symbols dimensions
I am writing some code to obtain publication-like plots (like the ones can be obtained with
SigmaPlot). I am not able to find the dimensions of a point. Parameters like cex make you able
to make it bigger or smaller but I need to know the exact dimension (in relative coordinates :
if my plot is 640x480 a dot plotted with cex=1.5 will be...)
Massimo Cressoni
2009 Dec 10
1
switch() called with just the EXPR argument causes R to hang (PR#14124)
Dear all,
switch() called with just the EXPR argument causes R to hang so that the
only way to stop it is to kill R.
Reproducible example:
> switch(EXPR="a")
the internal C subroutine behind switch is do_switch located in
R/src/main/builtin.c
For convenience I reproduce it below.
*****************************************************************************
SEXP attribute_hidden