Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subsetting the terrain matrix #1

Open
bweedop opened this issue Nov 9, 2016 · 3 comments
Open

subsetting the terrain matrix #1

bweedop opened this issue Nov 9, 2016 · 3 comments

Comments

@bweedop
Copy link
Member

bweedop commented Nov 9, 2016

I have not been able to figure out how to subset the matrix in order to perform not only the first diamond and square but the sequential ones after that. If you could help any advice I would appreciate it!

Bodie

@willpearse
Copy link
Member

I didn't see you in the practical today. If you were there, it would have
been easier to help you...

The general idea is: you've written two functions that calculate the
diamond step and the square step. You're now going to write a wrapper
that, on each iteration:

  1. Figures out what the sub-matrices that need to have the diamond and
    square steps applied to them
  2. Loops over all those sub-matrices and applies the diamond step
  3. Loops over all those sub-matrices and applies the square step

...and this will keep going until your entire matrix is filled in. Remember
that you don't have to split the matrix into parts and then recombine it
to do this
: you can use the subset notation so that something like
matrix[1:3,1:3]
<- square.step(matrix[1:3,1:3])
can be used to give you the answer.

Does that make sense?

@bweedop
Copy link
Member Author

bweedop commented Nov 10, 2016

Sorry, I thought you had probably went over this in class. I have been getting progressively more ill and I thought I should save the others from whatever I have caught.

Yes, that makes sense...partially.
I got the subsetting to work but I am not sure how to make the wrapper function to figure out which submatrices need to have the functions applied to them. Could I use the is.na() command in order to find the NA values of the matrix and apply the diamond and square functions to the matrix between values that are not NA?

@willpearse
Copy link
Member

pop over to https://appear.in/usubioprogramming and i can help you there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants