1]
if (length(x) >= n) break
}
stopifnot(length(x) >= n)
x <- x[1:n]
Hope this helps.
Petr Savicky.
__
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
ldn't put the result into a R
> variable.
> Do you have any comments on this?
Hi.
Try the following.
writeLines(c("uno dos tres", "cuatro cinco", "seis"), "some_file.txt")
out <- system("wc some_file.txt", intern=TRUE)
out
uot;, data.frame(Value=c(73, 73, 76, 76, 74, 75)))
dfA$dups <- duplicated(dfA$Value) | duplicated(dfA$Value, fromLast=TRUE)
dfA
State Value dups
1VA73 TRUE
2VA73 TRUE
3VA76 TRUE
4VA76 TRUE
5VA74 FALSE
6VA75 FALSE
Hope this helps.
Pe
ki.sciviews.org/doku.php?id=misc:r_accuracy
for further examples and some hints.
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-pro
0 11 1213
[4,]56789 10 11 12 1314
[5,] 6 789 10 11 12 13 1415
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE
k
}
If you want to generate a vector and avoid a loop over its components,
try something like the following
n <- 500
while (1) {
a <- rlnorm(2*n, 0.7, 1)
a <- a[0.5 < a & a < 30] # only one & here
if (length(a) >= n) break
}
a <- a[1:n]
Hop
also for the decimal
arithmetic. Using 3 digit precision, the arithmetic mean of
the three numbers 1.02, 1.01, 1.01 is 1.01. So, the sum of the
differences
1.02 - 1.01
1.01 - 1.01
1.01 - 1.01
is not zero.
See functions zapsmall(), all.equal().
Hope this helps.
Petr Savicky.
___
On Thu, Aug 23, 2012 at 09:49:33PM -0700, Gopi Goteti wrote:
> I would like to know whether there is a faster way to do the below
> operation (updating vec1).
>
> My objective is to update the elements of a vector (vec1), where a
> particular element i is dependent on the previous one. I need to d
On Fri, Aug 24, 2012 at 10:34:14AM +0200, Petr Savicky wrote:
> On Thu, Aug 23, 2012 at 09:49:33PM -0700, Gopi Goteti wrote:
> > I would like to know whether there is a faster way to do the below
> > operation (updating vec1).
> >
> > My objective is to update the
NA. The efficiency depends on the length of
the sequencies of consecutive NA in the initial vec2. If there are
many, but only short sequencies of consecutive NA, the code can
be more efficient than a loop over all elements.
Hope this helps.
Petr Savicky.
_
whether this should be the default, i would support this.
Factors are very useful and sometimes necessary, but they are hard to
manipulate.
As Jeff Newmiller said, it is a good strategy to prepare the data as character
type and convert to a factor, when they are complete. The users should know, how
and using function log1p(x).
set.seed(1234567)
x <- - runif(10)
A <- log(sum(exp(x)))
y <- x[-which.max(x)]
B <- max(x) + log1p(sum(exp(y - max(x
A
[1] 1.771461
abs(A - B)
[1] 2.220446e-16
See also
http://rwiki.sciviews.org/doku.php?
This is a rounding problem.
print(S[204], digits=20)
[1] 2.0302487
print(2.03, digits=20)
[1] 2.0298046
Use function round(, digits), for example
S <- round(seq(0,4,0.01), digits=7)
which(S==2.03)
[1] 204
which(S==3.03)
[1] 304
Hope this helps.
Petr
2<=0
> x3-2*z3<=0
> x4-1*z4<=0
> x5-4000*z5<=0
> x1 >= 200
> x2 >= 100
> x3>=100
> x4>=500
> x5>=0
>
> I had tried lp function from lpsolve but not able to set objective.in for
> objective function. Any hel
code yields on my computer
[,1] [,2] [,3] [,4]
[1,]6 3.5 2.67 2.25
[2,]8 5.0 4.00 3.50
Try the following
out <- a[, 1] + a[, 3] %o% (1/b)
max(abs(out - result))
[1] 4.440892e-16
Hope this helps.
Petr Savicky.
__
On Thu, Aug 02, 2012 at 02:27:43AM -0700, khris wrote:
>
> On Aug 2, 2012, at 12:39 PM, Petr Savicky [via R] wrote:
>
> > On Wed, Aug 01, 2012 at 04:55:30AM -0700, khris wrote:
> > > Hi Petr,
> > >
> > > It been sometime since I wrote. But here are t
On Wed, Aug 01, 2012 at 06:19:29AM -0700, khris wrote:
> Hi Petr,
>
> The following is different line of thought which is posted in different form,
> maybe you have some wise input on it.
>
> "I need to find Efficient(tracktable) deterministic algorithm for Matching
> Weighted Graphs with bound
On Wed, Aug 01, 2012 at 04:55:30AM -0700, khris wrote:
> Hi Petr,
>
> It been sometime since I wrote. But here are the latest developments.
>
> When I give the binary linear opt problem to lpSolve optimizer than for small
> instance it gives correct answer but when size of nodes increase let's
-308
and the smallest representable number (in limited precision) is 2^-1074 =
4.940656e-324.
See
http://en.wikipedia.org/wiki/Double_precision_floating-point_format
for more detail.
Hope this helps.
Petr Savicky.
__
R-help@r-project.o
mand
Z[i,,]=table(occ, data_matrix[,i])
does not stop with an error, then it does not change Z[i,,] if
Z[i,,] contains the values equal to table(occ, data_matrix[,i])
already before the command is executed. This may happen, for
example, if you run the command twice.
Petr Savicky.
__
t;=", times=nrow(mat))
rhs <- c(80, 65, 40)
out <- lp("min", objective.in=obj, const.mat=mat, const.dir=dir,
const.rhs=rhs, all.int=TRUE)
out$solution
[1] 55 25 40 0
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing
ot;a" "b" "c"
[2,] "a" "c" "b"
[3,] "b" "a" "c"
[4,] "b" "c" "a"
[5,] "c" "a" "b"
[6,] "c" "b" "a"
Th
on't charge any values in Z.
> Is there some error?
Hi.
I already deleted your previous emails from my folder and you
start a new thread. Can you recall, what is exactly the problem
and which code you use? Without a context, the reason for the
above pr
ighbours. These are neighbours of
order 2. A general iteration finds neighbours of order n by looking for
neighbours
of the points found in the previous step, which are the neighours of order n-1.
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mai
ctorial(r) * sum(e1^(r:0)*e2^(0:r))
}
f
}
getF(2, 3, 3)
[1] 25.3
Hope this helps.
Petr Savicky.
>
> Le Jul 19, 2012 ?? 8:52 AM, Petr Savicky [via R] a ??crit :
>
> > On Wed, Jul 18, 2012 at 06:02:27PM -0700, bilelsan wrote:
> > > Leave the Taylor expansion
On Fri, Jul 20, 2012 at 04:26:34PM +0200, Petr Savicky wrote:
> On Fri, Jul 20, 2012 at 05:45:30AM -0700, wwreith wrote:
> > General problem: I have 20 projects that can be invested in and I need to
> > decide which combinations meet a certain set of standards. The total
> >
eated using expand.grid() faster than using a for loop.
Try the following
g <- as.matrix(expand.grid(rep(list(0:1), times=20)))
s <- rowSums(g)
x <- g[s > 5 & s < 13, ]
nrow(x)
[1] 96
Hope this helps.
Petr Savicky.
__
R
1) {
x <- 10 + 250*diff(c(0, sort(runif(4)), 1))
if (all(x <= 100)) break
}
x
[1] 99.32985 77.04346 65.49482 33.98516 24.14672
sum(x)
[1] 300
According to some tests, the average number of repetitions of
the while loop is about 5.
Hope t
le
x^2 + 2y^2 + 3(c - x - y)^2
with no constraint.
Hope this helps.
Petr Savicky.
__
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 pro
s + 10)
out
[1] 70.63310 60.11320 67.40902 53.73936 48.10532
sum(out)
[1] 300
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-proj
tart node and w_n the value of an end-node.
Petr Savicky.
__
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 provide commented, minimal, self-contained, reproducible code.
r-1) + e2^r)
If this is correct, then try
f <- 0
for (r in 1:k) {
f <- f + 1/factorial(r) * sum(e1^(r:0)*e2^(0:r))
}
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE
On Wed, Jul 18, 2012 at 11:38:59AM +0200, Petr Savicky wrote:
> On Tue, Jul 17, 2012 at 12:31:38PM +0200, Peppe Ricci wrote:
> > Hi guys,
> >
> > I need some help to analyzing my data.
> > I start to describe my data: I have 21 matrices, every matrix on the
> >
ble
preferences.
Changing
UserItem <- rbind(M1, M2, ..., M21)
to
UserItem <- data.frame(rbind(M1, M2, ..., M21))
can resolve the problem, since then the columns will be coerced to factors,
whose list of levels is complete, even if some level is not use
then
a possible cause can be that the text file contains the names in a form,
which you do not expect. There may be a difference in case of the
letters (names are case sensitive) or there may be white space in the
names. Look at these names, they may be extracted using
On Fri, Jul 13, 2012 at 02:38:57PM -0500, Vineet Shukla wrote:
> Hi Petr,
>Yes, that's really very helpful.
>
>
> Petr : Using this interpretation, AB occurs at lines 1,3,4 and not 1,3,5.
> Is this correct?
> Vineet : Yes , thats right sorry for the typo.
>
>
>
> Petr: If some sequence con
tterns
singleSeq <- function(x, lpattern)
{
unique(embed(rev(x), lpattern))
}
lst1 <- lapply(lst, singleSeq, lpattern=2)
# combine the matrices to a single matrix
mat <- do.call(rbind, lst1)
# convert the patters to strings
pat <- do.call(paste, c(data.frame(
quot;, "def", "ghi")
paste(a, collapse=" ")
[1] "abc def ghi"
Hope this helps.
Petr Savicky.
__
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 provide commented, minimal, self-contained, reproducible code.
The difference is not specific to R, but to the standard
computer arithmetic implemented in the hardware, which uses 53 bits.
Hope this helps.
Petr Savicky.
P.S. If you want to make further comments, please, open a new thread.
__
R-help@r-project.org ma
getDigits(3.123456)
[1] 6
Hope this helps.
Petr Savicky.
__
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 provide commented, minimal, self-contained, reproducible code.
On Sun, Jul 08, 2012 at 11:39:22AM -0700, arun wrote:
> Hi Petr,
>
> I think sprintf and formatC are identical as it can round >22 decimal places
> as opposed to print and signif
> print(pi,digits=35)
Hi Arun:
Thank you for pointing this out. Funtion formatC()
is easier to use and uses the same
The same output as from print(, digits=17) may be obtained
using
sprintf("%20.17f", x)
Of course, if the required number of digits is close to 17 or
even more, the last digits are the last digits of the represented
number, not of the intended result of the computation.
Hope this helps.
On Mon, Jul 02, 2012 at 06:11:37AM -0700, khris wrote:
> Hi, Petr,
>
> >
> > Hi Khris:
> >
> > If i understand the problem correctly, you have a list of (x,y)
> > coordinates, where
> > some sensor is located, but you do not know, which sensor is there. The
> > database
> > contains data fo
On Tue, Jun 26, 2012 at 11:52:15PM -0700, khris wrote:
> Hi Petr,
>
> Appreciate your feedback and sorry for the delay in responding. The
> following is the description of problem from start:-
>
> We have a set of sensors in XY plane arranged in more or less a rectangular
> grid and we know thei
of this length,
which has TRUE for the numbers present in the set and FALSE
for the other. Removing a number means to set its bit from
TRUE to FALSE, which is a very simple operation.
# prepare an example
numbers <- c(2, 3, 6, 8, 12, 17)
x <- rep
tt-1] + W[, tt]
}
The code uses tt instead of t to avoid confusion with the transpose function.
If n is always at least 2, then seq.int(from=2, length=n-1) may be
replaced by 2:n.
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing
from 1+i:252+i, which is
equivalent to 1 + (i:252) + i.
i <- 10
identical(1+i:252+i, 1 + (i:252) + i)
[1] TRUE
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read
its of the number, use one of the
following.
print(x, digits=17)
[1] 123456789.0378
options(digits=17)
x
[1] 123456789.0378
The default setting of options("digits") is 7.
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mail
On Thu, Jun 21, 2012 at 02:46:10AM -0700, khris wrote:
> Hi Petr,
>
> Thanks for the reply. Your reply answers the question perfect.
> Unfortunately converting the problem to linear opt would increase the number
> of variable making it non solvable. I guess a general approach will be
> unfeasible
lo:
Try
x <- c(3, 2, 4, 1)
rank(-x)
[1] 2 3 1 4
Hope this helps.
Petr Savicky.
__
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
mber to 0.3.
print(x[4], digits=20)
[1] 0.2999889
print(0.3, digits=20)
[1] 0.2999889
See also
http://rwiki.sciviews.org/doku.php?id=misc:r_accuracy
for some more hints related to this.
Petr Savicky.
__
R-help@r-project.
e me something other than INF, but that
> does not work since R would recognize x==1 in this case and therefore,
> 1-x==0, so qnorm(1-x, lower.tail=F) will give me INF which is what I try to
> avoid in my code.
Function qnorm(x) satisfies the identity qnorm(x) = - qnorm(
15 16 17 18 19 20 3 4 5
[26] 6 7 8 9 10 11 12 13 14 15 1 2 3 4 5
Hope this helps.
Petr Savicky.
__
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
70 ...
F 65 ...
M 70 ...
where ... represent six numbers in each row, which form a matrix
x1 y1
x2 y2
x3 y3
However, i think, a list of matrices is more flexible.
Petr Savicky.
__
R-help@r-project.org mailing list
htt
e the number of variables significantly, so
it is not guaranteed that the problem is solvable. However, it can be.
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the pos
On Fri, Jun 15, 2012 at 02:08:13PM +0200, Petr Savicky wrote:
> On Fri, Jun 15, 2012 at 11:27:44AM +, Schumacher, G. wrote:
> > Dear subscribers,
> >
> > I have made a simulation using loops rather than apply, simply because the
> > loop function seems more
atrix(x, nrow=nrow(x), ncol=length(y))
ym <- matrix(y, nrow=nrow(x), ncol=length(y), byrow=TRUE)
dst2 <- -abs(xm - ym)
identical(distances, dst2)
[1] TRUE
Apply uses a loop internally, so it need not significantly improve efficiency.
Petr Savicky.
_
lt;- a %*% t(a)
diag(w) <- 0
w
[,1] [,2] [,3]
[1,]021
[2,]201
[3,]110
trans <- c(1, 10, 12)
w[, ] <- trans[w + 1]
w
[,1] [,2] [,3]
[1,]1 12 10
[2,] 121 10
[3,] 1
1121
[2,]1122
[3,]1012
The entries of w are the weights except of the diagonal, which
is all ones, since each row of A contributes to the same row of B
with weight one. Is this, what you are looking for?
Petr Savicky.
__
e(x)
for (i in 1:(10^dig - 1)) {
if (! i %in% x) {
print(i)
break
}
}
[1] 355
The result seems to be correct. The numbers 351, 352, 353, 354 do occur in
the sequence.
351 is in "135 136",
352 in "235 236",
353 in "335 336",
35
missing
number is at most choose(n+1, 2) + 1. Due to this, we can consider only
sequencies of digits of length at most ceiling(log10(choose(n+1, 2) + 1)).
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/l
# some data
base <- data.frame(x1=letters[1:5], x2=seq(1, 2, length=5), x3=seq(1.2, 1.8,
length=5))
observed <- data.frame(x1=letters[6:8], x2=c(1.4, 1.01, 1.27), x3=c(1.6,
1.21, 1.37))
# choose tolerance
eps <- 0.05
# inspect data
mat1 <- as.matrix(base[, 2:3])
mat2 <-
K] and it didn't work as expected...
Hi.
Try the following.
A <- matrix(1:16, nrow=4, ncol=4)
B <- matrix(FALSE, nrow=4, ncol=4)
B[2:3, 2:3] <- TRUE
A[rowSums(B) != 0, colSums(B) != 0]
[,1] [,2]
[1,]6 10
[2,]7 11
Hope this helps.
Petr Savicky.
__
The problem is that "21000 km" does not contain a space, but
a no-break space. This may be checked by
charToRaw("21000 km") # copied from your email
[1] 32 31 30 30 30 c2 a0 6b 6d
charToRaw("21000 km") # after rewriting the
1] 2 2 0 0
> [,2] 1 0 2 1
> [,3] 2 0 1 1
> [,4] 1 0 2 1
Hi.
Try the following.
a<-c("A", "A", "B", "B", "C", "A", "C", "D", "A", "D", "C", "A", "D"
times 3 or if it is 12 times 300. In the former
case, the row number 1:1200 will be translated to the values of the
first two indices. In the latter case, the column number 1:300 will
be translated to the last two indices.
Hope this helps.
Petr Savicky.
_
B1", "B2"),
D = c("D1", "D2"))
a2 <- array(a1, c(2, 2, 2, 1))
dimnames(a2) <- c(dimnames(a1), list(group = "low"))
a2
, , D = D1, group = low
B
AB1 B2
A1 1 3
A2 2 4
, , D = D2, group = low
eated in a grid 2 times 2, we get a partition
of a larger square into 20 equal regions. I did not check,
whether they contain the required points, since i do not know
their exact coordinates, but they could.
Hope this helps.
Petr Savicky.
__
R-help@r-project
if (is.na(a[i])) {
return(f[i]*getCell(i-1))
} else {
return(a[i])
}
}
x <- rep(NA, times=n)
for (i in 1:n) {
x[i] <- getCell(i)
}
identical(o, x) # [1] TRUE
Petr Savicky.
__
R-help@r-project.org ma
out
Success: the objective function is 9
out$solution
[1] 7.2 1.8
Hope this helps.
Petr Savicky.
__
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 provide commented, minimal, self-contained, reproducible code.
meters and the call are
library(lpSolve)
f.obj <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1)
f.rhs <- c(15, 35, 40, 0, 0, 0, 0, 0, 0, 0)
f.dir = c("<=", "<=", "<=", rep(">=", times=7))
out <- lp("max", f.obj, f.mat,
inear programming problem
by introducing additional variables m1, m2, m3 and the
constraints
m1 <= a/10
m1 <= b/11
m2 <= aa/13
m2 <= bb/12
m2 <= cc/10
m3 <= bb/24
m3 <= cc/26
and maximizing m1 + m2 + m3. This problem may be solved using
package lpSolve.
sing apply(x,2,median) and this does not
take much time. What do you mean by "choosing only those
columns with same column name"?
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the po
rdered frequencies may be used for the reordered data.
Hope this helps.
Petr Savicky.
__
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 provide commented, minimal, self-contained, reproducible code.
lowing. Calculate the order of
the original data according to each relevant variable and store them
as rank vectors determining the order of cases. Then, instead of
sorting a data frame representing a sample, determine the order from
the corresponding subset of the rank vector. This may be f
ut <- lp("max", objective.in=crit, const.mat=mat, const.dir=dir,
const.rhs=rhs)
x <- low + out$solution
round(x, digits=15)
[1] -1 -1 -1 0 1 1 1 1
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
https://sta
is that G(cc) = 0.025 for cc = 0.025/log(4).
I hope there are not too may errors in this calculation.
Petr Savicky.
__
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.o
q(0.1, 20, length=1000)
plot(a, f(a), ylim=c(-0.2, 0.2), type="l")
abline(h=0)
This suggests, that there is no root. This may also be obtained
analytically.
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.e
an be done in linear time, so theoretically more efficiently than
sorting. However, only a test may determine, what is more efficient in
your situation.
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listi
925540e-02
[44,] 0. 2.458672e-02
[45,] 0.3400 2.060188e-02
[46,] 0.3467 1.719140e-02
[47,] 0.3533 1.428992e-02
[48,] 0.3600 1.183727e-02
[49,] 0.3667 9.767969e-03
Hope this helps.
Petr Savicky.
__
R-help@r-proje
1)
For generating Z, use the function rnorm(), for computing the
sample mean and sample estimate of the standard deviation, use
functions mean() and sd().
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mail
a nearest
multiple of 0.05. Rounding down and up to a nearest multiple
of a unit u can be done as follows
x <- 0.18
u <- 0.05
floor(x/u)*u # [1] 0.15
ceiling(x/u)*u # [1] 0.2
Hope this helps.
Petr Savicky.
__
R-help@r-project.org
following
dat <- data.frame(x=c(80, 85, 90, 0), y=c(82, 76, 0, 0), z=c(83, 90, 86, 0))
dat[dat == 0] <- Inf
out <- pmin(dat$x, dat$y, dat$z)
out[out == Inf] <- 0
out
[1] 80 76 86 0
Hope this helps.
Petr Savicky.
__
R-help@r
y >= 0
x + y <= 3
2*x + y <= 5
x + 2*y <= 5
then try
library(lpSolve)
crit <- c(3, 2)
mat <- rbind(c(1, 1), c(1, 2), c(2, 1))
rhs <- c(3, 5, 5)
dir <- rep("<=", times=3)
out <- lp("max", objective.in=crit, const.mat=ma
n of numbers can be done simply with "/" or "%/%".
2/3 # [1] 0.667
10/3 # [1] 3.33
10 %/% 3 # [1] 3
Please, clarify the question.
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailma
The difference is that iris[,1] is not a dataframe, while
both iris[,1:2] and iris[,1, drop=FALSE] are.
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
) + 1:2] <- matrix(orig[i, ], nrow=nrow(out), ncol=2,
byrow=TRUE)
}
out
[,1] [,2] [,3] [,4] [,5] [,6]
[1,]563452
[2,]6743 64
[3,]799974
Hope this helps.
Petr Savicky.
_
On Fri, May 04, 2012 at 07:43:32PM +0200, Kehl Dániel wrote:
> Dear Petr,
>
> thank you for your input.
> I tried to experiment with (probably somewhat biased) truncated means
> like in the following code.
> How I got the 225 as a truncation limit is a good question. :)
>
> REPS1 <- REPS2 <- 100
n expected value is
s*X
where s is uniform on {-1, 1} and X has value 2^i with probability 2^-i
for i a positive integer.
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE d
s FALSE if one of the vectors is
> different.
Hi.
Try the following.
length(unique(list(vec1, vec2, vec3))) == 1
[1] FALSE
length(unique(list(vec1, vec2, vec1))) == 1
[1] TRUE
Hope this helps.
Petr Savicky.
__
R-help@r-project.org mailing list
[1,]79
[2,]99
[3,]74
Arr1 <- aperm(Arr, perm=c(2, 1, 3))
d <- dim(Arr1)
t(array(Arr1, dim=c(d[1]*d[2], d[3])))
[,1] [,2] [,3] [,4] [,5] [,6]
[1,]563452
[2,]674364
[3,]79997
> or
> c(5,10)
> versus
> c(5L,10L)
Hi.
The help page ?"1L" or, equivalently, ?NumericConstants says
An numeric constant immediately followed by ‘L’ is regarded as an
‘integer’ number when possible (and with a warning if it contai
t; "1,2" "1,2" "1,2"
[4,] "2,1" "2,1" "2,1" "2,2" "2,2" "2,2"
[5,] "2,1" "2,1" "2,1" "2,2" "2,2" "2,2"
[6,] "2,1" "2,1&quo
he seed a bit
The observation is that this cannot be improved much, since the estimate
is based on a very small sample. The average size of the sample of nonzero
values is N2/(N1+N2)*n = 29.1. So, the standard deviation should be
something close to 100/sqrt(29.1) = 18.5376.
Petr Savicky.
___
are not
Hi.
The difference is caused by different placement of parenthesis.
Replacing
(1 + 10^(params[1]-xx)^params[2])
by
(1 + 10^(params[1]-xx))^params[2]
yields
[1] 101.574364 101.057295 35.949148 6.428122 4.812942
which is equal to t5.
Petr Savicky.
__
> x y
> a 1 3
> b 2 2
> c 3 1
Hi.
If you want three coefficients, one for each point in A, then try
C <- sweep(A, 2, B)
C[, 2]/C[, 1]
[1] Inf 1 0
Petr Savicky.
__
R-help@r-project.org mailing list
https://stat
nt to generate a larger number of instances, which terminate
below 5, try
x <- matrix(runif(4*20, 0, 3), nrow=20, ncol=4)
a <- matrix(0, nrow=4, ncol=5)
a[col(a) > row(a)] <- 1
y <- x[rowSums(x) < 5, ] %*% a
Petr Savicky.
___
ue loop variable, which controls the loop, since
one can have a loop for (i in c(1, 1, 1, 1, 1)). The true
control variable is hidden and cannot be changed. So the
for loop
for (i in 1:3) {
for (i in 1:4) {
cat("*")
}
cat("\n")
}
ensity, more exactly a lower bound on the density. The area of an ellipse
is \pi a b, where a, b, are its axes. If we have two such ellipses, it is
possible to compute the area of their intersection, but again, for each
ellipse, a lower bound on the density is
ined, since the original data frame contains
factors. If the intention is to keep character values, then use
df$x1 <- ifelse(is.na(df$a), as.character(df$b), as.character(df$a))
df
ab x1
1a1 a1
2 a1 a1
3 a2 a2 a2
4 b1 b1
5 b2 b2 b2
6b3 b3
7
1 - 100 of 439 matches
Mail list logo