Hello,
I added your flags in my code but there are still errors.
Actually I tried some things:
- in function na.fill, I changed:
if(all(!is.na(y[1:8700,1]))) return(NA) to
if(all(!is.finite(y[1:8700,1]))) return(y)
In order to have this file unchanged.
It has removed my dimension problem.
Please read the posting guide mentioned at the bottom of every message.
You might also benefit from reading
http://stackoverflow.com/questions/5963269/how-to-make-a-great-reproducible-example.
We would certainly benefit from not having to guess what problems you are
really encountering.
Also,
Ok Jeff, but then it'll be a big one. I'm working on a list of files and my
problem depends on different functions used previously. So it's very hard
for me to summarize to reproduct my error. But here is the reproductible
example with the error at the last line of the code (just copy and paste
Still not clear what solution you would consider a success. On the one hand,
you said you needed the NULLs, but you want one big data frame also.
Does
refill - refill[ -which( sapply( refill, is.null ), arr.ind=TRUE ) ) ]
refill - as.data.frame( refill )
do what you want? If you need to keep
Thanks again for your help jeff.
Sorry if I'm not very clear. It's programmingly speaking hard to explain,
and even to explain in english as I'm French.
But i'll try again.
Well your proposition removes the error, but it's not the result I'm
expecting. You've removed NULL data.frames, but I need
Hello,
Why don't you test an all(is.na(x)) condition? If TRUE, return(NA), not
NULL.
Rui Barradas
Em 06-06-2012 16:42, jeff6868 escreveu:
Thanks again for your help jeff.
Sorry if I'm not very clear. It's programmingly speaking hard to explain,
and even to explain in english as I'm French.
Thanks again but my errors are still here. Is it maybe coming from the next
fonction (I combinate these 2 functions but I thought it was coming from the
first one):
process.all - function(df.list, mat){
f - function(station)
na.fill(df.list[[ station ]], df.list[[
Hello,
I believe the error is in function 'g'. If I'm right, follow these steps
1. Just before the first if include
flag - TRUE
2. Just before for(y in ord) include
flag - FALSE
3. Just before break include
flag - TRUE
3. Change the return value form simply x to
if(flag) x else NA
The code
I find that avoiding using the return() function at all makes my code easier to
follow. In your case it is simply incorrect, though, since ifelse is a vector
function and return is a control flow function.
Your code is not reproducible and your description isn't clear about how you
are
Hello,
'ifelse' is vectorized, what you want is the plain 'if'.
if(all(is.na(xx))) return(NA)
Hope this helps,
Rui Barradas
Em 04-06-2012 09:56, jeff6868 escreveu:
Hello dear R-users,
I have a problem in my code about ignoring NA values without removing them.
I'm working on a list of
Thanks for answering Jeff.
Yes sorry it's not easy to explain my problem. I'll try to give you a
reproductible example (even if it'll not be exactly like my files), and I'll
try to explain my function and what I want to do more precisely.
Imagine for the example: df1, df2 and df3 are my files:
Hello Rui,
Sorry I read your post after having answered to jeff.
If seems effectively to be better than ifelse, thanks. But I still have some
errors:
Error in x[1:8700, 1] : incorrect number of dimensions AND
In is.na(xx) : is.na() applied to non-(list or vector) of type 'NULL
It seems to have
Hello again,
The complete function would be
na.fill - function(x, y){
# do this immediatly, may save copying
if(all(is.na(y[1:8700,1]))) return(NA)
i - is.na(x[1:8700,1])
xx - y[1:8700,1]
new - data.frame(xx=xx)
x[1:8700,1][i] - predict(lm(x[1:8700,1]~xx,
13 matches
Mail list logo