search for: colnum

Displaying 20 results from an estimated 25 matches for "colnum".

Did you mean: folnum
2007 Mar 04
1
Scoping issue?
Hello, The code below is supposed to be a wrapper for matplot to do columnwise visible comparison of several matrices, but I'm doing something wrong because I can't access an argument called 'colnum'. I'd be most grateful for some insight. Thanks, John Thaden Little Rock, AR ################################ # mmatplot is a matplot wrapper to compare the same column of # several matrices. Arg y is either a list of matrices with # equal number of rows, or an array. The scalar n gives...
2006 Aug 08
3
Pairwise n for large correlation tables?
...t takes much, MUCH longer than the correlations do). Any hints, regarding other functions to use or ways to maket his speedier, would be much appreciated! pairwise.n <- function(df=stop("Must provide data frame!")) { if (!is.data.frame(df)) { df <- as.data.frame(df) } colNum <- ncol(df) result <- matrix(data=NA,nrow=colNum,ncol=ncolNum,dimnames=list(colnames(df),colnames(df))) for(i in 1:colNum) { for (j in i:colNum) { result[i,j] <- length(df[!is.na(df[i])&!is.na(df[j])])/colNum } } result } -- Adam D. I. Kramer University of...
2006 Jul 04
1
[Fwd: formatting using the write statement]
...en as it >is above ? i tried sep = " ", instead of ncolumns butt hat >just makde things worse. thanks. > >for (rownum in 1 (1:nrow(sortedForecastData)) { > >outfile=paste(forecsastfiledir,rownames(sortedForecastData[rownum],".mls",sep="") > >for colnum in (1:ncol(sortedForecastData) { > >if ( colnum == 1 ) { > >write(c(colnames(sortedForecastData[colnum],sortedForecastData[rownum,colnum],file=outfile,ncolumns=2,append=FALSE) > >} else { > >write(c(colnames(sortedForecastData)[colnum],sortedForecastData[rownum,colnum],fil...
2007 Jun 06
2
lookup in CSV recipe
...lied default if row not found? # add Excel and Openoffice support module Puppet::Parser::Functions newfunction(:lookup_csv, :type => :rvalue) do |args| filename = args[0] key = args[1] column = args[2] File.open(filename) do |file| # find which column we are after colnum = file.gets.chomp.split(/,/).index(column) return nil if colnum == nil # find row file.each_line { |line| row = line.chomp.split(/,/) if (row[0] == key) return row[colnum] end } end # no match found return nil end end Adrian
2011 May 18
4
Loop stopping after 1 iteration
...") data_grid<-read.table(file=paste(filename,".txt",sep="")) num_rows_data<-nrow(data_grid)-1 num_cols_data<-ncol(data_grid)-4 num_obs<-num_rows_data*num_cols_data time_series<-matrix(nrow=0,ncol=2) for(i in 1:length(num_obs)){ rownum<-ceiling(i/31)+1 colnum<-if(i%%31==0){ 35 }else{ (i%%31)+4 } year<-data_grid[rownum,2] month<-data_grid[rownum,3] day<-colnum-4 date_string<-paste(month,day,year,sep="/") date<-as.Date(date_string,format='%m/%d/%Y') value<-as.character(data_grid[rownum,colnum]) time_...
2009 Jan 22
2
"latex" in Hmisc: cell formating
...uot;scriptsize", + cgroup=c("group1","group2"), n.cgroup=c(6,1), + rgroup=c("n=1","n=5","n=10","n=20","n=50"), n.rgroup=rep(36,5), + cellTexCmds=cell.format, numeric.dollar = FALSE) Error in cat(rcellTexCmds[i, colNum], " ", cx[i, colNum], file = file, : subscript out of bounds > > ## if I remove the column name grouping, it works fine! ## > latex(table1, where='htbp', long=TRUE, lines.page=1000, size="scriptsize", + #cgroup=c("group1","group2"...
2011 Apr 04
1
moving mean and moving variance functions
Hello Lets say as an example I have a dataframe with the following attributes: rownum(1:405), colnum(1:287), year(2000:2009), daily(rownum x colnum x year) and foragePotential (0:1, by 0.01). The data is actually stored in a netcdf file and I'm trying to provide a conceptual version of the data. Ok. I need to calculate a moving mean and a moving variance for each cell on the following tempor...
2006 Aug 02
5
Finding the position of a variable in a data.frame
...ubset(Df, bat >= 50) ----results cat dog rat bat 5 0 0 0 54 Thus I know that my target is in row 5 but how do I figure out where 'bat' is? All I want to do is be able to say Df[5,4] <- 100 Is there some way to have function(bat) return the column number: some kind of a colnum() function? I had thought that I had found somthing in library(gdata) matchcols but no luck.
2011 Jun 23
2
Confidence interval from resampling
...ith shape=xwei.shape, scale = xwei.scale draw <- lapply(1:100, function(.x){ out<-rweibull(x, shape=xwei.shape, scale = xwei.scale) }) newx<- data.frame(draw) colnames(newx)<-paste("x", 1:100, sep = "") newmat<-data.matrix(newx) # matrix of coefficients rownum=2 colnum=100 ResultMat<-matrix(NA, ncol=colnum, nrow=rownum) rownum2=45 colnum2=100 ResultMat2<-matrix(NA, ncol=colnum2, nrow=rownum2) #loop through each column in the source matrix for (i in 1:100) { sel_col<-newmat[col(newmat)==i] {ResultMat[,i]<-coef(fitdistr(sel_co...
2002 Apr 18
5
Two problems
Hello! Two questions: 1: I have to import a matrix of adjacency from a file of a software that is not R (for example "bloc notes" of Windows). The problem is that the matrix is not in the explicit form as 0 1 1 1 0 0 1 0 0 but it is a scattered matrix where in each row there are two nodes that have a direct path. The matrix is a b a c b a c a For example, the first row
2009 Feb 03
1
pairs() help - colour histograms on diagonal
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'd like to be able to colour histograms along the diagonal using the colours stored in colnames(d): > d black blue brown cyan 1 0.96405751 -0.02964390 -0.060147424 -0.06460070 2 -0.03614607 0.95475444 -0.152382053 -0.07767974 3 -0.07095613 -0.05884884 -0.061289399 -0.06445973 4 -0.03708223 -0.05997624
2012 Oct 09
4
Convert COLON separated format
I have a bunch of data sets that were created for the libsvm tool. They are in "colon separated sparse format". i.e. 1 5:1 27:3 345:10 Is a row with the label of "1" and only has values in columns 5, 27, and 345. I want to read these into a data.frame in R. Is there a simple way to do this? -- Noah Silverman, M.S. UCLA Department of Statistics 8117 Math Sciences
2017 Dec 04
0
Dynamic reference, right-hand side of function
...so looping of names of things gets awkward. It is usually easier to use compound objects like lists and iterate over them. E.g. datanames <- paste0("aa_", 2000:2007) datalist <- lapply(datanames, get) names(datalist) <- datanames col1 <- lapply(datalist, "[[", 1) colnum <- lapply(col1, as.numeric) (The 2nd line assumes that the damage has already been done so that you have aa_2000 ... aa_2007 in your workspace. You might alternatively create the list directly while importing the data.) -pd > On 4 Dec 2017, at 12:33 , Love Bohman <love.bohman at sociolo...
2017 Dec 04
3
Dynamic reference, right-hand side of function
...e, so looping of names of things gets awkward. It is usually easier to use compound objects like lists and iterate over them. E.g. datanames <- paste0("aa_", 2000:2007) datalist <- lapply(datanames, get) names(datalist) <- datanames col1 <- lapply(datalist, "[[", 1) colnum <- lapply(col1, as.numeric) (The 2nd line assumes that the damage has already been done so that you have aa_2000 ... aa_2007 in your workspace. You might alternatively create the list directly while importing the data.) -pd > On 4 Dec 2017, at 12:33 , Love Bohman <love.bohman at sociolo...
2017 Dec 04
0
Dynamic reference, right-hand side of function
...gs gets awkward. It is usually easier to use compound objects like lists and iterate over them. E.g. > > datanames <- paste0("aa_", 2000:2007) > datalist <- lapply(datanames, get) > names(datalist) <- datanames > col1 <- lapply(datalist, "[[", 1) > colnum <- lapply(col1, as.numeric) > > (The 2nd line assumes that the damage has already been done so that you have aa_2000 ... aa_2007 in your workspace. You might alternatively create the list directly while importing the data.) > > -pd > >> On 4 Dec 2017, at 12:33 , Love Bohm...
2007 Nov 08
6
Extract correlations from a matrix
Dear R users, suppose I have a matrix of observations for which I calculate all pair-wise correlations: m=matrix(sample(1:100,replace=T),10,10) w=cor(m,use="pairwise.complete.obs") How do I extract only those correlations that are >0.6? w[w>0.6] #obviously doesn?t work, and I can?t find a way around it. I would very much appreciate any help! Best wishes Christoph (using R
2010 Oct 13
1
[LLVMdev] EXC_BAD_ACCESS: invalid MemoryBuffer from ContentCache::getBuffer
...EXC_BAD_ACCESS crashes in ContentCache::getBuffer. This happens when I'm printing out errors from a compilation run and iterating over TextDiagnosticBuffer returned errors. When checking the errors, I construct a FullSourceLoc and do: int LineNum = SourceLoc.getInstantiationLineNumber(); int ColNum = SourceLoc.getInstantiationColumnNumber(); which return sane values. Checking SourceLoc.isInvalid() always returns false, so I'm confident SourceLoc is valid. However, when I do: const char * bufname = SourceLoc.getManager().getBufferName(SourceLoc, &invalid); I get crashes. The diffe...
2008 Jul 29
1
correlation between matrices - both with some NAs
Hi everyone, I'm having trouble applying the Cor() function to two matrices, both of which contain NAs. I am doing the following: a<-cor(m1, m2, use="complete.obs") ... and I get the following error message: Error in cor(m1, m2, use = "complete.obs") : no complete element pairs Does anyone know how I can apply a correlation, ignoring any NAs? Thanks, rcoder --
2017 Dec 04
3
Dynamic reference, right-hand side of function
Hi R-users! Being new to R, and a fairly advanced Stata-user, I guess part of my problem is that my mindset (and probably my language as well) is wrong. Anyway, I have what I guess is a rather simple problem, that I now without success spent days trying to solve. I have a bunch of datasets imported from Stata that is labelled aa_2000 aa_2001 aa_2002, etc. Each dataset is imported as a matrix, and
2008 Feb 26
2
Combining series of variables using identifier
R users, I have df like this a <- data.frame( indx = 1:20, var1 = rep(c("I20", "I40", "A50", "B60"), each=5), var1_lab= rep(c("cat", "dog", "mouse", "horse"), each=5), var2 = rep(c("B20", "X40", "D50",