similar to: Non-alignment of <NA> in rownames

Displaying 20 results from an estimated 10000 matches similar to: "Non-alignment of <NA> in rownames"

2002 Aug 13
2
Misalignment of <NA> in rownames (PR#1905)
An NA in the rownames of a matrix (or dataframe) causes misalignment when the matrix is printed: R> x <- matrix(1:12, 3,4, dimnames=list(letters[1:3], LETTERS[1:4])) R> rownames(x)[2] <- NA R> x A B C D a 1 4 7 10 <NA> 2 5 8 11 c 3 6 9 12 The bug is in function Rstrlen, in src/main/printutils.c. MatrixRowLabel and MatrixColumnLabel (same file) rely on Rstrlen
2002 Aug 28
2
NA rownames in dataframes
Hey everyone! I am seeing strange behavior with NA in the rownames of dataframes: > a <- data.frame(1:3, row.names = c("r1", NA, "r3")) > cbind(a) X1.3 r1 1 <NA> 2 r3 3 Everything works. The peculiar thing is that when the NA is in the first row, things no longer work as I would have expected: > b <- data.frame(1:3, row.names
2003 Feb 20
2
subset with NA
Easy question that I can't find an answer for. I'm trying to subset a data frame and want to exclude the positive values, i.e. I want the NA values. My data: > summary(temp$tuna) Min. 1st Qu. Median Mean 3rd Qu. Max. NA's 1 2 3 3 4 5 1211 Querying for subset(temp, tuna %in% "NA", select.... subset(temp, tuna == NA,
2004 Jun 11
4
rownames of single row matrices
Hi I want to extract rows of a matrix, and preserve rownames even if only one row is selected. Toy example: R> a <- matrix(1:9,3,3) R> rownames(a) <- letters[1:3] R> colnames(a) <- LETTERS[1:3] R> a A B C a 1 4 7 b 2 5 8 c 3 6 9 Extract the first two rows: R> wanted <- 1:2 R> a[wanted,] A B C a 1 4 7 b 2 5 8 rownames come through fine. Now extract just
2002 Apr 08
2
subsetting with NA's
Hi, I often have large dataframes with many variables and many NA's, from which I would like to subset out some rows. Here is a toy example: > x <- data.frame(a = c("x", "y", "z"), b = c(1, NA, 5)) > x a b 1 x 1 2 y NA 3 z 5 I realize that, if I know the values in x$b that I want to subset, things are easy: > x[x$b %in% c(1),] a b 1 x 1
2012 Nov 29
1
Coerce rownames to factor for ordering
Hi all, I think this might be an easy one but I cannot think of a way to do this other than what I am currently attempting. I simply want to sort my data frame's rownames by a defined vector so that the plots I generate from that vector are in the desired order Consider the test data below: #Create test data DataToPlot.. <- data.frame("Location1" =
2008 Jan 04
1
predict.lm removes rownames for a single row. Why?
predict.lm keeps row names when working from several rows in newdata, but always removes rowname from a single row. The rownames are removed by the line in predict.lm predictor <- drop(X[, piv, drop = FALSE] %*% beta[piv]) What is the reason for that decision? I usually want to retain the row names. tmp <- data.frame(x=1:4, y=c(1,3,2,5)) tmp.lm <- lm(y ~ x, data=tmp) tmp.new <-
2010 Feb 05
1
Strange "rownames"
I find one row in my large dataset. But when I use the "rownames" for the data on the 100,000 row, the result show nothing. I try it by the following example, it still likes that. > tst[rownames(tst)==100000,] [1] x y <0 rows> (or 0-length row.names) ############## > tst=data.frame(x=1:200000,y=200000:1) > tst[rownames(tst)==1,] x y 1 1 200000 >
2009 Jul 27
2
Split rownames into factors
Hi Guys, I was wondering how you would go about solving the following problem: I have a list where the grouping information is in the row names. Rowname [,1] X1Jan08 324 X1Jun08 65 X1Dec08 543 X2Jan08 23 X2Jun08 54 X2Dec08 8765 X3Jan08 213 X3Jun08 43 X3Dec08 65 How can I create the following dataframe: Value Date Group [1,] 324 Jan 08 X1 [2,] 65 Jun 08
2010 Aug 16
1
Combining values from a data.frame row with matrix rownames.
Hello, I am trying to iteratively build a build a panel of variables to discriminate between two groups. My starting position is a matrix of experimental data and I have a function that will work through all pairs of variables and produce sensitivities, specificities and p-values for each pair and write it to a file (above particular cut-offs). I have a second function that will read that file
2009 Mar 02
3
Error setting rowname if rowname currently NULL
Hi, My first post here and new to R so please bear with me (long time programmer though, helping a friend with some scripts). I've noticed a behaviour when using rownames() that I think is odd, wondering if I'm doing something wrong. To illustrate, say I create a very simple matrix (called fred): fred<-matrix(,4,2) It looks like this: [,1] [,2] [1,] NA NA [2,] NA NA
2002 Apr 30
2
display of character NA's in a dataframe in 1.5.0
I understand that NA's in character vectors are displayed differently than NA's in factor vectors. > c("x", NA, "y") [1] "x" NA "y" > as.factor(c("x", NA, "y")) [1] x <NA> y Levels: x y That seems sensible enough. But shouldn't I see the same behavior in a dataframe? > test <- data.frame(a =
2008 May 19
2
Sort matrix with duplicate row names alphabetically by rowname
Hi, I've a matrix that contains 4 replicates of each rowname. (4 a's, 4 b's, 4 c's in no particular order) Like this: # c 32 a 1 b 4 c 87 c 34 b 54 a 23 a 12 b 9 a 3 b 87 c 43 There are a couple of more columns but I'm using the above as an example I need to sort it so that the same rownames appear together in alpahbetical order. Like this: # a 1 a 23 a 12 a 3 b 4
2002 May 20
1
(PR#1577) is.na<- coerces character vectors to be factors
The inconsistency is that you use $<- to set the column, then [[<- to change it. Had you tried to set the column by x[[1]] <- as.character(x[[1]]) you would have seen the problem immediately (it does not work as you would have intended). If you want to be sure to turn off conversion to factor, you need to set the column to class "AsIs". My belief is that will behave
2002 Apr 30
3
rbind'ing empty rows in dataframes in 1.4.1 versus 1.5.0
Hi, In 1.4.1, I was able to create extra "empty" rows in a dataframe as so: > x <- data.frame(a = letters[1:3], b = 1:3) > x a b 1 a 1 2 b 2 3 c 3 > x[4,] a b NA NA NA > rbind(x, x[4,]) a b 1 a 1 2 b 2 3 c 3 NA NA NA > R.version _ platform sparc-sun-solaris2.6 arch sparc os solaris2.6
2008 Sep 17
3
using for variable as rowname
Is there a way to use the cycle variable for rowname? v=1:6 for (a in 1:3){ for (b in 4:5) { v=rbind(v,a.b=1) } } v This above obviously does not work, but I couldn't find out how to use a and b to construct a rowname like 14, 15, 24, 25. Thanks for the help. Balazs -- View this message in context: http://www.nabble.com/using-for-variable-as-rowname-tp19533203p19533203.html Sent from
2006 Mar 25
2
pairwise combinatons of variables
Dear WizaRds, although this might be a trivial question to the community, I was unable to find anything solving my problem in the help files on CRAN. Please help. Suppose I have 4 variables and want to use all possible combinations: 1,2 1,3 1,4 2,3 2,4 3,4 for a further kmeans partitioning. I tried permutations() of package e1071, but this is not what I need. Thank you for your help and
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
2007 May 27
1
How to reference or sort rownames in a data frame
As I was working through elementary examples, I was using dataset "plasma" of package "HSAUR". In performing a logistic regression of the data, and making the diagnostic plots (R-2.5.0) data(plasma,package='HSAUR') plasma_1<- glm(ESR ~ fibrinogen * globulin, data=plasma, family=binomial()) layout(matrix(1:4,nrow=2)) plot(plasma_1) I find that data points