rowname

Removing display of row names from data frame

独自空忆成欢 提交于 2019-12-17 05:00:07
问题 I am creating a dataframe using this code: df <- data.frame(dbGetQuery(con, paste('select * from test'))) Which results in this: UID BuildingCode AccessTime 1 123456 BUILD-1 2014-06-16 07:00:00 2 364952 BUILD-2 2014-06-15 08:00:00 3 95865 BUILD-1 2014-06-06 09:50:00 I am then trying to remove the row names (1, 2, 3, etc) as suggested here by using this code: rownames(df) <- NULL But then when I print out df it still displays the row names. Is there a way to not include the row names when

How to set rownames of a data.frame?

旧巷老猫 提交于 2019-12-11 07:13:27
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 6 years ago . I came across an issue when creating a data.frame. When I can create a data.frame , and set the appropriate row and column names. Results looks like this: row.names Africa ALPS Benelux CS MRI Systems 92 151 130 CS Computed To 94 110 91 CS Interv X-Ray 548 535 614 Edit: see that after submitting, my formatting gets lost. Means to show that top left part of the data frame says

Give row names to table in R

房东的猫 提交于 2019-12-10 11:24:39
问题 I have a CSV file which somewhat looks like this: I need to cluster "NoOffaces" and count how many datasets has 1 face, 2 face and so on. Here is what I did in R : data<-read.csv('test.csv') a<-table(data$NoOffaces) a #for printing a And here is the output: 0 1 2 3 4 5 6 7 8 9 10 14 15 19 448 375 104 33 16 7 4 2 2 3 1 3 1 1 But, I want to give name to the first two rows so that it looks somewhat like this Faces :0 1 2 3 4 5 6 7 8 9 10 14 15 19 Count :448 375 104 33 16 7 4 2 2 3 1 3 1 1 I am

How can I subscript names in a table from kable()?

走远了吗. 提交于 2019-12-07 08:40:41
问题 Given a data.frame A, how can I use subscripted rows and columns names? Eventually I want produce a table through kable() in rmarkdown (output: word document). A <- data.frame(round(replicate(3, runif(2)),2)) rownames(A) <- c("Hola123", "Hola234") A X1 X2 X3 Hola123 0.47 0.55 0.66 Hola234 0.89 0.45 0.20 How could I make all numbers from row and column names subscripted when creating a table through kable(A)? I have tried: rownames(A) <- c(expression(Hola["123"]), expression(Hola["234"]))

Give row names to table in R

泄露秘密 提交于 2019-12-06 11:56:20
I have a CSV file which somewhat looks like this: I need to cluster "NoOffaces" and count how many datasets has 1 face, 2 face and so on. Here is what I did in R : data<-read.csv('test.csv') a<-table(data$NoOffaces) a #for printing a And here is the output: 0 1 2 3 4 5 6 7 8 9 10 14 15 19 448 375 104 33 16 7 4 2 2 3 1 3 1 1 But, I want to give name to the first two rows so that it looks somewhat like this Faces :0 1 2 3 4 5 6 7 8 9 10 14 15 19 Count :448 375 104 33 16 7 4 2 2 3 1 3 1 1 I am not able to name the rows, also how to access the each value in the column? I am a beginner in R , some

How can I subscript names in a table from kable()?

别说谁变了你拦得住时间么 提交于 2019-12-05 14:31:42
Given a data.frame A, how can I use subscripted rows and columns names? Eventually I want produce a table through kable() in rmarkdown (output: word document). A <- data.frame(round(replicate(3, runif(2)),2)) rownames(A) <- c("Hola123", "Hola234") A X1 X2 X3 Hola123 0.47 0.55 0.66 Hola234 0.89 0.45 0.20 How could I make all numbers from row and column names subscripted when creating a table through kable(A)? I have tried: rownames(A) <- c(expression(Hola["123"]), expression(Hola["234"])) names(A) <- c(expression(X["1"]), expression(X["2"]), expression(X["3"])) But it does not appears

How to select some rows with specific rownames from a dataframe? [closed]

我怕爱的太早我们不能终老 提交于 2019-12-05 12:24:05
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have a data frame with several rows. I want to select some rows with specific rownames (such as stu2,stu3,stu5,stu9 ) from this dataframe. The input example dataframe is as follows: attr1 attr2 attr3 attr4 stu1 0 0 1 0 stu2 -1 1 -1 1 stu3 1 -1 0 -1 stu4 1 -1 1 -1 stu5 -1 1 0 1 stu6 1 -1 1 0 stu7 -1 -1 -1 1

How to get row index number for particular name(s)?

别来无恙 提交于 2019-12-04 09:21:27
How can one determine the row index-numbers corresponding to particular row names? I have a vector of row names, and I would like to use these to obtain a vector of the corresponding row indices in a matrix. I tried row() and as.integer(rownames(matrix.object)) , but neither seems to work. In addition to which , you can look at match : m <- matrix(1:25, ncol = 5, dimnames = list(letters[1:5], LETTERS[1:5])) vec <- c("e", "a", "c") match(vec, rownames(m)) # [1] 5 1 3 Try which : which(rownames(matrix.object) %in% c("foo", "bar")) 来源: https://stackoverflow.com/questions/20663720/how-to-get-row

How to select some rows with specific rownames from a dataframe? [closed]

人走茶凉 提交于 2019-12-03 23:34:44
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have a data frame with several rows. I want to select some rows with specific rownames (such as stu2,stu3,stu5,stu9 ) from this dataframe. The input example dataframe is as follows: attr1 attr2 attr3 attr4 stu1 0 0 1 0 stu2 -1 1 -1 1 stu3 1 -1 0 -1 stu4 1 -1 1 -1 stu5 -1 1 0 1 stu6 1 -1 1 0 stu7 -1 -1 -1 1 stu8 1 -1 0 -1 stu9 -1 -1 1 -1 stu10 -1 1 0 1 Expected output: attr1 attr2 attr3 attr4 stu2

rownames and colnames with specific value

怎甘沉沦 提交于 2019-12-02 03:20:22
问题 I have this matrix and i want to get a 2 column matrix, where one column has the rowname and the other column, the colname of cells with value 1 x X1 X2 X3 X1 1 0 1 X2 0 1 0 X3 0 1 1 X4 1 0 0 str(x) num [1:886, 1:886] 1 0 1 1 1 0 1 1 1 1 I want a matrix like this # X1 X1 # X1 X3 # X2 X2 # X3 X2 # X3 X3 # X4 X1 which are the pairs that have value=1 Thanks in advance, A. 回答1: here another option : mm <- expand.grid(rownames(mat),colnames(mat))[as.vector(mat==1),] Var1 Var2 1 X1 X1 4 X4 X1 6 X2