Displaying 20 results from an estimated 30000 matches similar to: "Function question"
2010 Jan 08
4
Arguments of a function
Dear all,
I have a question about how to set arguments in my own function. For
example, I have a function that looks like this:
my.f <- function(a = x1, b = x2)
{
x1 = equation 1
x2 = equation 2
x3 = equation 3
y = a + b
}
x1, x2, and x3 are temporary variables (intermediate results) calculated
from other variables within the funciton. I want to use two of these three
2007 Nov 28
1
how to find and use specific column after spliting dataframe
Dear all:
I am a new R-user and I have 2 questions
about it.
1) I need to find specific sub-dataframe,
and then use specific column to calculate.
For example, after splitting dataframe, I find specific the
sub-dataframe, such as ?A.split [1]?.
But, I don?t know how to find ?time? and ?concentration? columns of ?A.split
[1]?.
2) The equation used to sub-dataframe is
2008 Oct 03
2
computing on expressions
Dear R-users,
Suppose I have an expression:
expr = expression(a>0)
and now I want to modify it to expression(a>0 & b>0). The following doesn't work:
expr = expression(expr & b>0)
What would be a good way of doing this?
Thanks,
Vadim
________________________________
Note: This email is for the confidential use of the named addressee(s) only and may contain
2009 Jun 12
2
Creating this vector, any suggetions?
Suppose I have the first vector: c(1, 6, 8, 9)
I will like to create a second vector of size 10 composed of 0 and 1's. The
second vector will be composed of four 1's and six 0's. The position of the
1's will be specificed by the first vector. So essentially, I want a second
vector in the form:
c(1, 0, 0, 0, 0, 1, 0, 1, 1, 0)
Any help is greatly appreciated!
--
View this message
2009 Jun 23
2
Vector of string
Hi all. Suppose I have a vector of strings ie: ["12384", "TYU123123",
"AVC3939", "hhr1919", "TYU0029"]
Is there an efficient method that would allow me to return a vector of the
position of strings that start with "TYU"? So essentially, I would like to
get back in return [2, 5]. Anyways, any help with be greatly appreciated!
--
View
2008 Feb 04
2
make dataframe from table
Dear R-experts,
I have got a dataframe:
data
ID disease
V1 V2
1 p1 1
2 p1 3
3 p3 3
4 p3 5
5 p5 1
From which I extract a usefull table: affect
affect
1 3 5
p1 1 1 0
p3 0 1 1
p5 1 0 0
I want to merge this with anotherdataframe:
age
p1 23
p2 24
p3 23
p4 11
p5 45
If have tried as.data.frame(affect) and other solutions to get the
following comment going:
2008 Mar 04
3
creating a matrix subset based on a threshold cutoff
Hi,
I have a table of x rows and y columns. The table is huge and so i'd like
to create a subset of the data containing rows where any of the y values are
below a threshold, say 1e-4. Is there a simple way of doing this in R?
thanks
Rich
2008 Feb 22
3
Problem with cut
Hi All,
I might misunderstood how cut works. But following behaviour surprises
me.
vv <- seq(150, 346, by= 4)
cc <- cut(vv, 12)
cc[vv == 330]
Results [1] (330,346]
I would have expected 330 to fall into (313,330] category.
Can you please advice what do I do wrong?
Many Thanks,
Jussi Lehto
-------------- next part --------------
Visit our website at http://www.ubs.com
This message
2008 Feb 29
4
help
Dear Sir/Madam,
I got some problem about using R.
I am a student, and need to use R a lot. But sometimes when I am working in
computer lab, we can not install some particular pacakges by ourselves because
of the previliges.
Can the folder of Librabry of R, move to, for instance the personal folder, my
documents... then we can install any specified package?
Best regards,
2008 Jul 18
1
creating names for lists
Dear R Users,
How can I create names for lists within a function where the name itself
is a function of several variables ?
> a<-1
> b<-2
> paste(a,b)
[1] "1 2"
> foo<-list(paste(a,b)=3) <<<===== DOES NOT WORK
Error: unexpected '=' in "foo<-list(paste(a,b)="
> eval(paste(a,b))
[1] "1 2"
>
2009 Sep 28
4
How to assess object names within a function in lapply or l_ply?
Dear All,
to produce output of several columns of a data frame, I tried to use
lapply and also l_ply. In both cases, I would like to print a header
line containing also the name of the respective column in the data frame.
For example, I would like the following
lapply(data.frame(a=1:3, b=2:4), function(x) print(deparse(substitute(x))))
to produce:
[1] "a"
[1] "b"
and
2008 Aug 13
3
conditional IF with AND
Hi everyone,
I'm trying to create an "if" conditional statement with two conditions,
whereby the statement is true when condition 1 AND condition 2 are met:
code structure:
if ?AND? (a[x,y] <condition1>, a[x,y] <condition2>)
I've trawled through the help files, but I cannot find an example of the
syntax for incorporating an AND in a conditional IF statement.
2008 Feb 08
2
Applying lm to data with combn
http://www.nabble.com/file/p15359204/test.data.csv
http://www.nabble.com/file/p15359204/test.data.csv test.data.csv
Hi,
I have used apply to have certian combinations, but when I try to use these
combinations I get the error
[Error in eval(expr, envir, enclos) : object "X.GDAXI" not found]. being a
novice I donot understand that after applying combination to the data I cant
access
2007 Oct 05
3
help in substitute function
Hi,
I try to use a substitute function to generalise a equation.
I have this:
expression(1+2*pred+3*lat)
I need to define the equation in function of x1 and x2 variables. Also I try
to define who is x1 and x2. I try this:
X1 <- "pred"
X2 <- "lat"
Now I need substitute pred and lat in equation by x1 and x2 defined on X1 and
X2 above, I try this way:
>
2005 May 04
1
Double hurdle model in R
I am interested in utilizing this so called "double hurdle" model
in my study. We can write the model in the following way:
if (z'a + u > 0 & x'b + e > 0) y = x'b + e, else y = 0
In the model, consumption y is the (left-) censored dependent variable. e
and u are the normally distributed error terms. z'a is the participation
equation and x'b is the
2009 Jul 12
2
Heckman Selection MOdel Help in R
Hi Saurav!
On Sun, Jul 12, 2009 at 6:06 PM, Pathak,
Saurav<s.pathak08 at imperial.ac.uk> wrote:
> I am new to R, I have to do a 2 step Heckman model, my selection equation is
> below which I was successful in running but I am unable to proceed further,
>
>
>
> I have so far used the following command
>
> glm(formula = s ~ age + gender + gemedu + gemhinc + es_gdppc +
2010 Jun 22
1
Generalised Estimating Equations on approx normal outcome with limited range
Dear R users
I am analysing data from a group of twins and their siblings. The measures
that we are interested in are all correlated within families, with the
correlations being stronger between twins than between non-twin siblings.
The measures are all calculated from survey answers and by definition have
limited ranges (e.g. -5 to +5), though within the range they are
approximately normally
2008 Mar 07
3
Combine two columns
Is there a way to combine two columns within a data frame?
Example data:
id snp AL1 AL2
1500 30 A B
1510 30 A A
1520 30 A B
This is what I would like:
indv snp AL1AL2
1500 30 AB
1510 30 AA
1520 30 AB
Any help is greatly appreciated.
Alysta
2007 Oct 17
2
Need help with function that includes 2 summation
I am relatively new to R, so this may be a much simpler question than it
seems to me. I am trying to create a function that includes two
summations, and can't figure out how. I am attaching the equation as a
pdf file. This function will then be optimized over a chosen range of
values, but right now I just need help with the function. Thank you.
Zack Darnell
Duke University
--
Zack
2002 Sep 23
2
RE:u32 filters and compression
Thanks:
To Stef and Tobias Geiger for giving me the answer. I used the prio to get the order right. Don't know why I did'nt think of it myself.
Compression:
Another thing that might be useful to the list is the use of compression (Deflate etc.) to get better bandwidth across links. This requires a Linux router at both ends of the link. I got the idea from a product called Peribit see