search for: colnames

Displaying 20 results from an estimated 563 matches for "colnames".

2008 Jun 14
5
cbind''ing multivariate ts objects
...method for multivariate time series (ts) objects. Consider the following example: > t <- ts(data.frame(a = 10:20, b = 20:30, c = 30:40, d = 40:50)) > t1 <- t[, c(''a'', ''b'')] > t2 <- t[, c(''c'', ''d'')] > > colnames(t1) [1] "a" "b" > colnames(t2) [1] "c" "d" > colnames(cbind(t1, t2)) [1] "t1.a" "t1.b" "t2.c" "t2.d" > Although it seems to be the documented behavior, I think it would be more consistent if the latter returne...
2013 Sep 05
5
Re: binary symmetric matrix combination
...e5 l15 y1 0 1 1 1 1 1 1 1 1 1 g24 1 0 0 0 0 0 0 0 0 0 c1 1 0 0 1 1 0 0 0 0 0 c2 1 0 1 0 1 0 0 0 0 0 l17 1 0 1 1 0 0 0 0 0 0 h4 1 0 0 0 0 0 1 1 0 0 s2 1 0 0 0 0 1 0 1 0 0 s30 1 0 0 0 0 1 1 0 0 0 e5 1 0 0 0 0 0 0 0 0 1 l15 1 0 0 0 0 0 0 0 1 0",sep="",header=TRUE)) names1<-unique(c(colnames(m1),colnames(m2),colnames(m3),colnames(m4))) Out2<-matrix(0,length(names1),length(names1),dimnames=list(names1,names1)) vec1<- paste0(colnames(m1)[col(m1)],rownames(m1)[row(m1)]) vecOut<- paste0(colnames(Out2)[col(Out2)],rownames(Out2)[row(Out2)]) Out2[match(vec1,vecOut)]<- m1 vec2<-...
2004 Sep 17
1
Confused about specifying plot colors as RGB values
Based on reading ''rgb'' documentation, I would have thought the following would have produced identical results. Can someone explain how to make this happen? I need to be able to specify an array of rgb values for the ''col'' parameter. colnames.col <- c("black", "red", "blue", "green") colnames.rgb <- apply(as.matrix(colnames.col), 1, col2rgb) dimnames(colnames.rgb)[[2]] <- colnames.col baseline <- 1:32 offset2 <- 2*baseline offset3 <- 3*baseline offset4 <- 4*baseline offsets &...
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 seq_along(mynames)) { colnames(mydata[[i]])[2] <- mynames[i] } Is there a nicer way to do thi...
2005 Oct 29
2
how to get colnames of a dataframe within a function called by 'apply'
Hello alltogether, how is it possible to assign the colnames of a data.frame to a function called by apply, e.g. for labeling a plot? Example: I want to plot several qqnorm-plots side by side and there should be a maintitle for each qqnorm-plot which is identical to the respective colname. I checked, but the column which is processed by the function calle...
2013 Jun 10
12
Combining CSV data
Hello R community, I am trying to combine two CSV files that look like this: File A Row_ID_CR, Data1, Data2, Data3 1, aa, bb, cc 2, dd, ee, ff File B Row_ID_N, Src_Row_ID, DataN1 1a, 1, This is comment 1 2a, 1, This is comment 2 3a,
2011 Aug 10
2
join columns
...s. Anthony > q1 = data.frame(a=1,b=2,c=3,row.names="q1") a b c q1 1 2 3 > q2 = data.frame(d=4,b=1,a=4, row.names="q2") d b a q2 4 1 4 -> myJoinColumns(q1,q2) a b c d q1 1 2 3 0 q2 4 1 0 4 myJoinColumns <- function(q1,q2){ allNames = sort(union(colnames(q1),colnames(q2))) for (i in 1:length(allNames)){ t1 = which(colnames(q1) == allNames[i]) t2 = which(colnames(q2) == allNames[i]) if (length(t1) == 1){ sec1 = q1[,t1] } else { sec1 = 0 } if (length(t2) == 1){ sec2 = q2[,t2] } else { sec2 = 0...
2007 Jul 18
0
sqlSave, ...colnames=F, using "odbcConnectExcel" .... I still get colnames in top row of exprted sheet
I am trying to save an R data.frame as an Excel sheet. I do NOT want the column names saved into row 1. I set colnames=F. However, it still seems that the colnames are saved into row 1. Is this a bug? Or am I coding incorrectly and.or misunderstanding this feature? #example code: sheet = "c:/test2.xls" temp=data.frame(matrix(data=NA,nrow=10,ncol=15)) temp[1,1] = ''sampletext.1.1'' te...
2016 Apr 03
1
row.names(), rownames(), colnames(), names() ...?
...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 over colnames. -- Sent from my phone. Please excuse my brevity. On April 2, 2016 5:54:10 PM PDT, Boris Steipe <boris.steipe at utoronto.ca> wrote: >The help text for row+colnames {base} states: > > "For a data frame, rownames and colnames eventually call row.names > and names respecti...
2017 Oct 13
1
Quotation marks hinder for loop
Dear mailing list members, My question is maybe very basic, but I could not find the solution. I would like to do the following things 1) colnames(V1)[2] <- par$V2[1] colnames(V2)[2] <- par$V2[2] colnames(V3)[2] <- par$V2[3] ... colnames(V37)[2] <- par$V2[37] 2) V1 <- V1[,-1] V2 <- V2[,-1] V3 <- V3[,-1] ... V37 <- V37[,-1] 3) ms <- merge(V1,V2) ms <- merge(ms,V3) ms <- merge(ms,V4) ... ms <- merge(ms,V37)...
2010 Jul 19
3
concatenating column names in a loop
Hi all, I am trying to concatenate words together to create new column names, using a loop. Please consider the following toy example: x <- matrix(nrow = 1, ncol = 3) colnames(x) <- c("a", "b", "c") x[1,1] <- "1" x[1,2] <- "2" x[1,3] <- "3" I would like to create a new matrix with column names based on the column names in x. Specifically, I would like the column names in y to be "q_" plus...
2016 Apr 03
1
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...
2017 Dec 27
1
Error in dimnames in R
...--------------------- #Assets: LUTAX, PFODX,BRGAX,GFAFX,NMSAX,EGINX,IPOYX,SCWFX,FGLDX,PAGEX #Getting monthly returns of the assets library(quantmod) library(tseries) library(timeSeries) LUTAX <- monthlyReturn((getSymbols("LUTAX",auto.assign=FALSE)[,4]),type = "arithmetic") colnames(LUTAX) <- c("LUTAX") PFODX <- monthlyReturn((getSymbols("PFODX",auto.assign=FALSE)[,4]),type = "arithmetic") colnames(PFODX) <- c("PFODX") BRGAX <- monthlyReturn((getSymbols("BRGAX",auto.assign=FALSE)[,4]),type = "arithmetic")...
2011 Aug 29
3
Problem in writing a R data frame to Excel format using RODBC package
Hi Experts, I was trying to write a data frame which has a header row, from R to Excel disk file using RODBC ( RODBC_1.3-1) package. I met with an issue:- If in sqlSave(), I set a parameter "colnames=FALSE" then I get first row as header in excel file. If ''colnames=TRUE'' then it gives me first 2 rows as header in excel file. Actually, according to my understanding, for FALSE it should not write header row to Excel file and for TRUE it should write a single hea...
2013 Sep 02
2
Re: R dataframe and looping help
...-Jan-12 c 0 3 3 0 1 9-Jan-12 a 3 3 0 0 1 31-Mar-13 a 3 0 0 0 2 31-Aug-12 a 0 3 3 0 2 24-Sep-12 a 3 3 0 0 2 25-Sep-12 b 3 0 0 0 ",sep="",header=TRUE,stringsAsFactors=FALSE) dat2<- dat1[,-c(1:3)] res<- lapply(seq_len(ncol(dat2)),function(i) {x1<-cbind(dat1[,c(1:3)],dat2[,i]);colnames(x1)[4]<- colnames(dat2)[i];x2<-x1[x1[,4]!=0,];within(x2, {daysbetweentrips<-unlist(tapply(as.Date(x2$TripDate,"%d-%b-%y"),list(x2$CustID),function(x) c(NA,as.numeric(diff(x)))));previoustripstore<-ave(x2$Store,x2$CustID,FUN=function(x) c(NA,x[-length(x)]));Nexttripstore<- a...
2012 Nov 08
3
Extracting columns
Hi, I have 22 files (A1, A2, ..., A22) with different number of columns, totaling 10,000 columns: c1, c2, c3, ..., c10000 I have another file with a list of 100 columns that I need to extract. These 100 columns are distributed in 22 files. How to extract the 100 columns of the 22 files? I have done it "manually" with the following commands, for example: cromo1 = read.table ("~
2003 Oct 13
2
colnames from submatrix?
...23 0 0 0 0 [20,] 0.2236068 0.51934865 -0.41193918 0 0 0 0 such that I only end up with a list of names (d0,d1,d2). I''ve been using the qr( x )$rank to get the number of non-zero columns, but I''m not sure how to only return the names of the non-zero columns as > colnames( qr( attr( eval( nlsystemols$eq[[1]]$deriv ), "gradient" ) )$qr ) will return > [1] "d0" "d1" "d2" "s0" "s1" "s2" "s3" Is/Are there one of those great S or R function/shortcuts that will return a submatrix...
2011 Mar 19
2
Output a table formatted with standard deviations below means
Is it in bad form to double post to StackOverflow and R-help? Apologies if so. Here''s my task: I''ve got a matrix of means like so means<-matrix(1:10,nrow=2) colnames(means)<-c("a","b","c","d","e") and a matrix of standard deviations like so sds<-matrix(seq(0.1,1,by=0.1),nrow=2) colnames(sds)<-c("a","b","c","d","e") and I want to output a Latex (or HTM...
2008 Dec 03
2
changing colnames in dataframes
...: c.as.character.rep.gender..8... c.6...F73..F78..F79..F82..6...F84..F94..F106..F109 1 w 2 2 w 3 3 m 1 etc. Instead of the automatic colnames ''c.as.character.rep.gender..8'' I like to have the colnames ''gender'' and ''J.value''. I tried levels, labels etc but without success. OK, I can fix(FF) manually, but this is bad, because it has to be done again and again .. OK, I can do gender.J&...
2011 Jun 18
1
Trouble with Paste and Quotes and List Objects
...2 months ending 2010-12-31" "12 months ending 2009-12-31" "12 months ending 2008-12-31" "12 months ending 2007-12-31" $ BS:List of 2 ..$ Q: num [1:42, 1:5] NA NA 6.53 326.25 NA ... .... I can get the column names for one of the sub-objects of this object. > colnames(AACC.f$IS$A) [1] "2010-12-31" "2009-12-31" "2008-12-31" "2007-12-31" Thanks for your patience so far; here''s the question. I want to get the column names from all the sub objects in each of the .f objects, so I want to build a loop, but I need to b...