similar to: Warning: condition has length > 1

Displaying 20 results from an estimated 11000 matches similar to: "Warning: condition has length > 1"

2018 Apr 15
4
Adding a new conditional column to a list of dataframes
Hi all .., I have a list of 7000 dataframes with similar column headers and I wanted to add a new column to each dataframe based on a certain condition which is the same for all dataframes. When I extract one dataframe and apply my code it works very well as follows :- First suppose this is my first dataframe in the list > OneDF <- Mylist[[1]] > OneDF ID Pdate
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
2011 Feb 10
3
help - "the condition has length > 1 and only the first element will be used"
Hello there, I don't know if I'm addressing my question to the right e-mail address, I hope I do. Actually I have a little problem concerning writing a code in R. I try to briefly sum up my problem. As you can see below, I created the functions "Equation1" and "Equation2" with some conditions. Equation1 <-function(x){ if
2018 Apr 15
0
Adding a new conditional column to a list of dataframes
> On Apr 15, 2018, at 4:08 AM, Allaisone 1 <Allaisone1 at hotmail.com> wrote: > > > Hi all .., > > > I have a list of 7000 dataframes with similar column headers and I wanted to add a new column to each dataframe based on a certain condition which is the same for all dataframes. > > > When I extract one dataframe and apply my code it works very well as
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
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
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 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
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')
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
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
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
2004 Oct 16
7
sapply and loop
Dear all, I am doing 200 times simulation. For each time, I generate a matrix and define some function on this matrix to get a 6 dimension vector as my results. As the loop should be slow, I generate 200 matrice first, and save them into a list named ma, then I define zz<-sapply(ma, myfunction) To my surprise, It almost costs me the same time to get my results if I directly use a loop
2004 Oct 16
7
sapply and loop
Dear all, I am doing 200 times simulation. For each time, I generate a matrix and define some function on this matrix to get a 6 dimension vector as my results. As the loop should be slow, I generate 200 matrice first, and save them into a list named ma, then I define zz<-sapply(ma, myfunction) To my surprise, It almost costs me the same time to get my results if I directly use a loop
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
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 = {
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:
2012 Jan 03
6
calculate quantiles of a custom function
Hi, I guess that my problem has an obvious answer, but I have not been able to find it. Suppose I create a custom function, consisting of two beta-distributions: myfunction <- function(x) { dbeta(x,2,6) + dbeta(x,6,2) } How can I calculate the quantiles of myfunction? I have not seen any continous function treated in the docs, and applying the "quantile function" gives me an