Hello,
Maybe something like
data<-c(1,5,10)
func1<-function(x) {
nm <- deparse(substitute(x))
y<-x^2
z<-x^3
out<-data.frame(nm,y,z)
return(out)
} #function
func1(data[1])
Hope this helps,
Rui Barradas
Em 14-10-2014 19:12, Evan Kransdorf escreveu:
Hello Everyone,
I was w
On Feb 12, 2013, at 12:38 AM, Rainer M Krug wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 12/02/13 08:30, Ian Renner wrote:
>> Hi,
>>
>> I am trying to write a function which defines some arguments, then uses
>> those arguments as
>> arguments of other function calls. It's a
Hi Ian,
The remark of Rainer is correct, but I think the solution is very simpe:
f1 = function(a)
{
b = a + 1
b
}
f2 = function(x, z)
{
y = x*z(x) -2
y
}
> f2(x = 3, z = f1)
[1] 10
Or are you intending something else?
Best wishes,
Frans
-Oorspronkelijk bericht-
Van: r-help-boun...
On 13-02-12 5:34 AM, Jan T Kim wrote:
On Tue, Feb 12, 2013 at 09:38:19AM +0100, Rainer M Krug wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 12/02/13 08:30, Ian Renner wrote:
Hi,
I am trying to write a function which defines some arguments, then uses those
arguments as
arguments of
On Tue, Feb 12, 2013 at 09:38:19AM +0100, Rainer M Krug wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 12/02/13 08:30, Ian Renner wrote:
> > Hi,
> >
> > I am trying to write a function which defines some arguments, then uses
> > those arguments as
> > arguments of other functio
On Tue, Feb 12, 2013 at 7:30 AM, Ian Renner wrote:
> Where I am running into trouble is when I want to call function f1 within
> function f2:
>
> f2(x = 3, z = f1(x))
>
> This returns the error:
>
> "Error in f1(x) : object 'x' not found"
>
> I'm not sure how to define environments within the fu
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 12/02/13 08:30, Ian Renner wrote:
> Hi,
>
> I am trying to write a function which defines some arguments, then uses those
> arguments as
> arguments of other function calls. It's a bit tricky to explain, so a simple
> example will have
> to suff
Try this variation; might have something to do with scope:
testA<-function(input)
{
dat<- data.frame(A=seq(input,5), B=seq(6,10))
vec.names<- c("a", "b")
for(i in 1:ncol(dat))
{
tab<- dat[,i]-1
assign(vec.names[i], tab)
}
do.call("rbind", lapply(
Thanks Baptiste
On Fri, Sep 4, 2009 at 5:13 PM, baptiste auguie <
baptiste.aug...@googlemail.com> wrote:
> Hi,
>
> I think you've got a problem with environments,
>
> testA<-function(input=1)
>
> {
>
> dat <- data.frame(A=seq(input,5), B=seq(6,10))
> vec.names<- c("a", "b")
> env
Hi,
I think you've got a problem with environments,
testA<-function(input=1)
{
dat <- data.frame(A=seq(input,5), B=seq(6,10))
vec.names<- c("a", "b")
env <- new.env()
for(i in 1:ncol(dat))
{
tab<- dat[,i]-1
assign(vec.names[i], tab, env=env)
}
Looks like nobody answered so far.
If you want help: It is a good idea to say which package you are talking
about. In a clean R session I get:
> specprop
Error: object 'specprop' not found
> spec
Error: object 'spec' not found
hence no idea which functions from which package we are talking a
Agreed --- if you provided a working example it might be as simple as,
library(reshape)
recast(res, Id~Tick, fun="mean", id.var=c("Id", "Tick"),
measure.var="X")
which i had to test with this,
res <- list(read.table(textConnection(
"IdX Tick
1 2.2 1
2 3.1 1
1
I say again:
Build a simple example;
--
David Winsemius
On Mar 20, 2009, at 1:00 PM, Altaweel, Mark R. wrote:
I will try to be clearer with what I wanted.
What I am trying to do is take a list, say defined as res, that has
a size of 1000
For example:
res[[1]]
re
It might be your return statement. Look up 'return' in the help file
and you will see that you can only return a single value. If you want
multiple values returned, use a list:
return(listGmean,Gsd))
On Wed, Oct 22, 2008 at 11:53 AM, Alex99 <[EMAIL PROTECTED]> wrote:
>
> Hi there,
>
> I have a
Hi,
A repeatable example with data would help, as that way we could
see what was happening.
>
> sampling=function(fname,Total,nSample,nPatient){
> trans=t(A)
What's A? It isn't one of the arguments to your function.
And what's the transpose of a non-existent thing?
You may well have it in your
Dear Letticia,
Are you using R-help for your homework?
See your previous postings:
1. 15th September:
With a single R command complete the following:
create a vector calles seqvec that repeats the sequence 1, 3,6,
10,15,21.( I was trying to use c() but this does not work)
create a 5-row, 6-col
I think this might be what you want:
ex1.fcn<-function(x){
h<-4/(1+x^2)
return(h)
}
my.pi <-
function(sample.size, sim.size, low, hi, func)
{
# create output vector
result <- numeric(sample.size)
for (i in seq(sample.size)){ # loop for 'sample.size' times
my.rand.x <- runif(si
17 matches
Mail list logo