语法:英语中表示时间范围的介词——sinceduringuntil/tillfor
Posted guosiying
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了语法:英语中表示时间范围的介词——sinceduringuntil/tillfor相关的知识,希望对你有一定的参考价值。
since
一、本义:自从...以来
We’ve been waiting here since two o’clock. 我们从两点钟开始就在这里等了
I haven’t played rugby since I left university. 我大学毕业后就没打过橄榄球
I have never been employed since January. 我从一月以来未被雇用
I\'ve lived here since I was born. 我自从出生以来一直住在这里
She left London ten years ago, and I haven’t seen her since. 她十年前离开伦敦,此后我再没有见过她。
The factory has been here since the 1970s. 这家工厂从 20 世纪 70 年代起就在这里了。
It was exactly five years since her father had died. 从她父亲去世到现在正好满五年
Since the end of the war, over five thousand prisoners have been released. 自从战争结束以后,已有五千多名战俘获释
He lost his job five years ago, but has since found other work. 他五年前失去工作,但此后找到了其他工作。
I left school in 1995, and since then I’ve lived in London. 我 1995 年离开学校,此后就在伦敦生活
二、辨析
since vs because
since/as 表示常识的理由,because 表示解释的理由
I hate you because I love you. 我恨你因为我爱你
We need to protect our environment since/as we have only one earth. 我们需要保护我们的环境,因为我们只有一个地球
三、扩展
ever since 至今,直到现在,迄今为止 | I have distrusted her ever since she cheated me. 自从她骗我以后,我就不信任她了
since then 从那时起,从那时以来 | And I no longer like skating since then. 从那时起我就不再喜欢滑冰了。
long since 很久以前;从前 | The wheel had long since rusted from years of disuse. 多年不用的车轮早已锈迹斑斑
during
一、本义:在...期间
during the 1990s 在 20 世纪 90 年代
During the summer she worked as a lifeguard. 夏天她当过救生员
He slept calmly during the early part of the night. 他上半夜睡得很安稳
Foxes remain hidden during the day. 狐狸白天一直躲藏着
二、引申
1、在一段时间中的某一时候
He was taken to the hospital during the night. 他在夜间被送到医院
My father was killed during the war. 我父亲在战争中牺牲
I mentioned the subject during our discussions at her Washington office. 我们在她华盛顿的办公室里讨论时,我提到了这件事
三、扩展
during probation 试用期间 | How to pay wages during probation period 试用期工资如何支付
during day 在白天 | You would be able to breathe fresh air, even though it is a bit hot during day time. 白天,即使温度高一点,也能闻到空气的清爽
until/till
一、本义:直到...为止
1、肯定句中,类似于 before
The ticket is valid until March. 这张票的有效期一直到 3 月份
He waited until she had finished speaking. 他一直等到她讲完
Until recently, Anna worked as a teacher in Japan. 直到最近,安娜一直在日本当老师
Up until last year, they didn’t even own a car. 一直到去年,他们连汽车也没有
2、否定句,用于强调某事在某个具体的时刻或者另一件事发生以前没有发生
‘Can I go out and play now?’ ‘Not until you’ve done your homework.’ “我现在可以出去玩吗?” “家庭作业做完以后才行。”
It was not until 1972 that the war finally came to an end. 直到 1972 年战争才终于结束
The traffic laws don\'t take effect until the end of the year. 交通法规直到年底在生效
二、扩展
till all hours 到深更半夜 | He stays up drinking till all hours. 他喝酒一直喝到深夜。
right up until 一直到 | It\'s a busy time now, right up until New Year. 现在很忙,一直到新年都会是这样
unless and until 直到 ... 才 | I will not believe it unless and until he tells me so. 除非他亲口对我说,否则我决不相信
for
一、本义:指向,为了
for 只表示目的,不表示结果。for 的本义是“指向”,在句子中常表示“为了”
1、表示目的,为了...,适用于...
for sale 有待出售 | for rent 有待出租 | for use 有待使用
a knife for cutting bread 切面包的刀子
Money is for consumption and not just for saving. 钱不只是用来存的,还是用来消费的
Time are for meaningful activities and not just for leisure. 时间是留给有意义的事情的,不只是为了消遣
What did you do that for? 你那样做是为了什么?
I’ve bought him a watch for his birthday. 我给他买了块手表作为生日礼物。
the documents prepared for his defense 为给他辩护而准备的文件
Are you waiting for the bus? 你在等公共汽车吗?
the qualifications necessary for a career in broadcasting 从事广播业必须具备的资格
Mother was too ill to get up for dinner. 母亲病得无法起床吃晚饭。
I paid $3 for a ticket. 我花三美元买了张票
For further details, write to this address. 欲知详情,请致函此地址
Let’s go for a walk. 我们去散步吧
2、表示对象,替...、给...、为...、对...
This dinner is for you. 这顿晚饭是为你做的
buy it for me please. 请为我买了它吧
I’ve got a present for you. 我有件礼物送给你。
Someone left a message for Vicky. 有人给维基留了言。
an English course for foreign students 为外国学生开的一门英语课程
I looked after the kids for them. 我为他们照看孩子
Let me carry that bag for you. 我来给你拿那个包吧
The doctor knew that there was nothing he could do for her. 医生知道自己无能为力帮不了她
Charles died fighting for his country. 查尔斯在战斗中为国捐躯
I’m sure she’s the ideal person for the job. 我确信她是这个职位的理想人选
二、引申
1、由现状指向原因
for the reason 因为这个原因 | for doing this 因为做这件事
Texas is famous for barbecue. 德克萨斯州因烧烤而著名
He apologized to her for tainting her clothes. 他因弄脏他的衣服而道歉
She gave me a car as a present for my birthday. 因为我今天过生日,她送了我一辆车
I could barely speak for laughing. 我几乎笑得说不出话来
If, for any reason, you cannot attend, please inform us. 如因故不能出席,请通知我们。
We could hardly see for the mist. 由于雾气,我们几乎什么也看不见
You’ll feel better for a break. 休息一下你会感觉好些
Campbell was arrested for dangerous driving. 坎贝尔因危险驾车而遭逮捕
2、表示支持、赞同
We have studied the arguments for and against nuclear energy. 我们研究了支持和反对核能的论点
How many people voted for the proposal? 有多少人投票支持这项提议
3、表持续时间
For three months since his 21st birthday, I have not heard even one word from him. 从他二十一岁生日到现在,三个月时间里我从未听到过他的任何消息
Bake the cake for 40 minutes. 将蛋糕烘烤40分钟
We had been talking for a good half hour. 我们谈了足足半个小时
4、表距离
We walked for miles. 我们走了好几英里。
Factories stretch for quite a way along the canal. 工厂沿运河延伸了很长一段距离
He returned home from Taxes for three hundred miles. 他从德克萨斯回家一共前进三百英里
5、对应关系
These chairs are for the office. 这些椅子是办公室的
This is a stall for vegetables. 这是一个卖蔬菜的摊位
What\'s the word for \'apple\' in French? Apple 在法语中对应的单词是什么
I\'m looking for the seats for us. 我在寻找我们的座位
Do you take me for a fool? 你把我当成傻子了吗
He takes his parents\' care for him for granted. 他把父母的关爱当成了理所当然
三、扩展
do duty for 当…用,起作用 | The living room also does duty for a home office. 这个居室可以用做办公室。
for ages 很久;很长时间 | Oh, I’ve had this for ages. 哦,我也曾有过这个问题很长时间。
for life 终身;为了保命 | The disease marked his face for life. 这种疾病在他的脸上留下了终身去不掉的疤痕
account for 说明;解释 | Can you account for the serial failures in our experiment? 你能够解释实验屡屡失败的原因吗
advertise for 登广告征求(寻找)某物 | The company advertised for a new secretary. 公司登广告招聘新秘书
aim for 力争…,针对 | His father advised him to aim for a better education. 他的父亲建议他力争获得更良好的教育
as for 至于,就…方面说 | You can ask the others, but as for myself, I\'ll be busy in the office. 你可以去问问其他人,但是至于我,我将在办公室非常忙
be available for 有效 | No figures are available for the number of goods sold. 出售的商品数量很难描述
如何在 R 中表示和合并具有*日期范围*的时间序列数据帧?
【中文标题】如何在 R 中表示和合并具有*日期范围*的时间序列数据帧?【英文标题】:How do I represent and merge time-series data-frames with a *date range* in R? 【发布时间】:2022-01-21 17:43:53 【问题描述】:我在R
工作,我有一些时间序列数据,其中相关时间是日期范围 --- 即,每一行都有开始日期和结束日期,并且该记录指定了该期间的结果。我希望能够在R
中以适当的方式表示此对象,并将其与具有特定日期的其他时间序列合并。在合并的情况下,我希望我的第一个时间序列(使用日期范围的那个)中的每条记录都与该范围内的日期相匹配,如果有两个或范围内的更具体的日期。这是我希望它使用模拟数据执行的一个简单示例:
#Time series with a date-range
TIME.SERIES1
Start End Value
2018-01-01 2018-01-31 80.6
2018-02-01 2018-02-28 140.5
2018-03-01 2018-03-31 122.1
2018-04-01 2018-04-30 108.5
2018-05-01 2018-05-31 96.0
2018-06-01 2018-06-30 103.3
#Time series using specific dates
TIME.SERIES2
Date Staff
2018-01-15 551
2018-02-14 606
2018-05-18 640
2018-06-02 635
2018-07-15 633
#Merge these using left-join of TIME.SERIES1 and TIME.SERIES2
[some merge command]
Start End Value Staff
2018-01-01 2018-01-31 80.6 551
2018-02-01 2018-02-28 140.5 606
2018-03-01 2018-03-31 122.1 NA
2018-04-01 2018-04-30 108.5 NA
2018-05-01 2018-05-31 96.0 640
2018-06-01 2018-06-30 103.3 635
我知道您可以在 SQL
中相当轻松地进行这种类型的合并,但我不确定如何在 R
中进行。我之前使用过xls
包进行时间序列分析,但不知道它是否能完成我想做的事情。这个包似乎允许我指定一个日期作为索引,但不是一个日期范围。同样,它似乎允许我在一个日期合并两个时间序列对象,但我不确定如何根据日期范围进行合并(以上面显示的方式)。
问题:R
中的时间序列工具能否处理时间索引为日期范围而不是特定日期的对象(即,可以您有一个包含开始时间和结束时间的索引)?我们如何将具有日期范围的数据与具有单个日期的日期合并?
【问题讨论】:
您的数据有多大? @kybazzi:虽然上面的例子很小,但实际上我的数据集非常大(几百万行)。 【参考方案1】:一个想法是创建一个笛卡尔积,然后应用过滤器以仅保留有效的案例。这种方法的好处是您可以对数据使用常规操作(分组、变异、过滤),从而为解决关系带来了灵活性。
感谢 G. Grothendieck 从问题中创建数据集的代码。
library(tidyverse)
library(lubridate)
# See G. Grothendieck's answer for ts1 and ts2
value = tibble(ts1)
staff = tibble(ts2)
full_join(value, staff, by = character()) %>%
mutate(valid = Date %within% interval(Start, End)) %>%
group_by(Start, End, Value) %>%
arrange(Date) %>%
summarise(Staff = Staff[valid][1])
输出
Start End Value Staff
<date> <date> <dbl> <int>
1 2018-01-01 2018-01-31 80.6 551
2 2018-02-01 2018-02-28 140. 606
3 2018-03-01 2018-03-31 122. NA
4 2018-04-01 2018-04-30 108. NA
5 2018-05-01 2018-05-31 96 640
6 2018-06-01 2018-06-30 103. 635
请注意,在此解决方案中,我使用了范围内最早的 Staff
值。您可以轻松更改此设置以满足您的要求。
sqldf
解决方案
library(sqldf)
library(tidyverse)
sqldf(
"SELECT *
FROM value
LEFT JOIN staff
ON staff.Date <= value.End AND staff.Date >= value.Start"
) %>%
group_by(Start, End, Value) %>%
summarise(Staff = Staff[Date == min(Date)], .groups = "drop")
【讨论】:
(+1) 这是一个很好的解决方案。我唯一担心的是,对于大型数据帧,笛卡尔积会很大,这可能使其在计算上不可行。 @Ben 你提到你可以在 SQL 中轻松地做到这一点,这是一个很好的观点 - 我已经使用sqldf
包添加了一个解决方案。
tidyverse 部分可能不需要,它可以简化为:library(sqldf); sqldf("SELECT * FROM ts1 v LEFT JOIN ts2 s ON s.Date between v.Start and v.End")
虽然问题中没有要求,但如果有多个匹配项并且您只想要最早匹配的 Date 它可能完全是像这样在 SQL 中完成:library(sqldf); sqldf("SELECT v.*, min(s.Date) Date FROM ts1 v LEFT JOIN ts2 s ON s.Date between v.Start and v.End group by v.rowid")
【参考方案2】:
由于期间始终是完整的单月,并且假设输入是末尾注释中显示的数据框,我们假设所有日期都属于 Date 类,因此向两者添加 yearmon 类列并加入该列。
library(zoo)
ts1$ym <- as.yearmon(ts1$Start)
ts2$ym <- as.yearmon(ts2$Date)
library(dplyr)
left_join(ts1, ts2, "ym")
给予:
Start End Value ym Date Staff
1 2018-01-01 2018-01-31 80.6 Jan 2018 2018-01-15 551
2 2018-02-01 2018-02-28 140.5 Feb 2018 2018-02-14 606
3 2018-03-01 2018-03-31 122.1 Mar 2018 <NA> NA
4 2018-04-01 2018-04-30 108.5 Apr 2018 <NA> NA
5 2018-05-01 2018-05-31 96.0 May 2018 2018-05-18 640
6 2018-06-01 2018-06-30 103.3 Jun 2018 2018-06-02 635
注意
TIME.SERIES1
Lines1 <- "
Start End Value
2018-01-01 2018-01-31 80.6
2018-02-01 2018-02-28 140.5
2018-03-01 2018-03-31 122.1
2018-04-01 2018-04-30 108.5
2018-05-01 2018-05-31 96.0
2018-06-01 2018-06-30 103.3"
ts1 <- transform(read.table(text = Lines1, header = TRUE),
Start = as.Date(Start), End = as.Date(End))
Lines2 <- "
Date Staff
2018-01-15 551
2018-02-14 606
2018-05-18 640
2018-06-02 635
2018-07-15 633"
ts2 <- transform(read.table(text = Lines2, header = TRUE),
Date = as.Date(Date))
【讨论】:
(+1) 我的错 --- 我可能让我的例子比我真正想知道的更简单 --- 为了简单起见,我给出的例子是用整整几个月构建的,但我当您有 任何 个日期范围时,即使该日期范围不方便跨越一个月,我也会更广泛地加入。以上是关于语法:英语中表示时间范围的介词——sinceduringuntil/tillfor的主要内容,如果未能解决你的问题,请参考以下文章