Hi,
Here is my data, the first 10 rows
u=regCond_all[1:10,]
dput(u)
structure(c(999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 1.9, 2, 1.97, 1.99, 1.83, 1.78, 1.6, 1.52, 1.52,
1.36, 10.53, 9.88, 9.88, 10.53,
Hi Yolande,
What's index() ?
I get
ind - which.min( abs(index(regCond_all) - thisStamp ))
Error in which.min(abs(index(regCond_all) - thisStamp)) :
could not find function index
There's probably an easier way to do whatever you're trying to
accomplish, but I'm afraid I can't tell what that
After replacing it to u
for(i in 1:dim(diveCond)[1]){
+ thisStamp - as.POSIXct(strptime(diveCond$timestamp[i], %Y-%m-%d
%H:%M:%S))
+ ind - which.min( abs(index(u) - thisStamp ))
+ diveCond$r_wvht[i]- u$WVHT[ind]
+ diveCond$r_dpd[i]- u$DPD[ind]
+ diveCond$r_apt[i] - u$APD[ind]
+
On Fri, Aug 3, 2012 at 4:04 PM, Yolande Tra yolande@gmail.com wrote:
I am sorry I forgot to mention it in the code.
library(xts) has the function index.
That's useful. But here's your first problem:
thisStamp - as.POSIXct(strptime(diveCond$timestamp[i], %Y-%m-%d %H:%M:%S))
You just
Yolande,
Please send your message to the R-help email list too, not just to me.
On Fri, Aug 3, 2012 at 4:28 PM, Yolande Tra yolande@gmail.com wrote:
Here is the description
I am trying to build the data diveCond from two datasets diveData_2008,
diveData_2009 and RegCond_all. How would I
When i == 10, what is ind?
diveCond$r_apt[10]
regCond_all$APD[ind]
Providing a subset is unhelpful. I gave you explicit dput() code to
use; that's how we need data to be provided.
I've given you various suggestions; if you don't implement them then
there's not much point in me trying to help.
Hi,
Here, I am getting the error:
for(i in 1:dim(diveCond)[1]){
thisStamp - as.POSIXct(strptime(diveCond$timestamp[i], %Y-%m-%d
%H:%M:%S))
ind - which.min( abs(index(regCond_all) - thisStamp ))
diveCond$r_wvht[i] - regCond_all$WVHT[ind]
diveCond$r_dpd[i] - regCond_all$DPD[ind]
This runs, so there must be something else going on that you haven't
told us about.
diveCond - structure(list(dive_id = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
timestamp = c(2008-08-06 08:49:00,
2008-08-06 10:03:00, 2008-08-06 10:25:00, 2008-08-08 09:42:00,
2008-08-08 10:53:00, 2008-08-08 12:42:00,
i=10
thisStamp - as.POSIXct(strptime(diveCond$timestamp[i], %Y-%m-%d
%H:%M:%S))
thisStamp
[1] 2008-08-11 14:12:00 EDT
ind - which.min( abs(index(regCond_all) - thisStamp ))
ind
[1] 506
diveCond$r_wvht[i]
[1] 0
regCond_all$WVHT[ind]
WVHT
2008-08-11 14:22:00 1.35
It did
On Fri, Aug 3, 2012 at 5:14 PM, Yolande Tra yolande@gmail.com wrote:
i=10
thisStamp - as.POSIXct(strptime(diveCond$timestamp[i], %Y-%m-%d
%H:%M:%S))
thisStamp
[1] 2008-08-11 14:12:00 EDT
ind - which.min( abs(index(regCond_all) - thisStamp ))
ind
[1] 506
diveCond$r_wvht[i]
[1] 0
10 matches
Mail list logo