Displaying 10 results from an estimated 10 matches for "somefun".
Did you mean:
somefunc
2010 Apr 19
2
How to pass a list of parameters into a function
Does anyone know how to pass a list of parameters into a function?
for example:
somefun=function(x1,x2,x3,x4,x5,x6,x7,x8,x9){
ans=x1+x2+x3+x4+x5+x6+x7+x8+x9
return(ans)
}
somefun(1,2,3,4,5,6,7,8,9)
# I would like this to work:
temp=c(x3=3,x4=4,x5=5,x6=6,x7=7,x8=8,x9=9)
somefun(x1=1,x2=2,temp)
# OR I would like this to work:
temp=list(x3=3,x4=4,x5=5,x6=6,x7=7,x8=8,x9=9)
some...
2023 Jan 12
1
return value of {....}
...d to C-type languages. But I will try to
explain some of the rationale.
In the case that "{...}" was a closure, then external variables would
need to be explicitly declared before the closure (in order to reuse
those values):
intermediate = c()
{
??? intermediate = ...;
??? result = someFUN(intermediate);
}
1.) Interactive Sessions
This is cumbersome in interactive sessions. For example: you often
compute the mean or the variance as intermediary results, and will need
them later on as well. They could have been computed outside the
"closure", but writing code in interact...
2005 May 03
2
General Question on learning R...
In the process of learning R, with a specific interest on financial
time series. While I continue to get through the documents I am more
a fan of learning by example and then looking up how each function is
used. Any websites which post sample code for R?
Thanks in advance.
--
Jonathan
jqm475 at gmail.com
2011 Jul 17
1
NAMESPACE
> Packages without explicit ?NAMESPACE? files will have a default one created at build or INSTALL time,
> so all packages will have namespaces. A consequence of this is that ?.First.lib? functions need to be
> renamed, usually as ?.onLoad? but sometimes as ?.onAttach?.
Couldn't R simply regard .First.lib as the appropriate function to
save many packages from
being needlessly changed?
2011 Feb 25
2
Variable names AS variable names?
How can I dynamically use a variable as the name for another variable?
I realize this sounds cryptic, so an example is best:
#Start with an array of "codes"
codes <- c("a1", "b24", "q99")
#Each code has a corresponding matrix (could be vector)
a1 <- matrix(rnorm(100), nrow=10)
b24 <- matrix(rnorm(100), nrow=10)
q99 <- matrix(rnorm(100),
2012 Mar 29
1
How to create arbitrary number of loops in R
Dear R users,
I'm wondering how I can generate an arbitrary number of loops in R.
For instance, I can generate two "for" loops to get ICC among any two-way combination among 10 variables. Here is the code
n<-10
for (i in 1:(n-1))
{
for (j in (i+1):n)
{
icc(cbind(DATA[,i],DATA[,j]))
}
}
If I need three-way combination, then a code with three "for" loops will be:
2020 Jan 21
2
class(<matrix>) |--> c("matrix", "arrary") -- and S3 dispatch
...;) which invalidates
> code (wrongly) assuming that length(class(obj)) == 1, a wrong
> assumption that is less frequently fulfilled now. (Currently
> only after setting _R_CLASS_MATRIX_ARRAY_ to non-empty.)
>
> S3 methods for "array", i.e., <someFun>.array(), are now also
> dispatched for matrix objects.
>
> ------------------------------------------------------------
> (where only the very last 1.5 lines paragraph is new.)
>
> Note the following
> (if you use a version of R-devel, with svn rev >= 77446; whi...
2019 Nov 21
0
class(<matrix>) |--> c("matrix", "arrary") -- and S3 dispatch
...atrix", "array") which invalidates
code (wrongly) assuming that length(class(obj)) == 1, a wrong
assumption that is less frequently fulfilled now. (Currently
only after setting _R_CLASS_MATRIX_ARRAY_ to non-empty.)
S3 methods for "array", i.e., <someFun>.array(), are now also
dispatched for matrix objects.
------------------------------------------------------------
(where only the very last 1.5 lines paragraph is new.)
Note the following
(if you use a version of R-devel, with svn rev >= 77446; which
you may get as a binary for Wind...
2020 Jan 28
0
class(<matrix>) |--> c("matrix", "arrary") -- and S3 dispatch
...alidates
>> code (wrongly) assuming that length(class(obj)) == 1, a wrong
>> assumption that is less frequently fulfilled now. (Currently
>> only after setting _R_CLASS_MATRIX_ARRAY_ to non-empty.)
>>
>> S3 methods for "array", i.e., <someFun>.array(), are now also
>> dispatched for matrix objects.
>>
>> ------------------------------------------------------------
>> (where only the very last 1.5 lines paragraph is new.)
>>
>> Note the following
>> (if you use a...
2019 Nov 15
5
class(<matrix>) |--> c("matrix", "arrary") [was "head.matrix ..."]
>>>>> Pages, Herve
>>>>> on Thu, 14 Nov 2019 19:13:47 +0000 writes:
> On 11/14/19 05:47, Hadley Wickham wrote:
>> On Sun, Nov 10, 2019 at 2:37 AM Martin Maechler
>> <maechler at stat.math.ethz.ch> wrote:
>>>
>>>>>>>> Gabriel Becker
>>>>>>>> on Sat, 2 Nov 2019