Displaying 20 results from an estimated 7000 matches similar to: "How to pack my stuff into a package (library, collection)?"
2008 Mar 22
2
More elegant multiplication or division of a data frame with a vector
Hello,
I am importing some raw voltage multichannel measurements into an R
data frame. I need to scale each column with the respective
sensitivity for that channel. I figured how to do it, but I am curious
if there isn't a more elegant way.
Now I start with something like this:
rawdata <- data.frame(rbind(c(1,2,3), c(4,5,6)))
sens <- c(2,4,6)
and I do this:
data <-
2008 Feb 25
1
Plotting series marked with a symbol on every nth data point, preferably in ggplot...
Hello!
I am working with signals and a plot of several signals on the same
axes can get quite messy. With lines that are very fractured,
distinction by only the linestyle is not very clear. If I add symbols
to the plot however, there are so many symbols, that they overplot and
the whole plot is unreadable once again. I am looking for advice on
how to make a plot with continuous lines and symbols
2008 Mar 25
1
Combining several mappings in ggplot2
Hello,
I want to be able to make a plot that has several series with
different color and linetype.
Online documentation suggest that this is possible, but I haven't found how:
"We can also create redundant mappings, mapping the same variable to
multiple aesthetics. This is most useful when producing a graphic for
both colour and black and white display."
Here's what I have to
2008 Mar 24
1
How to assign multiple return values
Hi,
I am moving from MATLAB, where one can easily assign a number of
output values from a function like this:
[x,y] = myfun(a,b)
Then variables x and y can be directly used in the caller workspace.
I understand that R functions return a single argument, which could be
a list. This in a way makes it possible to return multiple values with
a single function call, but accessing the list variables
2008 Mar 26
2
Moving data between R and Matlab back and forth?
Hi to the list,
I am trying to find a way to painlessly move structured data back and
forth between R and Matlab (also Octave). For this purpose I found the
R.matlab package great help. I wish to use a Matlab -v6 MAT file as an
intermediary format, because it is well read by both Matlab and
Octave. It is also well read by 'readMat' function in R.matlab
package, but that is where I run
2008 Feb 07
1
How to split a factor (unique identifier) into several others?
Hello,
I have a data frame with a factor column, which uniquely identifies
the observations in the data frame and it looks like this:
sample1_condition1_place1
sample2_condition1_place1
sample3_condition1_place1
.
.
.
sample3_condition3_place3
I want to turn it into three separate factor columns "sample",
"condition" and "place".
This is what I did so far:
#
2008 Feb 07
1
Bode plots in ggplot2
Hello,
I am trying to figure out how to make a bode plot (a.k.a. bode
diagram) in ggplot2.
An example of such a diagram can be found here:
http://meweb.ecn.purdue.edu/~me475/ctm/freq/bode2.GIF
The example above shows the gain and phase characteristic of a linear system.
In my case, I would like to compare visually several systems on the
same diagram.
The data in the data frame is arranged
2008 Mar 27
2
Rule for accessing attributes?
Hi !
I am a new user and quite confused by R-indexing.
Make a list and get the attributes
lst <- list(x = 1:3, y = 4:6, z = 7:9)
attributes(lst)
This returns:
$names
[1] "x" "y" "z"
I can easily do:
nm <-names(lst)
or
nm <-attr(lst,"names")
which both return the assigned names of the named list 'lst', but why
then this doesn't
2010 Sep 03
3
S4 Method Signatures
Hello,
If the signature of a method defines which generic it implements then I'm confused about why this minimal example I invented won't work :
setGeneric("myFun", function(rs, ...){standardGeneric("myFun")})
setGeneric("myFun", function(cs, ...){standardGeneric("myFun")})
setMethod("myFun", "numeric", function(rs, colour =
2003 Apr 17
4
A function as argument of another function
Dear all,
I would like to write a function like:
myfun<-function(x,fn) {xx<-exp(x); x*fn(xx)}
where fn is a symbolic description of any function with its argument to be
specified. Therefore
myfun(5,"2+0.3*y^2")
should return 5*(2+0.3*exp(5)^2),
myfun(5,"log(y)") should return 5*log(exp(5)) and so on.
I tried with "expression" and others, but without success.
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*
2006 Feb 02
2
How to get the namespace of a function?
I declared the environment of the function myfun to be NULL as follows:
environment(myfun) <- NULL
Later on I called that myfun and got an error message because the
function index() in the zoo package was called inside myfun and was
not visible:
Error in myfun(args) : couldn't find function "index"
I tried to use zoo::index() instead of index(), but that did not work.
In fact,
2013 Jun 07
1
It seams that fast99 function (sensitivity package) does not work out for norm distribution.
Dear all mailing listers,
Does Anyone have the same problem as mine when using the fast99
(extended-FAST method) to perform SA of model with norm distribution inputs?
See the simple example given following.
Any suggestion will be greatly appreciated.
Thank you!
Marino
# Simple example
# 1. uniform version (It works well)
library(sensitivity)
Myfun<-function(x){return(rowSums(x))}
SA1
2023 Aug 03
3
feature request: optim() iteration of functions that return multiple values
Dear all,
I have used optim a lot in contexts where it would useful to be able to iterate function myfun that, in addition to the primary objective to be minimized ('minimize.me'), could return other values such as alternative metrics of the minimization, informative intermediate values from the calculations, etc.
myfun <- function()
{
...
return(list(minimize.me = minimize.me, R2 =
2015 Oct 22
2
Changed behaviour when passing a function?
Of course (and unsurprisingly) Duncan is correct. I see that behavior in R
3.1.0, as well as the modern ones Duncan mentioned.
What I said is true, as far as it goes, but the symbol being resolved is
FUN, so when looking for a function it doesn't find the function version of
round.
Did you perhaps have a function named FUN in your global environment? If so
you are being bitten by what I
2011 Feb 02
1
pass nrow(x) to dots in function(x){plot(x,...)}
Dear Rers,
I have a function to barplot() a matrix, eg
myfun <- function(x, ...) { barplot(x , ... )}
(The real function is more complicated, it does things to the matrix first.)
So I can do:
m1 <- matrix(1:20,4)
myfun(m1)
myfun(m1, main="My title")
I'd like to be able to add the number of rows of the matrix passed to
the function to the "..." argument, eg
2005 Sep 20
1
Xgird, R, parallel computing
Hi, list,
Sorry if I am bothering you.
I am interested in using xgrid with R for distributed computing. I am using
MacOS X and my R 2.1. 1 is already installed and running. The client
computers are all of the same type and the same version of R has been
installed on them.
We have also set up xgrid on my system and client computers as well.
I am wondering if any one can give me some clues
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
##
2006 Sep 27
2
How to pass expression as an argument
Hi,
I am writing a function and need to pass a function expression as an argument, for instance,
myfun <- function( express) {
x<- c(1,2,3)
y<-express
}
if I call the above function by myfun( x*2 ), I get 2 as the result, instead of 2,4,6 , could someone help me to
fix this problem ?
Furthermore, is that
2013 Jan 04
1
Garbage collection problem
Hello all,
I am running into a problem with garbage collection not being able to
free up all memory. Unfortunately I am unable to provide a minimal
self-contained example, although I can provide a self contained
example if anyone feels like wading through some 600 lines of code. I
would love to isolate the relevant parts from the code but whenever I
try to run a simpler example, the problem does