On Fri, Aug 3, 2012 at 5:14 PM, Yolande Tra 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
> 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:0
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 1
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]
diveCo
> dput(head(diveCond, 10))
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", "2008-08-11 10:10:00",
"2008-08-11 11:01:00", "2008-08-11 11:
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.
Sa
I have tried 1 and 2. Then for i=10, the error came back
> i=1
> thisStamp <- as.POSIXct(strptime(diveCond$timestamp[1], "%Y-%m-%d
%H:%M:%S"))
> ind <- which.min( abs(index(regCond_all) - thisStamp ))
> diveCond$r_wvht[1]<- regCond_all$WVHT[ind]
> diveCond$r_dpd[1]<- regCond_all$DPD[ind]
> diveCond
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 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 dput each data for
On Fri, Aug 3, 2012 at 4:04 PM, Yolande Tra 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 created diveCond as a d
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]
+ diveCond$
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 th
Thanks Peter.
We did manage to solve the problem using the approach bellow.
Hab <- cbind(seq(1,21),habitat)
hab <- matrix(NA,nrow=3,ncol=7)
for (i in 1:3) {hab[i,] <- Hab[habitat==i,1]}
The problem was that the hab matrix was not a multiple of habitat.
--
View this message in context:
ht
On 2012-07-08 06:57, fabiano wrote:
Thanks Peter.
We had a look at both Hab and habitat. These are integers representing
habitat types.
habitat <- read.csv("Ungulate_vegetation.csv")
habitat <- habitat[,3]
habitat
[1] 3 3 4 3 3 3 4 4 3 3 3 3 3 4 2 3 2 3 2 3
Hab <- cbind(seq(1,20),habitat)
Hab
Thanks Peter.
We had a look at both Hab and habitat. These are integers representing
habitat types.
habitat <- read.csv("Ungulate_vegetation.csv")
habitat <- habitat[,3]
habitat
[1] 3 3 4 3 3 3 4 4 3 3 3 3 3 4 2 3 2 3 2 3
Hab <- cbind(seq(1,20),habitat)
Hab
habitat
[1,] 1 3
[2
On 2012-07-07 03:19, fabiano wrote:
I have been working on the following code but keep getting an err message. My
current thinking is that the problem is on the indexing but do not know how
to fix it. Any help please?
ungulate <- read.csv("Ungulate.csv",row.names=1)
ungulate <-
as.matrix(ungulat
Your request fails the reproducibility requirement from the posting guide,
because you have not supplied enough data to run the code and reproduce the
error.
---
Jeff NewmillerThe . .
16 matches
Mail list logo