search for: myfunctions

Displaying 20 results from an estimated 222 matches for "myfunctions".

Did you mean: myfunction
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 everything is in order, myfunction works
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()) source('mySourceFile')
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
2012 Mar 13
2
beginner's loop issue
Dear All, I hope 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] <-
2006 Jun 28
2
hopefully my last question on lapply
Marc and many other people ( whose names escape me ) have been very helpful in explaining the use of lapply to me. In his last response, Marc explained that if tradevectors is a list of vectors of different lengths ( excuse my terminology ) then lapply(tradevectors,function(x) G[x]*B[x] ) will go through each component of the list as if it was a vector and apply the element by element
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
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 the R...
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", append=TR...
2005 Oct 08
4
Warning: condition has length > 1
Hi - I was wondering if anyone came across a problem such as mine! I was trying to create a user-defined function, however, the results from calling the function are 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
2018 Aug 09
3
WishList: Remove Generic Arguments
I 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
2008 Dec 17
4
passing arguments to subset from a function
Hello R-helpers, I'm writing a long function in which I manipulate 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,
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
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 great...
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 = {
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 pac...
2007 Jul 06
2
access to 'formula' terms in a user function
This is probably buried somewhere in the R help archives, but I've been unable to find it, so perhaps the keywords I use here will help bring the topic to the surface more easily for future users. I want to write 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
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:
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