evaluation

R: Evaluate an expression in a data frame with arguments that are passed as an object

为君一笑 提交于 2019-12-01 02:09:19
问题 I want to write a function that evaluates an expression in a data frame, but one that does so using expressions that may or may not contain user-defined objects. I think the magic word is "non-standard evaluation", but I cannot quite figure it out just yet. One simple example (yet realistic for my purposes): Say, I want to evaluate an lm() call for variables found in a data frame. mydf <- data.frame(x=1:10, y=1:10) A function that does so can be written as follows: f <- function(df, expr){

Does EL automatically convert/cast the type? How does ${a.name} actually work?

南笙酒味 提交于 2019-11-30 22:45:20
I have a variable declared as type Object a which actually refers an instance of type A . In EL, I can directly use the following expression to print the name property of type A : ${a.name} How does it work? BalusC EL uses reflection under the hoods, usually via javax.beans.Introspector API . This is what it roughly does under the covers on ${a.name} . // EL will breakdown the expression. String base = "a"; String property = "name"; // Then EL will find the object and getter and invoke it. Object object = pageContext.findAttribute(base); String getter = "get" + property.substring(0, 1)

R: passing expression to an inner function

╄→尐↘猪︶ㄣ 提交于 2019-11-30 22:28:40
问题 Further delving into the mysteries of R evaluation...This is closely related to my previous question ( How to write an R function that evaluates an expression within a data-frame ). Let's say I want to write a function topfn that takes a data-frame and an expression involving column-names of that data-frame. I want to pass both these arguments on to another function fn that actually evaluates the expression within the "environment" of the data-frame. And I want both fn and topfn to work

Whats the best way to create interactive application prototypes?

本秂侑毒 提交于 2019-11-30 20:10:50
The question should be interpreted from a general point of view and not targeted solely at web apps or desktop apps. I have been looking around to find a simple and easy way of creating interactive prototypes for web applications. I'd like to use a technique that allows simple UI creation and especially UI recreation and modification in further iterations. Filling the UI with mockup data should be very simple. The technique may require a simple form of programming, e.g. to specify a drag and drop behaviour from UI element A to UI element B. One tool i currently use is the Adobe Flex Builder.

Does EL automatically convert/cast the type? How does ${a.name} actually work?

吃可爱长大的小学妹 提交于 2019-11-30 17:51:45
问题 I have a variable declared as type Object a which actually refers an instance of type A . In EL, I can directly use the following expression to print the name property of type A : ${a.name} How does it work? 回答1: EL uses reflection under the hoods, usually via javax.beans.Introspector API. This is what it roughly does under the covers on ${a.name} . // EL will breakdown the expression. String base = "a"; String property = "name"; // Then EL will find the object and getter and invoke it.

some ideas and direction of how to measure ranking, AP, MAP, recall for IR evaluation

笑着哭i 提交于 2019-11-30 16:33:29
I have question about how to evaluate the information retrieve result is good or not such as calculate the relevant document rank, recall, precision ,AP, MAP..... currently, the system is able to retrieve the document from the database once the users enter the query. The problem is I do not know how to do the evaluation. I got some public data set such as "Cranfield collection" dataset link it contains 1.document 2.query 3.relevance assesments DOCS QRYS SIZE* Cranfield 1,400 225 1.6 May I know how to use do the evaluation by using "Cranfield collection" to calculate the relevant document rank,

In R, evaluate expressions within vector of strings

左心房为你撑大大i 提交于 2019-11-30 09:54:15
I wish to evaluate a vector of strings containing arithmetic expressions -- "1+2", "5*6", etc. I know that I can parse a single string into an expression and then evaluate it as in eval(parse(text="1+2")) . However, I would prefer to evaluate the vector without using a for loop. foo <- c("1+2","3+4","5*6","7/8") # I want to evaluate this and return c(3,7,30,0.875) eval(parse(text=foo[1])) # correctly returns 3, so how do I vectorize the evaluation? eval(sapply(foo, function(x) parse(text=x))) # wrong! evaluates only last element Just apply the whole function. sapply(foo, function(x) eval(parse

C++ function evaluation order in assignment operator

穿精又带淫゛_ 提交于 2019-11-30 08:32:32
问题 int& foo() { printf("Foo\n"); static int a; return a; } int bar() { printf("Bar\n"); return 1; } void main() { foo() = bar(); } I am not sure which one should be evaluated first. I have tried in VC that bar function is executed first. However, in compiler by g++ (FreeBSD), it gives out foo function evaluated first. Much interesting question is derived from the above problem, suppose I have a dynamic array (std::vector) std::vector<int> vec; int foobar() { vec.resize( vec.size() + 1 ); return

Evaluate in T-SQL

不打扰是莪最后的温柔 提交于 2019-11-30 08:31:40
问题 I've got a stored procedure that allows an IN parameter specify what database to use. I then use a pre-decided table in that database for a query. The problem I'm having is concatenating the table name to that database name within my queries. If T-SQL had an evaluate function I could do something like eval(@dbname + 'MyTable') Currently I'm stuck creating a string and then using exec() to run that string as a query. This is messy and I would rather not have to create a string. Is there a way

What is “Call By Name”?

陌路散爱 提交于 2019-11-30 08:29:13
I'm working on a homework assignment where we are asked to implement an evaluation strategy called "call by name" in a certain language that we developed (using Scheme). We were given an example in Scala , but I don't understand how "call by name" works and how it is different to "call by need"? Call-by-need is a memoized version of call-by-name (see wikipedia ). In call-by-name, the argument is evaluated every time it is used , whereas in call-by-need, it is evaluated the first time it is used, and the value recorded so that subsequently it need not be re-evaluated. Call by name is a a