• ## R中which的用法

万次阅读 2018-11-15 17:01:27
which的用法 官方文档： 也就是找出你给的参数里逻辑值为TRUE的元素的索引。 举例： which(x!=1) #返回x中不等于1的变量值得位置 [1] 4 5 which(c(T,F,T)) #返回c(T,F,T)中为TURE值的位置。 [1] 1 3 which(c(1,0,1...
which的用法
官方文档：

也就是找出你给的参数里逻辑值为TRUE的元素的索引。
举例：

which(x!=1) #返回x中不等于1的变量值得位置
[1] 4 5
which(c(T,F,T)) #返回c(T,F,T)中为TURE值的位置。
[1] 1 3
which(c(1,0,1)) #只对T, F做判断。
Error in which(c(1, 0, 1)) : argument to ‘which’ is not logical


展开全文
• 大家都知道在定语从句中，有时候where，why，when可以换成“介词+which”结构，可是很多同学不明白...它应该和从句中动词形成一个短语、固定搭配或习惯用法等。例1：Lili's dream is to have her own garden __...
大家都知道在定语从句中，有的时候where，why，when可以换成“介词+which”结构，可是很多同学不明白这个结构里的介词是怎么来的。今天我们一起挖一挖，这个介词的由来。首先我们要搞清楚，这个介词的原来位置不是在which前面，它原本是放在从句中的。它应该和从句中的动词形成一个短语、固定搭配或习惯用法等。例1：Lili's dream is to have her own garden ______ to grow plenty of flowers.A. that B. by which C. which D. in which解析：答案选的是D。这个从句是省略结构。从句和先行词garden连起来：to grow plenty of flowers in her own garden.把从句和先行词连起来需要一个介词in。而介词in可以提前到which前面，就形成了in which结构。例2：While driving through the city, she showed me the building ______ she once worked as a lift operator.A. when B. which C. in which D. by which解析：答案选C。先行词是building，把从句和先行词连起来。She once worked in the building as a lift operator.所以，就有了in which。例3：The man ___________ you talked is my English teacher. A. to whom B. with who C. with whom D. that解析：答案选B。把从句和先行词连起来：You talked with the man. 而且the man是介词with的宾语，所以用宾格whom。例4：Eric received training in computer for one year, _____ he found a job in a big company.A. after this B. after that C. after it D. after which解析：答案选D。which代指前面一整句话。把从句变为主句是这样的：He found a job in a big company after Eric received training in computer for one year.所以就有了after which。大家明白了吗？介词其实很好确定，只要把从句和先行词连一下，就很容易看出需要的介词了。希望可以帮到大家。如有问题请留言。
展开全文
• 在定语从句中,which 和that 在指代事物时,一般可以互换使用,但并非在任何情况下都是这样,这里介绍宜用that, 而不宜用which 情况.①先行词为不定代词,all,much,something,everything,anything,nothing,none,the one...
在定语从句中,which 和that 在指代事物时,一般可以互换使用,但并非在任何情况下都是这样,这里介绍宜用that, 而不宜用which 的情况.①先行词为不定代词,all,much,something,everything,anything,nothing,none,the one等, 1.We should do all that is useful to the people .2.There's nothing that can be said about it .3.Do you mean the one that was bought yesterday?②先行词被only, any, few, little, no, just, very, one of等词修饰时.1.The only thing that we could do was to wait.2.That's the very word that is wrongly used.The last place (that) we visited was the chemical works.You can take any (=whichever) seat that is free.I hope the little that I can will be of some help to them.比较 *This is one of the best novels that were published last year.*This is the only one of the best novels that was published last year.③先行词是序数词时或被序数词修饰时.1.When we talk about Wuxi, the first that comes into mind is Tai Lake.2.This is the third film that has been shown in our school this term.④先行词是最高级或被最高级修饰时.1.This is the best that can be done now.2.The most important thing that should be done right now is how to stop him from going on.⑤先行词既有人又有物,用which和who都不适合,这时宜用that. 如：1.The writer and his novel that you have just talked about is really well known .2.The rider and his bike that had run over an old woman were held up by the police.⑥被修饰词为数词时. 1.Yesterday I caught two fish and put them in a basin of water .Now you can see the two that are still alive .⑦如果有两个从句,其中一个关系代词已用which ,另一个关系代词宜用that,以避免语言的单调或重复.Edison built up a factory which produced things that had never been seen before.⑧疑问词是who或which,关系代词宜用that,以避免重复.1. Which is the book that you like best?2. Who is the man that is standing at the gate?⑨主句是There be 结构,修饰其主句的定语从句宜用that 作关系代词. 如：1. There is still a seat in the corner that is still free.⑩被修饰成分为表语时,或者关系代词本身是定语从句的表语时,该关系代词宜用that . 1. That's a good book that will help you a lot.2. My home village is no longer the place ( that ) it used to be .定语从句中宜用which而不宜用that 的情况:①当关系代词的前面有介词时. 1.A zoo is a park in which many kinds of animals are kept for exhibition.2.Is this the room in which Mr. White lives?②在非限制性定语从句中. 1.Crusoe's dog, which was are now very old, became ill and died .2.More and more people are beginning to learn English, which is becoming very popular in our country. (which指代主句)③在一个句子中有两个定语从句,其中一个定语从句的关系代词用了that, 另一个宜用which . 1. Let me show you the novel,that I borrowed from the library which was newly open to us. 2. At the station I bought some magazines that might help me to pass the time on the train and which I could pass on to others when I finished them.④当关系代词后面带有插入语时. 1. Here's the English grammar which, as I have told you, will help improve your English.⑤先行词本身是that, 宜用which . What's that which she is looking at?⑥先行词是those+复数名词. A shop should keep a stock of those goods which sell best.
展开全文
• How to add my custom page resolver instead of Spartacus page resolver? I’m adding my resolver (which extended from PageMetaResolver) into providers in my own home.module. However, my method ...
前置阅读：
Angular路由里的resolve接口的使用方法
有网友遇到一个问题：
How to add my custom page resolver instead of Spartacus page resolver?

