Displaying 20 results from an estimated 900 matches similar to: "Changing "..." inside a function: impossible? desirable?"
2003 Feb 17
2
returning argument names
Dear r-list folks,
I have a problem which has been bugging me for a while now and I was hoping
someone out there might be able to help.
If I have a user-defined function with an indeterminate number of
arguments, using the well-known "..." construct, how can I get the
function to return the names of the items which were the arguments of the
function as part of the function's
2009 Jan 03
1
Equivalent of match for data.frame
Dear R-users,
I am translating a S script into R and having some troubles with the
match function. This function appears to work with vector and data.frame
in S, but not in R, e.g.:
a <- rep((1:4), each = 10)
b <- rep((1:10), times = 4)
mydf <- data.frame(a,b)
myarg <- mydf[1,]
match(myarg, mydf)
# S returns 1 but R returns NA NA
I guess one could use match(interaction(myarg),
2010 Jan 15
2
processing all files with certain extension in a directory
Hi all,
I'm trying to process all files with a certain extension "*.ext" in a
directory like this:
> R --slave --args /my/dir < dir_plot.r
where I then I want to do something like:
myarg <- commandArgs()
inputdir <- myarg[length(myarg)]
print(inputdir)
"for file with extension "*.ext in inputdir"
do
data = process.data(file)
outfile =
2011 May 26
1
Is it possible to define a function's arguments via a wildcard in 'substitute()'?
Dear List,
just out of pure curiosity: is it possible to define a function via
'substitute()' such that the function's formal arguments are specified
by a "wildcard" that is substituted when the expression is evaluated?
Simple example:
x.args <- formals("data.frame")
x.body <- expression(
out <- myArg + 100,
return(out)
)
expr <-
2006 Nov 24
1
Missing values for S4 slots
Using R 2.4, the following fails:
setClass("testc", representation(a="ANY"))
makeC <- function(myarg) new("testc", a=myarg)
makeC()
-> Error in initialize(value, ...) : argument "myarg" is missing,
with no default
On the other hand, this is OK:
f <- function(a) g(b=a)
g <- function(b) if(missing(b)) "missing" else "valid
2003 Mar 06
1
Proper way to document print( ) functions
Frequently we have a print method, say print.myclass, that has a variety of arguments. If in the .Rd file I say
\usage{
\method{print}{myclass}(x, myarg)
}
I get a warning when running R CMD chk:
* checking generic/method consistency ... WARNING
print:
function(x, ...)
print.myclass:
function(x, myarg)
What is the proper way to handle this?
Thanks
--
Frank E Harrell Jr
2014 Apr 14
1
duplication regression (?)
Below is an example of output that changed as a result of r64970. I
did not see any NEWS item suggesting this change is expected.
Note that the example is contrived and I don't have a use case for it.
I stumbled across it when playing with recent changes in R relating to
duplication. Does the example use undefined syntax?
-----
fn1 <- function(mylist) {
fn1a <- function()
2008 Jul 05
3
Editing the "..." argument
Dear all,
I'd like tweaking the ... arguments that one user can pass in my
function for fitting a model. More precisely, my objective function is
(really) problematic to optimize using the "optim" function.
Consequently, I'd like to add in the "control" argument of the latter
function a "ndeps = rep(something, #par)" and/or "parscale =
2012 Apr 12
1
Help with vectorization
Hi every one. I have a exponential function (3 fitting parameters) that I
would like to use to produce data (6 series) without having to use a loop.
Here
wl = seq(300,500,1)
k1 = c(1.2e-6, 4.9e-6, 9.6e-6, 2.7e-10, 6.7e-8, 7.44e-6)
k2 = c(726, 352, 128, 5232, 1538, 128)
k3 = c(-176, -224, -257, 88.7, -111, -256)
stations = c('R5d', 'R5a', 'R9', '108',
2006 Nov 30
3
writing function with ,... )
Hi to all
I did not found the right hints for functions with the dot-dot-dot argument.
Is it possible to write own functions with the tree dots and if yes
what's wrong with the following example?
test <- function(x, ...)
{
print (x)
if (exists("y"))print(y)
if (exists("z"))print(z)
}
test(4,y=2)
With regards Carmen
2012 Jan 18
1
use of UTF-8 \uxxxx escape sequences in function arguments
While preparing a function that contained non-ASCII characters for inclusion
into a package, I replaced all non-ASCII characters with UTF-8 escape
sequences (using \uxxxx) in order to make the package portable (and adhere to
"R CMD check"). What I didn't expect: when one uses UTF-8 escape sequences in
function arguments, one needs to use UTF-8 escape sequences when calling the
2010 Feb 28
1
dots for sample
Dear R-Developers,
could 'sample' gain a ... argument?
As a convenience function, I added a sample Method to my hyperSpec
class. This function however has a flag indicating whether the results
should be returned directly as a hyperSpec object or rather as indices
that give a random sample.
For the moment, I use SetGeneric to add the dots argument, but this of
course gives a warning
2011 Jul 04
1
superimposing different plot types in lattice panel.superpose
I would like to plot 3 best-fit models in a single panel of a lattice plot,
superimposed on 3 corresponding datasets in the same panel. My goal is to
show the models as lines of 3 different colors, and the data as points whose
colors correspond to the model colors. In essence, I have two levels of
grouping: 1) model vs. data, and 2) model number. Since there is only one
?groups? variable, I
2007 Jun 23
2
Names of objects passed as ... to a function?
Dear list,
I have a function whose first argument is '...'. Each element of '...'
is a data frame, and there will be at least 2 data frames in '...'. The
function processes each of the data frames in '...' and returns a list,
whose components are the processed data frames. I would like to name the
components of this returned list with the names of the original data
2009 Apr 17
2
suggestion for R >= 3.0: computer-readable CHANGELOG
Hello,
Here are a few questions that would be useful to get an answer via
dedicated functions in utils or tools packages:
- When did function foo appeared in R or in a given package?
- When did argument myarg appeared in function foo?
- When did function bar get deprecated or when did it disappeared?
- I wrote a script using functions foo and bar with R 1.9.1. My script
does not work any more
2010 Nov 13
1
Efficient marginal sums?
Hi Folks,
[This is not unrelated to the current "vector of vectors" thread,
but arises quite independently]
Say I have a function f(x,y) which computes a value for scalar
x and y; or, if either x=X or y=Y is a vector, a corresponding
vector of values f(X,y) or f(x,Y) (with the usual built-in
vectorisation of operations).
Now I have X=(x.1,x.2,...,x.m) and Y=(y.1,y.2,...,y.n).
I'm
2012 Aug 17
8
Get the filename from the given path
Hi,
Here i have a file path,
for eg : -
FPath <- "D:\\MyFolder\\MyFile.txt"
HOW IS POSSIBLE TO GET THE FILE NAME FROM THIS GIVEN PATH ?
- thanks in advance
Antony.
--
View this message in context: http://r.789695.n4.nabble.com/Get-the-filename-from-the-given-path-tp4640578.html
Sent from the R help mailing list archive at Nabble.com.
2006 Feb 03
6
Rails from the command line
I have controller that processes data in one table and puts results in
another. Now that its'' working, I would like to be able to run it from the
command line ( read: windows batch file). How can this be done?
It will be installed on a Windows box with InstantRails1.0, (if that
matters).
I will be doing more processes like this, so this is a good opportunity to
get it right.
--
Best
2012 Sep 11
5
Searching from Dataframe.
Hi,
i have a dataframe containing some values.
for eg:-
MyDataFrame<-
Name Age Place
------- ------ -----------
Aby 12 USA
Raj 25 UK
Romi 32 ENG
Amy 31 IND
My requirement what is, i have a search key word[it should search from all
the columns], that i need to find out from this dataframe. If search keyword
found , it
2013 Jan 27
1
Removing values containing a specific character
Awesome, thanks Arun, that's exactly what I was looking for!
On Sat, Jan 26, 2013 at 9:21 PM, arun kirshna [via R] <
ml-node+s789695n4656749h63@n4.nabble.com> wrote:
> Hi,
> Try this:
> df[]<-lapply(df,as.character)
> df2<-df
> df[,1][grep("@",df$names)]<- ""
> df
> #names emails
> #1 bob bobj@cup.com
> #2