First, you should define your function as :
test - function(cand2,phi,lambda,
whatever-arguments-you-want-to-use-further){... insert code here ...}
All variables you use inside a function only exist within that
function. Your parameters/arguments is the interface between the
function and the
Weston
REvolution Computing
From: dunno87 benparker1...@hotmail.com
Date: Wed, Oct 7, 2009 at 5:56 PM
Subject: [R] foreach loop - rejection method
To: r-help@r-project.org
Hi Everybody,
Thanks in advance for your help.
This is my first time using the foreach statement and I cant get
Hi Everybody,
Thanks in advance for your help.
This is my first time using the foreach statement and I cant get it to work
properly so here is what i have
test-function(){
repeat {
cand2[l-1]-rinvgamma(1,phi,lambda[l-1])
q2-dinvgamma(cand2[l-1],phi,lambda[l-1])
Hello everyone,
Can somebody give a hint on how to go about speeding the following loop:
system.time(
for(i in 1:nrow(dat)){
if(dat$ycon[i]==0 || dat$ytrt[i]==0)
dat$ycon[i]-dat$ycon[i]+0.5
dat$ytrt[i]-dat$ytrt[i]+0.5
dat$cony[i]-dat$cony[i]+0.5
dat$trty[i]-dat$trty[i]+0.5
}
On Sep 29, 2009, at 5:53 PM, Antonio Paredes wrote:
Hello everyone,
Can somebody give a hint on how to go about speeding the following
loop:
You could try a loop-less approach:
system.time(
targets - dat$ycon[i]==0 | dat$ytrt[i]==0
dat$ycon[targets]-dat$ycon[targets]+0.5
On Tue, 29 Sep 2009, Antonio Paredes wrote:
Can somebody give a hint on how to speed-up the following loop:
for(j in 0:KM1)
{
k=j*60
for(i in 1:60)
{
dat$yvac[k+i]= rbinom(1,dat$nvac[k+i],dat$p.trt[j+i])
}
}
K1=999
How about:
rbinom((KM1 + 1)*60, dat$nvac,
Can somebody give a hint on how to speed-up the following loop:
for(j in 0:KM1)
{
k=j*60
for(i in 1:60)
{
dat$yvac[k+i]= rbinom(1,dat$nvac[k+i],dat$p.trt[j+i])
}
}
K1=999
--
-Tony
[[alternative HTML version deleted]]
__
Hi,
My english isn't briliant and my problem is very dificult to descripe but I
try ;)
My first question is: May I write loop for like this or similar - for (i
in sth : sth[length(sth)], k in sth else : length(sth else) ) - I'd like
to have two independent conditions in the same loop for.
My
On Aug 23, 2009, at 4:34 PM, Grzes wrote:
Hi,
My english isn't briliant and my problem is very dificult to
descripe but I
try ;)
My first question is: May I write loop for like this or similar -
for (i
in sth : sth[length(sth)], k in sth else : length(sth else) ) -
I'd like
to have
I am trying to get the function Models to work each time there is an
instance of k. This code will stop after the first model is complete. I need
it to come back and pass the next value of c into the Initial.State
function. any ideas?
col-c(23:28)
#Setup
for(k in col){
What do you mean by stop? Is there an error message? What are you
getting as output? I don't see you saving or printing the output from
Models (whatever that is). PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained,
von waltzmiester
Gesendet: Wednesday, August 05, 2009 11:38 AM
An: r-help@r-project.org
Betreff: [R] for loop
I am trying to get the function Models to work each time there is an
instance of k. This code will stop after the first model is complete. I need
it to come back and pass the next value
Jim
Settle down, just because you can't understand my post doesn't mean I didn't
follow the guidlines.
1)The code is commented.
2)The problem in the code is succinct and therefore minimal even though it
cannot be self contained, the user-defined function itself is.
3) In order for you to be
The Initial.State function is the setup for Models. So Models will apply the
function to k columns in Initial.State. It will only work for the first
element in vector col however, and will not loop the function through all
elements in vector col
-C
waltzmiester wrote:
I am trying to get
-boun...@r-project.org] Im
Auftrag von waltzmiester
Gesendet: Wednesday, August 05, 2009 1:22 PM
An: r-help@r-project.org
Betreff: Re: [R] for loop
Jim
Settle down, just because you can't understand my post doesn't mean I didn't
follow the guidlines.
1)The code is commented.
2)The problem
-project.org] Im
Auftrag von waltzmiester
Gesendet: Wednesday, August 05, 2009 1:35 PM
An: r-help@r-project.org
Betreff: Re: [R] for loop
The Initial.State function is the setup for Models. So Models will apply the
function to k columns in Initial.State. It will only work for the first
element
On Aug 5, 2009, at 1:22 PM, waltzmiester wrote:
Jim
Settle down, just because you can't understand my post doesn't mean
I didn't
follow the guidlines.
1)The code is commented.
2)The problem in the code is succinct and therefore minimal even
though it
cannot be self contained, the
Um I still followed the guidelines...
David Winsemius wrote:
On Aug 5, 2009, at 1:22 PM, waltzmiester wrote:
Jim
Settle down, just because you can't understand my post doesn't mean
I didn't
follow the guidlines.
1)The code is commented.
2)The problem in the code is succinct
You followed only the ones you thought were important, but failed...
a) to reduce the problem to a reproducible form (and gave no evidence
of even trying to do so.) and failed ...
b) to read the helpful reply you got from Jim, which I suspect
contained the answer, and now ...
c) persist in
Hi,
On Aug 5, 2009, at 2:36 PM, waltzmiester wrote:
Um I still followed the guidelines...
Focus on trying to ask a better question rather than going down this
route ...
Honestly, your original question is rather vague and leaves us to
guess (i) what you're trying to do, and (ii) how to
Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
Auftrag von waltzmiester
Gesendet: Wednesday, August 05, 2009 2:37 PM
An: r-help@r-project.org
Betreff: Re: [R] for loop
Um I still followed the guidelines...
David Winsemius wrote:
On Aug 5, 2009, at 1
Hey guys,
How do I iterate such that I add 100 to the counter every time?
Suppose: for (i in c(1:100))
I want i to be 1, 10, 20, 30, ... instead of 1,2,3,4,5 ...
How can this be done?
Thanks,
Vivek
__
R-help@r-project.org mailing list
Hi,
On Aug 3, 2009, at 12:09 PM, Vivek Ayer wrote:
Hey guys,
How do I iterate such that I add 100 to the counter every time?
Suppose: for (i in c(1:100))
I want i to be 1, 10, 20, 30, ... instead of 1,2,3,4,5 ...
How can this be done?
?seq
-steve
--
Steve Lianoglou
Graduate Student:
Got it..Thanks
Vivek
On Mon, Aug 3, 2009 at 9:13 AM, Steve
Lianogloumailinglist.honey...@gmail.com wrote:
Hi,
On Aug 3, 2009, at 12:09 PM, Vivek Ayer wrote:
Hey guys,
How do I iterate such that I add 100 to the counter every time?
Suppose: for (i in c(1:100))
I want i to be 1, 10, 20,
I am trying to load binary files in the following fashion
load(pred/Pred_pres_a_indpdt)
load(pred/Pred_pres_b_indpdt)
load(pred/Pred_pres_c_indpdt)
load(pred/Pred_pres_d_indpdt)
load(pred/Pred_pres_e_indpdt)
load(pred/Pred_pres_f_indpdt)
but I would like to set up a for loop to replace the
Dear Chris,
Try this:
x - c(a,b,c,d,e,f)
sapply(x, function(i){
i - paste(pred/Pred_pres_,i,_indpdt, sep =)
load(i)
}
)
HTH,
Jorge
On Thu, Jul 30, 2009 at 4:06 PM, waltzmiester cwalt...@shepherd.edu wrote:
I am trying to load binary files in
Try this,
files = paste('pred/Pred_pres_', letters[1:6], '_indpdt',sep=)
lapply(files, load)
HTH,
baptiste
2009/7/30 waltzmiester cwalt...@shepherd.edu:
I am trying to load binary files in the following fashion
load(pred/Pred_pres_a_indpdt)
load(pred/Pred_pres_b_indpdt)
Try this:
sapply(sprintf(pred/Pred_pres_%s_indpt, x), load, envir = .GlobalEnv)
You need set the envir argument to global environment inside the sapply.
On Thu, Jul 30, 2009 at 5:06 PM, waltzmiester cwalt...@shepherd.edu wrote:
I am trying to load binary files in the following fashion
Thanks very much for these two solutions, but they are still printing
Pred_pres_[i]_indpdt on the screen and not executing the function load
Chris
baptiste auguie-5 wrote:
Try this,
files = paste('pred/Pred_pres_', letters[1:6], '_indpdt',sep=)
lapply(files, load)
HTH,
I'm just guessing but what about
letters - letters[1:6]
mynames - paste(pred/Pred_pres_,letters,_indpdt)
for(i in 1:6) load(mynames[i])
--- On Thu, 7/30/09, waltzmiester cwalt...@shepherd.edu wrote:
From: waltzmiester cwalt...@shepherd.edu
Subject: Re: [R] for loop for file names
To: r
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of waltzmiester
Sent: Thursday, July 30, 2009 1:29 PM
To: r-help@r-project.org
Subject: Re: [R] for loop for file names
Thanks very much for these two solutions
Hi
r-help-boun...@r-project.org napsal dne 15.07.2009 17:59:39:
see ?ifelse
you didn't specify what happens if a value is exactly zero in the
dataset
and so i've just bundled it in with the negative case:
x - rnorm(20, 0, 1)
y-ifelse(x=0, 10, 5)
For this simple case you can also use
Hi i am very new to R and I have been trying to change each individual piece
of data in a data set to 10 if it is below 0 and 5 if it is above 0. I know
this sounds very easy but i am struggling!!
--
View this message in context:
see ?ifelse
you didn't specify what happens if a value is exactly zero in the dataset
and so i've just bundled it in with the negative case:
x - rnorm(20, 0, 1)
y-ifelse(x=0, 10, 5)
HTH,
Tony Breyal
cmga20 wrote:
Hi i am very new to R and I have been trying to change each individual
Hi,
In a symmetric design one may have a data.frame with, say, two factors (two
columns), each one with n levels.
In a nested loop, to run a expression combining levels of each factors, to
produce a new data.frame, if one level is absent, the loop is interrupted;
one gets a empty object.
You can use drop=TRUE as argument in indexing (brackets) to drop
unused levels, see the following example:
a - factor(1:2, levels=1:3)
a
# [1] 1 2
# Levels: 1 2 3
for(i in levels(a)) print(i)
#[1] 1
#[1] 2
#[1] 3
for(i in levels(a[, drop=TRUE])) print(i)
#[1] 1
#[1] 2
Uwe Ligges
Paulo E.
Hi everyone!
I have this dataframe:
firm-c(rep(1,4),rep(2,4),rep(3,4),rep(4,4),rep(5,4),rep(6,4))
year-c(rep(2000:2003,6))
industry-c(rep(10,4),rep(20,4),rep(30,4),rep(10,4),rep(20,4),rep(30,4))
X1-c(10,14,18,16,20,45,23,54,24,67,98,58,16,32,57,12,54,0,0,22,11,3,5,6)
data-data.frame(firm,
Dear Cecilia,
Here is one way:
with(yourdata, tapply(X1, list(year, industry), mean))
Also, take a look at ?ave and its examples.
HTH,
Jorge
On Sun, Jun 28, 2009 at 12:39 PM, Cecilia Carmo cecilia.ca...@ua.pt wrote:
Hi everyone!
I have this dataframe:
Hi Cecilia,
Trying it your way there where three reasons for errors, I fixed them in the
following code:
means-matrix(nrow=3,ncol=4)
counter.i - 0
counter.j - 0
for (i in levels(factor(data$industry)))
{
counter.i - counter.i + 1
for (j in levels(factor(data$year)))
{
counter.j - counter.j +
Also consider ddply in the plyr package (although that's an over kill if
your only having two loops)
Maybe, but it sure is much simpler:
library(plyr)
ddply(data, c(industry,year), summarise, avg = mean(X1))
Hadley
--
http://had.co.nz/
__
My dear R buddies,
I'm writing a loop program like this:
for(i in 1:n){
for(j in 1:i){
...
}
}
I wonder if there is any simple apply()-like function to make the loop
a little bit easier and faster. Thanks a lot.
Best wishes,
--
彭河森 Hesen Peng
http://hesen.peng.googlepages.com/
Finally I ended up doing this:
temp - expand.grid(1:n,1:n)
temp-temp[temp[,1]temp[,2]]
apply(temp,1, ... )
and it seems much faster :)
On Sat, Jun 27, 2009 at 3:26 PM, Patrick Burnspbu...@pburns.seanet.com wrote:
See 'The R Inferno'.
Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525
Hi,
I need your help.
I have a vector of numbers reflecting the switch in the perception of a
figure. For a certain period I have positive numbers (which reflect the
perception A) then the perception changes and I have negative numbers
(perception B), and so on for 4 iterations. I need to
aledanda wrote:
Hi,
I need your help.
I have a vector of numbers reflecting the switch in the perception of a
figure. For a certain period I have positive numbers (which reflect the
perception A) then the perception changes and I have negative numbers
(perception B), and so on for 4
Hi, I am still not familiar with vectorization.
Could you help with making this for loop more efficient?
The code is trying to make a Q matrix for a multidimensional state space
with specific conditions.
thanks
Mira
tmp = 0:(maxvals[1])
for(i in 2:nchars) {
tmp - outer(tmp, 0:(maxvals[i]),
uhoh, missed two lines on the top.Sorry about that.
the whole code looks like this.
nchars = 4
maxvals = c(2,2,2,2)
tmp = 0:(maxvals[1])
for(i in 2:nchars) {
tmp - outer(tmp, 0:(maxvals[i]), FUN=paste, sep=.)
}
states = tmp
stateidx = array(1:length(states), dim=dim(states))
transition -
this 'ifelse' usage looks promising.
thank you very much.
On Thu, May 7, 2009 at 3:12 PM, Patrick Burns pbu...@pburns.seanet.comwrote:
If you haven't seen it yet,
'The R Inferno' may be of use
to you.
Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
Hi there,
Just wondering if someone can help me with the correct syntax to use
with for loops?
I have split my original file by count, wish to first of all assign
new tables based on the splits. Then I just want to create a new
variable. Please see code below.
This code works
What do you expect this statement to do:
trial[i] - data.frame(A2$`i`)
what is `i` supposed to mean? What is it that you want to do?
On Mon, Apr 27, 2009 at 10:25 AM, Bronagh Grimes
bronagh.gri...@distinct.ie wrote:
Hi there,
Just wondering if someone can help me with the correct
] [,3] [,4]
[1,] NaN NaN NaN NaN
[2,] NaN NaN NaN NaN
[3,] NaN NaN NaN NaN
[4,] NaN NaN NaN NaN
[5,] NaN NaN NaN NaN
[6,] NaN345
Could anyone give me a hand? Would be much appreciated.
Thanks Emma
--
View this message in context:
http://www.nabble.com/numbers-loop
://www.nabble.com/numbers-loop-in-R-tp23099591p23099591.html
Sent from the R help mailing list archive at Nabble.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
NaN NaN NaN
[6,] NaN 3 4 5
Could anyone give me a hand? Would be much appreciated.
Thanks Emma
--
View this message in context:
http://www.nabble.com/numbers-loop-in-R-tp23099591p23099591.html
Sent from the R help mailing list archive at Nabble.com
On Fri, Apr 17, 2009 at 12:19 PM, jim holtman jholt...@gmail.com wrote:
try this:
matrixx-function(A){
+ B=matrix(NaN,nrow=(A+1),ncol=4)
+ k - 1
+ for (i in 3:A){
+ for (j in i:A) {
+ B[k,] - c(NaN, i-2, i-1, j)
+ k - k + 1
+ }
+ }
Uwe Ligges-3 wrote:
Melissa2k9 wrote:
Hi,
I have written a for loop as such:
model-lm(Normalised~Frame,data=All,subset=((Subject==1)(Filmclip==Strand)))
summary(model)
###
#To extract just the Adjusted R squared
Melissa2k9 wrote:
Uwe Ligges-3 wrote:
Melissa2k9 wrote:
Hi,
I have written a for loop as such:
model-lm(Normalised~Frame,data=All,subset=((Subject==1)(Filmclip==Strand)))
summary(model)
###
#To extract just the Adjusted R squared
Melissa2k9 wrote:
Hi,
I have written a for loop as such:
model-lm(Normalised~Frame,data=All,subset=((Subject==1)(Filmclip==Strand)))
summary(model)
###
#To extract just the Adjusted R squared
###
Hello,
I'm trying to create a for loop for a data set, I have a list of results in
this data set and I want to take the 1st two add them together and divide by
the mean of the 1st to, then do the same for the 3rd and 4th values in the list
and so on and each time return a value for the
Al,
Is there any ID index for the pairs? For example, if the first pair can be
labeled a, and second pair labeled b etc., then you can add an index
column or you may already have such a column in your list. Then run
aggregate(your.data.column, by=index.column, FUN=mean). Or you can just add
an
Al,
Say, your data file is 'test', execute the following in sequence,
aggregate(test[1],test[2],mean)-inter
names(inter)[2]='mean'
merge(test,inter,all=T)-inter2
inter2$RSV=inter2$Result/inter2$mean
The column 'RSV' in inter2 should be what you want.
Jun
On Tue, Mar 31, 2009 at 11:11 AM,
If you add 2 numbers a and b and divide this sum
by the mean of these 2 number, you will always get 2
(a+b)/((a+b)/2) always simplifies to 2.
Alan O'Loughlin wrote:
Hello,
I'm trying to create a for loop for a data set, I have a list of results in
this data set and I want to take the
Dear Colleagues
I have the following code that generates a boxplot for one specific labtest:
boxplot.n(LBSTRESN~COHORT, main=Boxplot of laboratory data for XLXXX-XXX
test=Creatinine,
subset = LBTEST==Creatinine,
xlab = Cohort Number,
ylab = Units = umol/L,
varwidth=TRUE
I would like to
You could use the paste() function to dynamically assign label values.
For instance, like this:
dat-data.frame(id=1:4,x=1:4,y=1:4)
par(mfrow=c(2,2))
for (i in dat$id){
boxplot(dat$x[dat$id==i],
dat$y[dat$id==i],
main=paste(Results for Subject,i) )
}
There might be a better
Oops, the example only accounts for 1 observation, so better do
something like this in that case:
..
for (i in unique(dat$id)){
..
On Mon, Mar 30, 2009 at 07:50, Coen van Hasselt
coenvanhass...@gmail.com wrote:
You could use the paste() function to dynamically assign label values.
For instance,
Thanks! Why did I not think at that myself. .csv means 'Comma Separated
Value'
David Winsemius wrote:
write.csv does exactly what you would expect ... creates a *Comma*
Separated Values file. If you don't want a comma separated value
format then use write.table with sep=;
You can
I have one final question...
How can I save a CSV ifile with ; separation in stead of , separation?
I know the write.csv(file=filename.csv) an that you can use sep=; when
you open a .csv file, but that doesn't work with the write.csv command.
--
View this message in context:
Try using:
write.table(..., sep=;)
write.csv just calls write.table
On Mon, Jan 12, 2009 at 6:38 AM, Sake tlep.nav.e...@hccnet.nl wrote:
I have one final question...
How can I save a CSV ifile with ; separation in stead of , separation?
I know the write.csv(file=filename.csv) an that you
write.csv does exactly what you would expect ... creates a *Comma*
Separated Values file. If you don't want a comma separated value
format then use write.table with sep=;
You can still name it whatever.csv.
Or you if you also intend commas for decimal points, use write.csv2
as described
Sake wrote:
Hi,
I'm heaving difficulties with a dataset containing gene names and
positions of those genes.
Not such a big problem, but each gene has multiple exons so it's hard to
say where de gene starts and where it ends. I want the starting and ending
position of each gene in my
On Wed, Jan 7, 2009 at 3:51 AM, Sake tlep.nav.e...@hccnet.nl wrote:
aggregate(data[, c(Exon_Start.Chr.)], by = list(data$Gene), min)
aggregate(data[, c(Exon_Stop.Chr.)], by = list(data$Gene), max)
That could be written:
aggregate(data[Excon_Start.Chr.], data[Gene], min)
Hi,
I'm heaving difficulties with a dataset containing gene names and positions
of those genes.
Not such a big problem, but each gene has multiple exons so it's hard to say
where de gene starts and where it ends. I want the starting and ending
position of each gene in my dataset.
Attached is the
I'm heaving difficulties with a dataset containing gene names and
positions
of those genes.
Not such a big problem, but each gene has multiple exons so it's hard to
say
where de gene starts and where it ends. I want the starting and ending
position of each gene in my dataset.
Attached is
On Tue, Jan 06, 2009 at 07:21:48AM -0800, Sake wrote:
I'm heaving difficulties with a dataset containing gene names and positions
of those genes.
Not such a big problem, but each gene has multiple exons so it's hard to say
where de gene starts and where it ends. I want the starting and ending
On Tue, 6 Jan 2009, Sake wrote:
Hi,
I'm heaving difficulties with a dataset containing gene names and positions
of those genes.
Not such a big problem, but each gene has multiple exons so it's hard to say
where de gene starts and where it ends. I want the starting and ending
position of each
Hi,
Why isn't my loop incrementing i - the outer loop to 2 and then resetting
j=3?
It is. It runs out of bounds with j 26
Am I missing something obvious?
for (i in 1:25)
+ {
+ for (j in i+1:26)
You miss parentheses.
i + 1 : 26 is i + (1 : 26) as the vector
Hi all,
apologies if this is obvious - but I can't see it and would appreciate some
quick help!
the matrix mhouse is 26x3 and I'm computing odds ratios. The simple code
below should compute the odds vector for every pair (325) i.e. 26C2 in
cols 1 and 2.
On the first i=1 outer loop the inner j
Hi
start simple!
Work out *each* row combined with *each* row,
to give (in your case) a 26-by-26 matrix.
Only after you have got this working, start thinking about
making it run faster [eg by
only evaluating the upper triangular entries]
To do a nested loop, do
M - matrix(0,n,n)
for(i in
I have a series of csv files in several folders. All begin with a 7 digit
number and end with the letter E (eg. 0726016E.csv).
I want to be able to read a file in to R, take some of the data out of it
and store it in a matrix, then move on to the next file and do the same
thing.
I was planning
To get the file names in the current directory try:
list.files(pattern=[[:digit:]]{7}E)
On Tue, Dec 2, 2008 at 4:11 PM, Steven Kennedy [EMAIL PROTECTED] wrote:
I have a series of csv files in several folders. All begin with a 7 digit
number and end with the letter E (eg. 0726016E.csv).
I
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
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 trying to simplify my code by adding a for loop that will load and
compute a sequence of code 10 time. They way i run it now is that the same
8 lines of code are basically reproduced 10 times. I would like to replace
the numeric value in the code (e.g. Bin1, Bin2Bin10) each time the
# I would put this in a list in the following manner
Bin - lapply(1:10, function(.file){
#---
#Loads bin data frame from csv files with acres and TAZ data
fileName -
paste(I:/Research/Samba/urb_transport_modeling/LUSDR/Workspace/BizLandPrice/data/Bin_lookup_values/Bin,
.file,
Peter Dalgaard wrote:
megh wrote:
Is there anything like goto loop, which exists in most computer programs?
e.g. I am looking for this kind of stuff :
if(i 6) goto step-02
Any idea?
Regards,
It doesn't exist, but it can always be replaced by if() {} else {}
constructs. (You don't
Patrick Burns wrote:
Peter Dalgaard wrote:
megh wrote:
Is there anything like goto loop, which exists in most computer
programs?
e.g. I am looking for this kind of stuff :
if(i 6) goto step-02
Any idea?
Regards,
It doesn't exist, but it can always be replaced by if() {} else
Patrick Burns wrote:
Peter Dalgaard wrote:
megh wrote:
Is there anything like goto loop, which exists in most computer
programs?
e.g. I am looking for this kind of stuff :
if(i 6) goto step-02
Any idea?
Regards,
It doesn't exist, but it can always be replaced by if() {} else {}
megh wrote:
Is there anything like goto loop, which exists in most computer programs?
e.g. I am looking for this kind of stuff :
if(i 6) goto step-02
Any idea?
Regards,
It doesn't exist, but it can always be replaced by if() {} else {}
constructs. (You don't usually see goto in the
Is there anything like goto loop, which exists in most computer programs?
e.g. I am looking for this kind of stuff :
if(i 6) goto step-02
Any idea?
Regards,
--
View this message in context:
http://www.nabble.com/%22Goto%22-loop-tp20263445p20263445.html
Sent from the R help mailing list
2008/10/31 megh [EMAIL PROTECTED]:
Is there anything like goto loop, which exists in most computer programs?
Really? Not since 1968, I think:
http://www.cs.utexas.edu/users/EWD/ewd02xx/EWD215.PDF
e.g. I am looking for this kind of stuff :
if(i 6) goto step-02
Any idea?
Thinking you
2008/10/31 Peter Dalgaard [EMAIL PROTECTED]:
It doesn't exist, but it can always be replaced by if() {} else {}
constructs. (You don't usually see goto in the class of functional
programming languages to which R belongs. See also
http://en.wikipedia.org/wiki/Edsger_W._Dijkstra .)
Also see
Hello,
I'm trying to build a for loop, where I estimate a series of models with
different sets of (time series) data.
However my for loop doesn't recognize the i
# code
window.1=anomalies.CAK[(positions(anomalies.CAK)=timeDate(1/1/1971)
Scotty Nelson poorboy44 at hotmail.com writes:
I'm trying to build a for loop, where I estimate a series of models with
different sets of (time series) data.
However my for loop doesn't recognize the i
# code
?for doesn't return anything help.search(for) doesn't return anything-
Is the for loop so prevelant in computer programing that the
documentation is implicit or is R paradigm to discourage the use of
the for loop.
I will post data probably tonight, but here is my problem. I have
preformed an MDS
One must write ?for presumably since for is a reserved word in R.
On Wed, Oct 1, 2008 at 9:39 AM, stephen sefick [EMAIL PROTECTED] wrote:
?for doesn't return anything help.search(for) doesn't return anything-
Is the for loop so prevelant in computer programing that the
documentation is
Actually, help.search(for) finds
Control(base) Control Flow
which is exactly where 'for' is documented. In general, if you want
the manual page of reserved words, then you'll have to quote them:
?for
Gabor
On Wed, Oct 1, 2008 at 3:39 PM, stephen sefick [EMAIL PROTECTED] wrote:
?for
I will post data probably tonight, but here is my problem. I have
preformed an MDS on a set of data. I have the scores of the four axes
that
are the optimal solution. I want to calculate the euclidean distance
between time steps of the ordination.
See ?dist for a much faster
I am looking up a number based upon a randomly selected number and then
proceed to the rest of my code if the corresponding value is greater than or
equal to yet another value.
so if
Dev_Size = 14
and my randomly selected number is 102
and i am looking up 102 in the following table
100
It looks like you are test against TAZDetermine before it is defined.
Try something like this:
while(TRUE){
...generate random number
if (value Dev_size) break
}
On Tue, Sep 30, 2008 at 6:56 PM, PDXRugger [EMAIL PROTECTED] wrote:
I am looking up a number based upon a randomly selected
Hello,
I am fairly new to R programming. I have a series of netcdf files that
I am able to open one at a time using open.ncdf. I want to write this
into an R script so that I can successively open each file by date in a
for-loop. Any suggestions?
Thanks
Brian Pettegrew
--
Brian
Hi, you may use list.files('dir-of-your-files', ...) to get the paths
of all the files, and use file.info() to get the date attribute, then
order them by date, and finally in a loop
for(i in paths-of-your-files){
open.ncdf(i, ...)
...
}
Regards,
Yihui
--
Yihui Xie [EMAIL PROTECTED]
Phone:
Dear Rusers,
I am still an unexperienced builder of functions and loops, so my question is
very basic: Is it possible to introduce a second variable (j) into my loop.
To examplify:
# This works fine:
fn - function (x) {if (x46 x52) 1 else 0}
res -NULL
for (i in 40:60) res -c(res,fn(i))
res
701 - 800 of 865 matches
Mail list logo