I have a tibble of data which looks like:
Ticker Date.x Rclose Fclose Close Date.y dumone yindex
<chr> <dttm> <dbl> <dbl> <dbl> <dttm> <dbl> <dbl>
1 AAAU 2018-08-15 00:00:00 NA NA 11.8 2018-08-15 00:00:00 1 1
2 AAAU 2018-08-16 00:00:00 0.0166 0.0025 11.7 2018-08-15 00:00:00 1 2
3 AAAU 2018-08-17 00:00:00 0.0166 0.0025 11.8 2018-08-15 00:00:00 1 3
4 AAAU 2018-08-20 00:00:00 0.0166 0.0025 11.9 2018-08-15 00:00:00 1 4
5 AAAU 2018-08-21 00:00:00 -0.0258 0.045 11.9 2018-08-15 00:00:00 1 5
6 AAAU 2018-08-22 00:00:00 -0.0273 0.0464 12.0 2018-08-15 00:00:00 1 6
For each ticker symbol there is 30 days of data. I would like to find the ticker with a Fclose >.5 anywhere in the group. But I just want that specific day where Fclose>-.5 but all the records in the group where at least one of the records has a Fclose>.5.
I am able to do the following with no problem:
bigRates<-subset(newdata7,Fclose>=.5)
bigRates<-unique(bigRates$Ticker)
newdata7 is the dataset. The final bigRates has the tickers where at least one of the days had fclose>.5 gives the tickers:
[1] "ADPT" "ADRO" "AIMT" "ANAB" "APRN" "AQUA" "ARD" "ARLO" "AVRO" "BAND" "BE" "BEDU" "BOX" "BPMP" "BTAI"
[16]
Now the problem is to take bigRates and use it to subset the newdata7 file along the lines of ticker. Problem is bigRates has no ticker column name (and perhaps the wrong type?) so that it can be used to select data from newdata6
I tried
result<-subset(newdata7,Ticker==bigRates)
and got the error message:
In Ticker == bigRates : longer object length is not a multiple of shorter object length
and I also tried
bigData <-merge(bigRates,newdata7, by=c("Ticker"), all.x=TRUE)
and got the error message
Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column
Note that bigRates has no column name (which it should for this to work, but when I do
colname(bigRates)<-c("Ticker")
I get the error message
Error in colname(bigRates) <- c("Ticker") : could not find function "colname<-"