Displaying 20 results from an estimated 10000 matches similar to: "summary statistics for lists of matrices or dataframes"
2005 Mar 16
8
Summing up matrices in a list
Dear all,
I think that my question is very simple but I failed to solve it.
I have a list which elements are matrices like this:
>mylist
[[1]]
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
[[2]]
[,1] [,2] [,3]
[1,] 7 9 11
[2,] 8 10 12
I'd like to create a matrix M<-mylist[[1]]+mylist[[2]]
[,1] [,2] [,3]
[1,] 8 12 16
[2,] 10 14 18
2006 Nov 17
2
do.call("+", ...)
Hi
How do I make do.call() take "+" as a function for a list of more
than two elements?
Toy problem follows:
f <- function(i){matrix((1:6)^i,2,3)}
# Thus f() returns a matrix of size 2x3; I want to add a whole bunch
of such matrices,
# as in f(1) + f(2) + f(3) + f(4)
# But:
> do.call("+",sapply(1:4,f,simplify=FALSE))
Error in do.call("+",
2008 Jun 04
4
sum of unknown number of matrices
Hi R,
I have a list of matrices. I need to get the sum of all the matrices in
the list.
Example:
a=b=c=d=matrix(1:4,2,2)
l=list(a,b,c,d)
I need:
> a+b+c+d
[,1] [,2]
[1,] 4 12
[2,] 8 16
Something like do.call("+",l) is not working...why is this?
I may not be knowing the number of matrices in the list...
Thanks, Shubha
This e-mail
2006 Jun 14
2
Package naming best practices
R-devel,
I'm in the process of choosing a name for a new package. I've already
decided that the name will have two parts, 'portfolio' and 'sim', but
can't decide between 'portfolioSim' and 'portfolio.sim'. Is there any
good reason to choose one over the other?
Thanks in advance,
Jeff
--
Jeff Enos
Kane Capital Management
jeff at kanecap.com
2010 Jan 09
4
parsing pdf files
I have a pdf file that I would like to parse into R:
http://www.williams.edu/Registrar/geninfo/faculty.pdf
For now, I open the file in Acrobat by hand, then save it "as text"
and then use readLines(). That works fine but a) I am concerned that
some information may be lost and b) I may be doing this a lot, so I
would rather have R grab the information from the pdf file directly.
So: is
2004 Sep 15
5
replacing NA's with 0 in a dataframe for specified columns
I know that there must be a cool way of doing this, but I can't think
of it. Let's say I have an dataframe with NA's.
> x <- data.frame(a = c(0,1,2,NA), b = c(0,NA,1,2), c = c(NA, 0, 1, 2))
> x
a b c
1 0 0 NA
2 1 NA 0
3 2 1 1
4 NA 2 2
>
I know it is easy to replace all the NA's with zeroes.
> x[is.na(x)] <- 0
> x
a b c
1 0 0 0
2 1 0 0
3 2 1
2010 Aug 26
3
reliability of R-Forge?
How reliable is R-Forge? http://r-forge.r-project.org/
It is down now (for me). Reporting "R-Forge Could Not Connect to Database: "
I have just started to use it for a project. It has been down for
several hours (at least) on different occasions over the last couple
of days. Is that common? Will it be more stable soon?
Apologies if this is not an appropriate question for R-help.
Dave
2010 Aug 26
3
reliability of R-Forge?
How reliable is R-Forge? http://r-forge.r-project.org/
It is down now (for me). Reporting "R-Forge Could Not Connect to Database: "
I have just started to use it for a project. It has been down for
several hours (at least) on different occasions over the last couple
of days. Is that common? Will it be more stable soon?
Apologies if this is not an appropriate question for R-help.
Dave
2009 Mar 27
2
adding matrices with common column names
folks,
if i have three matrices, a, b, cc with some colnames in common, and i
want to create a matrix which consists of the common columns added up,
and the other columns tacked on, what's a good way to do it? i've got
the following roundabout code for two matrices, but if the number of
matrices increases, then i'm a bit stymied.
> a <- matrix(1:20,ncol=4); colnames(a) <-
2006 Aug 28
1
Affiliation Reporting Standards. was: Re: reshape scaling with large numbers of times/rows
After a question on R, Prof Brian Ripley writes:
> However, you did not give your affiliation and I do not like giving free
> consultancy to undisclosed commercial organizations. Please in future use
> a proper signature block so that helpers are aware of your provenance.
I have one question and one comment.
Question: Are there specific standards about this for R mailing lists?
I
2005 Nov 01
4
S4 classes in existing packages
R-devel,
I'm interested in looking at some examples of existing R packages that
rely heavily on S4 classes to get a feel for varying styles and
package organization techniques. Could you recommend any packages
that might serve as a good starting point?
Thanks in advance,
Jeff
2005 Nov 01
4
S4 classes in existing packages
R-devel,
I'm interested in looking at some examples of existing R packages that
rely heavily on S4 classes to get a feel for varying styles and
package organization techniques. Could you recommend any packages
that might serve as a good starting point?
Thanks in advance,
Jeff
2009 Dec 15
1
R question type in Moodle
Moodle (www.moodle.org) is an open source course management system, a
competitor to Blackboard. I am writing several hundred R questions
that will be used within the quiz module in Moodle. Unfortunately,
Moodle does not have a built in question type for R. You can read
about the different questions types in Moodle here:
2013 May 03
2
Declare a set (list?) of many dataframes or matrices
Hi,
I would like to read several datasets and would like to create a set
(list? sequence?) of many empty dataframes. How could this be done? How
could I declare a set (list? sequence?) of many empty matrices?
Thanks,
Miao
[[alternative HTML version deleted]]
2002 Apr 30
3
rbind'ing empty rows in dataframes in 1.4.1 versus 1.5.0
Hi,
In 1.4.1, I was able to create extra "empty" rows in a dataframe as so:
> x <- data.frame(a = letters[1:3], b = 1:3)
> x
a b
1 a 1
2 b 2
3 c 3
> x[4,]
a b
NA NA NA
> rbind(x, x[4,])
a b
1 a 1
2 b 2
3 c 3
NA NA NA
> R.version
_
platform sparc-sun-solaris2.6
arch sparc
os solaris2.6
2009 Dec 11
1
Sources for open sourced homework questions for R?
Hi,
I am teaching a one month class in applied statistics and want to
bring my students up to speed in R without devoting much/any lecture
time to R instruction. I think that the best way to do this is to
provide them with a lot of R questions for homework. These questions
would be numerous (there is a lot of material to cover), go from very
simple to somewhat complex, and focus on all the
2008 Aug 13
3
issue building dataframes with matrices.
Hello,
Is this a bug or a feature? I am using R 2.7.1 on Apple OS X.
> y <- matrix(1:3,nrow=3) # y is a single-column matrix
> df <-data.frame(x=1:3,y=y)
> sapply(df,data.class)
x y
"numeric" "numeric"
> df$yy <- y
> sapply(df,data.class)
x y yy
"numeric" "numeric" "matrix"
2003 Aug 11
4
subscripts in lists
I am tying myself in knots over subscripts when applied to lists
I have a list along the lines of:
lis<-list(c("a","b","next","want1","c"),c("d", "next", "want2", "a"))
>From which I want to extract the values following "next" in each
member of the list, i.e. something along the lines of
2010 Nov 24
3
apply over list of data.frames
R users,
This probably involves a simple incantation of one of the flavors of apply... that I can't yet figure out. Consider a list of data frames. I'd like to apply a function (mean) across the list and return a dataframe of the same dimensions where each cell represents the mean of that cell across all dataframes.
# set up the list
x <- vector("list",2)
names(x) <-
2006 Apr 05
5
List to Array
Hi,
this is probably the easiest thing to do but I manage
not finding the answer:
I have a list with matrices of exact same format and
headers. Now I would like to transform the list into
an normal array. What is the proper way to do this?
as.array changes the entire format and right now I
only found the method of creating a new array, going
through the entire list and copy the matrix in each