通过从该日期开始减去1年,以比今天更大的日期更新class MySelect extends Component {
state = {
options: [],
}
populateArray = () => {
var newOptions = [];
/* Populate the `newOptions` array */
this.setState({ options: newOptions });
}
render() {
return (<>
<Button onClick={this.populateArray}>Click me</Button>
<Select { ... } options={this.state.options} />
<>);
}
}
列
dataframe
答案 0 :(得分:1)
如果目的是更新原始列,则无需filter
。使用case_when
,我们创建一个逻辑条件并在日期大于today()
时减去一年,否则返回日期
library(dplyr)
df1 %>%
mutate(Fresh.email.date = ymd(Fresh.email.date),
Fresh.email.date = case_when(Fresh.email.date > today() ~
Fresh.email.date - years(1),
TRUE ~ Fresh.email.date))