Thank you all for your helpful comments!
I solved my problem by creating an empty matrix before the loop and
adjusting the loop itself, this is the code:
size <- dim(input)
out <- matrix('',nrow =size[1], ncol = 9)
for (i in 1:nrow(input)) {
out[i,1:3] <- unlist(MyFunction(input[i,1],input[
On Tue, Mar 13, 2012 at 11:27 AM, aledanda wrote:
> Dear All,
>
> I hope you don't mind helping me with this small issue. I haven't been using
> R in years and I'm trying to fill in a matrix
> with the output of a function (I'm probably using the Matlab logic here and
> it's not working).
> Here i
Yes, the short answer is that you need to define out before running
the loop. The most effective way to do so will be to set up a matrix
with the exact right dimensions (if you know them up front); something
like out <- matrix(NA, nrow = length(input), ncol = 9)
Michael
On Tue, Mar 13, 2012 at
Dear All,
I hope you don't mind helping me with this small issue. I haven't been using
R in years and I'm trying to fill in a matrix
with the output of a function (I'm probably using the Matlab logic here and
it's not working).
Here is my code:
for (i in 1:length(input)){
out[i,1:3] <- MyFunc
4 matches
Mail list logo