Displaying 20 results from an estimated 10000 matches similar to: "deparse operators in expressions"
2009 Nov 09
1
deparse() and the 'else' statement
Hi all,
It is recommended in ?'if' that we use 'else' right after '}' instead
of starting a new line, but I noticed deparse() will separate '}' and
'else' when the 'if...else' clause is used inside {...} (e.g. function
body). Here is an example:
## if/else inside {}
> cat(deparse(parse(text='function(){if (TRUE) {1} else {2}}')),
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)?
>
2013 Oct 21
2
png(type='cairo'): point symbols without boarders are not anti-aliased?
Hi,
It seems that anti-aliasing in png(type = 'cairo') is not well
supported for the point symbols without boarders, e.g. pch = 16. The
Cairo package works well, though. You can compare png() with
CairoPNG():
png(): http://i.imgur.com/8niB3jX.png
CairoPNG(): http://i.imgur.com/FZBJOxm.png
f = function(dev, ..., main = '') {
dev(...)
plot(c(1, 2, 1, 2), c(1, 1, 2, 2),
2011 Mar 05
1
file mode lost in file.copy()?
Hi,
Recently I noticed file.copy() would discard the file mode
information. Is this the expected behaviour or a bug for file.copy()?
> file.create('testfile')
[1] TRUE
> file.info('testfile')
size isdir mode mtime ctime
testfile 0 FALSE 644 2011-03-05 17:06:39 2011-03-05 17:06:39
atime uid gid uname grname
2011 Mar 05
1
file mode lost in file.copy()?
Hi,
Recently I noticed file.copy() would discard the file mode
information. Is this the expected behaviour or a bug for file.copy()?
> file.create('testfile')
[1] TRUE
> file.info('testfile')
size isdir mode mtime ctime
testfile 0 FALSE 644 2011-03-05 17:06:39 2011-03-05 17:06:39
atime uid gid uname grname
2010 Sep 18
1
Check for updates under Windows (Was: a reliable way to check the latest version of R on CRAN?)
Dear R developers,
I asked this question in r-help list but have not got a definite
solution yet, and I think it might be more appropriate to ask
developers or CRAN maintainers directly. Many software packages often
have a menu item like "Check for updates" under the "Help" menu, e.g.
Filezilla and Firefox, and I believe it is also necessary for R (at
least for R GUI under
2013 Jan 04
1
Bug in R CMD check for \ in Rd?
Hi,
I have a function knit_expand() and its source/Rd are below:
https://github.com/yihui/knitr/blob/master/R/template.R#L43-L44
https://github.com/yihui/knitr/blob/master/man/knit_expand.Rd
When I run R CMD check on the package I get this warning (with both R
2.15.2 and R-devel):
* checking for code/documentation mismatches ... WARNING
Codoc mismatches from documentation object
2012 May 22
2
how to remove the 'promise' attribute of an R object (.Random.seed)?
Hi,
The problem arises when I lazyLoad() the .Random.seed from a
previously saved database. To simplify the process of reproducing the
problem, see the example below:
## this assignment may not really make sense, but illustrates the problem
delayedAssign('.Random.seed', 1L)
typeof(.Random.seed)
# [1] "integer"
rnorm(1)
# Error in rnorm(1) :
# .Random.seed is not an integer
2012 May 22
2
how to remove the 'promise' attribute of an R object (.Random.seed)?
Hi,
The problem arises when I lazyLoad() the .Random.seed from a
previously saved database. To simplify the process of reproducing the
problem, see the example below:
## this assignment may not really make sense, but illustrates the problem
delayedAssign('.Random.seed', 1L)
typeof(.Random.seed)
# [1] "integer"
rnorm(1)
# Error in rnorm(1) :
# .Random.seed is not an integer
2013 Apr 08
2
savePlot() under Windows
Hi,
A Windows user asked me a question and I believe this is a bug of R
3.0.0 under Windows:
> plot(1:10)
> savePlot('test.wmf')
Error in .External(C_savePlot, device, filename, type, restoreConsole) :
Incorrect number of arguments (4), expecting 3 for 'savePlot'
> sessionInfo()
R version 3.0.0 (2013-04-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1]
2010 Nov 25
3
Go (back) from Rd to roxygen
Hi all,
Since roxygen is a great help to document R packages, I am wondering
if there exists an approach to go back from the raw Rd files to
roxygen-documentation? E.g. turn "\author{Somebody}" into "@author
Somebody". This sounds ridiculous, but I believe it helps in the long
term for me to maintain R packages.
Thanks!
Regards,
Yihui
--
Yihui Xie <xieyihui at
2011 Jun 20
1
Quote the path of graphics output in Sweave when it contains spaces
Hi,
I'm aware of the definition of a "valid filename" in
.SweaveValidFilenameRegexp, but I think it might be better to quote
the filename when it contains spaces instead of just giving a warning.
This should bring us safer LaTeX code (although I never use spaces in
paths).
Here is the simple patch:
Index: src/library/utils/R/SweaveDrivers.R
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
2011 Oct 17
1
What does \Sexpr[results=rd]{} exactly mean in Rd?
Hi,
I have spent a few hours on the R-exts manual and the documentation of
parse_Rd() (as well as the PDF document in the references), but I
still have not figured out what results=rd means. I thought I could
use an R code fragment to create an Rd fragment dynamically. Here is
an example, in which I was expected the output to be a describe list
<DL> in HTML, but it turns out not to be true.
2013 Sep 18
1
getParseData() for imaginary numbers
Hi,
The imaginary unit is gone in the 'text' column in the returned data
frame from getParseData(), e.g. in the example below, perhaps the text
should be 1i instead of 1:
> p=parse(text='1i')
> getParseData(p)
line1 col1 line2 col2 id parent token terminal text
1 1 1 1 2 1 2 NUM_CONST TRUE 1
2 1 1 1 2 2 0 expr
2013 Mar 09
1
Why cannot `Rscript -e` accept an empty line?
See the example below (under Ubuntu):
$ Rscript -e '1' -e '2'
[1] 1
[1] 2
$ Rscript -e '1' -e '' -e '2'
ERROR: option '-e' requires an argument
$ uname -a
Linux xie 3.5.0-25-generic #39-Ubuntu SMP Mon Feb 25 18:26:58 UTC 2013
x86_64 x86_64 x86_64 GNU/Linux
Similar problem under Windows:
Rscript -e "1" -e "" -e "2"
[1]
2010 Sep 16
1
a reliable way to check the latest version of R on CRAN?
Hi all,
We know old.packages() can check for updates of add-on packages, but
is there a way to check updates of R itself? "go to R homepage" is a
way, of course, but I hope this can be done by R.
I'm not sure about the "reliable" place to check; here is a simple
example to check from one of the CRAN webpages (kind of nasty
approach...):
x =
2010 Dec 14
1
redesign R.css for HTML help pages
Hi,
I feel the CSS definitions for the HTML help pages are not visually
appealing enough. I admit this is a very subjective matter, so I don't
have strong arguments for this wishlist, although I wrote my version
of R.css with some web design instructions in mind (e.g. use
browser-safe sans-serif fonts).
Anyway, here is what I've done:
2010 Nov 02
1
Line numbers in Sweave
Hi,
I thumbed through the source code Sweave.R but was unable to figure
out when (under what conditions) R will insert the line numbers to the
output. The R 2.12.0 news said:
? Parsing errors detected during Sweave() processing will now be
reported referencing their original location in the source file.
Do we have any options to turn off this reporting? Thanks!
Regards,
Yihui
--
2010 Nov 19
1
a rounding option for \Sexpr{}?
Hi all,
Currently Sweave does not format the (especially numeric) value in
\Sexpr{}, and I often have to round() the numbers explicitly,
otherwise I will get more than 10 digits, which is not necessary for
me in most cases. Is there a way to specify the number of digits to be
kept for values in \Sexpr{}? e.g. can we make \Sexpr{} respect
getOption('digits')?
Thanks!
Regards,
Yihui
--