Try using indexes. i.e.
idx=which(fxdata == 0, TRUE) #stores observations with values =0
(assuming all your zeros are true zeros and not just a print problem)
fxdata2=fxdata[-(idx),] #Removes rows with one or more observations = 0
fxdata2
bid ask
6300 109.79 109.81
6302 109.79 109.81
6303 109.79 109.80
6304 109.79 109.81
6305 109.79 109.80
6308 109.78 109.80
6309 109.78 109.79
6310 109.76 109.79
6311 109.76 109.78
6313 109.77 109.79
6314 109.77 109.80
6315 109.77 109.78
6316 109.77 109.79
6317 109.77 109.80
6318 109.77 109.78
6319 109.77 109.80
6320 109.77 109.78
Is this what you are after?
Cheers,
Francisco
Leeds, Mark (IED) wrote:> I have the structure, fxdata, below and I want to only keep data points
> of it in which the "bid" and the "ask" column names are
both
> greater than zero. It's very hard to reproduce my problem because it
> seems like the behavior ( whether it gets rid of all the the zeros or
> not ) depends on the size of fxdata ?
>
> I had the following line for doing the above :
>
> fxdata<-fxdata[( fxdata[,"bid"] > 0.0 ) & (
fxdata[,"ask"] > 0.0 ),]
>
> But I am thinking that there maybe there is a problem with this
> type of approach because of roundoff error ? Does someone know of a more
> stable way
> of checking this condition ?
>
> There is no need to cut and paste the code above or below because the
> above
> line above, for certain sizes of temp, does seem to work. But,
> then when temp gets too large, it seems to only get some of the zeros ?
> I realize this seems strange but I
> honestly seemed to have found this, unless I am making a mistake and not
> realizing it ? Hs anyone ever had a case where the behavior of an if
> statement depended on the size of the object it was working on ? Thanks
> a lot.
>
> # fxdata OBJECT
>
> fxdata<-structure(c(109.79, 109.79, 109.79, 109.79, 109.79, 109.79,
> 109.78,
> 109.78, 109.78, 109.78, 109.76, 109.76, 109.77, 109.77, 109.77,
> 109.77, 109.77, 109.77, 109.77, 109.77, 109.77, 109.81, 109.8,
> 109.81, 109.8, 109.81, 109.8, 0.0, 0.0, 109.8, 109.79, 109.79,
> 109.78, 0.0, 109.79, 109.8, 109.78, 109.79, 109.8, 109.78,
> 109.8, 109.78), .Dim = c(21, 2), .Dimnames = list(c("6300",
"6301",
> "6302", "6303", "6304", "6305",
"6306", "6307", "6308", "6309",
> "6310", "6311", "6312", "6313",
"6314", "6315", "6316", "6317",
> "6318", "6319", "6320"), c("bid",
"ask")), index > structure(c(1097576426,
> 1097576429, 1097576442, 1097576443, 1097576451, 1097576459, 1097576465,
> 1097576469, 1097576471, 1097576478, 1097576494, 1097576495, 1097576496,
> 1097576498, 1097576510, 1097576511, 1097576513, 1097576519, 1097576521,
> 1097576523, 1097576526), class = c("POSIXt",
"POSIXct"), tzone = ""),
> class = "zoo")
> --------------------------------------------------------
>
> This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Dr. Francisco J. Zagmutt
College of Veterinary Medicine and Biomedical Sciences
Colorado State University