Trying to generate a third variable, called "var", to the dataset that only has a value of 100 for the date "2010-09-24" and NA for all other time periods.
> dataset
weight
2010-10-04 52495
2010-10-01 53000
2010-09-30 52916
2010-09-29 52785
2010-09-28 53348
2010-09-27 52885
2010-09-24 52174
2010-09-23 51461
2010-09-22 51286
2010-09-21 50968
2010-09-20 49250
> dataset=merge(dataset,var=NA)
I know I could I use the ifelse(index(dataset)=="2010-09-24",100,NA)
to generate the variable. But are there any functions that one could employ to restrict the sample only to "2010-09-24" and then place the value in that right column and row?