similar to: column names only

Displaying 20 results from an estimated 60000 matches similar to: "column names only"

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
2010 Nov 27
1
return vector of element names for vector, matrix or array
Just as as.vector() takes a vector, matrix or array and returns a vector in row-major order, I'd like to write a function to take such an object and return the dimension names, pasted with some separator, as a similar vector. Here is something ugly cobbled together to demonstrate what I want: a function to work for any number of dimensions. vecnames <- function(x, sep=':') {
2010 Jul 28
1
How to point a column of dataframe by a "character"
Hello, Here is a dilemma I am having for a long time. But, I couldn't figure it out. I have an vector of Y and a data frame named "data",which contains all Xs. I tried to be more efficient in fitting a simple linear regression with each X. Firstly, for (i in 1:(dim(data)[2])){ model<-lm(Y~data[,i]) # this is not what I want since the name of coefficient will be data[,i] # I
2012 May 25
1
columnames changes behaviour of formula
Hello. precompiled R-2.15.0, svn58871, macosx 10.7.4. I have discovered that defining column names of a dataframe can alter the behaviour of lm(): d <- c(4,7,6,4) x <- data.frame(cbind(0:3,5:2)) coef(lm(d~ -1 + (.)^2,data=x)) X1 X2 X1:X2 -1.77 0.83 1.25 R> R> OK, so far so good. But change the column names of 'x' and the behaviour changes: colnames(x) <-
2010 Dec 05
3
lm() and interactions in model formula for x passed as matrix
Suppose I have x variables x1, x2, x3 (however in general I don't know how many x variables there are). I can do X<-cbind(x1,x2,x3) lm(y ~ X) This fits the no-interaction model with b0, b1, b2, b3. How can I get lm() to fit the model that includes interactions when I pass X to lm()? For my example, lm(y~x1*x2*x3) I am looking for something along the lines of lm(y~X ...) where ... is some
2010 Nov 15
2
rotate column names in large matrix
Dear List, I have a large (1600*1600) matrix generated with symnum, that I am using to eyeball the structure of a dataset. I have abbreviated the column names with the abbr.colnames option. One way to get an even more compact view of the matrix would be to display the column names rotated by 90 degrees. Any pointers on how to do this would be most useful. Any other tips for displaying the
2011 May 06
2
editor: not possible to change the variable name
Hi again everybody I have I new problem concerning the editor of R. It is possible to add a new variable column, but they all have the name "var1".I read somewhere that it should be possible to change the variable name by clicking on it, but that doesn't work. Is that a bug or how is it possible to change the variable header? Many thanks Matthias -- View this message in
2010 Oct 10
2
How to add a new column to a matrix?
Hi - I am a beginner to the R language. I have written the following matrix: Z.mat=matrix(c(2,2,2,1,1,1,3,2,1,6,5,4,9,1,1,2,3,2), nrow=6) I would like to add a 4th column consisting of: 6, 9, 8, 15, 16, 17 I would also like to name each column a, b, c, d as well. Thanks! [[alternative HTML version deleted]]
2011 Dec 10
2
p-value for hazard ratio in Cox proportional hazards regression?
Hi, I'm new to R and using it for Cox survival analysis. Thanks to this great forum I learned how to compute the HR with its confidence interval. My question would be: Is there any way to get the p-value for a hazard ratio in addition to the confidence interval? Thanks, Thierry -- Thierry Panje Visiting Student Researcher Department of Psychology Stanford
2010 Jan 14
5
Better way than an ifelse statement?
Hello All, I am trying to create a column of weights based off of factor levels from another column. I am using the weights to calculate L scores. Here is an example where the first column are scores, the second is my "factor" and the third I want to be a column of weights. I can do what I want with an ifelse statement (see below), but I am wondering if anyone knows of a cleaner way
2011 Oct 27
2
help with paste
Hello gurus, I have some variables, and i am creating combinations for analysis in the end i need these variables to be displayed like "LEPTIN+SAA+PTH". currently i am using loop to perform this. I would appreciate any pointers to do it without the loop. > mols=c("LEPTIN","SAA","PTH","sEGFR") > samples=mols[1:3] > samples [1]
2012 Oct 28
6
Hausman test in R
Hi there, I am really new to statistics in R and statistics itself as well. My situation: I ran a lot of OLS regressions with different independent variables. (using the lm() function). After having done that, I know there is endogeneity due to omitted variables. (or perhaps due to any other reasons). And here comes the Hausman test. I know this test is used to identify endogeneity. But what I
2010 Nov 15
3
How to plot effect of x1 while controlling for x2
Hello R-helpers, Please see a self-contained example below, in which I attempt to plot the effect of x1 on y, while controlling for x2. Is there a function that does the same thing, without having to specify that x2 should be held at its mean value? It works fine for this simple example, but might be cumbersome if the model was more complex (e.g., lots of x variables, and/or interactions). Many
2011 Feb 07
1
Seeking help to define s4 method for 'print'
I have got another question on defining a method for print() function for my s4 class. Here is my class definition as well as what I have done till now: > setClass("Me", representation(x1 = "numeric", x2 = "numeric", y1 = "character")) [1] "Me" > setMethod("print", "Me", definition=function(x) { + cat("Values
2011 Jul 22
1
how to fix coefficients in regression
Hello all, I am using a glm() and would like to fix one of the regression coefficients to be a particular value and see what happens to the fit of the model. E.g.: mod1 <- glm(Y ~ X1 + X2,family='binomial') mod2 <- glm(Y~[fixed to 1.3]X1 + X2,family='binomial') The beta for X1 is freely estimated in mod1 but is constrained to be 1.3 in mod2. Is there a way to do this?
2008 May 07
1
Automatically generating new column names (and columns)
Once again I need to tap into the collective knowledge here. Let's say I have the following columns and data below Y X1 X2 X3 X4 I would like to generate additional new columns and column names (ie the data would be squared - and I'd like the column names to reflect this) like: Y X1 X2 X3 X4 X1^2 X2^2 X3^2 X4^2 I believe I can compute the values correctly with the code below, but I
2010 Jul 12
1
problem with comparisons for vectors
I don't know the real reason, but help("==") gives some clues. For numerical and complex values, remember == and != do not allow for the finite representation of fractions, nor for rounding error. Using all.equal with identical is almost always preferable. See the examples. x1 <- 0.5 - 0.3 x2 <- 0.3 - 0.1 x1 == x2 # FALSE on most machines
2011 Mar 13
4
readMat - how to retrieve the variables
Hello I have a matlab MAT file that contains one single variable: a. The structure of a is as follows: a.river1.flow (flow values) a.river1.date_flow (date) a.river1.precip (precipitation values) a.river1.date_precip a.river2.flow a.river2.date_flow a.river2.precip a.river2.date_precip I have used readMat to load the variable a in R, however I have no idea how readMat translates a. I managed
2011 Jul 24
1
barplot colors
Hi, In barplot(height, col = ...), the col = vector recycles so that the same colors are used for each bar. I would like to use different colors in different bars (corresponding to another piece of information, here, the region of the country being represented). For example, x = matrix(c(5,2,3,1),nrow=2) barplot(x,col=1:4) will draw two bars with two segments each, but each colored red and
2011 Feb 17
2
sort by column and row names
Hello, All, How can one sort on column and row names. For example: How can this X1 X3 X2 X1 1 0 0 X3 0 1 0 X2 0 0 1 become this? X1 X2 X3 X1 1 0 0 X2 0 1 0 X3 0 0 1 Thank you for your time! Jim [[alternative HTML version deleted]]