similar to: Can't convert list to matrix properly

Displaying 20 results from an estimated 6000 matches similar to: "Can't convert list to matrix properly"

2010 Mar 26
5
smart way to turn a vector into a matrix
Hello guys, I am working on a matrix which looks like this one: > initialMatrix <- > rbind(cbind(rep("A",3),seq(1,3)),cbind(rep("B",4),seq(1,4)),cbind(rep("C",3),seq(1,3))) > initialMatrix [,1] [,2] [1,] "A" "1" [2,] "A" "2" [3,] "A" "3" [4,] "B" "1" [5,]
2004 Nov 01
5
make apply() return a list
Hi, I have a dataframe (say myData) and want to get a list (say myList) that contains a matrix for each row of the dataframe myData. These matrices are calculated based on the corresponding row of myData. Using a for()-loop to do this is very slow. Thus, I tried to use apply(). However, afaik apply() does only return a list if the matrices have different dimensions, while my matrices have
2012 Mar 20
1
Remove individual rows from a matrix based upon a list
Dear All, Thanks in advance for any help. I have a square matrix of measures of interactions among individuals and would like to calculate a values from a function (colSums for example) with a single individual (row) excluded in each instance. That individual would be returned to the matrix before the next is removed and the function recalculated. I can do this by hand removing rows based upon
2010 Mar 03
5
filtering signals per day
Hello R lovers, I have a vector of dates and signals. I want to filter the signals per day in a way that only the first signal of the day remains like this: Dates Signals Filtered Signal 2006-11-02 0 0 2006-11-02 1 1 2006-11-02 0 0 2006-11-02 1 0 2006-11-02 1
2010 Mar 25
4
Convert number to Date
Hello, I have a date value in excel: 1/4/2010 which in number format gives me 40182. When I read this with read.xls from R I get same 40182 so what I do is that I use the as.Date() function but here is what the as.Date() function returns me: > as.Date(40182) [1] "2080-01-06" Why don't I get the same thing as in excel? Thanks! ----- Anna Lippel -- View this message in context:
2010 Jan 29
7
Simple question on replace a matrix row
Hello, I have a matrix mat1 of dim [1,8] and mat2 of dim[30,8], I want to replace the first row of mat2 with mat1, this is what I do: mat2[1,]<-mat1 but it transforms mat2 in a list I don't understand, I want it to stay a matrix... ----- Anna Lippel -- View this message in context: http://n4.nabble.com/Simple-question-on-replace-a-matrix-row-tp1427857p1427857.html Sent from the R help
2010 Apr 05
1
Deleting many list elements in one time
Hi guys, here is a simple thing I want to do but it doesn't work: I have a vector of the element indexes that I want to delete called index so when I write myList[[index]] <- NULL to delete these elements here is what I get: Error in myList[[index]] <- NULL : more elements supplied than there are to replace Isn't it possible to delete multiple elements? ----- Anna Lippel --
2010 Jan 29
3
Applying a function on each columns of a matrix
Hello everyone, I have the following matrix [,1] [,2] [,3] [,4] [1,] 0.002809706 0.0063856960 0.0063856960 0.011749681 [2,] 0.004893124 0.0023118418 -0.0005122951 -0.014646465 [3,] 0.003547897 0.0063355297 0.0030410542 0.011403953 [4,] 0.004838299 -0.0040383645 -0.0090406831 -0.011027569 [5,] 0.035648755 0.0334815590 0.0380977404
2010 Feb 12
3
Code working but too slow, any idea for how to speed it up ?(no loop in it)
Hello my friends, here is a code I wrote with no loops on matrix that is taking too long (2 seconds and I call him 720 times --> 12 minutes): mat1 and mat2 are both matrix with 103 columns and 164 rows. sequence <- matrix(seq(1 : ncol(mat1))) returns <- apply(sequence, 1, function, mat1= mat1, mat2 = mat2, day = 1) function<- function(mat1, mat2, colNb, day){
2010 Apr 19
2
Using split and then unsplit
Hello everyone, I use the split function splitting with the f function on a 3 columns and more than 100 000 rows data frame. Once it's split I have a list of data frames still with 3 columns and n rows. I manipulate those list elements and get a list of data frames still with 3 columns but less rows. So when I unsplit it, I get an error as I use the same factor function I used to split ( f in
2012 Sep 11
5
Searching from Dataframe.
Hi, i have a dataframe containing some values. for eg:- MyDataFrame<- Name Age Place ------- ------ ----------- Aby 12 USA Raj 25 UK Romi 32 ENG Amy 31 IND My requirement what is, i have a search key word[it should search from all the columns], that i need to find out from this dataframe. If search keyword found , it
2010 Feb 02
2
Retrieve distinct values within a whole data frame
Hello everyone, I am trying to retrieve the list of distinct values within a whole data frame. I tried to use unique() function but it retrieves the distinct values within each column or row, I want it for the entire data frame, any idea? ----- Anna Lippel -- View this message in context: http://n4.nabble.com/Retrieve-distinct-values-within-a-whole-data-frame-tp1460205p1460205.html Sent from
2010 Mar 17
2
Troubles on retrieving rownames
Hi guys, I am using the blp() function from RBloomberg package which returns a matrix of prices with the columns corresponding to the security name and the columns to the date. When I have a look at the matrix I can see the rownames (dates) on the left of the prices but when I call the rownames() function it returns me a NULL value. It worked perfectly until I had to reinstall the RBloomberg
2010 Mar 26
3
Using lapply with two lists
Hello guys, I have a list L1 of matrix. I have another list L2 with the same number of elements representing the row of the L matrix that I want to delete (L1[[i]][-L2[[i]],]) but I can't do this with lapply as it iterates through L1 (first argument) and not L2. Any idea? ----- Anna Lippel -- View this message in context:
2010 Jan 26
3
Apply a function on an array with the parameter as an array
Hello R buddies, I want to apply a function on an array but for each element of the array I want to use a different parameter, So here is how I tried to enter the function: apply(as.matrix(X),2, function, parameter1 = arrayOfParameter) I put X as a matrix because it was initially an element of a list. It returns me an array with the same length as X but with values that I don't even
2009 Nov 16
5
Writing a data frame in an excel file
Hello, I am having trouble by using the write.table function to write a data frame of 4 columns and 7530 rows. I don?t know if I should just use a sep="\n" and change the .xls file into a .csv file. Thanks in advance ----- Anna Lippel new in R so be careful I should be asking a loooooooot of questions!:teeth: -- View this message in context:
2010 Feb 03
2
Delete missing value rows from a matrix
Hi everyone, I have a matrix with many Na's. Some rows contain some Na's and some others are entirely composed of Na's. I want to delete the rows that are entirely composed of Na's but not the other ones so I can't use a simple removeNA. Has any one an idea? ----- Anna Lippel -- View this message in context:
2008 Oct 20
2
convert matrix to dataframe with repeating row names
Hi R, I have a matrix x with repeating row names. > dim(x) [1] 862 19 zz<-matrix(0,4,4) rownames(zz)=c("a","a","b","b") data.frame(zz) (?) I need to use x in a linear regression lm(as.formula(paste("final_dat[,5]~",paste(colnames(x),collapse="+"))),x ) this gives me a error Error in
2012 Jul 19
2
problem with using apply for dataframe
Dear people, I am including an example of a dataframe: mydataframe<-data.frame(X=c(1:4),total_bill=c(16.99,10.34,21.01,23.68),tip=c(1.01,1.66,3.50,3.31),sex=c("Male","Male","Male","Female")) When I use the sapply function getting the information about the factors works: sapply(mydataframe,function(x)is.factor(x)) X total_bill tip
2009 Nov 20
2
Problem at adding lines on a graphics with lines() function
Hello, I am trying to plot a graphic with many lines with the following command: plot(datas[1:n,1],datas[1:n,2],type="l",main="SP500 Prices and Moving Averages",xlab="Date",ylab="Prices",col="black") lines(datas[1:n,1],datas[1:n,3],type="l",col="green",lty="solid") But I just see the first curve. I have tried it on