an using them.
>
> 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 C W
> > Sent: Sunday, April 07, 2013 3:11 PM
>
There are a number of different ways to do this, so it would have been
helpful if you had set the context with a stripped down example. That
said, here are some pointers:
> x1 <- NULL
> x1 <- c(x1,3)
> x1
[1] 3
> x1 <- c(x1,4)
> x1
[1] 3 4
So you see that you can add elements to the end of a vect
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of C W
> Sent: Sunday, April 07, 2013 3:11 PM
> To: John Kane
> Cc: r-help@r-project.org; Baylee Smith
> Subject: Re: [R] While loop history
>
> May I say also ask one thing?
anada
>>
>>
>> > -Original Message-
>> > From: bayywa...@gmail.com
>> > Sent: Sun, 7 Apr 2013 14:36:33 +1200
>> > To: r-help@r-project.org
>> > Subject: [R] While loop history
>> >
>> > Hi,
>> > I am ne
ON Canada
>
>
> > -Original Message-
> > From: bayywa...@gmail.com
> > Sent: Sun, 7 Apr 2013 14:36:33 +1200
> > To: r-help@r-project.org
> > Subject: [R] While loop history
> >
> > Hi,
> > I am new at R and still trying to get the hang of things.
ust write the values into the vectors
as you proceed through the loop.
John Kane
Kingston ON Canada
> -Original Message-
> From: bayywa...@gmail.com
> Sent: Sun, 7 Apr 2013 14:36:33 +1200
> To: r-help@r-project.org
> Subject: [R] While loop history
>
> Hi,
> I a
Hi,
I am new at R and still trying to get the hang of things.
I am running a while loop and wish to save the results of each iteration.
The results are a vector x of length two and I wish to save the results of
each iteration as two vectors, one for x[1] and the other for x[2].
Thanks!
[[
Hi
>
> Thanks to Berend and the others,
>
> I've found a solution which works fine for my problem.
>
> I have not only 2 vectors, but also 4.
> Question is, if q1 and q2 is equal to w1 and w2.
> The computational time is very short, also for large data.
>
> q1 <- c(9,5,1,5)
> q2 <- c(9,2,1,5)
On Feb 2, 2012, at 6:55 AM, Chris82 wrote:
Thanks to Berend and the others,
I've found a solution which works fine for my problem.
I have not only 2 vectors, but also 4.
Question is, if q1 and q2 is equal to w1 and w2.
The computational time is very short, also for large data.
q1 <- c(9,5,1,
Hey Chris,
I would take advantage from the apply function:
apply(cbind(q1,q2),1,function(x)any((x[1]==w1)&(x[2]==w2)))
Regards
PF
On Thu, Feb 2, 2012 at 12:55 PM, Chris82 wrote:
> Thanks to Berend and the others,
>
> I've found a solution which works fine for my problem.
>
> I have not only 2
Thanks to Berend and the others,
I've found a solution which works fine for my problem.
I have not only 2 vectors, but also 4.
Question is, if q1 and q2 is equal to w1 and w2.
The computational time is very short, also for large data.
q1 <- c(9,5,1,5)
q2 <- c(9,2,1,5)
w1 <- c(9,4,4,4,5)
w1 <- c
On 01-02-2012, at 17:32, Chris82 wrote:
> Thanks to both.
>
> This is just a simple example. In real I have two vectors with different
> lengths.
> The code consists of two for loops for r and z. The main problem is the
> computational time, so I try to stop the loop if w is TRUE for the first
I guess you want something like
w=F
z <- c(0,1,2,3,4,5,6,7,8,9)
r <- 7
while(w == F) {
for ( i in 1:10 ){
w <- r == z[i]
print(w)
}
}
But this loop will run forever. The condition for "while" is checked
when i jumps from 10 to 1. At that momen
No. The while loop is only tested after the for loop has completed. Use debug
to understand this if it doesn't make sense to you.
---
Jeff NewmillerThe . . Go Live...
DCN:Basi
Thanks to both.
This is just a simple example. In real I have two vectors with different
lengths.
The code consists of two for loops for r and z. The main problem is the
computational time, so I try to stop the loop if w is TRUE for the first
time.
First I tried to use the command "stop" in comb
On 01-02-2012, at 16:55, Chris82 wrote:
> Hi R users,
>
> is there any possibilty that a while loop is working like that:
>
> z <- c(0,1,2,3,4,5,6,7,8,9)
> r <- 7
>
> while(w == T) {
>for ( i in 1:10 ){
>w <- r == z[i]
>print(w)
>}
> }
>
>
Le mercredi 01 février 2012 à 07:55 -0800, Chris82 a écrit :
> Hi R users,
>
> is there any possibilty that a while loop is working like that:
>
> z <- c(0,1,2,3,4,5,6,7,8,9)
> r <- 7
>
>while(w == T) {
> for ( i in 1:10 ){
> w <- r == z[i]
> print(w)
You are combining too many loop constructs: perhaps you just want to
use for and break.
Of course, in your case it's much faster to write which(r == z) or
which.min(r == z)
Michael
On Wed, Feb 1, 2012 at 10:55 AM, Chris82 wrote:
> Hi R users,
>
> is there any possibilty that a while loop is wor
Hi R users,
is there any possibilty that a while loop is working like that:
z <- c(0,1,2,3,4,5,6,7,8,9)
r <- 7
while(w == T) {
for ( i in 1:10 ){
w <- r == z[i]
print(w)
}
}
The loop should stop if w == TRUE
best regards
--
View this mes
Hi , i am trying to get this loop in my r program to work but it is
not giving me the results that I desire. I am trying to model an
insurance contract where there are n securities that have a fixed
likelihood of default vector(data[i,2]) and a payout
vector(data[i,1]).
i need to price the value o
Hello,
after (1) getting independent components from the (200*20) data matrix X_t by
applying
PearsonICA(data matrix, n.comp = 2, row.norm = FALSE, maxit = 200, tol = 1e-04,
border.base = c(2.6, 4), border.slope = c(0, 1), verbose = FALSE, w.init =
NULL, na.rm = FALSE, whitening.only = FALSE
Hi Marcel,
Not quite sure what you want the while loop for. Does this do what you want?
mydat <- read.table(textConnection("
Pair group param1
1 D 10
1 D 10
1 R 10
1 D 10
2 D 10
2
age-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Marcel Curlin
Sent: Monday, 30 August 2010 2:08 PM
To: r-help@r-project.org
Subject: [R] while loop until end of file
Hi Guys,
stumped by a simple problem. I would like to take a file of the form
Pair
Hi Guys,
stumped by a simple problem. I would like to take a file of the form
Pair group param1
1 D 10
1 D 10
1 R 10
1 D 10
2 D 10
2 D 10
2 D 10
2
Hello Rodrigo,
You're almost there:
you should make the variable distance before the while loop, and this should
be higher than 14 to go inside the while loop:
selectmarkers<- function(n=10){
tapply(mm$marker, mm$chr, function(m){
distances <- 15
while (max(distances) > 14) {
I am attempting to sample 10 markers from each chr, with a maximum distance
of 14, calculated by the location of the marker in each chromosome as
loc[i+1] - loc[i]. I presume the easiest way to do this is with a while
loop, so that the function keeps resampling when the max distains is greater
tha
If I understand correctly, you can try:
m <- matrix(sample(0:5, 24, rep = TRUE), nc = 3)
# A list with the index
lapply(apply(m == 0, 2, which), head, 1)
# A vector
unlist(lapply(apply(m == 0, 2, which), head, 1))
On Fri, Jul 11, 2008 at 2:06 PM, Rheannon <[EMAIL PROTECTED]> wrote:
>
> Hello,
Hello,
I am trying to loop through a matrix column and find the first value <=0 and
store that matrix location in a variable called Start.
I have tried the following:
i <- 1
j <- 1
while (Matrix[i, j] > 0)
i = (i + 1)
#loop until matrix [i, j] value <= 0
#strore that row number in a variable
Sta
zack holden:
> I need to sort through a vector (x) and identify the point at which 2
> successive values become smaller than the previous value.
x <- c(5,5,7,6,5,4,3)
a=c(diff(x, 1) < 0, FALSE) & c(diff(x, 2) < 0, FALSE, FALSE)
a # FALSE FALSE TRUE TRUE TRUE FALSE FALSE
which(a) # 3 4 5
Does this give the answer that you want?
> x <- c(5,5,7,6,5,4,3)
> result <- NULL
> for (i in 1:(length(x) - 2)){
+ if ((x[i + 1] < x[i]) && (x[i + 2] < x[i])) result <- c(result, i)
+ }
> result
[1] 3 4 5
>
On 2/29/08, zack holden <[EMAIL PROTECTED]> wrote:
>
> Dear list,
> I'm trying to w
Dear list,
I'm trying to write my first looping function in R. After many hours of
searching help files and previous posts, I'm at wits end. Please forgive my
programming ignorance...any help is greatly appreciated.
I need to sort through a vector (x) and identify the point at which 2
success
31 matches
Mail list logo