ommended, but can, and
should be used when needed.
John
From: R-help on behalf of avi.e.gr...@gmail.com
Sent: Sunday, January 15, 2023 10:53 PM
Cc: 'R help Mailing list'
Subject: Re: [R] return value of {}
Again, John, we are comparing d
d often for verse.
-Original Message-
From: R-help On Behalf Of Sorkin, John
Sent: Sunday, January 15, 2023 8:08 PM
To: Richard O'Keefe ; Valentin Petzel
Cc: R help Mailing list
Subject: Re: [R] return value of {}
Richard,
I sent my prior email too quickly:
A slight addition to y
entin Petzel
Cc: R help Mailing list
Subject: Re: [R] return value of {}
I wonder if the real confusino is not R's scope rules?
(begin .) is not Lisp, it's Scheme (a major Lisp dialect), and in Scheme,
(begin (define x ...) (define y ...) ...) declares variables x and y that
are loca
ss all needed values to the function
> myfunction(y,b)
>
> Don't use the following code that depends on a global value that is known to
> the function, but not passed as a parameter to the function:
>
> y <- 2
> myNGfunction <- function(a){
> cat("a=",a
d will be know to the function,
# but should be passed as a parameter as in example above.
b <- 100
myNGfunction(y)
John
From: R-help on behalf of Sorkin, John
Sent: Sunday, January 15, 2023 7:40 PM
To: Richard O'Keefe; Valentin Petzel
Cc:
ar Valentin,
> > > But why should {} "return" a value? It
> > could just as well evaluate all the expressions and store the resulting
> > objects in whatever environment the interpreter chooses, and then it would
> > be left to the use
Richard O'Keefe
Sent: Sunday, January 15, 2023 6:39 PM
To: Valentin Petzel
Cc: R help Mailing list
Subject: Re: [R] return value of {}
I wonder if the real confusino is not R's scope rules?
(begin .) is not Lisp, it's Scheme (a major Lisp dialect),
and in Scheme, (
o the user to manipulate any object he chooses. Don't you think
> returning the last, or any value, is redundant? We are living in the
> 21st century world, and the R-core team might,I suppose, have a definite
> reason for"returning" the last value. Any comments?
> >
&
Dear valentin,
Thanks for a comprehensive background
THanking you,
Yours sincerely,
AKSHAY M KULKARNI
From: Valentin Petzel
Sent: Friday, January 13, 2023 4:48 AM
To: akshay kulkarni
Cc: R help Mailing list
Subject: Re: [R] return
Dear Bill,
Thanks for your reply.
thanking you,
Yours sincerely,
AKSHAY M KULKARNI
From: Bill Dunlap
Sent: Friday, January 13, 2023 10:48 PM
To: Valentin Petzel
Cc: akshay kulkarni ; R help Mailing list
Subject: Re: [R] return value of
dear Heinz,
Thanks for your replyreason is as old as the Sun..!
THanking you,
Yours sincerely,
AKSHAY M KULKARNI
From: R-help on behalf of Heinz Tuechler
Sent: Friday, January 13, 2023 4:30 PM
To: r-help@r-project.org
Subject: Re: [R
M KULKARNI
From: Leonard Mada
Sent: Friday, January 13, 2023 1:44 AM
To: Akshay Kulkarni
Cc: R-help Mailing List
Subject: Re: [R] return value of {}
Dear Akshay,
The best response was given by Andrew. "{...}" is not a closure.
This is unusual for someone used to C
ld, and the R-core team might,I suppose, have a definite
> reason for"returning" the last value. Any comments?
> >
> > Thanking you,
> > Yours sincerely,
> > AKSHAY M KULKARNI
> >
> >
> > *From:* Valentin Petzel
09.01.2023 18:05:58 akshay kulkarni :
We are living in the 21st century world, and the R-core team might,I suppose,
have a definite reason ...
Maybe compatibility reasons with S and R-versions from the 20st century?
But maybe, you would have expected some reason even then.
best regards,
Hei
--
> *From:* Valentin Petzel
> *Sent:* Monday, January 9, 2023 9:18 PM
> *To:* akshay kulkarni
> *Cc:* R help Mailing list
> *Subject:* Re: [R] return value of {}
>
> Hello Akshai,
>
> I think you are confusing {...} with local({...}). This o
Dear Akshay,
The best response was given by Andrew. "{...}" is not a closure.
This is unusual for someone used to C-type languages. But I will try to
explain some of the rationale.
In the case that "{...}" was a closure, then external variables would
need to be explicitly declared before the
O'Keefe
Sent: Wednesday, January 11, 2023 8:31 AM
To: akshay kulkarni
Cc: R help Mailing list
Subject: Re: [R] return value of {}
I am more than a little puzzled by your question.
In the construct {expr1; expr2; expr3} all of the
expressions expr1, expr2, and expr3 are evaluated,
in that
I am more than a little puzzled by your question.
In the construct {expr1; expr2; expr3} all of the
expressions expr1, expr2, and expr3 are evaluated,
in that order. That's what curly braces are FOR.
When you want some expressions evaluated in a
specific order, that's why and when you use curly
br
ailing list'
Subject: RE: [R] return value of {}
Fair enough, Akshay. Wondering why a design was chosen is reasonable.
There are languages like python that allow unpacking multiple values and it is
not uncommon to return multiple things from some constructs as in this:
>>&g
t(1+2, sin(.7), cos(.7))
> vals[2:3]
[[1]]
[1] 0.6442177
[[2]]
[1] 0.7648422
You get the idea. R returns ONE thing and it ca have parts, named or not.
From: akshay kulkarni
Sent: Tuesday, January 10, 2023 9:33 AM
To: avi.e.gr...@gmail.com
Cc: 'R help Mailing list
From: R-help on behalf of avi.e.gr...@gmail.com
Sent: Tuesday, January 10, 2023 4:39 AM
Cc: 'R help Mailing list'
Subject: Re: [R] return value of {}
Akshay,
Your question seems a tad mysterious to me as you are complaining about
NOTHING.
R was designed to return sin
Hello Akshai,
I think you are confusing {...} with local({...}). This one will evaluate the
expression in a separate environment, returning the last expression.
{...} simply evaluates multiple expressions as one and returns the result of
the last line, but it still evaluates each expression.
A
"I suspect akshay is (or was? Not sure) unclear about what braces do.
They are not closures... they create an expression that wraps multiple
expressions into one expression... they are a little more like
parentheses than closures. They are not **intrinsically associated**
with creation of environme
I suspect akshay is (or was? Not sure) unclear about what braces do. They are
not closures... they create an expression that wraps multiple expressions into
one expression... they are a little more like parentheses than closures. They
are not intrinsically associated with creation of environment
Petzel
Cc: R help Mailing list
Subject: Re: [R] return value of {}
Dear Valentin,
But why should {} "return" a value? It could
just as well evaluate all the expressions and store the resulting objects in
whatever environment the interpreter chooses,
Dear Andrew,
Nice point.
THanking you,
Yours sincerely,
AKSHAY M KULKARNI
From: Andrew Simmons
Sent: Monday, January 9, 2023 10:52 PM
To: akshay kulkarni
Cc: Valentin Petzel ; R help Mailing list
Subject: Re: [R] return value of
t;
> Thanking you,
> Yours sincerely,
> AKSHAY M KULKARNI
>
>
> From: Valentin Petzel
> Sent: Monday, January 9, 2023 9:18 PM
> To: akshay kulkarni
> Cc: R help Mailing list
> Subject: Re: [R] return value of {}
>
> Hello Akshai,
>
> I thi
From: Valentin Petzel
Sent: Monday, January 9, 2023 9:18 PM
To: akshay kulkarni
Cc: R help Mailing list
Subject: Re: [R] return value of {}
Hello Akshai,
I think you are confusing {...} with local({...}). This one will evaluate the
expression in a separate environment, retu
dear Rui,
Thanks a lot
Thanking you,
Yours sincerely,
AKSHAY M KULKARNI
From: Rui Barradas
Sent: Monday, January 9, 2023 9:48 PM
To: akshay kulkarni ; R help Mailing list
Subject: Re: [R] return value of {}
�s 14:47 de 09/01/2023
Perhaps the following may be of use to you.
Consider:
> f <- function(){ x <- 3; function(y) x+y}
> x <- 5
##What does this give?
> f()
## Why?
## How about this?
>f()(10)
## Why?
## If you remove "x <- 3" from the above, what will you get when you repeat
the exercise?
-- Bert
On Mon, Jan 9,
dear Bert,
Thanks a lot...
Thanking you,
Yours sincerely,
AKSHAY M KULKARNI
From: Bert Gunter
Sent: Monday, January 9, 2023 9:59 PM
To: akshay kulkarni
Cc: R help Mailing list
Subject: Re: [R] return value of {}
Unless you do something
Unless you do something special within a function, only the value(s)
returned are available to the caller. That is the essence of
functional-type programming languages.
You need to read up on (function) environments in R . You can search on
this. ?function and its links also contain useful informa
Às 14:47 de 09/01/2023, akshay kulkarni escreveu:
Dear members,
I have the following code:
TB <- {x <- 3;y <- 5}
TB
[1] 5
It is consistent with the documentation: For {, the result of the last
expression evaluated. This has the visibility of the last evaluation.
Dear members,
I have the following code:
> TB <- {x <- 3;y <- 5}
> TB
[1] 5
It is consistent with the documentation: For {, the result of the last
expression evaluated. This has the visibility of the last evaluation.
But both x AND y are created, but the "return val
Thank you Bert, I see your point.
The problem is that I am not sure if this is a statistical issue -
i.e., there is something wrong with my procedure - or, in a manner of
speaking, a software issue: e.g. lm is not expected to return the same
estimates for different approaches because of the way in
You could get lucky here, but strictly speaking, this list is about R
programming and statistical issues are typically off topic Someone might
respond privately, though.
Cheers,
Bert
On Thu, Oct 6, 2022 at 4:24 AM Valerio Leone Sciabolazza <
sciabola...@gmail.com> wrote:
> Good morning,
> I am t
Good morning,
I am trying to use R to estimate a fixed effects model (i.e., a panel
regression model controlling for unobserved time-invariant
heterogeneities across agents) using different estimation approaches
(e.g. replicating xtreg from Stata, see e.g.
https://www.stata.com/support/faqs/statist
Hi Nevil,
As I don't have the filematrix package this is really an "any suggestion":
FM[,which(colnames(FM) %in% c("one","three"))]
Jim
On Tue, Sep 8, 2020 at 9:43 PM nevil amos wrote:
>
> Is there a way to get columns out of a filematrix using the column name
> directly in the same way that y
Is there a way to get columns out of a filematrix using the column name
directly in the same way that you can with a regular matrix?
library(filematrix)
M<-t(matrix(1:3,3,4))
colnames(M)<-c("one","two", "three")
M
#Extract column
M[,1]
M[,"one"]
M[,c(1,3)]
M[,c("one","three")]
FM<-fm.create.from.
A long time ago (before the mid-1990's?) with S or S+
ff <- function(n){ for(i in 1:n) (i+1)
op <- ff(3)
would result in 'op' being 4, since a for-loop's value
was the value of the last expression executed in the
body of the loop. The presence of a 'next' or 'break'
in the loop body would af
Ramnik,
a final mail is actually really important: this is to document in the archives,
for the benefit of those who found the thread at a later time, that the
responses indeed solved the problem.
Other than that, the single most important advice is to
- provide a minimal working example of the
(Apparently I hit "send" too early)
1. I have cc'ed this to the list, as others may well have some good
suggestions re: books.
2. The posting guide is your best resource as to what is appropriate
for the list. I defer to others re: conventions, as I have have been
accused of violating them from t
OK. I stand corrected. Thanks.
-- Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Sun, Apr 16, 2017 at 11:36 PM, David Winsemius
wrote:
> Both 'for' and
> On 17 Apr 2017, at 10:04 , Ramnik Bansal wrote:
>
> This is my output for is.function
>
>> is.function("for")
> [1] FALSE
>> is.function(for)
> Error: unexpected ')' in "is.function(for)"
>> is.function("next")
> [1] FALSE
>> is.function(next)
> Error: no loop for break/next, jumping to top l
This is my output for is.function
> is.function("for")
[1] FALSE
> is.function(for)
Error: unexpected ')' in "is.function(for)"
> is.function("next")
[1] FALSE
> is.function(next)
Error: no loop for break/next, jumping to top level
*I did not get the TRUE value. R version 3.3.3 on Mac. What am I
Both 'for' and 'next' return TRUE from is.function
is.function('for')
is.function('next')
Not at an R console at the moment but I did check this earlier today. Thinking
of it as different is definitely the way to think about it. (ISTR Bert and I
have had this exchange in the past.)
--
Best
D
David et. al.:
"this levels is the level where you realize that the `for` function is
different from most other R functions. It is really a
side-effect-fucntion. "
for(), while(), if(), next, etc. are *not* functions.
?for says: "These are the basic control-flow constructs of the R language."
> On Apr 16, 2017, at 7:26 PM, Ramnik Bansal wrote:
>
> In the code below
>
>
> *ff <- function(n){ for(i in 1:n) (i+1)}*
>
> *n<-3;ff(n)->op;print(op)*
>
> Why doesnt *print(op) * print 4 and instead prints NULL.
> Isnt the last line of code executed is *i+1 * and therefore that should be
>
In the first case you have a "for" and it is the statement after the
'for' that is the return value and it is a NULL. For example:
> print(for (i in 1:4) i+1)
NULL
In the second case, the last statement if the expression '(n+1)' which
give you the correct value:
> xx <- function(n) n+1
> print(
In the code below
*ff <- function(n){ for(i in 1:n) (i+1)}*
*n<-3;ff(n)->op;print(op)*
Why doesnt *print(op) * print 4 and instead prints NULL.
Isnt the last line of code executed is *i+1 * and therefore that should be
returned instead of NULL
instead if I say
*ff <- function(n){ (n+1) }*
The
Dear,
i am using the programming of the package "sampleSelection" for a study and
I do not understand the error of my simulation, I posted the detailed doubt
in stackoverflow! Link below:
http://stackoverflow.com/questions/41404416/return-of-the-gradient-function-when-using-optim-functions-and-co
There are many good R tutorials on the web. Some recommendations can
be found here:
https://www.rstudio.com/online-learning/#R
Please spend some time learning fundamental R constructs and
functionality before posting what appear to be very basic questions
here.
Cheers,
Bert
Bert Gunter
"The t
On 9/19/2016 10:37 PM, John wrote:
Hi,
I have the following dataframe:
temp<-data.frame(a=c(1,1,2), b=2:4, c=1:3)
row.names(temp)<-c("D", "E", "F")
temp
a b c
D 1 2 1
E 1 3 2
F 2 4 3
I would like R to tell me which rows has value "a" equal to 1. The
answer is the first row and t
What do you think?
This is covered in the Introduction to R document that comes with R.
--
Sent from my phone. Please excuse my brevity.
On September 19, 2016 8:37:30 PM PDT, John wrote:
>Hi,
>
> I have the following dataframe:
>
>> temp<-data.frame(a=c(1,1,2), b=2:4, c=1:3)
>> row.names(temp)
Hi,
I have the following dataframe:
> temp<-data.frame(a=c(1,1,2), b=2:4, c=1:3)
> row.names(temp)<-c("D", "E", "F")
> temp
a b c
D 1 2 1
E 1 3 2
F 2 4 3
I would like R to tell me which rows has value "a" equal to 1. The
answer is the first row and the second row, or row D and row E. Whi
Dear R users,
I am trying to calculate NAV of portfolio using Return.portfolio function in
PerformanceAnalytics Package. I am having difficulties with how I should
specify weight in the function.
I tried to replicate using fixed weights with rebalance_on = "months" by
specifying weights expl
You cannot do that in one step. Do it right after:
names(out) <- df$nm
Please don't post using HTML format.. it scrambles code, and since we cannot
see what you saw it doesn't help in any way.
Also note that "df" is a function in the base stats package... not a good name
to use.
-
Hello all,
I've been trying to figure out how to return a named list from foreach.
Given that the order of the returned list is guaranteed to be in the
order in which the object is passed to foreach, list members can be
named afterwards. However, I'm wondering if there's a better way to do
i
Hi,
This should be little more faster.
indx <- A==B
indx1 <- which(indx, arr.ind=TRUE)
indx[indx1[duplicated(indx1[,1]),]]<- FALSE
indx
##Speed comparison
##previous method
fun1 <- function(mat, vec) {
stopifnot(dim(mat)[1] == length(vec))
indx <- mat == vec
t(apply(indx, 1, functio
Hi Nevil,
Try
apply(A, 2, function(x) x == B)
HTH,
Jorge.-
On Fri, May 2, 2014 at 6:46 PM, nevil amos wrote:
> I wish to return " True" in a matrix for only the first match of a value
> per row where the value equals that in a vector with the same number of
> values as rosw in the matrix
>
Hi,
Try:
indx <- A==B
t(apply(indx,1,function(x) {x[duplicated(x) & !is.na(x)] <- FALSE; x}))
# [,1] [,2] [,3]
#[1,] TRUE FALSE FALSE
#[2,] FALSE NA FALSE
#[3,] NA NA NA
#[4,] TRUE NA FALSE
#[5,] FALSE TRUE FALSE
A.K.
On Friday, May 2, 2014 4:47 AM, nevil amos wrote:
I wish to return " True" in a matrix for only the first match of a value
per row where the value equals that in a vector with the same number of
values as rosw in the matrix
eg:
A<-matrix(c(2,3,2,1,1,2,NA,NA,NA,5,1,0,5,5,5),5,3)
B<-c(2,1,NA,1,5)
desired result:
[,1] [,2] [,3]
[1,] TRUE FA
Hi,
Try:
indx <-
which(round(rowSums(abs(sweep(edm[,grep("perturb",colnames(edm))],1,edm[,"base"],`-`))),4)
>=0.0025) ##if there is threshold value
indx
#[1] 22 23 24 25 28 31 33
edm[indx,]
A.K.
On Monday, February 17, 2014 11:49 AM, "Morway, Eric" wrote:
Using the small data set below (w
Using the small data set below (which is a small snippet of a much larger
dataset), I'd like to get the row(s) that corresponds to the largest,
cumulative, absolute difference between the value in "base" and each of the
remaining columns. For example, in row 2, the three absolute differences of
ab
Thanks
this does it:
script.name <- basename(sys.frame(1)$ofile)
On Tue, Aug 27, 2013 at 4:07 PM, Henrik Bengtsson wrote:
> See findSourceTraceback() of R.utils. /Henrik
>
> On Mon, Aug 26, 2013 at 10:58 PM, peter dalgaard wrote:
> >
> > On Aug 27, 2013, at 07:12 , nevil amos wrote:
> >
> >
See findSourceTraceback() of R.utils. /Henrik
On Mon, Aug 26, 2013 at 10:58 PM, peter dalgaard wrote:
>
> On Aug 27, 2013, at 07:12 , nevil amos wrote:
>
>> Is there a fuction that will allow me to retrun the filename for a script
>> from within that script.
>
> Not a standard one, but you shou
On Aug 27, 2013, at 07:12 , nevil amos wrote:
> Is there a fuction that will allow me to retrun the filename for a script
> from within that script.
Not a standard one, but you should be able to get at it via a bit of breaking
and entering: sys.status() and friends (sys.calls, sys.frames) give
Is there a fuction that will allow me to retrun the filename for a script
from within that script.
fir instance
If I have a script "myscript.r":
FileName<-unknown.fucntion()
print(FileName)
and run it
source("myscript.r")
will return
"myscript.r"
Thanks
Nevil Amos
[[alternative
On Tue, 25 Jun 2013, nevil amos writes:
> I want to print a vector of strings to the console formatted as if it were
> input
>
> X<-c("a","b","c")
>> X
> [1] "a" "b" "c"
>
> what I would like to get is
>
> the.function(X)
>>"a","b","c"
>
> what is the function?
>
the.function <- function(x)
Hello,
Maybe ?cat
cat(X, "\n")
(But it doesn't put the vector elements between quotes.)
Hope this helps,
Rui Barradas
Em 25-06-2013 08:14, nevil amos escreveu:
I want to print a vector of strings to the console formatted as if it were
input
X<-c("a","b","c")
X
[1] "a" "b" "c"
what I wou
I want to print a vector of strings to the console formatted as if it were
input
X<-c("a","b","c")
> X
[1] "a" "b" "c"
what I would like to get is
the.function(X)
>"a","b","c"
what is the function?
cheers
Nevil amos
[[alternative HTML version deleted]]
__
Hi,
Try this:
set.seed(24)
b1<- sample(1:40,20,replace=TRUE)
set.seed(28)
a1<- sample(30:50,20,replace=TRUE)
t_test_apparie <- function(x,y)
{
t.test(x,y,paired=TRUE,alternative = "greater")$p.value
}
t_test_apparie(a1,b1)
#[1] 6.571404e-08
A.K.
>Hi,
>
>I have written this function :
>
>t
At 20:51 10/05/2013, Tomos_D wrote:
That's great thanks
There is a closed form expression for the nth Fibonacci number.
See Wikipedia for details.
--- Original Message ---
From: "arun kirshna [via R]"
Sent: May 10, 2013 3:34 PM
To: "Tomos_D"
Subject: Re: Return a vector in Fibonacci seque
That's great thanks
--- Original Message ---
From: "arun kirshna [via R]"
Sent: May 10, 2013 3:34 PM
To: "Tomos_D"
Subject: Re: Return a vector in Fibonacci sequence function
Hi,
May be this helps:
fibv =function(n)
{
f1 = f2 = 1
f3<- c(f1,f2)
for(i in seq(2, n-1)) {
if(n == 0 || n == 1) ret
Hi,
May be this helps:
fibv =function(n)
{
f1 = f2 = 1
f3<- c(f1,f2)
for(i in seq(2, n-1)) {
if(n == 0 || n == 1) return(n)
if(n == 2) return(1)
f = f1 + f2
f2 = f1
f1 = f
f3<- c(f3,f)
}
f3
}
fibv(0)
#[1] 0
fibv(1)
#[1] 1
fibv(3)
#[1] 1 1 2
fibv(10)
# [1] 1 1 2 3 5 8 13 21 34 55
A.K.
>I
10 #this means 4th and 10 element of res2 matches with first
element of v1[1]
res2[4]
#[1] "age_1_height_1"
#The
goal is to get the corresponding element of v2 that matches with v1.
Since the order of res2 and v2 are the same, we can index it to get the
matching v2 #elements
grep(v1[8],res1)]
#[1] "age_height_2_2"
A.K.
- Original Message -
From: frespider
To: r-help@r-project.org
Cc:
Sent: Thursday, November 1, 2012 10:20 AM
Subject: Re: [R] Return Vector Component
Hi A.K.
Thank you so much for replying this could work but the problem you rec
Hi A.K.
Thank you so much for replying this could work but the problem you recreate the
newv1, to match v2 but I don't want to do that. I just want to check if v2 has
that component from v1
THanks
Date: Thu, 1 Nov 2012 06:32:03 -0700
From: ml-node+s789695n4648123...@n4.nabble.com
To: frespi
-paste0(v3[grep("age",v3)],v5[grep("height",v5)],v4[!v4%in%v4[grep("height",v4)]],"_",v6[!v6%in%v6[grep("age",v6)]])
newv1[newv1%in%v2]
#[1] "age_height_1_1" "age_height_2_2" "age_height_3_3" "age_height_4
Hi,
I am new R user and I am still learn this fabulous software. I am stuck on
this part. I need to check 2 character vectors
v1 <-
c("age_1","age_2","age_3","age_4","age_5","age_6","height_1","height_2","height_3","height_4","height_5","height_6","height_7","height_8")
and
v2 <-
c("sex_1","s
Hi Michelle,
Please cc the list on your replies so others (far more knowledgeable
than I) can answer.
On Mon, Sep 24, 2012 at 12:12 AM, Michelle Cipullo wrote:
>>> I am doing some extreme value analysis on model output (WRF) which have the
>>> following dimensions:
>>>
>>> speed(time,lat,lon)
>>
Hi Michelle:
On Sep 23, 2012, at 3:38 PM, MichelleNCSU wrote:
> On Fri, Sep 21, 2012 at 3:45 PM, David Winsemius [via R]
> wrote:
>>
>> On Sep 21, 2012, at 7:17 AM, MichelleNCSU wrote:
>>
>>> Hello,
>>>
>>> First of all, let me apologize that my statistics background is modest at
>>> best.
>
On Fri, Sep 21, 2012 at 3:45 PM, David Winsemius [via R]
wrote:
>
> On Sep 21, 2012, at 7:17 AM, MichelleNCSU wrote:
>
>> Hello,
>>
>> First of all, let me apologize that my statistics background is modest at
>> best.
>>
>> I am doing some extreme value analysis on model output (WRF) which have
>>
On Sep 21, 2012, at 7:17 AM, MichelleNCSU wrote:
> Hello,
>
> First of all, let me apologize that my statistics background is modest at
> best.
>
> I am doing some extreme value analysis on model output (WRF) which have the
> following dimensions:
>
> speed(time,lat,lon)
How is this object
On Fri, Sep 21, 2012 at 3:17 PM, MichelleNCSU wrote:
> Hello,
>
> First of all, let me apologize that my statistics background is modest at
> best.
>
> I am doing some extreme value analysis on model output (WRF) which have the
> following dimensions:
>
> speed(time,lat,lon)
>
> I am trying to fit
Hello,
First of all, let me apologize that my statistics background is modest at
best.
I am doing some extreme value analysis on model output (WRF) which have the
following dimensions:
speed(time,lat,lon)
I am trying to fit the GPD (gpd.fit) to each point (time,lat,lon) to get a
return level
eld
To: r-help@r-project.org
Cc:
Sent: Tuesday, August 28, 2012 3:58 PM
Subject: [R] return first index for each unique value in a vector
I would like to efficiently find the first index of each unique value in a
very large vector.
For example, if I have a vector
A<-c(9,2,9,5)
I would l
r-help@r-project.org
Cc:
Sent: Tuesday, August 28, 2012 3:58 PM
Subject: [R] return first index for each unique value in a vector
I would like to efficiently find the first index of each unique value in a
very large vector.
For example, if I have a vector
A<-c(9,2,9,5)
I would like to return
apsed
0.090.020.11
> identical(z1, z2)
[1] TRUE
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of Bronwyn Rayfield
> Sent: Tuesday, August
On 8/28/2012 5:52 PM, Bert Gunter wrote:
Sheesh!
I would have thought that someone would have noticed that on the
?unique Help page there is a link to ?duplicated, which gives a
_logical_ vector of the duplicates. From this, everything else can be
quickly derived -- and packaged in a simple Matl
Sheesh!
I would have thought that someone would have noticed that on the
?unique Help page there is a link to ?duplicated, which gives a
_logical_ vector of the duplicates. From this, everything else can be
quickly derived -- and packaged in a simple Matlab like function, if
you insist on that. e.
Hi,
Try this:
order(A)[!duplicated(sort(A))]
--
Noia Raindrops
noia.raindr...@gmail.com
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and
On Tue, Aug 28, 2012 at 2:58 PM, Bronwyn Rayfield
wrote:
> I would like to efficiently find the first index of each unique value in a
> very large vector.
>
> For example, if I have a vector
>
> A<-c(9,2,9,5)
>
> I would like to return not only the unique values (2,5,9) but also their
> first indi
I would like to efficiently find the first index of each unique value in a
very large vector.
For example, if I have a vector
A<-c(9,2,9,5)
I would like to return not only the unique values (2,5,9) but also their
first indices (2,4,1).
I tried using a for loop with which(A==unique(A)[i])[1] to
Hello,
return( list(y, x, z, dy, dx) )
# or
return( list(y=y, x=x, z=z, dy=dy, dx=dx) )
That's ONE variable returned, a list. In the first case you access the
list members by number,
ret <- dgp.par(...)
ret[[ 1 ]] # 'y' value
In the second case, by number or name.
ret[[ 4 ]]
ret[[ "dy" ]]
Hi!
I have some questions about R function. I try to write a function for
multi-returns. The function code is as attachment.
dgp.par<-function(ai, bi, t, n)
{
t0<-t+20
y0<-matrix(0, nr=t0, nc=n)
y0[1,]<-ai/(1-bi)
for(tt in 2:t0)
{ y0[tt,]<-ai+bi*y0[tt-1,]+rnorm(n, 0, 1) }
y<-y0[21:t0,]
x<-y0[2
if(!require("TTR")){install.packages("TTR"); library(TTR)}
? ROC
Michael
On Wed, Jul 4, 2012 at 11:20 PM, Akhil dua wrote:
> Hello Every one
> I have data on Stock prices and I want to calculate the return on all the
> stocks
> and then replace all the stock prices with the returns
>
> can any o
Stock2 Stock3
1 2000-01-01 NA NA NA
2 2000-01-02 1.609438 1.098612 0.8472979
3 2000-01-03 -1.609438 -1.098612 -0.8472979
4 2000-01-04 1.609438 1.098612 0.8472979
A.K.
- Original Message -
From: Akhil dua
To: r-help@r-project.org
Cc:
Sent: Thursday, July 5,
Hello Every one
I have data on Stock prices and I want to calculate the return on all the
stocks
and then replace all the stock prices with the returns
can any one tell me how to do
My data is in the format given below
Date Stock1 Stock2 Stock3
01/01/20001 2
It depends on which return you want. See
the "R computation" section of "A tale of
two returns".
http://www.portfolioprobe.com/2010/10/04/a-tale-of-two-returns/
Pat
On 05/07/2012 05:58, Akhil dua wrote:
Hello Every one
I have data on Stock prices and I want to calculate the return on all the
1 - 100 of 199 matches
Mail list logo