similar to: collapsing list to data.frame

Displaying 20 results from an estimated 10000 matches similar to: "collapsing list to data.frame"

2008 Mar 05
3
types of vectors / lists
Hello, I am an advanced user of R. Recently I found out that apparently I do not fully understand vectors and lists fully Take this code snippet: T = c("02.03.2008 12:23", "03.03.2008 05:54") Times = strptime(T, "%d.%m.%Y %H:%M") Times # OK class(Times) # OK is.list(Times) # sort of understand and not understand that length(Times)
2007 Feb 22
3
List filtration
Hello R-ologists, Imagine you have a list "list" like so: >list [[1]] [1] "IPI00776145.1" "IPI00776187.1" [[2]] [1] "Something" "IPI00807764.1" "IPI00807887.1" [[3]] [1] "IPI00807764.1" [[4]] [1] "Somethingelse" What I need to achieve is a filtered list "list2" like so: >list2 [[1]] [1]
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("+",
2007 Apr 03
5
converting a list to a data.frame
Hello, I have a list with n numerical components of different length (3, 4 or 5 values in each component of the list); I need to export this as a text file where each component of the list will be a row and where missing values should fill in the blanks due to the different lengths of the components of the list. I think that as a first step I should convert my list to a data frame, but this is
2008 May 12
2
Collection of lm()s
Hello, I would like to create a subscriptable collection (presumably a list) of lm() models. I have a data frame DX containing 6 groups of data. The general idea is (NOT RUN) ... for (i in 1:6) { DXS = subset( DX, <whatever>); LMX[ i] = lm( <formula>, data = DXS); } Now access model results by subscript ... e.g. coefficients( LMX[ 2]). Or would it be [[ 2]]? I
2004 Jun 25
3
String manipulation
Hi, let's see, if someone can help my with this one: I have the string as follows: > str<-("one","two","three") Now I want to concatenate the items to one string, seperateted by space or something else, >str >"one, two, three" If possible without a loop. My actual goal ist to create string like >str.names >"female = names1, male
2007 Dec 08
2
Function to tell you how an object is put together
Question: Suppose I have an arbitrary object. Is there a function which will accept the object as an argument and sort of give the format of the object, how it is put together, etc.? The analysis would include the attributes and the names of the attributes. Also, things like whether or not the object is an array; whether or not it is a matrix, etc. Tom Jones
2005 Jan 26
2
string evaluation
Hello, I would like to be able to compose an expression using some of the arguments I give to a function, that is assuming I have a list such as: my.list<-list(A=1:3,B=c("Brave", "new", "world")) and a function printComponent<-function(component){ if (component=="A"||component=="B"){
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
2005 May 10
4
summary statistics for lists of matrices or dataframes
Is there a simple way to calculate summary statistics for all the matrices or dataframes in a list? For example: > z <- list(matrix(c(2,2,2,2), ncol = 2), matrix(c(4,4,4,4), ncol = 2)) > z [[1]] [,1] [,2] [1,] 2 2 [2,] 2 2 [[2]] [,1] [,2] [1,] 4 4 [2,] 4 4 > I would like to calculate, for example, the mean value for each cell. I can do that the hard
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
2007 Jan 21
5
Integration + Normal Distribution + Directory Browsing Processing Questions
Hi everyone, I am new to R, but it's really great and helped me a lot! But now I have 2 questions. It would be great, if someone can help me: 1. I want to integrate a normal distribution, given a median and sd. The integrate function works great BUT the first argument has to be a function so I do integrate(dnorm,0,1) and it works with standard m. and sd. But I have the m and sd given.
2005 Feb 17
3
A vector or array of data frames
Hi A simple question again, but I can't find it by google-ing R-help. Quite simply, I want to read in the contents of a number of files, using read.table, and assign the results to elements of a vector/array/list/whatever. I want it so that, if my vector/array/whatever is "pos", that pos[1] will give me the first data frame, pos[2] will give me the second etc... Kind of basic
2006 Sep 12
4
variables in object names
Is there any way to put an argument into an object name. For example, say I have 5 objects, model1, model2, model3, model4 and model5. I would like to make a vector of the r.squares from each model by code such as this: rsq <- summary(model1)$r.squared for(i in 2:5){ rsq <- c(rsq, summary(model%i%)$r.squared) } So I assign the first value to rsq then cycle through models 2 through
2008 Mar 30
2
Alignment and Reshaping of the matrix
Dear R users, I have a matrix like 85 .90 86 .89 87 .98 86 .87 88 .98 90 .78 88 .76 89 .56 90 .67 95 .67 89 .89 90 .87 91 .56 96 .87 90 .76 92.98 each pair of columns present a variable name and next the value. I have matrix with more than 500 rows and column. Now I want to convert this matrix in to. 85 .90 00 .00 00 86 .00 .89 .00 .87 87 .00 00 .98 00 88 .98 00 .76
2004 Sep 08
3
do.call("[", ...) question
Hi again everyone I have an arbitrarily dimensional array "a" and a list "jj" of length length(dim(a)). The elements of jj are vectors of indexes. How do I use do.call() to extract a[ jj[[1]], jj[[2]], jj[[3]], ...] ? Toy example follows: a <- matrix(1:30,5,6) jj <- list(5:1,6:1) I want the following a[ jj[[1]],jj[[2]] ] How do I do this? OBAttempts:
2005 Jan 06
2
Generating Data mvrnorm and loops
Dear List: I am generating N datasets using the following Sigma<-matrix(c(400,80,80,80,80,400,80,80,80,80,400,80,80,80,80,400),4,4 ) mu<-c(100,150,200,250) N=100 for(i in 1:N) { assign(paste("Data.", i, sep=''), as.data.frame(cbind(seq(1:1000),(mvrnorm(n=1000, mu, Sigma))))) } With these datasets, I need to work on some of the variables and then run each dataset
2005 Feb 10
3
Using a number as a name to access a list
Hi Dumb question time again, for which I apologise. I have a variable that contains the following numerical text "04010". This is the name to access a list: > as.list(KEGGPATHID2NAME)$"04010" [1] "MAPK signaling pathway" Marvellous! Except I want to do that when "04010" is assigned to a variable called path and I can't figure out how to do it!
2005 Feb 03
5
How to convert a list to a matrix
Hi Sorry to ask such a basic question. I have a list, each element of which is a vector of two values. What I actually want is a matrix with two columns, and one row per element of the list. Obviously I have tried as.matrix(), and as.vector() but I didn't expect the latter to work. I feel so lame asking this. Any suggestions? Mick