Displaying 20 results from an estimated 4000 matches similar to: "Extracting column name in apply/lapply"
2004 Apr 27
2
Gcc 3.4.0 and syslinux-2.09 menu
The menu directory won't compile with gcc 3.4.0 because gcc complains
that "ebp" cannot be used as a constraint. If preserving ebp is
necessary then it will have to be done in the assembler code. Gcc 3.3.3
just seems to ignore the constraint. It didn't do anything special to
preserve the register.
I also noticed that getnumrows returns the contents of 0x484 which is
the
2002 Jun 21
1
naming things in functions
Hello,
I'm working with R version 1.5.0 in Windows. I've written a function
(SummaryMat, segment below) which uses a loop to
repeatedly call another function (PercentsMat, segment below).
PercentsMat creates a matrix and adds rows to it each time it is called.
I use deparse(substitute(...)) to get the names of the lists sent to
PercentsMat to use them as row names in the generated
2009 Jun 02
2
bigmemory - extracting submatrix from big.matrix object
I am using the library(bigmemory) to handle large datasets, say 1 GB,
and facing following problems. Any hints from anybody can be helpful.
_Problem-1:
_
I am using "read.big.matrix" function to create a filebacked big matrix
of my data and get the following warning:
> x =
read.big.matrix("/home/utkarsh.s/data.csv",header=T,type="double",shared=T,backingfile
2006 Aug 16
1
bwplot in loop doesn't produce any output
Hi,
running the following code by itself runs as expected.
----------------------------------------------------------------------------
k <- 1
i <- 2
j <- 3
NumName <- varnames[num.cols[k]]
FacNames <- varnames[fac.cols[c(i,j)]]
tmp <- paste(FacNames[1],NumName,sep="~")
fml <- formula(paste(tmp,FacNames[2],sep="|"))
bwplot(fml, data
2006 Oct 04
1
A more efficient code using whole object approach?
Dear All,
I have the following code which works fine but takes 16+ hours to run and I was hoping someone could give me a hint as to how I could make it more efficient.
Let me explain what the code is supposed to do. Each single row of the m.o.f matrix (n*p dim) has to go through the following operation Dm*m.o.f[i]^alpha1m where both Dm and alpha1m have n*1 dimensions. Each row of the m.o.f
2004 Oct 23
0
Re: FXTable -- numColumns & resize
On Fri, 22 Oct 2004 13:39:06 -0700, Bob Sidebotham <bob@windsong.bc.ca> wrote:
> In 1.2 FXTable, numColumns is documented as numCols, but should be
> numColumns, I think. Also the examples/table.rb app uses numCols, and
> should use numColumns.
Yes, you''re right. I''ve added both of these bugs to the FXRuby bug
list, found here:
2010 Apr 30
3
Why do data frame column types vary across apply, lapply?
Hi,
I still have little ability to predict how these functions will treat the
columns of data frames:
> # Here's a data frame with a column "a" of integers,
> # and a column "b" of characters:
> df <- data.frame(
+ a = 1:2,
+ b = c("a","b")
+ )
> df
a b
1 1 a
2 2 b
>
> # Except -- both columns are characters:
>
2007 Dec 06
0
alternatives to latex() or xtable()
An alternative solution that allows you to break it down by categories is in
the functions below. Comments/suggestions welcome and encouraged.
Note that much thanks is due to those who responded to an earlier post of
mine on a similar topic.
To use (assuming you have a data.frame falled pathDist with columns
distances (your numeric data of interest), Capacity, Surface, and SITE
(vectors of
2009 Feb 09
2
subsets problem
Help with this much appreciated
I have a large dataframe that I would like to subset where the constraint
Test1 <- subset(df, date == uniques[[1]]), where uniques is a list of dates
that must be matched to create Test1.
I would like to perform an operation on Test1 that results in a single
column of data. So far so good.
How do loop through all values in the uniques list (say
2010 Mar 30
1
Adding RcppFrame to RcppResultSet causes segmentation fault
Hi,
I'm a bit puzzled. I uses exactly the same code in RcppExamples
package to try adding RcppFrame object to RcppResultSet. When running
it gives me segmentation fault problem. I'm using gcc 4.1.2 on redhat
64bit. I'm not sure if this is the cause of the problem. Any advice
would be greatly appreciated. Thank you.
Rob.
int numCol=4;
std::vector<std::string>
2012 Dec 27
4
Finding (swapped) repetitions of numbers pairs across two columns
Hi,
I've had this problem for a while and tackled it is a quite dirty way
so I'm wondering is a better solution exists:
If we have two vectors:
v1 = c(0,1,2,3,4)
v2 = c(5,3,2,1,0)
How to remove one instance of the "3,1" / "1,3" double?
At the moment I'm using the following solution, which is quite horrible:
v1 = c(0,1,2,3,4)
v2 = c(5,3,2,1,0)
ft <-
2009 Mar 02
2
R-code help for filtering with for loop
Dear Sir / Madam,
I am new for R coding. Kindly help me out in sorting out the following problem.
There are 50 rows with six coloumns(you could see in the attached .txt file). I
wish to go for filtering this 50 rows for any one of the six coloumns
satisfying the value >= 64.
I need to have a final table with rows having >= 64 value in any one of the six
coloumns and the rest could be
2010 Feb 17
1
lapply to apply a function using a vector
Hi,
First, thank you all for your help.
Here is my problem (simplified):
Say I have a list:
a=list(matrix(50,nrow=5,ncol=5),matrix(25,nrow=5,ncol=5),matrix(10,nrow=5,ncol=5))
I'd like to use rbinom with a different probability for each matrix. I
tried:
b=c(.8,.1,.9)
brep=rep(b,each=25)
lapply(a,function(a) rbinom(25,a,brep))
but that doesn't work-- it just uses the first value of b
2011 Apr 09
1
For->lapply->parallel apply
Dear all,
I would like to ask your help understand the subsequent steps for making my program faster.
The following code:
Gauslist<-array(data=NA,dim=c(dimx,dimy,dimz))
for (i in c(1:dimz)){
print(sprintf('Creating the %d map',i));
Gauslist[,,i]<-f <- GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha))
}
creates 100 GaussMaps (each
2004 Nov 16
0
From S-Plus to R
Dear Isabelle,
for most of my work I have switched from S-Plus to R, because it is
easier to make scripts with due to the better documentation and some
other more reasonable implementations. And there was also a cost
issue with the S-Plus Server, which is not for free at all.
In R I use the its package for time series, which is quite sufficient
for my needs. The only problem I encountered was
2013 Mar 10
2
list + lapply insead of matrix + apply
I need to develop a simple list manipulation. Although it seems easier to
do it in matrix form, but I need it in list form.
I have a matrix
x <- matrix(c(12.1, 3.44, 0.1, 3, 12, 33.1, 1.1, 23), nrow=2)
for list form example, the conversion is
x.list <- lapply(seq_len(nrow(x)), function(i) x[i,])
### list version
calcnorm=function(a, b){
diff <- mapply("-", a, b)
2012 Jun 07
1
select subrows based on a specific column in a matrix
Hi all,
I have a matrix with 10000 rows and 10 columns. The last columns contains another identifiers but the values are not uniques so that I want to generate another matrix with rows with unique values in the last column.
If I did
tmp<-unique(my_mat$col10)
this will give me 8560 unique entries so the ideal matrix will be 8560X10 columns now then.
I tried
sub_mat<-my_mat[tmp,]
but
2007 Jul 30
2
apply, lapply and data.frame in R 2.5
Hello everyone,
A recent (in 2.5 I suspect) change in R is giving me trouble. I want
to apply a function (tolower) to all the columns of a data.frame and
get a data.frame in return.
Currently, on a data.frame, both apply (for arrays) and lapply (for
lists) work, but each returns its native class (resp. matrix and list):
apply(mydat,2,tolower) # gives a matrix
lapply(mydat,tolower) # gives
2010 Jul 13
2
Checking for duplicate rows in data frame efficiently
I wrote something to check for duplicate rows in a data frame, but it is too inefficient. Is there a way to do this without the nested loops?
This code correctly indicates rows 1-7, 1-8, 2-9 and 7-8 are duplicates.
> m <- matrix(c(1,1,1,1,1, 2,2,2,2,2, 6,6,6,6,6, 3,3,3,3,3, 4,4,4,4,4, 5,5,5,5,5, 1,1,1,1,1, 1,1,1,1,1, 2,2,2,2,2, 7,7,7,7,7), ncol=5, byrow=TRUE)
> df <- data.frame(m)
2018 Mar 01
0
how to simplify FP ops with an undef operand?
We can do "add %x, undef" => "undef" because for any value of %x, we can
always find a value that when added to %x produces any value in the domain
of integers.
This is not the case with floats since with some inputs, e.g., NaNs, we are
not able to produce some values in the domain (e.g., there's no value of %x
that makes "fadd NaN, %x" return 42.0).
In