Re: [R] Pass Conditional loop argument into a function

2012-08-09 Thread David Winsemius
On Aug 8, 2012, at 2:16 PM, greatest.possible.newbie wrote: Ok I see that point with the quotes. But what I want to do still doesn't work: a - matrix(1:15,ncol=3) b - paste( paste(a[, ,paste(1:3), ],sep=) ,^,1:3,sep=,collapse=+) b #[1] a[,1]^1+a[,2]^2+a[,3]^3 #instead of (which I want)

[R] Pass Conditional loop argument into a function

2012-08-08 Thread greatest.possible.newbie
Dear R community, I have been spending hours to solve my problem myself but I'm just unable to do it. So excuse me if I demand your time. My problem is, that inside my function, I want to pass conditional arguments (that are the result of a loop) into a function. I am sure that my approach is

Re: [R] Pass Conditional loop argument into a function

2012-08-08 Thread S Ellison
First thing; are you trying to fit a model specified as y ~ X + X^2 + X^3 ? ... because if you are you're unlikely to get anything useful. That uses formula syntax in which ^ does not have the arithmetic power meaning; see section 11.1 'Defining statistical models; formulae' in 'an

Re: [R] Pass Conditional loop argument into a function

2012-08-08 Thread greatest.possible.newbie
Thank you for your improvement suggestions. I forgot to write the I() and it's clear that I have to specify the data (which I was indicating with the '...' without explicitly writing it). In this special case where I need a formula you really helped me with the function as.formula() to transform

Re: [R] Pass Conditional loop argument into a function

2012-08-08 Thread Rui Barradas
Hello, The other problem with the boxplot question is that it's ill defined. Those data[,1], ..., data[, n] variables, what are they? All of them numeric? If so, then where is the factor? Some time ago there was a question on multiple boxplots with cut() defining the factor. I wrote a

Re: [R] Pass Conditional loop argument into a function

2012-08-08 Thread Jeff Newmiller
The quotes shown on a string when you print it are artifacts of making the string usable in source code... they are not present in the string as it is stored in memory. (Same goes for escape sequences, such that \n occupies one byte of UTF8 storage.) You can use the cat function to send the

Re: [R] Pass Conditional loop argument into a function

2012-08-08 Thread greatest.possible.newbie
Ok I see that point with the quotes. But what I want to do still doesn't work: a - matrix(1:15,ncol=3) b - paste( paste(a[, ,paste(1:3), ],sep=) ,^,1:3,sep=,collapse=+) b #[1] a[,1]^1+a[,2]^2+a[,3]^3 #instead of (which I want) a[,1]^1+a[,2]^2+a[,3]^3 #[1] 1368 1779 2264 2829 3480 or I want to

Re: [R] Pass Conditional loop argument into a function

2012-08-08 Thread S Ellison
, e=1:3) # [1] 1368 1779 2264 2829 3480 From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of greatest.possible.newbie [daniel.h...@gmx.net] Sent: 08 August 2012 22:16 To: r-help@r-project.org Subject: Re: [R] Pass Conditional loop

Re: [R] Pass Conditional loop argument into a function

2012-08-08 Thread David Winsemius
On Aug 8, 2012, at 2:16 PM, greatest.possible.newbie wrote: Ok I see that point with the quotes. But what I want to do still doesn't work: a - matrix(1:15,ncol=3) b - paste( paste(a[, ,paste(1:3), ],sep=) ,^,1:3,sep=,collapse=+) b #[1] a[,1]^1+a[,2]^2+a[,3]^3 #instead of (which I want)