Trouble with Matrix and Table functions in R -


i'm having trouble changing matrix table using as.table function in r. namely, global environment calls them lists 64 variables when want them called num [1:32] [1:2] in global environment. without num [1:32] [1:2], cannot seem linear model function work data.

i believe problem related how getting data matrix main data table using. if grab values using:

datam1 = matrix(c(datatable[6,3:10],                  datatable[2,3:10],                  "etc"),                ncol=2) 

then matrix (and subsequent as.table table) list of 64. however, if type actual values of datatable[6,3:10], datatable[2,3:10], etc, this:

datam2 = matrix(c(1,2,3,4,5,6,7,8,                  16,26,36,46,56,66,76,86,                  "etc"),                ncol=2) 

then create matrix (and subseqent as.table table) in correct num [1:32] [1:2] format in global environment.

i believe problem that, when grabbing values using datatable[row,columns], carrying on information headers or datatable might screwing way matrix stores things. have suggestions how these values without having manually enter them (as did in datam2, 1 worked purposes)?

so, i've tried make reproducible example you.

if data looks this

a <- 1:10 b <- 1:10 datatable <- data.frame(a, b) datatable <- t(datatable) 

then seems fine, can't reproduce error.

datam1 = matrix(c(datatable[1,3:10],                   datatable[2,3:10]),                   ncol=2)  datam2 = matrix(c(1,2,3,4,5,6,7,8,                   16,26,36,46,56,66,76,86),                   ncol=2) 

give

> str(datam1)  int [1:8, 1:2] 3 4 5 6 7 8 9 10 3 4 ... 

and

> str(datam2)  num [1:8, 1:2] 1 2 3 4 5 6 7 8 16 26 ... 

only difference numeric or integer.

are sure slicing dataframe correctly? datatable[1,3:10] selects column, not row.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -