Displaying 20 results from an estimated 94 matches for "fn1".
Did you mean:
fn
2010 Jul 05
3
data.frame: adding a column that is based on ranges of values in another column
...Fortnight" to the existing data.frame. The components of the new "Fortnight" column are based on the existing "Date" column so that if the value in "Date" falls within the first fortnight (f.n1) then the value of the new "Fortnight" column would be "FN1", and if the value of the "Date" column falls within the second fortnight (f.n2), then the value of the "Fortnight" column would be "FN2", and so on.
The end result should look like:
X Y Date Fortnight
1 114.5508 47.14094 2009-01-01...
2013 Jan 01
1
Behavior or as.environment in function arguments/call (and force() behaviors...)
...? Happens in all the versions of R I have on hand.
Behavior itself is confusing, but ?as.environment also provides no clue.
The term used in that doc is 'search list', which is ambiguous, but the
see also section mentions search(), so I would *think* that is what is
intended. Either way Fn1() below can't really be explained.
Major question is what in the world is Fn1 doing, and why is Fn2 not equal
to Fn3? [ Fn3/Fn4 are doing what I want. ]
Fn1 <- function(x="test",pos=-1,env=as.environment(pos)) {
ls(env)
}
Fn2 <- function(x="test",pos=-1,env=as.envi...
2010 Sep 14
5
Problem with cat()
Dear all, I have a problem with the cat() function. Let say I have following:
fn1 <- function(n = 5){
mat <- matrix(rnorm(5*5), 5, 5)
cat(as.character(mat))
return(n)
}
However when I run above function I get this:
> fn1()
-0.601930631438248 -1.16950049447942 0.469257329394626
-1.39766868242906 -1.02580943892082 1.4067931110327 -1.07245318857022
-0.0205043699310245 0.2...
2008 Aug 25
0
[LLVMdev] Proposal : Function Notes
On Aug 22, 2008, at 4:40 PM, Devang Patel wrote:
> The LLVM passes are responsible to take appropriate actions based on
> Function
> Notes associated with function definition. For example,
>
> define void @fn1() notes("opt-size=1") { ... }
>
> The function fn1() is being optimized for size without losing
> significant
> performance. The inliner will update inlining threshold for fn1()
> such that the
> functions called by fn1() are checked for size threshold for fn1()
&...
2011 Apr 07
1
An extention of outer() ?
...er my understanding, outer() function is to facilitate
2-dimensional function evaluation, like to evaluate f(x,y) for different
values of x and y. However I have slightly modified version of that, where x
is a matrix with, say, 5 rows and 2 columns and y is a vector. Let take
following example:
fn1 <- function(x1, x2, y) return (x1+x2+y)
x <- matrix(1:10, nc = 2)
y <- 1:5
with this input, I want to construct a 5x5 matrix whose (1,1)th element will
be : fn1(x[1,1], x[1,2], y[1]), (1,2)th element will be : fn1(x[1,1],
x[1,2], y[2])..... (1,5)th element will be : fn1(x[1,1], x[...
2008 Apr 11
2
system.time gives error when "=" is used for assignment (R-2.6.0)
...o use "=" instead of "<-", R
gave an error message:
"Error in system.time(your argument here...)". It happened with a few
functions I tried. Is this a bug or is there any circumstances that
"=" cannot be used for assignment? Here is a real simple example.
fn1 <- function(x) x+1
r1 <- system.time(res1=fn1(2))
r2 <- system.time(res2 <- fn1(2))
Thank you.
Kyeongmi
University of Memphis
2013 Sep 21
1
[LLVMdev] LLD input graph handling proposal
Hi Joerg,
I would love to have this behavior(solaris/hp-ux linkers used to do this).
cat > main.c << \!
int main() {
fn();
fn1();
}
!
cat > fn.c << \!
int fn() {
return 0;
}
!
cat > fn1.c << \!
int fn1() {
return 0;
}
!
gcc -c -fPIC main.c fn.c fn1.c
ld -shared fn1.o -o libfn1.so
ld -shared fn.o -o libfn.so -L. -lfn1
ld main.o libfn.so
ld: warning: libfn1.so, needed by libfn.so, not found (try us...
2006 Jun 22
2
weights in lm, glm (PR#9023)
Full_Name: James Signorovitch
Version: 2.2.1
OS: WinXP
Submission from: (NULL) (134.174.182.203)
In the code below, fn1() and fn2() fail with the messages given in the comments.
Strangely, fn2() fails for all data sets I've tried except for those with 100
rows.
The same errors occur if glm() is used in place of lm(), or if R 2.1.1 is used
on a unix system. Thanks for looking into this. JS
fn1 <- functi...
2011 May 09
2
Vectorizing a function: what does it mean?
...ctorizing function means, to create a function such a way so that if input(s) are vector then this function will also return a vector output (without having any extra effort like use of 'for' loop etc.) Is this understanding correct?
Here I have tried 2 essentially similar functions:
> fn1 <- function(x,y,z) return(x+y+z)
> fn2 <- Vectorize(function(x,y,z) return(x+y+z), SIMPLIFY=TRUE)
> fn1(1:3, 4:6,5)
[1] 10 12 14
> fn2(1:3, 4:6,5)
[1] 10 12 14
You see that, fn1() and fn2() is giving same answer (vectorized?) despite of the fact that fn1() is not wrapped within Vec...
2005 Dec 29
1
S4 classes: referencing slots with other slots
..."self.*"
semantics of Python so that I can reuse a slot. That is, for various
reasons it would be nice to be able to do something like:
setClass("fooWfcn",
representation(dat1="vector",
dat2="vector",
fn1="function",
fn2="function"),
prototype=list(dat1=0:10,
dat2=10:20,
fn1=function(x) { return(x - mean(self.dat1)) },
fn2=function() { mean(self.dat2) }))
and in the context of
foo <- new("fooWfcn")...
2016 Dec 15
2
distinct DISubprograms hindering sharing inlined subprogram descriptions
...stood
from above that with the SP->CU link (and distinct SPs), prevented
deduplication. But this last bit sounds like we are in fact removing the
duplicates in the DWARF and possibly also in the metadata.
Ah, right - I can see how it reads that way, sorry.
Old old way:
first.ll:
CU1 -> {fn1_SP -> @fn1, inl_SP -> @inl, ... }
@fn1 ...
@inl ...
Resulting DWARF:
compile_unit CU1
subprogram fn1
high/low pc, etc
subprogram inl
high/low pc, etc
second.ll:
CU2 -> {inl_SP2 -> @inl, SP2 -> @fn2, ... }
@inl ...
@fn2 ...
Resulting DWAR...
2016 Dec 16
0
distinct DISubprograms hindering sharing inlined subprogram descriptions
...(and distinct SPs), prevented
> deduplication. But this last bit sounds like we are in fact removing the
> duplicates in the DWARF and possibly also in the metadata.
>
>
> Ah, right - I can see how it reads that way, sorry.
>
> Old old way:
>
> first.ll:
> CU1 -> {fn1_SP -> @fn1, inl_SP -> @inl, ... }
> @fn1 ...
> @inl ...
> Resulting DWARF:
> compile_unit CU1
> subprogram fn1
> high/low pc, etc
> subprogram inl
> high/low pc, etc
>
> second.ll:
> CU2 -> {inl_SP2 -> @inl, SP2 -&...
2009 Feb 04
0
Problem using option packeg with new R version (PR#13498)
...589 -0.4101295 1.5204661 1.3439740[4,] -1.54003312 -0.03145120 0.17489151 1.1248919 0.6047474 1.1909949[5,] -0.94150604 0.19836236 -0.63982776 0.5272774 -0.4088086 -0.2593536> > n<-nrow(X)> p<-ncol(X)> n[1] 5> p[1] 6> > v<-rep(0,p-1)> v[1] 0 0 0 0 0> > fn1<-function(v) {+ a<-sum(v*v)+ u<-v/sqrt(1+a)+ b<-sum(u*u)+ u[length(v)+1]<-sqrt(1+b)+ c<<- X %*% u # also I try c<- X %*% u+ fn1<- - optim(c(0,1),fn2,NULL,method="BFGS",c)$value+ }> > > fn2<-function(par){+ fn2<- -length(c)*log(par[2])+sum(log(par...
2016 Dec 16
2
distinct DISubprograms hindering sharing inlined subprogram descriptions
...(and distinct SPs), prevented
> deduplication. But this last bit sounds like we are in fact removing the
> duplicates in the DWARF and possibly also in the metadata.
>
>
> Ah, right - I can see how it reads that way, sorry.
>
> Old old way:
>
> first.ll:
> CU1 -> {fn1_SP -> @fn1, inl_SP -> @inl, ... }
> @fn1 ...
> @inl ...
> Resulting DWARF:
> compile_unit CU1
> subprogram fn1
> high/low pc, etc
> subprogram inl
> high/low pc, etc
>
> second.ll:
> CU2 -> {inl_SP2 -> @inl, SP2 -&...
2010 Jul 14
3
How to see inside of this function?
...If I type
"skewness", I get followings:
> skewness
function (x, ...)
{
UseMethod("skewness")
}
<environment: namespace:timeDate>
Would be great if someone tell me how to see the codes of this function.
2ndly suppose I create following function:
fn1 <- function(x) return(x+2)
How I can make above kind of shape like, when user types "fn1" then he will
see:
fn1
function(x,.)
{
UseMethod("fn1")
}
..........
Etc.
Thanks and regards,
[[alternative HTML version deleted]]
2007 Feb 02
1
Assigning labels to a list created with apply
I have a simple data base and I want to produce tables
for each variable. I wrote a simple function
fn1 <- function(x) {table(x)} where x is a matrix or
data.frame. and used apply to produce a list of
tables. Example below.
How do I apply the colnames from the matrix or names
from the data.frame to label the tables in the results
in the list. I know that I can do this individually
but there sho...
2016 Dec 16
0
distinct DISubprograms hindering sharing inlined subprogram descriptions
...eduplication. But this last bit sounds like we are in fact removing the
>> duplicates in the DWARF and possibly also in the metadata.
>>
>>
>> Ah, right - I can see how it reads that way, sorry.
>>
>> Old old way:
>>
>> first.ll:
>> CU1 -> {fn1_SP -> @fn1, inl_SP -> @inl, ... }
>> @fn1 ...
>> @inl ...
>> Resulting DWARF:
>> compile_unit CU1
>> subprogram fn1
>> high/low pc, etc
>> subprogram inl
>> high/low pc, etc
>>
>> second.ll:
>...
2008 Aug 22
10
[LLVMdev] Proposal : Function Notes
...functions definitions. They are not attached to call
or invoke
instructions. All supported notes must be documented in LLVM language
reference.
The LLVM passes are responsible to take appropriate actions based on
Function
Notes associated with function definition. For example,
define void @fn1() notes("opt-size=1") { ... }
The function fn1() is being optimized for size without losing
significant
performance. The inliner will update inlining threshold for fn1() such
that the
functions called by fn1() are checked for size threshold for fn1()
while being
inlined inside fn1...
2008 Apr 23
3
[LLVMdev] Compile units in debugging intrinsics / globals
...mpile unit records but this only works
when all are defined in the same source file. If data or a function is
defined in an included file then they appear to be in a different compile
unit.
Suppose I have the following source:
file1:
#include "file2"
#include "file3"
int fn1(void) ...
file2:
int a;
file3:
int fn2(void) ...
then fn1, along with all the base types etc appear to be in compile unit
"file1", the variable a appears to be in compile unit "file2" (and there are
no basic types in file2, so int is not defined), and fn2 appears to be...
2007 Feb 26
1
2 data frames - list in one out put , matrix in another ??
...o be that bdata variables are labelled.
About now I really don't care which I get but I would
like them to be the same. Can anyone suggest what I
am doing wrong or should be looking at?
Windows XP , R 2.4.1 Using Hmisc and gtools as well as
the basic R installation.
Problem
load(adata)
fn1 <- function(x) {table(x)}
jj <-apply(adata[,110:127], 2, fn1)
OUTPUT jj is aa list of 18 tables
Examine a variable:
> typeof(adata$act.toy)
[1] "integer"
> class(adata$act.toy)
[1] "integer"
load(bdata
fn1 <- function(x) {table(x)}
kk <-apply(bdata[,9...