Must be the heat or something but I can't get my brain into gear and
figure out how to get something like
if (1) { c - 1; foo - function () print(c); }
c - 2
foo()
to print 1, not 2. (The real life example is a little more complex, but
you get the idea. I don't want the variable c in the
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Allan Engelhardt
Sent: Thursday, July 02, 2009 9:47 AM
To: r-help@r-project.org
Subject: [R] How to use current value of variable in function
definition?
Must be the heat or something but I can't get
() a
Allan
On 02/07/09 18:28, William Dunlap wrote:
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Allan Engelhardt
Sent: Thursday, July 02, 2009 9:47 AM
To: r-help@r-project.org
Subject: [R] How to use current value of variable in function
definition
Hi.
I've stared at your code for a number of minutes and can't understand
what you're trying to achieve here. It looks as if you're fighting
scope - it may be worth refactoring your approach to simplify matters.
Otherwise, it sounds like a recipe for obfuscation! What are you
trying to do really?
On 02/07/09 21:02, Mark Wardle wrote:
Hi.
I've stared at your code for a number of minutes and can't understand
what you're trying to achieve here. It looks as if you're fighting
scope - it may be worth refactoring your approach to simplify matters.
Otherwise, it sounds like a recipe for
Mark Wardle wrote:
Hi.
I've stared at your code for a number of minutes and can't understand
what you're trying to achieve here. It looks as if you're fighting
scope - it may be worth refactoring your approach to simplify matters.
Otherwise, it sounds like a recipe for obfuscation! What are you
From: Allan Engelhardt [mailto:all...@cybaea.com]
Sent: Thursday, July 02, 2009 11:12 AM
To: William Dunlap
Cc: r-help@r-project.org
Subject: Re: [R] How to use current value of variable in
function definition
...@r-project.org] On
Behalf Of William Dunlap
Sent: Thursday, July 02, 2009 2:44 PM
To: Allan Engelhardt
Cc: r-help@r-project.org
Subject: Re: [R] How to use current value of variable in function definition?
From: Allan Engelhardt [mailto:all
The proto package generalizes this to an OO approach based
on the prototype or object-based model of OO.
This corresponds to the previous code:
library(proto)
p - proto(c = 1, foo = function(.) print(.$c))
p$foo() # 1
# but now we can also create q which overrides c
# while inheriting foo from
Hi, I'm using R to do a time series analysis. In the model, I use the lags
of some variables. such the lags of the variables have different length, I
just can't use them directly in the lm function. Intuitively, I feel that
subset might be useful, but I do not know how to use it. Anyone can give
Like this?
x-1:100
y-runif(100)
df-data.frame(cbind(x,y))
mycoef.list-NULL
for (i in 10:65)
{
mycoef-coef(lm(y~x, data=subset(df, x %in% 1:i)))[2]
mycoef.list -c(mycoef.list, mycoef)
}
hist(mycoef.list)
regards
milton
brazil=toronto
On Mon, Jun 29, 2009 at 2:50 PM, Hongwei Dong
The dyn package (and also the dynlm package) can be used for
this.
library(dyn)
y - ts(1:10)
dyn$lm(y ~ lag(y, -1))
On Mon, Jun 29, 2009 at 2:50 PM, Hongwei Dongpdxd...@gmail.com wrote:
Hi, I'm using R to do a time series analysis. In the model, I use the lags
of some variables. such the lags
Dear Ruser's
I want to substitute each NA by the group mean of which the NA is
belonging to. For example, substitute the first record of traits NA by the
mean of BSPy01-10 in the dummy dataframe.
I have ever tried to solve this problem by using doBy package. But, I
failed. I ask for the advice
Here are four ways:
# using lapplyBy - DF is already sorted by group
library(doBy)
f - function(x) {
x$traits[is.na(x$traits)] - mean(x$traits, na.rm = TRUE)
x
}
do.call(rbind, lapplyBy(~ group, DF, f))
# using by - same f as before
do.call(rbind, by(DF, DF$group, f))
# using
Try this:
library(zoo)
z - zoo(cbind(a = 1:4, b = 5:8), Sys.time() + 0:3 * 3600)
z0 - zoo(coredata(z), format(time(z), %m-%d-%y %H:%M:%S))
write.zoo(z0, sep = ,)
Index,a,b
05-01-09 17:59:31,1,5
05-01-09 18:59:31,2,6
05-01-09 19:59:31,3,7
05-01-09 20:59:31,4,8
On Fri, May 1, 2009 at 5:11
Use write.csv to output a zoo object, and found the first column in excel
like: (08-10-16 13:12:00)
How to make it look like : 10/16/2008 13:12:00 ?
write.csv(x=zoo.object)
Thanks!
[[alternative HTML version deleted]]
__
Hi,
I'm using the cubic splines from termstrc package. I invoked the
splines_estim function with a group of 43 bonds. It computes 6 knot points
and returns values for alpha1 to alpha7. My question is how to use these
alpha1 to alpha7 in the equation of yield? For example, if I'm trying to
find
Hi,
I'm trying to use the package termstrc. However I cannot figure out
how to invoke helper functions like create_cashflows_matrix
create_maturities_matrix. Even when I try to invoke those with the
data supplied with the package (say, corpbonds), it throws error
saying Error in as.vector(x,
Got code?
On Mar 20, 2009, at 8:15 AM, Chirantan Kundu wrote:
I'm trying to use the package termstrc. However I cannot figure out
how to invoke helper functions like create_cashflows_matrix
create_maturities_matrix. Even when I try to invoke those with the
data supplied with the package (say,
Here it goes -
library(termstrc)
ISIN - vector()
ISIN[1]-IN0020080019
ISIN[2]-IN0020020163
MATURITYDATE-as.Date(c(20081231,20101231),%Y%m%d)
STARTDATE-as.Date(c(20010101,20020101),format=%Y%m%d)
COUPONRATE-c(8.24,7.95)
PRICE-(50,100)
ACCRUED-c(5,2)
TODAY-c(Sys.Date(),Sys.Date())
mybonds -
On Mar 20, 2009, at 10:15 AM, Chirantan Kundu wrote:
Here it goes -
library(termstrc)
ISIN - vector()
ISIN[1]-IN0020080019
ISIN[2]-IN0020020163
MATURITYDATE-as.Date(c(20081231,20101231),%Y%m%d)
STARTDATE-as.Date(c(20010101,20020101),format=%Y%m%d)
COUPONRATE-c(8.24,7.95)
PRICE-(50,100)
Besides needing a grouped structure and not calling that function with
a group name, your sub-structure does not seem complete when compared
with the AAA group within the example dataset;
str(allbonds) # your structure
List of 1
$ mybonds:List of 7
..$ ISIN: chr [1:2]
Thanks for the help. RATING NAME are not required for this call as
par documentation. About the CASHFLOWS I'm not sure as I'm going to
call create_cashflows_matrix which is supposed to return me the
cashflow matrix. Do I still need to have the CASHFLOWSlist in the
structure?
On Fri, Mar 20, 2009
How could I (or anyone for that matter) possibly answer that question?
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
On Mar 20, 2009, at 1:07 PM, Chirantan Kundu wrote:
Thanks for the help. RATING NAME are not required for this call as
par documentation. About the CASHFLOWS
Actually I was looking for someone who has some experience in using
the package. Anyway, thanks for your input.
On Fri, Mar 20, 2009 at 10:51 PM, David Winsemius
dwinsem...@comcast.net wrote:
How could I (or anyone for that matter) possibly answer that question?
David Winsemius, MD
Heritage
There is probably a greater density of potential users on the SIG-
Finance mailing list.
I still think you attribute special powers to that function that the
authors never build into it. It does not predict the future. It
doesn't even simulate the future. It just reformats into a matrix the
I am trying to plot two things on one graph, with a y-axis at the left for
one variable, and a y-axis at the right, for the other variable. I thought
I could do as follows
par(mar=rep(4.5, 4))
plot(0:10, 10:20)
par(new=TRUE)
plot(0:10, 100:110, axes=FALSE)
axis(4)
but this writes both y-axis
Dan Kelley wrote:
I am trying to plot two things on one graph, with a y-axis at the left for
one variable, and a y-axis at the right, for the other variable. I thought
I could do as follows
par(mar=rep(4.5, 4))
plot(0:10, 10:20)
par(new=TRUE)
plot(0:10, 100:110, axes=FALSE)
axis(4)
but this
Duncan Murdoch-2 wrote:
...Are you really sure you want a graph with two different scales on it?
Thanks, Duncan. I'll use mtext. It is common for people in my research area
to put several axes on plots. The top two panels from
library(oce)
data(ctd)
plot(ctd)
shows this. Actually,
Hi all,
I want to draw n plots whose titles are Main effect of X_i, i= 1,
2, ..., n, respectively.
More specifically, I use:
par(mfrow = c(n/2, 2))
for ( i in 1:n)
{
plot(1:J, y[i, 1: J], main = 'Main effect of X_i')
}
This gives me a series of plots with the common title with a
see ?paste
main = paste (Main effect of , variable)
par(mfrow = c(n/2, 2))
for ( i in 1:n)
{
plot(1:J, y[i, 1: J], main = 'Main effect of X_i')
}
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do
i want to know how to use the Hosmer–Lemeshow test in R. Can anyone show me
the program to me and tell me how to use it?
--
View this message in context:
http://www.nabble.com/HOW-to-use-the-Hosmer%E2%80%93Lemeshow-test%E2%80%8F-in-R-tp19675283p19675283.html
Sent from the R help mailing list
leo_wa wrote:
i want to know how to use the Hosmer–Lemeshow test in R. Can anyone show me
the program to me and tell me how to use it?
Please read the archives as this question has been posed many times in
the past few years. My answer is always the same: read the following
article and see
Hi,
I am working on calculating X^2 for some matrix (most of them have either two
rows or 2 columns) by using chisq.test in R. However when there are 0s in the
matrix, chisq.test does not work. For example:
elements - matrix( c( 0, 0, 9, 5, 71, 168), nr = 2 )
elements
Hi,
How can I use a substring match as a condition in a subset command?
Sth like this:
subset(input, field1==blah1 field2==blah2) # but now with substring
match in field2
subset(input, field1==blah1 field3 *substringmatch* blah3)
I've tried with gsub, but it won't work:
subset(input,
] how to use substring match as condition?
Hi,
How can I use a substring match as a condition in a subset command?
Sth like this:
subset(input, field1==blah1 field2==blah2) # but now with
substring match in field2
subset(input, field1==blah1 field3 *substringmatch* blah3)
I've tried with gsub
On Thu, 29 May 2008, Albert Vilella wrote:
Hi,
How can I use a substring match as a condition in a subset command?
Perhaps
subset(input, field1==blah1 regexpr(blah2,field3) != -1 )
??
Study in
example(gsub)
the regexpr example
and in
?gsub
the 'Value'
The weights given should correspond to the ordering of levels(y) where y
contains the class labels. If in doubt, you can also give the classwt
as a named vector (e.g., classwt=c(B=3, A=2, C=1)).
Search in the R-help archive to see other options and why you probably
shouldn't use classwt.
Andy
Hi,
I am trying to model a dataset with the response variable Y, which has
6 levels { Great, Greater, Greatest, Weak, Weaker, Weakest}, and
predictor variables X, with continuous and factor variables using
random forests in R. The variable Y acts like an ordinal variable, but
I recoded it as
Hi ,
I am using the deal package (for learning and comparing the bayesian
network).
I am getting the negative score for the heuristics search , i am not able to
interpret the result .
more negative(smaller) is better or larger value is better.Please Help me
out .I will be thankful to you.
Hi,
Please help me out with this.Im a new user of R.
Thanks
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of kakul modani
Sent: Saturday, April 26, 2008 10:40 AM
To: r-help@r-project.org
Subject: [R] How to use the optim function if the length of the
objectivefunction is greater than 1?
Hi,
Please help me out with this.Im a new user of R.
Thanks
Dear netters, suppose I have a matrix X [1,] 'c1' 'r6' '150'[2,] 'c1' 'r4'
'70'[3,] 'c1' 'r2' '20'[4,] 'c1' 'r5' '90'[5,] 'c2' 'r2' '20'[6,] 'c3' 'r1'
'10'I want to apply some funciton to groups of rows by the first column.If the
function is just to calculate the average X[,3], it will
Does something like this work for you? It is using 'lapply' with the
indices of the rows:
x - matrix(c( 'c1' , 'r6', '150', 'c1' , 'r4' ,'70' ,'c1' , 'r2' ,'20',
+ 'c1' , 'r5' ,'90', 'c2' ,'r2' ,'20', 'c3' , 'r1' ,'10'),
byrow=TRUE, ncol=3)
# use lapply
result - lapply(split(seq(nrow(x)),
I'm having a little trouble with the glm.predict function. I read the other
answers related to this question (the lm.predict question), but i'm still
receiving the same warnings, then i thought i didnt got it right.
Warning:
'newdata' had 87 rows but variable(s) found have 263 rows
Commands:
I an R-beginner.
I would like to use/call some functions/objects of R from
microsoft .NET environment. I was wondering whether or not
it is possible. If yes, could you please give me some suggestions
on how to approach it (any documentation on this)? Thanks!
-James
[[alternative
Delightfully straightforward! Thanks.
On Feb 16, 2008, at 5:15 PM, Duncan Murdoch wrote:
On 16/02/2008 4:51 PM, Michael Kubovy wrote:
Dear R-helpers,
label2 - expression(paste(italic(attraction function:), 'slope'))
Error: unexpected 'function' in label2 -
On 16/02/2008 4:51 PM, Michael Kubovy wrote:
Dear R-helpers,
label2 - expression(paste(italic(attraction function:), 'slope'))
Error: unexpected 'function' in label2 -
expression(paste(italic(attraction function
How do I tell R that in this case I don't want 'function' to be
Dear R-help,
In nlme package, anova () can be used to test the difference between
two coefficients as shown on page 225
of Mixed Effects Models in S and S-Plus:
anova(fm2BW.lme, L = c(Time:Diet2 = 1, Time:Diet3 = -1))
Now my question is instead of test the difference between two
coefficients,
Hi, List
I am trying to use variables named A1, A2, ..., A100 to store some values,
each variable could store some values with different length, how can I
achieve this?
Thanks,
Jack
[[alternative HTML version deleted]]
__
Nasser Abbasi wrote:
Duncan Murdoch [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Why did you change the parameters? If you used the same ones as above,
you get
sghyper(a=-1, k=-1, N=5)
$title
[1] Generalized Hypergeometric
$Mean
[1] 0.2
I think I should have posted this question here as well. I am posting my
question here since it is R related. Please see below. I originally posted
this to sci.stat.math
Nasser Abbasi [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I think R documentation is a bit hard for me to
On 06/01/2008 9:36 AM, Nasser Abbasi wrote:
I think I should have posted this question here as well. I am posting my
question here since it is R related. Please see below. I originally posted
this to sci.stat.math
Nasser Abbasi [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi,
I would like to use R to estimate the following model:
X(t) = a + b1*X(t-1) + b2*X(t-2) + c1*Y(t) + c2*Y(t-1) + c3*Y(t-2)
Is there any R function that performs this type of estimation? I know
that if I only have one time series (i.e. lagged value of X) on the
right hand side then there are
Hi,
I would like to use R to estimate the following model:
X(t) = a + b1*X(t-1) + b2*X(t-2) + c1*Y(t) + c2*Y(t-1) + c3*Y(t-2)
Is there any R function that performs this type of estimation? I know
that if I only have one time series (i.e. lagged value of X) on the
right hand side then there are
If you don't need a complex error structure then the dyn package
(and also the dynlm package) can do it. Using R's builtin
EuStockMarkets time series:
library(dyn)
z - as.zoo(EuStockMarkets)
mod1 - dyn$lm(DAX ~ lag(DAX, -(1:2)) + lag(FTSE, -(0:2)), z)
mod1
# compare to model without FTSE
mod2 -
Hi All,
I am now using R version 2.5.1 under Linux (Red Hat), and have
some problems to use some graphical devices (e.g., png, jpeg, bmp
and so on). Can you tell/teach me how to solve the problem(s)? See
below for details.
(1) I make sure that package:grDevices is on the list using
I'd like to fit a linear model on a subset of a data frame with given weights.
I am curious how the lm() works when both subset and weights argument
is specified.
Let me give an example: filter is a boolean vector of length the same
as one column of df, my dataframe. What I want is the linear
Dear R-Users,
I have a large number of data(54000) and the field of data is 50 to 2.0e9.
I want to use normalmixEM (package:mixtools) to fit them in finite mixture
narmal distributions,but get some mistakes.I don't know which steps make the
error.
I have used the following
)? For what command is this an
option?
Thanks.
--Chris Ryan
Original message
Date: Sat, 6 Oct 2007 22:38:04 -0400 (EDT)
From: [EMAIL PROTECTED]
Subject: [R] how to use \Sexpr{} with sweave
To: [EMAIL PROTECTED]
I'm trying to learn Sweave. So far things are going well with the chunks
Hi,
this works for me (R 2.5.1, Linux):
echo=false=
data(airquality)
library(ctest)
kruskal.test(Ozone ~ Month, data = airquality)
@
Wir haben hier also \Sexpr{nrow(airquality)} Datenzeilen in airquality.
This works
\Sexpr{2+6}
I think the error is in your latex setup, not in R or Sweave.
[EMAIL PROTECTED] wrote:
I'm trying to learn Sweave. So far things are going well with the chunks of
code identified by =
But I'm having trouble with the in-line text use of \Sexpr.
Here is a short example .Rnw file:
\documentclass[12pt]{article}
\usepackage[margin=1.25in]{geometry}
Duncan--
The .tex file that you describe as output of Sweave(test.Rnw) is what I had
expected. But I get this .tex file when I run Sweave:
\documentclass[12pt]{article}
\usepackage[margin=1.25in]{geometry}
\usepackage{graphicx}
\usepackage{Sweave}
\begin{document}
\begin{Schunk}
I think some inadvertent cutting and pasting may have made my last e-mail
difficult to interpret. Here is the .tex file I get as output of Sweaving my
.Rnw file. Note that \Sexpr{2+6} appears where you get (and I want) simply
8.
\documentclass[12pt]{article}
501 - 564 of 564 matches
Mail list logo