similar to: Named components in a list

Displaying 20 results from an estimated 10000 matches similar to: "Named components in a list"

2011 Nov 17
3
Named rows in a table (data frame) read from a file
I read a table as follows: > F1 <- read.table("Rtext3.txt") > F1 Price Floor Area Rooms Age Cent.heat a 52.00 111 830 5 6.2 no b 54.75 128 710 5 7.5 no c 57.50 101 1000 5 4.2 no d 57.50 131 690 6 8.8 no e 59.75 93 900 5 1.9 yes As it is seen, the rows have a name. However I don't know how to access a
2012 Jul 30
6
Convert variable to STring
Dear all, I have a variable that I would like also to use it as a string. The reasons is that I want to collect results from different function to one table.. So when I use the  colnames(mymatrix) <-c(function1.function2,function3) the function1, function2, function3 to be "converted" to simple strings so as  colnames(mymatrix)
2008 Aug 11
6
number of an element in a matrix
Hi, I wonder if there is any function which gives the number of times which an element is repeated in the matrix. Let say there is a matrix, I would like to find out how many times number 2 has been repeated in the matrix, or in other words, how many elements of the matrix are equal 2. Thanks for your help, Rostam [[alternative HTML version deleted]]
2008 Nov 06
1
trouble with for loop
Hello, I'm having two similar problems with for loop and I would appreciate any help or comment. I want to use "for loop" to calculate series of initial values for an optimization problem. But some initial values have my function quit due to problems like calculating the inverse of singular matrices. I don't want to make my program check determinants and skip it if it is
2011 Sep 29
1
documenting a behavior of adding named item to a list
Folks, Per a post to StackOverflow, I'm looking for an opinion on whether something should be documented: When adding a named item to a list, its guaranteed that the item will be added to the end of the list. SO post: http://stackoverflow.com/questions/7599349/adding-named-item-to-list-guaranteed-to-append-to-end-of-list/7599610#7599610 This is my first email to r-devel, so I hope this is
2023 Oct 17
1
transform a list of arrays to tibble
I work with a list of crypto assets daily closing prices in a xts class. Here is a limited example: asset.xts.lst <- list(BTCUSDT = structure(c(26759.63, 26862, 26852.48, 27154.15, 27973.45), dim = c(5L, 1L), index = structure(c(1697068800, 1697155200, 1697241600, 1697328000, 1697414400), tzone = "UTC", tclass = "Date"), class = c("xts", "zoo")), ETHUSDT
2023 Oct 17
1
transform a list of arrays to tibble
Arnaud, Short answer may be that the tibble data structure will not be supporting row names and you may want to simply save those names in an additional column or externally. My first thought was to simply save the names you need and then put them back on the tibble. In your code, something like this: save.names <- names(my.ret.lst) result.tib <- as_tibble_col(unlist(my.ret.lst),
2012 Sep 11
1
lapply with different size lists?
Hello, I have 2 functions (a and b) a = function(n) { matrix (runif(n*2,0.0,1), n) } > > > b = function (m, matrix) { > n=nrow (matrix) > p=ceiling (n/m) > lapply (1:p, function (l,n,m) { > inf = ((l-1)*m)+1 > if (l<p) sup=((l-1)*m)+m > else sup=n >
2013 Jun 27
3
using "rollapply" to calculate a moving sum or running sum?
#using "rollapply" to calculate a moving sum or running sum? #I am tryign to use rollapply to calcualte a moving sum? #I tried rollapply and get the error message #"Error in seq.default(start.at, NROW(data), by = by) : # wrong sign in 'by' argument" #example: mymatrix <- ( matrix(data=1:100, nrow=5, ncol=20) ) mymatrix_cumsum <- ( matrix(data=NA, nrow=5,
2009 Jul 20
1
S4 method dispatch with inheritance
Hi, I'm trying to create a new S4 class (myMatrix) which for now just extends dgCMatrix (from package Matrix). Then I want to use "[" which is defined in Matrix. Out of the box with "[" (defined in Matrix) I lose the class information and the result is an object of class dgCMatrix. If I specify a "["-method for myMatrix, it is not used because a signature
2005 Jan 21
6
Avoiding a Loop?
Dear R-Helpers, I have a matrix where the first column is known. The second column is the result of multiplying this first column with a constant "const". The third column is the result of multiplying the second column with "const"..... So far, I did it like this (as a simplified example): nr.of.columns <- 4 myconstant <- 27.5 mymatrix <- matrix(numeric(0), nrow=5,
2005 Feb 21
3
Sorting a matrix on two columns
Hello, If a matrix with 5 columns has been defined and the first two columns need to be sorted in ascending order, how can this be achieved whilst ensuring the other 3 columns data are in relative position to the sorted columns? Glen Jones [[alternative HTML version deleted]]
2013 Sep 05
12
[PATCH 0/5] Memory leaks amended
Memory leaks found by the tool--valgrind along with static reviewing. Based on Daivd''s branch ''integration-20130903''. Gui Hecheng (5): btrfs-progs:free local variable buf upon unsuccessful returns btrfs-progs:local variable memory freed btrfs-progs: missing tree-freeing statements added btrfs-progs:free the local list pending_list in btrfs_scan_one_dir
2006 Apr 04
2
Selecting out certain values from a MATRIX
I have two objects, one matrix and one vector. I want to use my vector to subset certain values out of my matrix. For example: I want to tell R, to select out all rows in myMatrix into a new myMatrix2 IF that corresponding row is less than a 0.5 in myVector. So: myMatrix = a matrix of 8000 by 20 myVector = vector of 8000 myMatrix2 = a matrix of < 8000 by 20 (based on selection criteria in
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 Jul 31
2
Remove a complete row as per the Range in a Matrix
Hi, Here i have a Matrix MyMatrix <- Name Age --------- ------- ANTONY 27 IMRAN 30 RAJ 22 NAHAS 32 GEO 42 and here i have an array with Minimum and Maximum values. MinMaxArray <- data.frame(MIN = 25,MAX=35) MIN MAX ------ -------- 25 35
2008 May 21
2
Converting Data Types
Hi, How can I convert the matrices to list. For example I have this snippet: samples<-mymatrix[1,] print(samples) which prints: V1 V2 V3 V4 V5 V6 1 103.9 88.5 242.9 206.6 175.7 164.4 How can I convert the object "samples" such that it prints: [1] 103.9 88.5 242.9 206.6 175.7 164.4 The reason I ask this because I can't use the former "samples"
2012 Aug 01
1
Error message: $ operator is invalid for atomic vectors
HI, The code was working perfectly fine yesterday and today, until half an hour ago.? Couldn't find any problems in the code. Still, I am getting error message. myMatrix <- data.matrix(read.table(text=" Name??????????? Age ANTONY??????? 27 IMRAN????????? 30 RAJ????????????????? 22 NAHAS????????? 32 GEO??????????????? 42 ", header=TRUE)) MinMaxArray? <- data.frame(MIN =
2007 Feb 12
3
processing a large matrix
I would like to compare every column in my matrix with every other column and get the r-squared. I tried using the following formula and looping through every column: > summary(lm(matrix[,x]~matrix[,y]))$r.squared If I have 10,000 columns, the loops (10,000 * 10,000) take forever even if there is no formula inside. Then, I attempted to vectorize my code: > cor(matrix)^2 With 10,000
2006 Mar 16
6
removing ROWS with missing values
I am trying to find out if R can recognize specific criteria for removing rows (i.e. a prexisting function) I have a matrix myMatrix that is 12000 by 20 I would like to remove rows from myMatrix that have: -999 across all columns -999 across all columns but one -999 across all columns but two -999 across all columns but three -999 across all columns but four -999 across all columns but five