similar to: How to add a new column to a matrix?

Displaying 20 results from an estimated 10000 matches similar to: "How to add a new column to a matrix?"

2009 Jul 24
1
How to convert a matrix to a dataframe and makes its first row be the column name
Hi I want to convert a matrix to a dataframe. The matrix is like this Site A B C D X 1 2 3 4 Y 5 6 7 8 Z 9 10 11 12 The converted dataframe need to have the first row as column names and the values of each column (1, 2, 3, 4; ......12;) be numeric, not factors. I used data.frame(), but it gave me auto-assigned column
2010 May 27
1
adding column to data frame conditionally
Dear all and thanks in advance for helping me with a rather stupid question: I imported a data set ("freqg") into R consisting of 14 variables. Now a want to compute a variable and add it in an additional column to my data frame. The value of this new variable ("condition") depends on the values of two other variables ("mat" and "flank") already
2008 Dec 15
2
How to sell linux tools?
Hi, I need clarifications on how to sell linux tools. (Though i' not sure how people ready to buy it :) ) I have written few tools and planning to write more(by giving up current non-linux & boring job). I want to know,which license will allow me to sell tools/softwares? (I hope to sell the products through online) Cheers, Lakshmipathi.G www.giis.co.in
2011 Jan 11
1
how to coerce part of each column of a matrix to a vector and merge them
Hello Suppose I have a matrix mat=(1:16,2) [,1] [,2] [,3] [,4] [1,] 1 5 9 13 [2,] 2 6 10 14 [3,] 3 7 11 15 [4,] 4 8 12 16 there is a vector end=c(2,3,1,3) #coerce the 1st 2 numbers of the 1st column to a vector [1] 1 2 #coerce the 1st 3 numbers of the 2nd column and append it to the previous vector [1] 1 2 5 6 7 #coerce the 1st number of
2011 Mar 08
1
repeat matrix column within each array third dimension
Hello all, I'm working with a matrix that will have varying dimensions. It will populate an array such that the number of matrix columns will determine the number of 3rd dimension levels of the array. Rows will be the same for both. For this example lets say the array will have 2 columns, but that's not fixed. dim(arr)<-c(dim(mat)[1],2,dim(mat)[2]) I wish to repeat each matrix
2007 Apr 16
2
Dealing with data frame column names beginning with a numeric
I wish to set up a simple function using boxplot so that it will be available to someone using R for Windows. (I myself use Linux.) The way the data is organised makes it convenient to use the boxplot function in a manner similar to this example given in the help. > mat <- cbind(Uni05 = (1:100)/21, Norm = rnorm(100), + T5 = rt(100, df = 5), Gam2 = rgamma(100, shape
2008 Jan 15
1
Newbie Question -- Remove entire column in a matrix
I'm ordering "The R Book" and hope to learn a lot more about R. In a meantime, I have a matrix of digits and I would like to look for a column that contains zeroes and remove the entire column from the matrix. I can write a piece of R code to do that (and it works); however, I think the R-experts have more tricks to do such a 'simple' thing. Many thanks in advance.
2010 Jan 23
1
How to apply a function on each column of a matrix
Hello everyone, I get for each date a measure for n elements in the form of a matrix. I am converting it to a ts object using ts(). I want to apply a function on each column. I started using the apply function ( set to 2) but what it returns is a matrix with the same columns representing the function applied on the last column of the initial matrix. I have been trying to use the sapply function or
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) <-
2012 Jul 26
3
Remove rows that have repeated items in a particular column
Dear R Users, I apology for not being able to provide an adequately informative subject. Let me describe my problem with an example. For a matrix * (mat <- matrix(c(1,1,2,2,2,3,3, 5,9,1,3,7,4,8), ncol = 2))* my desired output is * (desired <- matrix(c(1,2,3, 5,1,4), ncol = 2))* That is, the first column is numerically grouped and only the first item in each group is wanted. The
2005 Mar 16
1
Help in persp (VERY URGENT ASSISTANCE)
Dear All, I am very new to R projects.May be i am wrong in some steps.I have given the code which i tried for drawing 3d surface using persp.I need to label the axes with scales z <- array(topnew2$V2, dim=c(600,2)) x <- 10 * (1:nrow(z)) y <- (1:ncol(z)) persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue", xlab ="fluidlevel", ylab
2008 May 09
1
Rescaling a column in a matrix based on a certain rows
Hi, Let say I have this matrix: > mat<-matrix(cbind(rnorm(20),rnorm(20)), ncol = 2) And I want to rescale values of column [,1] and [,2] using values from row 1 to 5, such that the values of row 1:5 should be rescale to the same amplitude (kinda like take the z-score of population from row 1:5). column 1 and 2 are two different samples need to be compared. I hope I made myself clear
2007 Mar 12
1
How to modify a column of a matrix
? stato filtrato un testo allegato il cui set di caratteri non era indicato... Nome: non disponibile Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070312/5b30b712/attachment.pl
2012 Sep 17
2
How to divide each column with its own value
Hi, I have a matrix as below: mat= [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 What I want to do is, I would like to divide each column with its own value, in order to get value 1. Is there any simple script for that? [[alternative HTML version deleted]]
2007 Aug 10
4
help with counting how many times each value occur in each column
Dear list, I have the following dataset and want to know how many times each value occur in each column. >data [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] -100 -100 -100 0 0 0 0 0 0 -100 [2,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [3,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [4,] -100 -100 -100 -100 -100 -100 -100 -100 -100
2010 Jun 10
2
adding column of ordered numbers to matrix
Hello everyone, I have a matrix of over 40000 line and about 30 columns. For my analysis I would like to add another column with ascending numbers (column header should be "order", and than 1,2,3,4 ....the end of the matrix). During my analysis I reorder them ( due to merge commands by a different column). How do I add such a column in an ascending order (or descending for what it
2007 May 01
2
Matrix column name
Dear R users, Having searched the mail archive I think the conclusion was that it is not possible to have a column name when there is only one column in the matrix. But I thought I'd check with the more experienced users. What I tried to do was: in a loop I pick a column, record the column name and remove the column from the matrix. But when there were 2 columns left, after one column was
2005 Dec 16
1
column name of a table
hy all, I wish to switch in a part in my code that use "read.table" to "scan", actually i use this: tab<-scan("data.dat",what=integer(),skip=1) dim(tab)<-c(75,length(tab)/75) tab<-t(tab) It gives me a new tab with 75 columns, but i when i was using read.table with headers then attach i could use the columns names to access the data values, now how can i
2008 Feb 04
3
counts of each column that are not NA, and/or greater than column means
Hi, Given a test matrix, test <- matrix(c(1,2,3,NA,2,3,NA,NA,2), 3,3) A) How to compute the counts of each column (excluding the NA) i.e., 3, 2, 1 B) How to compute the counts of each column (excluding the NA) that are greater than the column means ? i.e., 1, 1, 0 I could write a for loop, but hope to use better alternative. [[alternative HTML version deleted]]
2019 Mar 22
3
[PATCH 1/2] readtable: add hook for type conversions per column
This commit adds a function parameter to readtable. The function is called for every column. The goal is to allow specific (non-standard) type conversions depending on the input. When the parameter is not given, or the function returns NULL, the legacy default applies. The colClasses parameter still takes precedence, i.e. the colConvertFn only applies to the default conversions. This allows to