Displaying 20 results from an estimated 222 matches for "myfunct".
Did you mean:
myfunc
2009 Oct 26
2
R CMD check: Error in .C
Function/file names are hypothetical. Say I have written myfunction.R,
which calls myfunction.c via .C("myfunction", ...).
I've compiled successfully myfunction.c via R CMD SHLIB myfunction.c
in the terminal. Then, in the R console:
dyn.load("myfunction.so")
source("myfunction.R")
test <- myfunction() # works fine
So every...
2007 Apr 03
3
Referencing function name from within function
Hello,
For verbose coding I'd like to do something like:
> myfunction <- function(x){
> if (a){
> stop(paste(myfunction_name_here,"requires xyz!")
> }
Is that possible?
Thanks for any hints, Joh
2009 Jun 03
1
Using constrOptim() function
I have a function myFunction(beta,x) where beta is a vector of coefficients
and x is a data frame (think of it as a matrix). I want to optimize the
function myFunction() by ONLY changing beta, i.e. x stays constant, with 4
constraints. I have the following code (with a separate source file for the
function):
rm(list=ls())...
2012 Nov 23
1
Adding a function with default parameters into the Rcmdr menu
Hi everyone,
I made some tests with Rcmdr, to add a function with default parameters :
For example (very simple):
myfunction<-function(var="314"){
print("hello")
print(var)
}
if I run myfunction() directly i see :
> myfunction()
[1] "hello"
[1] "314"
it's ok.
But if i edit de Rcmdr-menu.txt (in
C:\Users\myname\Documents\R\win-library\2.15\Rcmdr\etc)
and add :
menu...
2012 Mar 13
2
beginner's loop issue
...e you don't mind helping me with this small issue. I haven't been using
R in years and I'm trying to fill in a matrix
with the output of a function (I'm probably using the Matlab logic here and
it's not working).
Here is my code:
for (i in 1:length(input)){
out[i,1:3] <- MyFunction(input[i,1],input[i,2], input[i,3])
out[i,4:6] <- MyFunction(input[i,5],input[i,7], input[i,6])
out[i,7:9] <- MyFunction(input[i,8],input[i,10], input[i,9])
}
'input' is a matrix
> dim(input)
[1] 46 10
and each raw corresponds to a different subject.
The error I...
2006 Jun 28
2
hopefully my last question on lapply
...of vectors.
This is fine and I understand it.
What I find confusing is that sometimes I want
to take the two vectors G abd B and send them totally
into some function with the respective indices from
tradevectors not just the element by element index.
For example, suppose I have a function called
myfunction that takes two vectors as its inputs.
Then, here are my ideas for what could be done.
Attempt 1 : lapply(tradevectors,function(i) myfunction(G[i],B[i])
Attempt 2 : lapply(along=tradevectors),function(i) myfunction(G[[i]],B[[i]]
In attempt1, I am just putting tradevectors and indexing
using t...
2006 May 16
3
multiple plots in a function()
Dear all,
I have the following problem:
I have written a function genereating to plots, eg
myfunction <- (data, some.parameters) {
#some calculations etc
.
par (mfrow=c(1,2))
plot1(......)
plot2(.....)
}
which works fine. But for analysing several variants, I tried a slope, eg:
par (mfrow=c(5,5))
for ( i in 1:10) {
myfunction(data, i)
}
Off cou...
2006 Apr 17
4
R debugging options
Hello,
What options are available for me to debug my R scripts? For example I
normally do something like
>source("myfunctions.R")
>function1("height", "weight")
myfunctions.R is a large R source file that contains many functions. function1
is the "main" function in myfunctions.R. It calls many other user-written
functions that are also in myfunctions.R.
I only want to debug th...
2000 Sep 28
2
organizing work; dump function
...ted in one place, and to make them available in R
no matter which working directory I use.
Reading the manual "An Introduction to R Version 1.0.0", chapter 10.8
("Customizing the environment"), I guess the (best ?) way to this is to dump
all my functions into one big file "myfunctions.R" and source that into R
via a .First function in my Rprofile file.
But, when I write new functions and want to add these to my personal
collection "myfunctions.R", it would be nice to have something like
> dump("new.function", file="myfunctions.R", appen...
2005 Oct 08
4
Warning: condition has length > 1
...unexpected!
When passing X parameter as a single value variable (x<-c(3)), everything
works fine. However, when passing a parameter as a vector with multiple
values (as the case in my code), the 'if condition' is only executed once!
Here is my code:
> x
[1] 0.3 1.0 0.7 22.0
> myfunction<-function(x)
+ {
+ if (x>=1) 0
+ else x^2
+ }
> myfunction(x)
[1] 0.09 1.00 0.49 484.00
Warning message:
the condition has length > 1 and only the first element will be used in: if
(x >= 1) 0 else x^2
>
Is there a way to overcome this issue? Can you please explain what...
2018 Aug 09
3
WishList: Remove Generic Arguments
...apologize if this issue has been raised before.
I really like object oriented S3 programming.
However, there's one feature of object oriented S3 programming that I don't
like.
Generic functions can have arguments other than dots.
Lets say you have an R package with something like:
print.myfunction (f, ...)
{ dosomething (f, ...)
}
Noting that I use function objects a lot.
R CMD check will generate a warning because you've named your object f
rather than x.
I don't want to name my object x.
I want to name my object f.
Naming the object x makes the program unreadable.
Especiall...
2008 Dec 17
4
passing arguments to subset from a function
...ulate a certain number of datasets. I want the arguments of said function to allow me to adapt the way I do this. Among other things, I want my function to have an argument which I will pass on to subset() somewhere inside my function. Here is a quick and simplified example with the iris dataset.
myfunction<-function(table, extraction) {
table2<-subset(table, extraction)
return(table2) }
myfunction(iris, extraction= Species=="setosa")
############## end
What I would like is for this function to return exactly the same thing as :
subset(iris, Species=="setosa"...
2011 Jun 10
4
running R commands asynchronously
I am interested in running R commands asynchronously.
My first choice is in the same R session that I am currently in.
Here, the goal would be to run something like
RunAsynchSameSession(myfunction(), "outputname.rda")
Once RunAsynchSameSession had started myfunction(),
RunAsynchSameSession would complete immediately. myfunction would
keep going. It is OK if execution of the myfunction() command
prevents new input to R until it has completed. The important feature
is that Run...
2007 Oct 09
3
How to create something between a script and a package
...ow, I want something like a package, to be able to share functions
between ourselves. Having read a few package tutorials, I feel that
this is not exactly what I want and I'm kinda lost regarding what
alternatives are available.
What I want could be summarized as this:
- A plain text file (eg: myfunctions.R)
- Can be located in other folders besides the default (easier to
synchronize using subversion). Eg: myproject/rfunctions/myfunctions.R
- Can be accessed from the R console (without having to load a
specific workspace).
Is there any solution that can provide this?
Any suggestions would be g...
2011 Oct 28
3
program never enters browser mode when I add browser()
Dear All
I have a program that breaks at the following lines of code:
bigfunction =
{
...
object1 = myfunction(x)
object2 = strsplit(object1, ",")[[1]]
...
}
where myfunction is defined elsewhere outside of bigfunction.
The error I get is "error in strsplit() -- object1 not found".
However, when I insert browser() into my code so that the above reads,
bigfunction =
{
...
brow...
2011 Jun 30
2
error building package: packaging into .tar.gz failed
I am trying to build a package using windows xp. Here is the error I am getting:
R CMD build myfunctions
* checking for file 'myfunctions/DESCRIPTION' ... OK
* preparing 'myfunctions':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building 'myfunctions_1.0.tar.gz'
ERROR...
2007 Jul 06
2
access to 'formula' terms in a user function
...my own modeling function (ultimately for some
multidimensional windowing - but this question is on scripting basics). For
purposes of figuring out my needs, lets just consider writing a function
that takes a formula and a dataset, and outputs the mean of each variable in
the formula model. So:
MyFunction <- function(AFormula, ADataFrame) {
...
}
>MyFunction(Y ~ A + B, TheData)
would give results something like:
Mean of MyData$Y is 5.3
Mean of MyData$A is 3.4
Mean of MyData$B is 8.2
QUESTION 1:
How do I determine the terms in the formula within the function?
QUESTION 2:
How do I...
2011 Nov 21
3
How do I query "..." in a function call?
This is probably a very noobish question, but if I want to create a
function that allows an undetermined number of, say, numeric vectors to be
fed to it, I would use:
myfunction = function(...)
{
# Do something
}
Right? If so, how do I a) count the number of vectors "fed" to the
function, and b) how do I treat those vectors as variables, e.g. for the
call:
myfunction(c(1:10),c(2:11),c(3:13))
Thanks!
--j
--
Jonathan A. Greenberg, PhD
Assistant Professor...
2005 Jul 19
2
Obtaining argument name within a function
Dear all
How can I obtain the name of the argument passed in a function? Here is a
simplistic example of what I would like to obtain:
myfunction= function(name) {
print(paste("The parameter name was",unknownFunction(name))
}
myfunction(myobject)
[1] "The parameter name was myobject"
Thanks
Francisco
2018 Mar 28
7
[RFC] Generate Debug Information for Labels in Function
Hello all,
I would like to enhance LLVM debug info that supports setting
breakpoint on labels in function.
Generally, if users use GDB as their debugger, they could set
breakpoints on labels in function. Following is an example.
// C program
static int
myfunction (int arg)
{
int i, j, r;
j = 0; /* myfunction location */
r = arg;
top:
++j; /* top location */
if (j == 10)
goto done;
for (i = 0; i < 10; ++i)
{
r += i;
if (j % 2)
goto top;
}
done:
return r;
}
int
main (void)
{
int i, j;
for (i =...