Hi, I have a data set (data frame) approx. 50 rows * 600 columns. The columns are separated by commas. I would like to know how to remove those commas between the columns. What should I do to remove those commas? Secondly, if I want only to use part of the (data frame), say (50 rows * 300 columns) instead of (50 rows * 600 columns), what should I do? Thanks, Stephen
Hi, there, I have a question about multinom rountine. The response is a matrix, and the predicator is a data frame called dat. I would like multinom to get response and data from within this function test instead of from R Console session. --------------------------------------------------------------------- test <- function() { library(nnet) response <- diag(1,3) dat <- as.data.frame(matrix(round(rnorm(6)),3,2)) fit <- summary(multinom(response ~ ., data=dat)) coefficients <- fit$coefficients return(coefficients) } -------------------------------------------------------------------------- The response and dat are two different data sets, and one does not include another. But it seems multinom automatically get data and response from R Console environment, not the function test itself. So when I run the above function (assume that in R console we don't have objects response and dat), it gives error: cannot find response and dat. How can I let multinom get the data for the formula from within the function test without assigning response and dat into the R console environment. Thanks very much. Jun Han [[alternative HTML version deleted]]
Stephen Opiyo wrote:> Hi, > > I have a data set (data frame) approx. 50 rows * 600 columns. The > columns are separated by commas. I would like to know how to remove > those commas between the columns. What should I do to remove those > commas?I guess during the import of the data? Please read the R Data Import/Export manual and the help page ?read.table. It tells you how to use the argument "sep".> Secondly, if I want only to use part of the (data frame), say > (50 rows * 300 columns) instead of (50 rows * 600 columns), what should > I do?Index the data frame appropriately. See the manual "An Introduction to R". Also, the help page ?data.frame points you to subsetting methods in its "See Also" Section. Uwe Ligges> Thanks, > > Stephen > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help