Displaying 20 results from an estimated 20000 matches similar to: "Correcting the display of colnames and rownames"
2008 Jun 17
2
Reshape or Stack? (To produce output as columns)
Dear all,
I have used 'read.table' to create a data frame of 720 columns and 360 rows (and assigned this to 'Jan'). The row and column names are numeric:
> columnnames <- sprintf("%.2f", seq(from = -179.75, to = 179.75, length = 720)).
> rnames <- sprintf("%.2f", seq(from = -89.75, to = 89.75, length = 360))
> colnames(Jan) <- columnnames
2008 Jul 15
3
Melt (reshape) question
Dear all,
I
have a grid of 720 columns by 360 rows of global population density
values, and hope to convert this to column format using the 'melt' command in the 'reshape' package. I'm not receiving
any errors as such, but when the code has finished running, my output
looks like this:
> head(PopDens.long)
Latitude Longitude PopDensity
1 -84.75 V1 0
2
2009 Apr 08
2
Reshape - strange outputs
Dear R Users,
I am using the reshape package to reformat gridded data into column format using the code shown below. However, when I display the resulting object, a single column is fomed (instead of three) and all the latitude values (which should be in either column one or two) are collected at the bottom. Also, the NA values aren't removed, despite this being requested in the code.
Code:
2009 Mar 31
0
Row/columns names within 'assign' command
Dear all,
I am attempting to add row and column names to a series of tables (120 in total) which have 2 variable parts to their name. These tables are created as follows:
# Create table indexes
index <- expand.grid(year = sprintf("%04d", seq(1986, 1995)), month = sprintf("%02d", 1:12))
# Read in and assign file names to individual objects with variable name components
2017 Oct 23
2
A list of data frames and a list of colnames.
I have a list of file names, and a list of data frames contained in those files.
mynames <- list.files()
mydata <- lapply(mynames, read.delim)
Every file contains two columns.
> colnames(mydata[[1]])
[1] "Name" "NumReads"
> colnames(mydata[[2]])
[1] "Name" "NumReads"
I can set the colnames easily enough with a for loop.
for (i in
2006 Mar 21
1
rownames, colnames, and date and time
I noticed something surprising (in R 2.2.1 on WinXP)
According to the documentation, rownames and colnames are character vectors.
Assigning a vector of class POSIXct or POSIXlt as rownames or colnames
therefore is not strictly according to the rules.
In some cases, R performs a reasonable typecast, but in some other cases
where the same typecast also would be possible, it does not.
Assigning a
2006 Mar 21
1
rownames, colnames, and date and time
I noticed something surprising (in R 2.2.1 on WinXP)
According to the documentation, rownames and colnames are character vectors.
Assigning a vector of class POSIXct or POSIXlt as rownames or colnames
therefore is not strictly according to the rules.
In some cases, R performs a reasonable typecast, but in some other cases
where the same typecast also would be possible, it does not.
Assigning a
2016 Apr 03
0
row.names(), rownames(), colnames(), names() ...?
Data frames are lists of columns. The names() function is appropriate for lists.
It doesn't pay to fall into the trap of thinking that data frames are truly symmetric between columns and rows, because there is a performance penalty for accessing rows that is greater than the cost of accessing columns. With that in mind, thinking of data frames as lists is preferred, so names is preferred
2006 Jul 03
1
rownames, colnames, and date and time
Hi all
I was wondering whether there has ever been an update on the rownames and
colnames behaviour as described by Eric below?
I still get the same behaviour, exactly as described by Eric, on my WinXP
installation of R-2.3.0. I also posted a message to r-help on Friday but
looking through the online archives it seems to have not made it to the
list. I would agree with Eric that a consistent
2016 Apr 03
2
row.names(), rownames(), colnames(), names() ...?
The help text for row+colnames {base} states:
"For a data frame, rownames and colnames eventually call row.names
and names respectively, but the latter are preferred."
Why are they "preferred"?
Why is it names(), not col.names()?
I have only ever used names() for vectors - I'm surprised it works on data.frames... IMO this is not great for code readability, thus
1998 Nov 09
1
Proposal for discussion: COLNAMES & ROWNAMES
Looking into several different parts of R../src/library/base/R/*.R
has led me to the conclusion
that quite a bit of code doubling could be saved by using the following two
functions whose naming philosophy is derived from that of NROW() & NCOL():
COLNAMES <- function(x)
if(is.null(n <- colnames(x))) paste(seq(length=NCOL(x))) else n
ROWNAMES <- function(x)
2004 Aug 20
3
Loss of rownames and colnames
Hi,
I am working on some microarray data, and have some problems with
writing iterations.
In essence, the problem is that objects with three dimensions don't
have rownames and colnames. These colnames and rownames would
otherwise still be there in 2 dimensional objects.
I need to generate multiple iterations of a 2 means-clustering
algorithm, and these objects thus probably need 3
2012 Feb 17
5
How to change the order of columns in a data frame?
Dear all,
I have a data frame in which the columns need to be ordered. The first column X is at the right position, but the remaining columns X1-Xn should be ordered like this: X1, X2, X3 etc instead of like below.
> colnames(pos1)
[1] "X" "X1" "X10" "X11" "X12" "X13" "X14" "X15" "X16"
2010 Jul 28
1
How get colnames and rownames in Rcpp method?
Hi all,
How get colnames and rownames in Rcpp method?
attecthed file : RGui.exe capture
my work environment :
R version : 2.11.1
OS : WinXP Pro sp3
Thanks and best regards.
Young-Ju, Park
from Korea
[1][rKWLzcpt.zNp8gmPEwGJCA00]
[@from=dllmain&rcpt=r%2Dhelp%40r%2Dproject%2Eorg&msgid=%3C20100728211143%2EH
2000 Dec 11
2
row.names, rownames; colnames, no col.names?
There's a bit of a symmetry issue, which may or may not be important
(led to 15 seconds of confusion until I got my bearings straight):
row.names, rownames; colnames, no col.names?
I _NOW_ realize the difference between row.names and rownames, but
is there any reason not to have col.names for re-naming columns in a
data.frame?
(if there is, I don't particular need to know it, but it
2007 Aug 03
1
O(?) access time for rownames/colnames/named dimensions
Dear princely R developers to whom I owe so much of my daily productivity
level,
I am wondering how indexing by row and column names are implemented. That
is, when I have a matrix with named rows (or columns) and I then index into
that matrix using the string names (rather than integers), how does R scan
through the list of names in order to figure out which row/column to use?
My current
2009 Jul 09
2
correct way to subset a vector
Hi,
#make example data
dat <- data.frame(matrix(rnorm(15),ncol=5))
colnames(dat) <- c("ab","cd","ef","gh","ij")
If I want to get a subset of the data for the middle 3 columns, and I
know the names of the start column and the end column, I can do this:
mysub <- subset(dat,select=c(cd:gh))
If I wanted to do this just on the column names,
2010 Jun 10
1
To give column names of a data-frame
Sir,
I want to export the results of R in a data frame. So I want to give
rownames,columnnames & title to the data-frame.I have applied the following:
data.frame(matrix(c(...),nrow=,ncol=),row.names=c("a","b"),col.names=c("c","d"),title="aaa")
But, it does not work.
Can you help me?
Regards,
Suman Dhara
[[alternative HTML version
2008 Sep 22
1
how to set rownames / colnames for matrices in a list
Hello,
I have another stupid question. I hope you can give me a hint how to solve this:
I have a list and one element is again a list containing matrices, all of the
same dimensions. Now, I'd like to set the dimnames for all matrices:
example code:
m1 <- matrix(1:25, nrow=5)
m2 <- matrix(26:50, nrow=5)
# ... there can be much more than two matrices
l <- list()
l[[1]] <-
2009 Feb 12
0
Error Message: Error in dim(data) <- dim : attempt to set an attribute on NULL
I have the following code, from which I get the following error message:
Error in dim(data) <- dim : attempt to set an attribute on NULL
I think the error is coming from the part of my code in BOLD RED. The script works fine until then.
#Load libraries
source("http://bioconductor.org/biocLite.R")
biocLite()
library(limma)
library(Biobase)
#change directory to folder where