search for: colnm

Displaying 11 results from an estimated 11 matches for "colnm".

Did you mean: colnum
2017 Jun 27
2
paste strings in C
...w to do in C, for very large matrices: > (mymat <- matrix(c(1,0,0,2,2,1), nrow = 2)) [,1] [,2] [,3] [1,] 1 0 2 [2,] 0 2 1 And I would like to produce: [1] "a*C" "B*c" Which can be trivially done in R via something like: foo <- function(mymat, colnms, tilde = FALSE) { apply(mymat, 1, function(x) { if (tilde) { colnms[x == 1] <- paste0("~", colnms[x == 1]) } else { colnms[x == 1] <- tolower(colnms[x == 1]) } paste(colnms[x > 0], collapse = "*") }) } &g...
2017 Jun 27
0
paste strings in C
To do this in C, it would probably be easier and faster to just do the string manipulation directly. Luckily, there are already packages that have done this for you. See an example below using the S4Vectors package. foo2 <- function(mymat, colnms, tilde=FALSE) { chars <- colnms[col(mymat)] lowerChars <- if (tilde) paste0("~", chars) else tolower(chars) chars <- ifelse(mymat==1L, lowerChars, chars) keep <- mymat > 0L charList <- split(chars[keep], row(chars)[keep]) S4Vectors::unstrsplit(ch...
2024 Aug 02
1
grep
..."somewhatm", "verym", "somewhatc", "veryc", "somewhatl", "veryl", "village", "married", "social", "agricultural", "communist", "minority", "religious") colnms <- c("depression", "sleep", "female", "village", "agricultural", "married", "communist", "minority", "religious", "social", "no", "primary", "m...
2024 Aug 02
2
grep
Good Morning. Below I like statement like j<-grep(".r\\b",colnames(mydata),value=TRUE); j with the \\b option which I read long time ago which Ive found useful. Are there more or these options, other than ? grep? Thanks. dstat is just my own descriptive routine. > x ?[1] "age"????????? "sleep"??????? "primary"????? "middle" ?[5]
2007 May 29
2
summing up colum values for unique IDs when multiple ID's exist in data frame
I have data.frame's with IDs and multiple columns. B/c some of IDs showed up more than once, I need sum up colum values to creat a new dataframe with unique ids. I hope there are some cheaper ways of doing it... Because the dataframe is huge, it takes almost an hour to do the task. Thanks so much in advance! Young # ------------------------- examples are here and sum.dup.r is at the
2011 Feb 08
1
Set a Numeric Field To Blank
Hi, I have one of those questions that I suspect is very simple, but hard to classify, so I have been searching for quite some time and am not able to find it. If I have a data frame and I want to change all the values of one of the columns to blanks, what is the syntax? I tried a few different spellings of Null, etc., but can't get it. Can someone please send me what I suspect is a one
2005 Oct 10
1
lmer / variance-covariance matrix random effects
Hello, has someone written by chance a function to extract the variance-covariance matrix from a lmer-object? I've noticed the VarCorr function, but it gives unhandy output. Regards, Roel de Jong
2009 Jul 15
4
Extract pairs (rowname, columname) from a matrix where value is 0
Dear sir, I have a matrix like a<-matrix(c(0,2,0,4,0,6,5,8,0),nrow=3) colnames(a)<-c("F1","F2","F3") rownames(a)<-c("A1","A2","A3") a F1 F2 F3 A1 0 4 5 A2 2 0 8 A3 0 6 0 I want to extract all pairs (rownames, columnames) from which the value in the matrix is 0 The result should be something like this A1, F1 A2,
2009 Oct 11
3
passing field name parameter to function
Hi, I am passing a data frame and field name to a function. I've figured out how I can create the formula based on the passed in field name, but I'm struggling to create a vector based in that field. for example if I hard code with the actual field name Y = df$Target, everything works fine. but if I use the passed in parameter name, it doesn't give me what I want, Y =
2005 Jul 20
2
Is it possible to create highly customized report in *.xlsformat by using R/S+?
Your surest bet is to look into S+, not R, since the former does 'integrate' with Microsoft applications. To what extent, I don' know. This is a desirable feature (IMO) and a reason to use S+ rather then R (already discussed in different thread). Try the S+ newsgroup. > -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at
2004 Aug 26
4
Column names of a data frame
I'm coming out with all the classic problems today ;-) Can anyone tell me how to change the column names of an already existing data frame? I've read the docs for ?data.frame and ?as.data.frame but can't figure it out. I want to make a new data.frame from some of the columns of an existing data.frame, but when I do that, the new data.frame columns have the same names as the old