Displaying 20 results from an estimated 2000 matches similar to: "bug: Editing function formals deletes the environment"
2008 Oct 24
18
Transferring results from R to MS Word
R-users
At the moment I am teaching a course on the use of R for data analysis.
Part of course requirements involves the transfer of results from R to
something that resembles the APA (American Psychological Associations)
type tables to MS Word. Until now I have used the HTML function in the
R2HTML library, with a call like this:
HTML(summary(model1), file("clipboard",
2005 Jul 21
3
vectorising ifelse()
Hi All,
is there any chance of vectorising the two ifelse() statements in the
following code:
for(i in gp){
new[i,1] = ifelse(srow[i]>0, new[srow[i],zippo[i]], sample(1:100, 1,
prob =Y1, rep = T))
new[i,2] = ifelse(drow[i]>0, new[drow[i]>0,zappo[i]], sample(1:100,
1, prob =Y1, rep = T))
}
Where I am forced to check if the value of drow and srow are >0 for each
line... in
2007 Nov 05
1
R2HTML package and Open Office: text only pasted
I am trying to use R2HTML (just downloaded from CRAN) to paste R (2.6.0)
results output via the clipboard to OpenOffice Writer and Calc
(version 2.3on WinXPPro)
Pasting into Excel gives a formatted table of results (as expected), but
pasting into Calc simply pastes the HTML code. Trying paste special only
gives an option to paste unformatted text.
Equally, with Writer, in the past when I tried
2006 Feb 09
9
Transferring R results to word prosessors
There has been an incredible number of responses in a short time, with a
number of different suggestions. With hindsight, I must admit I have not
been quite clear, so additional (somewhat lengthy) explanation is needed.
I want to use R in an introductory course on multiple regression (among
other things) starting in two weeks time for students of psychology at my
University. These students
2005 Apr 28
1
strange behaviour of importFrom directive in name space
Dear listers,
After activating the name space for my bioconductor package (prada) I
successfully ran R CMD check. However when loading the package in R and
running the examples the imported function brewer.pal from package
RColorBrewer is not found. I can directly call brewer.pal from the
RColorBrewer name space typing RColorBrewer::brewer.pal, but it is not
imported into my prada name space. When
2005 Apr 28
1
strange behaviour of importFrom directive in name space
Dear listers,
After activating the name space for my bioconductor package (prada) I
successfully ran R CMD check. However when loading the package in R and
running the examples the imported function brewer.pal from package
RColorBrewer is not found. I can directly call brewer.pal from the
RColorBrewer name space typing RColorBrewer::brewer.pal, but it is not
imported into my prada name space. When
2018 Oct 06
1
Warning when calling formals() for `[`.
Hi,
Thanks for the note. How would explain the following snippet taken from
`formals` doc page (the code comment is also from that doc) ?
## formals returns NULL for primitive functions. Use it in combination with
## args for this case.
is.primitive(`+`)
formals(`+`)
formals(args(`+`))
Le sam. 6 oct. 2018 ? 13:42, Rui Barradas <ruipbarradas at sapo.pt> a ?crit :
2003 Oct 10
1
incorrect behaviour of formals (PR#4511)
Full_Name: Jörg Polzehl
Version: 1.8.0
OS: Windows XP
Submission from: (NULL) (62.141.176.1)
I encountered a problem when playing with the mle library and specifying
negative
starting values for the parameters.
The reason seems to be an incorrect behaviour of function formals:
glike<-function(a=1,b=1,c=1) a
> formals(glike)
$a
[1] 1
$b
[1] 1
$c
[1] 1
> unlist(formals(glike))
a b c
2007 Jun 26
1
slight anomaly in formals<- ? (PR#9758)
Hi,
The R input/output after the following paragraph is from a session with
version.string R version 2.4.0 Patched (2006-11-23 r39958).
The last element, x$c, of x has no value and after the assignment of x to the
formals of f, x$c does not become a formal argument of f. The second assignment
does the job. It seems that x$c actually becomes the body of f after the first
assignment. There is no
2016 Mar 13
1
formals(x)<- drops attributes including class
Just checking in to see whether it is intended or not that assigning
new formals to a function/closure causes any attributes to be dropped:
EXAMPLE:
> fcn <- structure(function() {}, foo="foo", class=c("foo"))
> str(fcn)
function ()
- attr(*, "srcref")=Class 'srcref' atomic [1:8] 1 18 1 30 18 30 1 1
.. ..- attr(*, "srcfile")=Classes
1999 Mar 29
3
problems with formals and get (PR#151)
With 0.63.3, try
test <- function(){
fn <- function(a) print("hello")
print(is.function(fn))
print(names(formals("fn")))}
test()
if fn is not quoted in the last line of test, it works properly.
test <- function(){
fn <- function() print("hello")
formals(fn) <- alist(a=,b=)
return(fn)}
formals(test())
now try with line 3 of test changed to
2010 May 23
2
possible bug in formals
Hi,
I am a little bit surprised by the following output of
'formals'. Is this the intended behavior?
> f <- function(a=1,b=-1) { a+b }
> class(formals(f)$a)
[1] "numeric"
> class(formals(f)$b)
[1] "call"
Josef
--
-----------------------------------------------------------------------------
Josef Leydold | WU (Vienna University of Economics and
2007 Feb 05
1
Build error with last R-devel tarball
Hi,
On Windows, with last R-devel tarball (r40647) from
ftp://ftp.stat.math.ethz.ch/Software/R/R-devel_2007-02-04.tar.gz
I get the following build error:
E:\biocbld\bbs-2.0-bioc\R\src\gnuwin32> make
...
...
---------- Making package utils ------------
adding build stamp to DESCRIPTION
installing NAMESPACE file and metadata
installing R files
Error in namespaceExport(ns, exports) :
2005 Apr 30
1
formals assignment now strips attributres
The assignment form of 'formals' strips attributes (or something close
to that) from the values in the list. This wasn't intentional, was it?
The current behavior (2.0.0 through 2.1.0 on Windows at least):
> fjj <- function() x
> formals(fjj) <- list(x=c(a=2, b=4))
> fjj
function (x = c(2, 4))
x
Previous behavior:
> fjj <- function() x
> formals(fjj)
2014 Jan 19
1
formals() adds 0 to complex function arguments
Dear list,
I'm facing an issue with the automated documentation of a function using
roxygen2. The function has a complex-valued default argument, which is
picked up by roxygen2 using formals() to generate the corresponding Usage
section of the Rd file. Unfortunately, it appears that formals() reformats
complex numbers. Consider the example below,
test <- function(a = 1+2i){}
>
2018 Oct 06
5
Warning when calling formals() for `[`.
Hi,
A short code example showing the warning might the only thing needed here:
```
> formals(args(`[`))
NULL
*Warning message:In formals(fun) : argument is not a function*
> is.function(`[`)
[1] TRUE
> is.primitive(`[`)
[1] TRUE
```
Now with an other primitive:
```
> formals(args(`sum`))
$...
$na.rm
[1] FALSE
> is.function(`sum`)
[1] TRUE
> is.primitive(`sum`)
[1] TRUE
2016 May 01
2
Storage of byte code-compiled functions in sysdata.rda
Thanks, Luke, for having a look to it.
Sure, I can give you some reproducible example -- even in two degrees of
completeness ;-): see below.
Thanks again, Peter
%-----------------------------------
(I) first example
%-----------------------------------
Just to reproduce the error, on r-devel, try:
install.packages("RobAStRDA")
require(RobAStRDA)
getFromNamespace(".RMXE", ns
2016 May 01
2
Storage of byte code-compiled functions in sysdata.rda
Hi r-devels,
we are seeing a new problem with our packages RobAStRDA (just new on CRAN, thanks
to Uwe and Kurt!) and RobExtremes (to be submitted).
It must be something recent with the way you internally treat/store byte-code compiled
functions, as we have no problems with R-3.1.3, but do see an "Error in fct(x) : byte code
version mismatch" with R-devel SVNrev r70532.
Background:
2008 May 26
2
R 2.7.0: pdf() > pdf.options versus formals
Hi,
I have a tiny question about the graphics change in R 2.7.0.
If I write a script ? la:
options(device="pdf")
formals(pdf)[c("file","onefile","width","height")] <- list("~/Rplot
%03d.pdf", FALSE, 8, 8)
plot(3)
plot(4)
both plots will be written into ONE pdf file. (not two as expected)
This worked fine under 2.6.x
In R 2.7.0 I
2009 Jul 24
1
Most elegant way to use formals() in building functions
Dear Group:
I want to create a function having a ... argument and to have the
default arguments evaluated, as thus:
g <- function(a, b, ...) a+b
formals(g) <- alist(a=,b=2+3,...=)
g
function (a, b = 2 + 3, ...)
a + b
But I want the default argument for b to be evaluated as 5. How can
this be done? Note: My real need is for a more complex expression to be
evaluated for the default