Displaying 20 results from an estimated 5000 matches similar to: "loop question"
2011 Jun 22
2
[LLVMdev] Improving cast<> failure messages.
Would anyone object to an attempt to improve cast<> error messages by
outputting the expected type and the type received?
The interface I'm thinking of is to use ADL to do visitor-style lookup,
so we don't need to change every client. In particular, for clients in
clang, we can just create these functions implicitly from our
TableGen-generated files. I'm not sure about
2013 Aug 25
3
Rodondeo de una matriz
Gracias, Jorge. Y cual fue la solucion a la que llegaron? --JIV
Sent from my phone. Please excuse my brevity and misspelling.
On Aug 25, 2013, at 8:36 AM, Jorge Ayuso Rejas <jayusor@gmail.com> wrote:
Esto lo hice yo en una práctica en la universidad,
Definíamos un problema de optimización entera minimizando el error de
redondeo y restringiendo a la suma de filas y columnas.
El 23 de
2010 Sep 15
1
contr.sum, model summaries and `missing' information
Hi,
I have a dataset with a response variable and multiple factors with more
than two levels, which I have been fitting using lm() or glm(). In
these fits, I am generally more interested in deviations from the global
mean than I am in comparing to a "control" group, so I use contr.sum()
as the factor contrasts. I think I'm happy to interpret the
coefficients in the model summary
2005 Mar 15
2
Lemon drops
I bumped into the following situation:
Browse[1]> coef
deg0NA deg4NA deg8NA deg0NP deg4NP deg8NP
(Intercept) 462 510 528 492 660 762
Browse[1]> coef[,1]
[1] 462
Browse[1]> coef[,1,drop=F]
deg0NA
(Intercept) 462
where I really wanted neither, but
(Intercept)
462
Anyone happen to know a neat way out of the conundrum?
I can think of
2011 Aug 08
3
on "do.call" function
Dear all,
Even though one of R users answered my question, I cannot understand, so I
re-ask this question.
I am trying to use "do.call", but I don't think I totally understand this
function.
Here is an simple example.
--------------------------------------------
> B <- matrix(c(.5,.1,.2,.3),2,2)
> B
[,1] [,2]
[1,] 0.5 0.2
[2,] 0.1 0.3
> x <- c(.1,.2)
>
2008 Sep 24
4
rowSums()
Say I have the following data:
testDat <- data.frame(A = c(1,NA,3), B = c(NA, NA, 3))
> testDat
A B
1 1 NA
2 NA NA
3 3 3
rowsums() with na.rm=TRUE generates the following, which is not desired:
> rowSums(testDat[, c('A', 'B')], na.rm=T)
[1] 1 0 6
rowsums() with na.rm=F generates the following, which is also not
desired:
> rowSums(testDat[, c('A',
2005 Feb 09
4
subset
Dear all,
I am trying to extract rows from a data.frame based on the
rowSums != 0. I want to preserve rownames in the first column in the subset.
Does anyone know how to extract all species that don't have rowSums equal
to zero? Here it is:
# dataset
x <- data.frame(
species=c("sp.1","sp.2","sp.3","sp.4"),
site1=c(2,3,0,0),
site2=c(0,0,0,0),
2012 Nov 22
1
Data Extraction - benchmark()
Hi Berend,
I see you are one of the contributors to the rbecnhmark package.
I am sorry that I am bothering you again. I have tried to run your code (slightly tweaked) involving the benchmark function, and I am getting the following error message. What am I doing wrong?
Error in benchmark(d1 <- s1(df), d2 <- s2(df), d3 <- s3(df), d4 <- s4(df), :
could not find function
2009 Nov 30
2
command similar to colSums for rowSums?
Working with an NxMxO sized matrix, currently I can do this in my code:
if (max(colSums(array)) >= number)
But to get an equivalent result using rowSums, I have to do:
for (i in 1:10)
{
if (max(rowSums(array[,,i])) >= number)
}
I'm running both in a much larger loop that loops millions of times, so
speed and such is quite a big factor for me. Currently, the colSums line
uses about
2011 Nov 22
3
On-demand importing of a package
Dear All,
in some functions of my package, I use the Matrix S4 class, as defined
in the Matrix package.
I don't want to depend on Matrix, however, because my package is
perfectly fine without Matrix, most of the functionality does not need
Matrix. Matrix is so included in the 'Suggests' line.
I load Matrix via require(), from the functions that really need it.
This mostly works
2005 Apr 21
1
colSums and rowSums with arrays - different classes and dim ?
Hi,
I'm using colSums and rowSums to sum the first dimensions of arrays. It
works ok but the resulting object is different. See
> a3d <- array(rnorm(120, mean=2), dim=c(20,6,1))
> dim(colSums(a3d))
[1] 6 1
> dim(rowSums(a3d))
NULL
> class(colSums(a3d))
[1] "matrix"
> class(rowSums(a3d))
[1] "numeric"
I was expecting rowSums to preserve the array
2011 May 16
2
conditional rowsums in sapply
Hi all
I have a data frame with duplicate columns and i want to remove duplicates
by adding rows in each group of duplicates, but have lots of NA's.
Data:
dfrm <- data.frame(a = 1:4, b= 1:4, cc= 1:4, dd=1:10, ee=1:4)
names(dfrm) <- c("a", "a", "b", "b", "b")
dfrm[3,2:3]<-NA
dfrm
a a b b b
1 1 1 1 1 1
2 2 2 2 2 2
3
2018 Mar 21
5
Sum of columns of a data frame equal to NA when all the elements are NA
Dear list users,
let me ask you this trivial question. I worked on that for a long time, by now.
Suppose to have a data frame with NAs and to sum some columns with rowSums:
df <- data.frame(A = runif(10), B = runif(10), C = rnorm(10))
df[1, ] <- NA
rowSums(df[ , which(names(df) %in% c("A","B"))], na.rm=T)
If all the elements of the selected columns are NA, rowSums
2011 Aug 08
1
problem in do.call function
Dear all,
I am trying to use "do.call", but I don't think I totally understand this
function.
Here is an simple example.
--------------------------------------------
> B <- matrix(c(.5,.1,.2,.3),2,2)
> B
[,1] [,2]
[1,] 0.5 0.2
[2,] 0.1 0.3
> x <- c(.1,.2)
> X <- cbind(1,x)
> X
x
[1,] 1 0.1
[2,] 1 0.2
>
> lt <-
2005 May 02
4
"apply" question
Dear R users,
I??ve got a simple question but somehow I can??t find the solution:
I have a data frame with columns 1-5 containing one set of integer
values, and columns 6-10 containing another set of integer values.
Columns 6-10 contain NA??s at some places.
I now want to calculate
(1) the number of values in each row of columns 6-10 that were NA??s
(2) the sum of all values on columns 1-5
2013 Sep 26
2
Sums based on values of other matrix
Dear all,
I have a big problem:
- I got two matrices, A and B
- A shows identifies the value of B, however the values of B must be summed
- For instance,
1 1 2 2
2 2 1 1
gives matrix a
3 4 2 1
1 1 2 2
gives matrix b
Now the result for the value 1 would be
7
4
which are the rowsums of the values of matrix B given that matrix A has the value 1.
How can I do this automatically? I
2010 Nov 28
4
how to divide each column in a matrix by its colSums?
Hi,
I have a matrix, say
m=matrix(c(
983,679,134,
383,416,84,
2892,2625,570
),nrow=3
)
i can find its row/col sum by
rowSums(m)
colSums(m)
How do I divide each row/column by its rowSum/colSums and still return in
the matrix form?
(i.e. the new rowSums/colSums =1)
Thanks.
Casper
--
View this message in context:
2007 Nov 09
2
rowSums() and is.integer()
Hi
[R-2.6.0, macOSX 10.4.10].
The helppage says that rowSums() and colSums()
are equivalent to 'apply' with 'FUN = sum'.
But I came across this:
> a <- matrix(1:30,5,6)
> is.integer(apply(a,1,sum))
[1] TRUE
> is.integer(rowSums(a))
[1] FALSE
>
so rowSums() returns a float.
Why is this?
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre,
2006 Nov 21
2
using nested ifelse and rowSums to create new variable?
Dear R-help community,
If I have a data.frame df as follows:
> df
x1 x2 x3 x4 x5 x6
1 5 5 1 1 2 1
2 5 5 5 5 1 5
3 1 5 5 5 5 5
4 5 5 1 4 5 5
5 5 1 5 2 4 1
6 5 1 5 4 5 1
7 5 1 5 4 4 5
8 5 1 1 1 1 5
9 1 5 1 1 2 5
10 5 1 5 4 5 5
11 1 5 5 2 1 1
12 5 5 5 4 4 1
13 1 5 1 4 4 1
14 1 1 5 4 5 5
15 1 5 5 4
2008 Apr 20
1
Exception DatabaseCorruptError under php
Hello,
I'm having a litle issue with Xapian-1.0.6 with php bindings under
php5 when trying to add a new document it throws:
Fatal error: Uncaught exception 'Exception' with message
'DatabaseCorruptError: Failed to unlink
/var/lib/xapian/trade.ar/termlist.baseA: No such file or directory'
in /usr/share/php5/xapian.php:1140
Stack trace:
#0 /usr/share/php5/xapian.php(1140):