similar to: pass names from dataframe as arguments

Displaying 20 results from an estimated 9000 matches similar to: "pass names from dataframe as arguments"

2010 Jan 14
5
Better way than an ifelse statement?
Hello All, I am trying to create a column of weights based off of factor levels from another column. I am using the weights to calculate L scores. Here is an example where the first column are scores, the second is my "factor" and the third I want to be a column of weights. I can do what I want with an ifelse statement (see below), but I am wondering if anyone knows of a cleaner way
2010 Mar 12
2
Return one value, print another
Dear R users, I am stuck trying to figure out how to make a function return one value and print another.? Here is an example function: ################## eg <- function(x, digits=4) { xbar <- mean(x) sdx <- sd(x) value <- list(xbar, sdx) names(value) <- c("Mean of X", "SD of X") return(value)} ################## My current "solution" has been to
2019 Mar 02
1
stopifnot
A private reply by Martin made me realize that I was wrong about stopifnot(exprs=TRUE) . It actually works fine. I apologize. What I tried and was failed was stopifnot(exprs=T) . Error in exprs[[1]] : object of type 'symbol' is not subsettable The shortcut assert <- function(exprs) stopifnot(exprs = exprs) mentioned in "Warning" section of the documentation similarly fails
2019 Mar 05
0
stopifnot
>>>>> Suharto Anggono Suharto Anggono >>>>> on Tue, 5 Mar 2019 17:29:20 +0000 writes: > Another possible shortcut definition: > assert <- function(exprs) > do.call("stopifnot", list(exprs = substitute(exprs), local = parent.frame())) Thank you. I think this is mostly a matter of taste, but I liked your version using eval()
2019 Mar 02
0
stopifnot
Instead of if(!is.null(names(cl))) names(cl) <- NULL , just names(cl) <- NULL looks simpler and the memory usage and speed is not bad in my little experiment. -------------------------------------------- Subject: Re: [Rd] stopifnot To: r-devel at r-project.org Date: Saturday, 2 March, 2019, 3:28 PM [...] A revised patch (also with simpler 'cl'): --- stop.R 2019-02-27
2018 Sep 11
0
Modification-proposal for %% (modulo) when supplied with double
On 11/09/2018 11:23 AM, Emil Bode wrote: > Hi all, > > > > Could we modify the "%%" (modulo)-operator to include some tolerance for rounding-errors when supplied with doubles? > > It's not much work (patch supplied on the bottom), and I don't think it would break anything, only if you were really interested in analysing rounding differences. > >
2010 May 01
0
access http directories requiring authentication across platforms
Hello R users, I am trying to read files from a website that requires authentication. I have been working with url() to to open a connection in Windows. For example: setInternet2(TRUE) con <- url(description="http://myusername:mypassword at www.somesite.com/myfile.txt", open="r") open(con) read.table(con, sep="\t") This works like a charm. My question is does
2018 Sep 11
2
Modification-proposal for %% (modulo) when supplied with double
Hi all, Could we modify the "%%" (modulo)-operator to include some tolerance for rounding-errors when supplied with doubles? It's not much work (patch supplied on the bottom), and I don't think it would break anything, only if you were really interested in analysing rounding differences. Any ideas about implementing this and overwriting base::`%%`, or would we want another
2019 Mar 05
2
stopifnot
Another possible shortcut definition: assert <- function(exprs) do.call("stopifnot", list(exprs = substitute(exprs), local = parent.frame())) After thinking again, I propose to use ??? ? ? stop(simpleError(msg, call = if(p <- sys.parent()) sys.call(p))) - It seems that the call is the call of the frame where stopifnot(...) is evaluated. Because that is the correct context, I
2018 Sep 11
1
Modification-proposal for %% (modulo) when supplied with double
Duncan, I think Emil realizes that the floating point format isn't able to represent certain numbers, that's why he is suggesting this change rather than complaining about our arithmetic being broken. However, I agree with you that we should not adopt his proposal. It would not make things more "user friendly" for people. Everyone has a different application and a different use
2011 Mar 22
1
help need on working in subset within a dataframe
Dear R-experts Execuse me for an easy question, but I need help, sorry for that. >From days I have been working with a large dataset, where operations are needed within a component of dataset. Here is my question: I have big dataset where x1:.....x1000 or so. What I need to do is to work on 4 consequite variables to calculate a statistics and output. So far so good. There are more vector
2011 Sep 26
4
Testing for arguments in a function
I don't understand how this function can subset by i when i is missing.... ## My function: myfun = function(vec, i){ ret = vec[i] ret } ## My data: i = 10 vec = 1:100 ## Expected input and behavior: myfun(vec, i) ## Missing an argument, but error is not caught! ## How is subsetting even possible here??? myfun(vec) Is there a way to check for missing function arguments, *and*
2019 Feb 27
1
stopifnot
My points: - The 'withCallingHandlers' construct that is used in current 'stopifnot' code has no effect. Without it, the warning message is the same. The overridden warning is not raised. The original warning stays. - Overriding call in error and warning to 'cl.i' doesn't always give better outcome. The original call may be "narrower" than 'cl.i'. I
2005 Mar 11
1
Ploting a function of two arguments
Hi, I've written a function: myfun <- function(x, y) { // blah blah } and I want to graph it. My plan is to use persp(), and my question is: how do I create the array of values? One possibility is: x <- seq(0, 10, by=.1) y <- seq(0, 10, by=.1) inputs <- <somehow create an array of x,y pairs> outputs <- apply(A, c(1,2), myfun) The "inputs" array would
2009 Jun 26
3
changing default arguments of a function and return the modified function as a result
Dear R-users, I am trying to develop a function that takes another function as an argument, changes its default values and returns a list of things, among which the initial function with its default arguments changed. An example of what i will like to obtain below: ## initial function myfun <- function(x, a=19, b=21){ return(a * x + b) } ## this is the function i will like to create ##
2009 Nov 22
1
transferring SIP call: no voice
I'm trying to connect a sip call from sipgate to Asterisk A to Asterisk B. Both are behind NAT, but port forwarded. I get the connection, but no voice - either in or out. I can call on SIP from A to B (and from B to A). Do it all the time. Asterisk A receives SIP calls from Junction and Teliax. CLI on A looks right: == Using SIP RTP TOS bits 184 == Using SIP RTP CoS mark 5 ==
2007 May 18
3
lapply not reading arguments from the correct environment
Hello, I am facing a problem with lapply which I ''''think''' may be a bug. This is the most basic function in which I can reproduce it: myfun <- function() { foo = data.frame(1:10,10:1) foos = list(foo) fooCollumn=2 cFoo = lapply(foos,subset,select=fooCollumn) return(cFoo) } I am building a list of dataframes, in each of which I want to keep only column
2014 Aug 07
2
How to (appropropriately) use require in a package?
Dear All, What is the preferred way for Package A, to initialize a cluster, and load Package B on all nodes? I am writing a package that parallelizes some functions through the use of a cluster if useRs are on a Windows machine (using parLapply and family). I also make use of another package in some of my code, so it is necessary to load the required packages on each slave once the cluster is
2010 Sep 17
1
how to work with Year-Month dates
Hi all, Is there a built in or easier way to work with dates that are *just* Year-Month? Right now I paste() on a day as a work around, but it ultimately needs to be in Year-Month form, so then I use format() to get rid of the day. x <- c("2006-December", "2006-July") x <- paste(x, "-01", sep='') x <- as.Date(x, "%Y-%B-%d") x <- sort(x)
2010 Jul 26
1
After writing data in MMF using SEXP structure, can i reference in R?
Hi all, After writing data in MMF(Memory Map File) using SEXP structure, can i reference in R? If input data is larger than 2GB, Can i reference MMF Data in R? my work environment : R version : 2.11.1 OS : WinXP Pro sp3 Thanks and best regards. Park, Young-Ju from Korea. ---------[ ???????? ???????? ???????? ]---------- ???????? : R-help Digest, Vol 89,