Displaying 20 results from an estimated 30000 matches similar to: "questions about using loop, while and next"
2010 Jun 03
1
Question about avoid the for loop
Dear R-helpers,
I would like to generate a binary random variable within a stratum's
stratum. Here is a simple example.
## x is the first level strata index, here I have 3 strata.
x=c(rep(1,5), rep(2,5), rep(3,5))
## within x, there is a second strata indexed by t=0 and t=1
t=rep(c(0,0,1,1,1),3)
## and within strata i and t=0 and t=1, I generate the random binomial
variable respectively,
2010 Sep 24
1
color of lines while printing through for loop
I am trying to find a convenient way to control line colors when
printing from a for loop using the lines command.
Right now I have solved this by creating a colors vector that is refered
to in the loop with index. However, the colors choosen here are just
1,2,3,4,5...
I would like to get colors from the col = rainbow(x) that you can use in
plot() and set the to be my number of lines (I think
2020 Apr 26
2
Icecast Auto DJ
Hello,
I’ve a question. I have a station now with Shoutcast and shoutcast transcoder for 2 bitrates. 192kbps mp3 and 64 kbps aac+.
I want to transfer these to Icecast. I’ve an working icecast server but i need an auto dj that can encode 2 bitrates, 192kbps mp3 and 64kbps aac.
I had a working setup, but my nonstop machine is not on the icecast server but externally. Now in shoutcast transcoder i
2010 May 23
2
Bernoulli random variable with different probability
Dear R-helpers,
I would like to generate a variable that takes 0 or 1, and each subject has
different probabilities of taking the draw.
So, which of the following code I should use ?
suppose there are 5 subjects, and their probabilities of this Bernoulli
variable is p=c(0.2, 0.9, 0.15, 0.8, 0.75)
n<-5
Ber.var <- rbimon(n,1,p) ## I doubt if this will take the first probability,
which is
2006 Nov 20
2
problem with loop to put data into array with missing data for some files
Dear R-help community,
My main goal of this message is to find a way of skipping a file of a month/year
in a loop that does not exist (and making it's output into an data.out array
would be NA) and moving onto the next year/month in the loop to carry on filling
data.out with real precipitation data.
The situation so far:
I downloaded 50 years worth of GRIB data files from the NCEP data
2020 Sep 20
2
Call for testing: OpenSSH 8.4
On Sun, Sep 20, 2020 at 03:13:28PM -0400, Randall S. Becker wrote:
> On September 20, 2020 2:02 AM, Damien Miller wrote:
> > OpenSSH 8.4p1 is almost ready for release, so we would appreciate testing
> > on as many platforms and systems as possible. This is a bugfix release.
>
> I will be testing this shortly on HPE NonStop platforms.
>
> Side question: We now have
2006 Nov 20
3
problem with loop to put data into array with missing data forsome files
Hi Jenny
If you want a general solution I understand.
However I just downloaded the file fine (as far as I can tell) so you
are welcome to have a copy. I can email it to you if you want.
I do not think your test for NA is valid. i.e
if(test != "NA"){
}
I think you should use
if(is.na(test)){
}
Or something similar.
J
---
John Seers
Institute of Food Research
Norwich
2013 Mar 19
1
How can I eliminate a loop over a data.table?
I've two data.tables as shown below:
***
N = 10
A.DT <- data.table(a1 = c(rnorm(N,0,1)), a2 = NA))
B.DT <- data.table(b1 = c(rnorm(N,0,1)), b2 = 1:N)
setkey(A.DT,a1)
setkey(B.DT,b1)
***
I tried to change my previous data.frame implementation to a
data.table implementation by changing the for-loop as shown below:
***
for (i in 1:nrow(B.DT)) {
for (j in nrow(A.DT):1) {
if
2008 Jul 28
2
Help with a loop
HI:
I need ideas on how to make this code shorter (maybe with a second loop?).
The code as it is works, but in this case I only have 14 samples, but it
will become insane with more, so I need a way to make it more automatic. The
problem is that the output from ts1, ts2, and so on is a vector with more
than one value, so I do not know how to solve this.
Thanks
Prenewbie
The code is the
2010 May 13
3
select subset based on another variable
Hi, dear R-helpers,
I have a simple question regarding selecting subset of a variable based on
another variable.
Here is the example:
xx=rnorm(10)
id=sample(1:10, 10)
temp=c(6, 1, 8, 2)
Now, all I want is xx's that their id are 6, 1, 8, 2, instead of the
position.
Any suggestions ?
Thank you all your help !!
Carrie
[[alternative HTML version deleted]]
2006 Jun 29
1
Question on memory allocation & loop
Hello All,
I am trying to work on writing the following piece of (pseudo)
code in an optimal fashion:
----------------------------------------------------
# Two data frames with some data
a = data.frame(somedata)
b = data.frame(somedata)
for(i in 1:nrow(dt) {
# Merge dates for a given date into a new data frame
c = merge(a[a$dt==dt[i],),b[b$dt == dt[i],], by=c(some column));
}
2015 Apr 13
3
[Compile Issue] netcat.c on HP NonStop
Greetings,
I am porting the openssh-portable 6.8 release to the HP NonStop (NSE)
platform. Prior versions were no real problem, with minor tweeks. However,
with the inclusion of regress/netcat.c, which depends on arpa/telnet.h, we
have an issue. Unfortunately, the platform does not have this file, nor
anything like it - telnet is done rather differently. We do have a version
of netcat (0.7.1
2011 Jul 27
2
plotting the ending point in a for loop
Hello,
I would appreciate if someone could help me with this query. I would like to
plot a line chart of all of the points in a "for" loop. I would also like
to plot the final point with a symbol (to show where the random walk ends).
Here is the code I am using:
Brownian.fn <- function(mu, sigma, T, N){
dt <- T/N
t <- c(rep(NA, N))
B1 <- c(rep(NA, N))
B2 <- c(rep(NA,
2018 Nov 27
2
ScalarEvolution class returns no valid loop exit count
Hi,
I have problems to estimate the loop exit count of a simple loop with the
ScalarEvolution class.
simple loop:
......
int a = 0;
for(int i; i < 10; ++i){
a = a + 1;
};
......
For the loop analyzation I use the ScalarEvolution class with the following
initialization:
......
void analysis(Function* func)
DominatorTree DT = DominatorTree();
DT.recalculate(*func);
2011 Nov 16
0
[LLVMdev] CallSite in innermost loop
On Nov 16, 2011, at 2:43 AM, Pankaj Gode wrote:
> In order to detect whether CallSite is present in innermost loop, do I need to insert logic from LoopInfo pass for collecting loops, within a CallGraphSCC pass?
>
> Is there any other approach for this?
>
PassManager not only schedules passes, it also
- manages memory
- ensures that analysis info is valid at the point of use
-
2010 Jul 09
3
apply is slower than for loop?
I thought the "apply" functions are faster than for loops, but my most
recent test shows that apply actually takes a significantly longer than a
for loop. Am I missing something?
It doesn't matter much if I do column wise calculations rather than row wise
## Example of how apply is SLOWER than for loop:
#rm(list=ls())
## DEFINE VARIABLES
mu=0.05 ; sigma=0.20 ; dt=.25 ; T=50 ;
2010 Sep 17
2
Constant vs Nonstop vs Invariant TSC question
>From /xen-unstable.hg/xen/arch/x86/cpu/intel.c
if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
(c->x86 == 0x6 && c->x86_model >= 0x0e))
set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
if (cpuid_edx(0x80000007) & (1u<<8)) {
set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
set_bit(X86_FEATURE_NONSTOP_TSC,
2017 Nov 14
1
Dates to numeric in for loop
Hi
Can anyone explain why a date becomes numeric when you loop over a series
of dates?
> dt <- Sys.Date()
> dt
[1] "2017-11-14"
> class(dt)
[1] "Date"
> dts <- dt - 1:0
> class(dts)
[1] "Date"
>
> for (i in dts) {
+ print(i)
+ print(class(i))
+ print(as.Date(i, "1970-01-01"))
+ print(class(as.Date(i,
2019 Mar 29
2
Proposal for O1/Og Optimization and Code Generation Pipeline
When I worked on the HPE NonStop compilers for x86 (we used Open64, not
LLVM), we adjusted our -O1 to make sure the source display didn't
"bounce around" based on feedback from users. We disabled any
optimization that would move things across statement boundaries. We
also disabled/de-tuned dead store since our DWARF location list support
was pretty basic and with the removed store,
1997 Jul 09
1
R-beta: Problem with `rpois'
There is a problem with `rpois'. It does seem to take care about the
order of the arguments. This is an example:
> rpois(n=1,lambda=2)
[1] 3
> rpois(lambda=2,n=1)
[1] 2 0
It obviously uses the first argument as the number of samples to be
drawn, which is wrong.
I used Version 0.49 Beta (April 23, 1997).
Fredrik