Displaying 2 results from an estimated 2 matches for "newdepth".
Did you mean:
new_depth
2012 Jan 11
3
Accomplishing a loop on multiple columns
Hello,
I have a question concerning ?for loops? on multiple columns.
I made 91 columns with results (all made together with a for loop) and I
want to us lm to fit the model.
I want to compare the results of all these calculated columns (91) with one
column with observed values. I use the function lm to fit the model and
calculate r.squared. I manage to do this for each column separately:
For
2012 Jan 18
3
manipulating data of several columns simultaneously
...e done on column 2 till column
27, not on column 1
for (n in 2:27)
{
# I don?t know if I should indicate that there should be created an new
variable with 60 rows? I saw people doing it in a script, but it didn?t seem
necessary in an other script that was similar to it and I made myself?
# results$newdepth<-(1:60)
#next line I also don?t know if I should give it. If I did this whole thing
for only 1 column, the firs row was NA without asking for it.
results$newdepth[1,n]<-NA
for (t in 2:60)
{
results$newdepth[t,n] <- new[t-1,n]
}
results<- cbind(results, results$newdepth)
}
names(resu...