I have a loop that isn't working but I need to figure out a better way to phrase the question. Can't delete it because someone tried to help me answer it already.
Asked
Active
Viewed 364 times
0
-
Hi there, please do the following three things: [1] copy the output of `dput(head(data))` here, where `data` is the name of your data frame. [2] Please provide the code before the loop as well, or at the very least the part where you specify `i`. [3] I'm getting the impression that you are writing an ifelse-clause where you don't need one. What exactly are you trying to achieve with the code? – slamballais Feb 15 '16 at 18:15
1 Answers
0
With out any data, its hard to tell the exact problem. If you really think it is truly an NA issue then you can add an is not NA clause to your if statement.
if (i == 1 && !is.na(i)){
Tab = as.data.frame(cbind(ID = i,
Value = ExtValue,
S40 = S40v,
S100 = S100v))}
else {
Tab = rbind(Tab, as.data.frame(cbind(ID = i,
Value = ExtValue,
S40 = S40v,
S100 = S100v)))
}
}
If you post your full code (including the loop) and a data using dput we can better help you.

Ted Mosby
- 1,426
- 1
- 16
- 41
-
I'm sorry, I'm very new to this and I don't know what dput is. I will start researching it asap. – userfriendly Feb 15 '16 at 18:01
-
type in dput(your data frame name) in the console and copy and paste that into your question. – Ted Mosby Feb 15 '16 at 18:03
-
-
subset it to include a minimal example. [READ THIS](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Ted Mosby Feb 15 '16 at 18:11
-
Thank you! I hope I did this correctly. Because I am doing spatial statistics, I also have a raster layer (LDI) and I'm not sure how to subset this in a way that will work because I only need the parts that intersect the sample points. – userfriendly Feb 15 '16 at 18:49