I’m adding my resolver (which extended from PageMetaResolver) into providers in my own home.module. However, my method ‘resolve’ is not called. Have you got any ideas?

@Injectable({
providedIn: 'root'
})
export class HomePageMetaResolver extends PageMetaResolver implements PageDescriptionResolver {

constructor(
protected routingService: RoutingService,
protected translationService: TranslationService,
protected cms: CmsService
) {
super();
this.pageType = PageType.CONTENT_PAGE;
}

resolve(): Observable<PageMeta> {
console.log('RESOLVE')

return this.cms.getCurrentPage().pipe(
switchMap(page =>
combineLatest([
this.resolveDescription()
])
),
map(([description]) => ({ description }))
);
}

resolveDescription(): Observable<string> {
return new Observable(sub => {
sub.next('test description');
});
}
}

分析
The most specific Page Meta Resolver wins
Guessing from the name of your meta resolver, you want to provide custom meta only for your Home page. Please note that the most specific meta resolver wins thanks to the simple scoring algorithm, which takes into consideration 2 factors: page type and page template (see source https://github.com/SAP/cloud-commerce-spartacus-storefront/blob/develop/projects/core/src/cms/page/page-meta.resolver.ts#L11).
Currently your resolver HomePageMetaResolver has the same specificity as the generic one so your resolve method is not called.

specificity of all Page Meta Resolvers
You need to specify more your meta resolver by defining its property this.pageTemplate = ‘’. Then your HomePageMetaResolver will get higher score than a default ContentPageMetaResolver whenever you visit a homepage.
Custom scoring algorithms
For custom scoring algorithms (which could take pageId into account, for instance), you can overwrite the method getScore of your PageMetaResolvers. You can even extend the method PageMetaService.getMetaResolver to redefine all rules of chosing the right page meta resolver. But for your case the standard solution (described above) should suffice.


展开全文
• 在Python中，有些开源项目中...Returning self from a method simply means that your method returns a reference to the instance object on which it was called. This can sometimes be seen in use with object or
• Starting Activities and Getting Results ...ThestartActivity(Intent)method is used to start a new activity, which will be placed at the top of the activity stack. It takes a single argument, anIntent, ...
• Copies the first num characters of source to destination. If the end of the source C string (which is signaled by a null-character) is found before num characters have been copied, destinatio
• ## def 定义函数的用法

千次阅读 2016-12-02 17:37:41
def 的用法 def dead(why): print why, "\nGood job!\n" exit(0) def start(): print "You are in a dark room.\n" print "There is a door to your right and left.\n" print "Which one do y
• insert()是Python中内置...用法:list_name.insert(index, element)参数：index - the index at which the element has to be inserted.element - the element to be inserted in the list.返回值：This method ...
• OutputDebugString is a API function, it is used to help programmer debug the program, which is like TRACE or afxDump, it is work with Dbgview. in Debug mode it performance as TRACE. But in Rel
• The following example uses anAutoResetEventto synchronize the activities of two threads.The first thread, which is the application thread, executesMain.It writes values to the protected resourc...
• ## numpy中的norm用法

千次阅读 2018-11-26 14:08:00
np.linalg.norm()computes the norm of a NumPy array according to an order,ord, which specifies the metric by which the norm takes. For example, if we are given an array
• Projects each source value to an Observable which is merged in the output Observable, in a serialized fashion waiting for each one to complete before merging the next. 将source Observable里每个元素...
• 下面的脚本是根据实际工作的环境，为了操作简便而写的，主要是select循环的用法，和大家分享一下。#!/bin/bash#Used for logining logserver quickly!#Written on xxxx.#Author：Levin.HAHA3='Choose which host you...
• Help里解释 function Locate(const KeyFields: String; const KeyValues: Variant; Options: TLocateOptions): ...KeyFields:is a string containing a semicolon-delimited list of field names on which to...
• Each value emitted on the source is given to the predicate function which returns a boolean, representing a condition to be satisfied by the source values. The output Observable emits the s..
• 一、“介词+关系代词which/whom”引导定语从句 正式语体中，关系代词作介词宾语，常常把介词置于关系代词which/whom之前;非正式语体中，介词可置于从句末。介词选择取决于其与作先行词名词、代词搭配或与...
• numpy.where(condition [，x，y])函数返回满足...参数:condition : When True, yield x, otherwise yield y.x, y : Values from which to choose. x, y and condition need to be broadcastable to some shape.返回...
• CeCopyFile 在MSDN上说明及原型如下：CeCopyFile is a remote application programming interface (RAPI), which enables an application running on a desktop computer to make function calls on a Windows CE...
• Always put inverse=”true” in your collection ...There are many Hibernate articles try to explain the “inverse” with many Hibernate “official” jargon, which is very hard to understand (at least...
• Lodash Common function Collection 1. reduce .reduce(collection, [iteratee=.identity], [accumulator]...Reduces collection to a value which is the accumulated result of running each element in collecti...
• Interface for classes whose instances can be written to and restored from a Parcel。 Classes implementing the Parcelable interface must also have a static field called CREATOR， which i
• 将对象转为hash对象 Creates aHash(which is synonymous to "map" or "associative array" for our purposes). A convenience wrapper around theHashconstructor, with a safeguard that lets y...
• Projects each source value to an Observable which is merged in the output Observable, emitting values only from the most recently projected Observable. 例子： const switched = of(1, 2, 3).pipe...
• ## Linux下mv命令的用法

千次阅读 2016-01-12 20:21:11
After knowing about copy command, the next command which is related is mv command. When you want to move files from one place to another and you don’t want to duplicate it, then mv command is ...
• 我觉得这个例子挺不错，对sizeof的用法有了更一步的认识！   MSDN上的解释： When applied to a structure type or variable, sizeof returns the actual size, which may include padding bytes inserted for ...

...