Please, please do not use html formatted mail.
It is clearly requested by the mailing list
The code of your last mail is a mess and when replying it becomes even more of
a mess.
I told you to do
siml[g,] <- optm(perm=20)
See the comma after g.
and not what you are now doing with siml[g]<-op
On 07-06-2013, at 11:57, Laz wrote:
> Dear Berend,
>
> I have made some changes but I still get errors:
>
> For reproducibility,
> Rspatswap() is a function which originally returns a single value. For
> example Rspatswap(...) and you get 0.8
>
> So, run Rspatswap() 20 times and store all
Hi,
I am almost getting there, but still have errors. Thanks for your help.
I have tried improving but I get the following errors below:
>itn<-function(it){
+siml<-matrix(NA,ncol=5,nrow=it)
+for(g in 1:it){
+siml[g]<-optm(perm=20)[g]
+}
+siml
+}
>itn(3)
[,1] [,2] [,3] [,4] [,5]
[1,
Dear Berend,
For reproducibility,
Rspatswap() is a function which originally returns a single value. For
example Rspatswap(...) and you get 0.8
So, run Rspatswap() 20 times and store all the values.
Then from these 20 values, calculate the calculate average,
sd,se,min,max to get something si
On 07-06-2013, at 10:59, Laz wrote:
> Dear R users,
>
> I am stuck here: My first function returns a vector of 5 values.
> In my second function, I want to repeat this, a number of times, say 10
> so that I have 10 rows and five columns but I keep on getting errors.
>
> See the code and resul
Dear R users,
I am stuck here: My first function returns a vector of 5 values.
In my second function, I want to repeat this, a number of times, say 10
so that I have 10 rows and five columns but I keep on getting errors.
See the code and results below:
optm <-function(perm, verbose = FALSE)
{
Is this what you want? I was not clear on your algorithm, but is looks
like you wanted descending values:
> testx <-
+ function(n, verbose = FALSE)
+ {
+ mat <- cbind(optA = sample(n, n, TRUE), perm = seq(n))
+ if (verbose){
+ cat("***starting matrix\n")
+ print(mat)
+
Dear R Users,
I created a function which returns a value every time it's run (A
simplified toy example is attached on this mail).
For example spat(a,b,c,d) # run the first time and it gives you ans1=
10, perm=1 ;
run the second time and gives you ans2= 7, perm=2 etc
I store both the result
Thanks Jim!
--- On Tue, 12/7/10, jim holtman wrote:
From: jim holtman
Subject: Re: [R] Help on loops
To: "Anup Nandialath"
Cc: r-help@r-project.org
Date: Tuesday, December 7, 2010, 7:47 PM
use split and lapply to make it easier. Substitute in your own
calculations since this
use split and lapply to make it easier. Substitute in your own
calculations since this is just an example:
> x
id t X1 X2
1 1 1 4 3
2 1 2 9 2
3 1 3 7 3
4 1 4 6 6
5 2 1 6 4
6 2 2 5 3
7 2 3 1 1
8 3 1 9 6
9 3 2 5 5
> # first split the data by 'id'
> x.s <- split(x, x$id)
Dear R-helpers,
I have a basic question on using loops.
I have a panel data set with different variables measured for "n" firms over
"t" time periods. A snapshot of the data is given below
id t X1 X2
1 1 4 3
1 2 9 2
1 3 7 3
1 4 6 6
2 1 6 4
11 matches
Mail list logo