Displaying 20 results from an estimated 4000 matches similar to: "deparse() and the 'else' statement"
2009 Mar 23
2
How to get commands history as a character vector instead of displaying them?
Hi Everyone,
I want to get the commands history as a character vector instead of
just displaying them, but the function history() just returns NULL. I
checked the source code of 'history' and could not find a solution.
Anybody has an idea? Thanks!
P. S. My original problem is, when a user opens a graphics device like
png() or pdf(), I want to know the file name used by this device. I
2009 Oct 04
1
Modify base R functions in Rprofile.site
Hi everyone,
I want to modify two base R functions 'parse' and 'deparse'
immediately after R has started, so I added some code in the file
'Rprofile.site' under the 'etc' directory. Here is a simple example:
parse=function(...){
base::parse(...)
}
I'll get an error when I start R as follows:
Error: cannot change value of locked binding for
2009 Oct 06
2
Help file doesn't display correctly
Dear R Developer,
It seems to be a problem with help file. Not sure if it is related to
the new format of Rd parser. Multiple lines are joined together
without proper line break.
> ?mean
There were 14 warnings (use warnings() to see them)
## All lines are joined together and not easy to read.
> warnings()
Warning messages:
1: In grepl("^[[:blank:]]*$", buffer[length(buffer)]) :
2011 Jan 05
2
convert expressions to characters
Hi,
Suppose I have
x = parse(text = "
{y=50+50+50#'asfasf'
}
")
now x is an expression with some src attributes.
> x
expression({y=50+50+50#'asfasf'
})
attr(,"srcfile")
<text>
attr(,"wholeSrcref")
{y=50+50+50#'asfasf'
}
My question is, how can I get my string back (the string passed to
parse() as the text argument)?
>
2006 May 09
1
A question about encoding
I use R 2.3.0 under windows.
> Sys.getlocale()
[1] "LC_COLLATE=Chinese_People's Republic of
China.936;LC_CTYPE=Chinese_People's Republic of
China.936;LC_MONETARY=Chinese_People's Republic of
China.936;LC_NUMERIC=C;LC_TIME=Chinese_People's Republic of China.936"
> localeToCharset()
[1] "CP936"
Now I want to use JGR,which uses UTF-8 encoding.
So when I use
2005 Apr 19
3
error due to locales again
>example(lm)
Error in switch(x[2], "1250" = return("ISO 8859-2"), "1251" = return("KOI8-U"), :
argument is missing, with no default
> Sys.getlocale(category = "LC_ALL")
[1] "LC_COLLATE=Chinese_People's Republic of China.936;LC_CTYPE=Chinese_People's Republic of China.936;LC_MONETARY=Chinese_People's Republic of
2011 Nov 14
1
Error .jcall(mxe, "S", "fit", c("autorun", "-e", afn, "-o", dirout, : java.lang.NoSuchMethodError: density.Params.readFromArgs([Ljava/lang/String; )Ljava/lang/String;
Dear all,
I get the error when I use maxent.jar:
Error .jcall(mxe, "S", "fit", c("autorun", "-e", afn, "-o", dirout, :
java.lang.NoSuchMethodError: density.Params.readFromArgs([Ljava/lang/String;)Ljava/lang/String;
sessionInfo() result:
R version 2.14.0 (2011-10-31)Platform: i386-pc-mingw32/i386 (32-bit)locale:[1]
2009 Nov 15
3
Error running lda example from Help File (MASS library )
Hello all,
I'm trying to run lda() from the MASS library but the Help example generates
the
following error:
#Code from example in lda Help file
# Resulting Error
>Error in if (targetlist[i] == stringname) { : argument is of length zero
My Current R Installation:
MacOSX: 10.5.8
R: 2.10.0
--
Gregory Riddick, PhD.
CRTA Research Fellow
National Institutes of Health
National
2013 Feb 17
1
tidy.source() gets confused when # is not a comment but a part of a literal string?
I needed to clean someone else code and run it through tidy.source. It encountered a number of hangups which after some experimentation lead me to suspect that the culprit is # symbol when it is a part of literal string. For example if i copy the following to the clipboard
confuse.tidy <-
function()
{
txt <- 'abra # cadabra'
}
and run with default arguments
>tidy.source()
2011 Apr 10
1
deparse operators in expressions
Hi,
I observed a slight problem in deparse(): it will add spaces around
most operators except /. I wonder if this is easy to fix. I know this
is quite trivial, but I will appreciate if / is not treated as an
exception. Examples:
> deparse(expression(1/1))
[1] "expression(1/1)"
> deparse(expression(1+1))
[1] "expression(1 + 1)"
> deparse(expression(1%in%1))
[1]
2009 Apr 03
1
new line between '}' and 'else' in function body
Hi list members,
?"else" tells us
In particular, you should not have a newline between '}' and
'else' to avoid a syntax error in entering a 'if ... else'
construct at the keyboard or via 'source'.
but there's no syntax error when you break the line between "}" and
"else" in a function, e.g.
f = function(x) {
2010 Mar 11
1
parse an HTML page with verbose error message (using XML)
I'm using the function htmlParse() in the XML package, and I need a
little bit help on error handling while parsing an HTML page. So far I
can use either the default way:
# error = xmlErrorCumulator(), by default
library(XML)
doc = htmlParse("http://www.public.iastate.edu/~pdixon/stat500/")
# the error message is:
# htmlParseStartTag: invalid element name
or the tryCatch()
2013 Jan 14
1
Issue with getParserData in R3.0.0
Hello,
I am migrating my package lambda.r to R3.0.0 and am experiencing some issues with the getParserData function (which replaces the parser package). Basically the function works in the R shell but fails when either called from RUnit or from R CMD check.
I've narrowed it down to the function getSrcfile, which is returning different values depending on the code path. From the command line
2011 Nov 14
1
.jinit() : Cannot create Java virtual machine
Dear all,
when using .jinit() I get the message .jinit() : Cannot create Java
virtual machine (-1).
The details:
I am using the Dismo package.Dismo has a function 'maxent' that communi-cates with this program(MaxEnt).MaxEnt is available as a stand-alone Java program.
It is normal when I execute the command : "jar <- paste(system.file(package="dismo"),
2008 May 14
2
basename/dirname produce incorrect results
The incorrect result incurs when the file path contains Chinese character.
It seems that dirname/basename action on unit of byte instead of char, so
the result in the following example is half of what is expected.
> g<-"d:\\$BG!2L4^M-CfJ8(B\\$BG!2L4^M-CfJ8(B.txt"
> dirname(g)
[1] "d:/$BG!2L4^(B"
> basename(g)
[1] "$BG!2L4^M-(B"
--
HUANG Ronggui,
2009 May 21
3
file descriptor leak in getSrcLines in R 2.10.0 svn 48590
I noticed the following file descriptor leak when I couldn't remove
a package unless I shut down the R session that had loaded and
used it. The function that triggered the problem printed the output
of a call to parse(). Each time one prints a srcref a connection is
opened and not closed. It looks like it happens in
as.character.srcref's
call to getSrcLines, which has some logic I
2024 May 30
1
[External] Re: Segfault when parsing UTF-8 text with srcrefs
I get an R error and no segfault:
> parse(textConnection(text), srcfile = srcfile)
Error in parse(textConnection(text), srcfile = srcfile) :
test.r:1:1: unexpected $end
1: ?
^
This is R 4.3.0, so maybe the bug has been introduced since then...
Version and system info:
> version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system
2024 May 28
2
Segfault when parsing UTF-8 text with srcrefs
Hi all,
When I run the following code, R segfaults:
text <- "?"
srcfile <- srcfilecopy("test.r", text)
parse(textConnection(text), srcfile = srcfile)
It doesn't segfault if text is ASCII, or it's not wrapped in
textConnection, or srcfile isn't set.
Hadley
--
http://hadley.nz
[[alternative HTML version deleted]]
2010 Apr 13
1
formatR: farewell to ugly R code
This is an announcement of the release of an R package 'formatR',
which can help us format our R code to make it more human-readable. If
you have ugly (I mean unformatted) R code like this:
?# rotation of the word "Animation"
# in a loop; change the angle and color
# step by step
for (i in 1:360) {
? # redraw the plot again and again
2010 Apr 13
1
formatR: farewell to ugly R code
This is an announcement of the release of an R package 'formatR',
which can help us format our R code to make it more human-readable. If
you have ugly (I mean unformatted) R code like this:
?# rotation of the word "Animation"
# in a loop; change the angle and color
# step by step
for (i in 1:360) {
? # redraw the plot again and again