Displaying 20 results from an estimated 10000 matches similar to: "Retain names in conversion of matrix to vector"
2011 Apr 15
2
adding a name to cross tab margins
Listers,
I have created a cross-tab matrix using the following code:
S <-
c(1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,1,2,3,1,1,2,3,1,2,2)
F <-
c(1,2,3,1,2,3,1,1,1,1,2,3,1,1,3,2,2,2,1,2,3,1,1,1,1,2,3,3,1,3,1,3,1,1,2,3,1,1,3,2,3,2,1,1,1,2,3,1,1,2)
table(S,F)
fF <-factor(F, labels = c("Dem","Ind","Rep"))
fS <-factor(S,
2014 Jun 13
2
Crear matriz binaria
Hola,
Estoy tratando de crear una matriz cuadrada, binaria y no tengo idea por dónde comenzar.
Los datos que tengo son patentes e inventores por patente, las patentes las identifico por su código y a los inventores por nombre y también los tengo codificados.
Deseo hacer una matriz de nxn en donde los renglones son inventores de la A a la Z y columnas son los mismos inventores de la A a la Z,
2009 Feb 02
1
Assigning colnames in loop
Dear R-listers,
I am trying to assign colnames to a data frame within a loop, but I keep
getting a "target of assignment expands to non-language object"-error. I
need to split up a large dataset into about 20 smaller ones, and I would
like to assign colnames within the loop, so I won't have to type the
same thing 20 times over.
I have concocted this really goofy example which
2011 Apr 06
1
Error in match.names(clabs, names(xi))
Hi Guys,
I have this part of a program:
library(survival)
Gastric <- cbind.data.frame(Gp=c(rep(1,45),rep(0,45)), ### 2nd gp 0
time=c(1,63,105,129,182,216,250,262,301,301,342,354,356,358,
380,383, 383,388,394,408,460,489,499,523,524,535,562,569,675,676,
748,778,786,797,955,968,1000,1245,1271,1420,1551,1694,2363,2754,2950,
2014 Jun 13
2
Crear matriz binaria
Hola, no encuentro el momento en el que se relacionan los inventores, es decir, lo que relaciona a dos o más inventores es la patente.
Primero, ¿cómo debo ordenar los datos?
Tengo 1813 número de patentes, es decir, la matriz es de dimension 1813 x 1813.
Tengo varios órdenes en los datos, por ejemplo, el primer arreglo es por patente, en las columnas tengo ?no. de patente?, ?inventor 1?,
2008 Dec 03
1
Create unique sets of 3 from a vector of IDs?
Dear all:
This is one of those "should be easy" problems that I'm having great difficulty solving. I have a vector containing ID codes, and I need to generate a 3-column matrix that contains all possible combinations of three.
For example, my ID vector looks like this:
A
B
C
D
E
I need to generate a matrix that looks like this:
A B C
A B D
A B E
A C B
A C D
A C E
A D B
A D C
A D E
2004 Dec 12
2
Help : generating correlation matrix with a particular structure
Hi,
I would like to generate a correlation matrix with a
particular structure. For example, a 3n x 3n matrix :
A_(nxn) aI_(nxn) bI_(nxn)
aI_(nxn) A_(nxn) cI_(nxn)
aI_(nxn) cI_(nxn) A_(nxn)
where
- A_(nxn) is a *specified* symmetric, positive
definite nxn matrix.
- I_(nxn) is an identity matrix of order n
- a, b, c are (any) real numbers
Many attempts have been unsuccessful because a
2016 Mar 03
2
as.vector in R-devel loaded 3/3/2016
I just installed R-devel to check my package before submitting. I got an
error in my vignette in regards to as.vector. When I looked at the code
for as.vector in R-devel it is
standardGeneric for "as.vector" defined from package "base"
function (x, mode)
standardGeneric("as.vector")
<environment: 0x0918ad70>
Methods may be defined for arguments: x, mode
Use
2005 Apr 28
1
strange behaviour of importFrom directive in name space
Dear listers,
After activating the name space for my bioconductor package (prada) I
successfully ran R CMD check. However when loading the package in R and
running the examples the imported function brewer.pal from package
RColorBrewer is not found. I can directly call brewer.pal from the
RColorBrewer name space typing RColorBrewer::brewer.pal, but it is not
imported into my prada name space. When
2005 Apr 28
1
strange behaviour of importFrom directive in name space
Dear listers,
After activating the name space for my bioconductor package (prada) I
successfully ran R CMD check. However when loading the package in R and
running the examples the imported function brewer.pal from package
RColorBrewer is not found. I can directly call brewer.pal from the
RColorBrewer name space typing RColorBrewer::brewer.pal, but it is not
imported into my prada name space. When
2006 Feb 07
1
matching tables
Dear Listers,
I am trying to match tables that DO NOT have the same length. The
tables result from the function "table()" so they look like this:
table 1
2 3 4
3 5 7
table 2
1 2 3
6 4 5
I need the following output: (NOTICE THE ZEROS)
1 2 3 4
table1 0 3 5 7
table2 6 4 5 0
Unfortunately, I was not successful using "match()". Previous postings
explain how to do
2007 Jun 12
4
pretty report
Dear Listers:
I have a couple of data frames to report and each corresponds to
different condtions, e.g. conditions=c(10, 15, 20, 25). In this
examples, four data frames need to be exported in a "pretty" report.
I knew Perl has some module for exporting data to Excel and after
googling, I found R does not.
So I am wondering if there is a package in R for generating good
reports. I
2008 Aug 18
2
matrix row product and cumulative product
I spent a lot of time searching and came up empty handed on the
following query. Is there an equivalent to rowSums that does product or
cumulative product and avoids use of apply or looping? I found a rowProd
in a package but it was a convenience function for apply. As part of a
likelihood calculation called from optim, I?m computing products and
cumulative products of rows of matrices with
2009 Feb 11
4
Efficent way to create an nxn upper triangular matrix of one's
The code below create an nxn upper triangular matrix of one's. I'm
stuck on finding a more efficient vectorized way - Thanks. --Dale
n <- 9
data <- matrix(data=NA, nrow=n, ncol=n)
data
for (i in 1:n) {
data[,i] <- c(rep(1,i), rep(0,n-i))
}
data
2009 Jan 19
3
download/retain text file structure with RCurl/getURL()
Dear list,
I'm trying to download a text file directly from the internet using the RCurl package and the command getURL. Duncan Lang graciously helped me solve the first step in this problem using the following command:
#################
txtfile <- getURL('ftp://ftp.wcc.nrcs.usda.gov/data/snow/snow_course/table/history/idaho/13e19.txt',
ftp.use.epsv = FALSE)
#################
2008 Oct 29
2
behavior of "by"
Any insight into the behavior of "by" in the following case would be
appreciated. There is a note in the help details for "by" about
documenting behavior since v2.7 but I don't entirely understand what it
is saying. I'm using R2.7.2 Windows. I'm interested if the following
behavior was a change or whether it has always worked this way. I
looked at
2009 Aug 21
4
help with median for each row
Hi,
I tried looking through google search on whether there's a way to computer
the median for each row of a nxn matrix and return the medians for each row
for further computation.
And also if the number of columns in the matrix are even, how could I
specify which median to use?
Thank you very much!
--
Edward Chen
[[alternative HTML version deleted]]
2006 Oct 22
1
how to convert multiple dummy variables to 1 factor variable?
Dear Listers,
I am wondering how to convert multiple dummy variables to 1 factor variable.
Thanks.
wensui
2006 Jul 04
5
removing for loop
Dear Rusers,
Trying to reduce my for loops addiction,
could somebody tell me if there are ways to simplify
(and perhaps accelerate ?) the following line
for (i in 1:N) for (j in 1:N) m[i,j] = b[i]-b[j];
(where m is a NxN matrix and b a vector of length N)
Thanks for any hint.
2004 Mar 29
9
Aggregating frequency of irregular time series
> S-Plus has the function AggregateSeries() whose name is self
> explanatory. For instance one can derive monthly series from daily
> ones by specifying end-of-period, averages, sums, etc. I looked for
> a similar function in the packages "its" and "tseries", but found
> nothing. I also help.searched() for aggregate to no avail. Would
> anybody be so kind