Displaying 20 results from an estimated 4000 matches similar to: "select element from each row of the matrix"
2011 Aug 10
1
rbind/cbind
Dear list,
I wonder if there a better way to have rbind/cbind/append to create
the first element (if it is empty) instead of doing the following in a
loop?
for (i in 1:10) {
if (i == 1) {
aRow = SomeExpression(i)
} else {
aRow = rbind(aRow,SomeExpression(i))
}
}
Thanks
Anthony
2008 Jun 05
7
Improving data processing efficiency
Hi everyone!
I have a question about data processing efficiency.
My data are as follows: I have a data set on quarterly institutional
ownership of equities; some of them have had recent IPOs, some have not
(I have a binary flag set). The total dataset size is 700k+ rows.
My goal is this: For every quarter since issue for each IPO, I need to
find a "matched" firm in the same
2010 Aug 02
1
Multibyte characters in (row) names
I have an array with names which contain multibyte characters. ?When I try to
write the array to a file using write.table and row.names = T I receive an error
message when the first such name is encountered, saying that I have not
specified the option to generate NA instead. ?I really would be satisfied if the
row name in the file were exactly what is displayed when I print the array on
the
2011 Jan 14
1
Help on a Display function
>
I wanted to simulate the Matlab DISPLAY function for some time now.
After seeing a recent proposal by Gabor Grothendieck I came up with the
following solution,
display <- function(...) {
my_names <- lapply(substitute(placeholderFunction(...))[-1], deparse)
for (my in my_names) cat(my, "=", eval(parse(text=my)), "\n", sep=" ")
}
that works about as
2009 May 14
3
memory usage grows too fast
Hi All,
I have a 1000x1000000 matrix.
The calculation I would like to do is actually very simple: for each row, calculate the frequency of a given pattern. For example, a toy dataset is as follows.
Col1 Col2 Col3 Col4
01 02 02 00 => Freq of ?02? is 0.5
02 02 02 01 => Freq of ?02? is 0.75
00 02 01 01 ?
My code is quite simple as the following to find the pattern ?02?.
2008 Nov 24
3
select a subset
I have the complete data like
id time censor
1 10 0
1 20 0
1 30 0
2 10 0
2 20 1
2 30 0
2 40 0
3 10 0
3 20 0
3 30 1
....
for id 1, i want to select the last row since all censor indicator is 0; for
id 2, i want to select the row where censor ==1; for id 3, i also want to
select the row where censor==1. So if there is a 1 for censor, then I want
to select such a row, otherwise I want to select the
2009 Jan 02
7
the first and last observation for each subject
I have the following data
ID x y time
1 10 20 0
1 10 30 1
1 10 40 2
2 12 23 0
2 12 25 1
2 12 28 2
2 12 38 3
3 5 10 0
3 5 15 2
.....
x is time invariant, ID is the subject id number, y is changing over time.
I want to find out the difference between the first and last observed y
value for each subject and get a table like
ID x y
1 10 20
2 12 15
3 5 5
......
Is there any easy way to generate
2010 Apr 22
4
how to select the first observation only?
Dear r-helpers,
I have a very simple question. Suppose my data is like
id=c(rep(1,2),rep(2,2))
b=c(2,3,4,5)
m=cbind(id,b)
> m
id b
[1,] 1 2
[2,] 1 3
[3,] 2 4
[4,] 2 5
I wish to select the first observation for each id. That is, I want to
quickly select two rows:
id b
1 2
2 4
only. how should i do this?
[[alternative HTML version deleted]]
2009 Mar 20
1
CCA - manual selection
Hello,
I am trying to obtain f-values for response (independent) variables from a
CCA performed in vegan package, to see which ones of them have
significative influence in my dependent variables (like the manual selection
in canoco), but I can't find any function (or package) that do such a thing.
The dependents variables are species data, and the independents are
ambiental data.
Than you.
2019 Jul 30
2
LLVM Build Error: Target object too big
While trying to assemble a particular input file, my build system failed because
the target object was too big. I calculated that the input source file after
preprocessing would be about 3.91Mb.
system: CYGWIN_NT-10.0 x86_64 Cygwin
file: llvm-master/lib/Passes/PassBuilder.cpp
build output:
Scanning dependencies of target LLVMPasses
[ 84%] Building CXX object
2008 Jun 06
6
Subsetting to unique values
I want to take the first row of each unique ID value from a data frame.
For instance
> ddTable <-
data.frame(Id=c(1,1,2,2),name=c("Paul","Joe","Bob","Larry"))
I want a dataset that is
Id Name
1 Paul
2 Bob
> unique(ddTable)
Will give me all 4 rows, and
> unique(ddTable$Id)
Will give me c(1,2), but not accompanied by the name column.
2012 Jan 30
1
Quantum scalar i40 tape partitions
Hi All,
I have a Quantum scalar i40 tape library. I need to configure it to TWO tape partition libraries, e.g., library_a and library_b, so that each library has its own tape drive. Then connect this physical tape library to two different CentOS servers so that each server can see its own media changer and tape drive. I once had a successful configuration on one host but NOT on the other. One
2004 Nov 25
4
Avoiding for-loops
Hello R-users,
I have a symmetric matrix of numerical values and I
want to obtain those values in the upper or lower
triangle of the matrix in a vector. I tried to do the
job by using two for-loops but it doens't seem to be a
clever way, and I'd like to know a more efficient code
for a large matrix of thousands of rows and columns.
Below is my code for your reference.
Thanks a lot.
2009 Jan 29
2
Taking the min of each row in a matrix
Hi,
I'm a new user. I've been reading through the manual and looking at
various examples but am still trying to make sense of the most
efficient ways to handle matrices of data.
If I have a 2D matrix of data, how do I get the mean, min, max value
of each row? I see the "mean" function on a matrix will give me
averages by row, but min and max give me the value for the entire
2010 Apr 23
2
Matrix diagonal help
Hi
Suppose I have a matrix (cohort are rows and years are columns)
[2000] [2001] [2002] [2003]
[C1] 0.01 0.03 0.02 0.09
[C2] 0.06 0.05 0.07 0.11
[C3] 0.1 0.5 0.4 0.98
[C4] 0.7 0.6 0.2 0.77
I want to extracts the diagonals to get a matrix which looks like this (C1
becomes C2 in 2002, C2 becomes C3 in 2003
2005 May 19
14
R annoyances
Dear R Folks,
I'm a big fan of R, but there are a couple of things
that repeatedly annoy me, and I wondered if anyone
has neat ways to deal with them.
(a) When using "apply" row-wise to a matrix, it returns
the results column-wise, and to preserve the original
orientation, I've to do a transpose. E.g. I've to keep
doing a transpose, which I consider to be quite
2008 Mar 13
3
Overland Arcvault 12 and sequential/random settings
My unit's firmware: library 05.03, tape d22h, shows the device as set to
random mode. But mtx -f /dev/st0 status gives an error that google says
the device is in sequential mode. dmesg|grep -i hp does reflect CentOS
thinks the device is a sequential unit.
I've tried this with Fedora 8, too, and both show the same, so it is
either an issue with CentOS/Fedora RPMs, or the version of
2005 Feb 23
1
H-F corr.: covariance matrix for interaction effect
Hi,
I'm still not quite there with my H-F (G-G) correction code. I have it
working for the main effects, but I just can't figure out how to do it
for the effect interactions. The thing I really don't know (and can't
find anything about) is how to calculate the covariance matrix for the
interaction between the two (or even n) main factors.
I've looked through some books
2005 Feb 23
1
H-F corr.: covariance matrix for interaction effect
Hi,
I'm still not quite there with my H-F (G-G) correction code. I have it
working for the main effects, but I just can't figure out how to do it
for the effect interactions. The thing I really don't know (and can't
find anything about) is how to calculate the covariance matrix for the
interaction between the two (or even n) main factors.
I've looked through some books
2004 Nov 02
3
n-th power of a matrix
Hello all,
To calculate the power of a matrix, I used the command "mtx.exp(X, n)", but
there is an error saying "Error: couldn't find function "mtx.exp"". How can
I deal with this problem?
Jing