[R] keeping seperate row.names
I have microarray data with gene names in the first column, gene id in the second and the expression data in the remaining columns. When trying use read.table I get the error, . . . more columns than column names. Is there any way to keep both columns of names without having to discard one. or the other? The raw data is read from a text file and is in the form mitogen-activated protein kinase 3 1000_at 946 1928.8 1504.9 722.5 873.9 836.9 1294.3 631.1 606 1126.6 841.2 833.6 689.6 1256.9 685.8 755.3 974.8 where, mitogen-activated protein kinase 3 is the first column of this (tab delimited) text file and 1000_at is the second column. I want to keep both columns as labels. Is there a way to do that? I've used: test - read.table(path, header=T, sep=\t, row.names=1) and get the error, more columns than column names. Many Thanks, Patrick Van Andel Institute Grand Rapids, MI -- View this message in context: http://www.nabble.com/keeping-seperate-row.names-tp18512130p18512130.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Extracting row.names
List, I'm trying to extract the row names of a table I have read into R. data - read.table(mesodata.txt, header=TRUE, row.names=1) When I try to extract them using, names - data$row.names I get, names NULL I've tried changing to a matrix, data frame, etc. and still get NULL. I've checked ?row.names as well as help on extracting part of an object, etc. and unless I'm missing something obvious (likely), I can't figure out how to extract them. BACKGROUND I want to extract the row names (which are basically gene id's) as well as some other columns (which I can do successfully) and cbind them into another data frame (which I can also do successfully). I just can't get the row names extracted (Assigned) to an seperate object. Any suggestions would be appreciated. Many Thanks, Patrick sessionInfo() R version 2.7.0 (2008-04-22) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base -- View this message in context: http://www.nabble.com/Extracting-%22row.names%22-tp18072521p18072521.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ML Estimation Differences with R and SAS
List, I'm working on fitting a logistic model for a well known dataset (which is given below in case anyone wants to try to reproduce). I used both R and SAS to fit the model and have some differences in the parameter estimates. I'm wondering if R calculates the ML estimates differently. I'm making NO accusations as to which program is right or wrong. That is not the focus of this posting. As a newer R user I'm trying to understand the algorithm that R might use to calculate ML estimation. The largest difference seems to with the race factors. R gives a p-value of 0.46995 for race=black and SAS gives a p-value of 0.0753 for race=black. Clearly one is borderline significant and the other is not. Many thanks to all who might be able to offer any insight on this. Both R and SAS code and output are included in this message (along with the dataset). Thanks, Patrick MY R CODE IS: Dataset - read.table(path, header=TRUE, sep=, na.strings=NA, dec=., strip.white=TRUE) Dataset$race - factor(Dataset$race, levels=c('other','black','white')) GLM.1 - glm(low ~ lwt + ptl + ht + race + smoke , family=binomial(logit), data=Dataset) summary(GLM.1) MY SAS CODE IS: PROC LOGISTIC descending DATA=p2; class race (ref='other'); MODEL LOW = lwt ptl ht race smoke / lackfit parmlabel expb link=logit; RUN; MY R OUTPUT IS: Coefficients: Estimate Std. Error z value Pr(|z|) (Intercept)0.926190.85549 1.083 0.27897 lwt -0.016500.00692 -2.384 0.01712 * ptl1.231160.44607 2.760 0.00578 ** ht 1.761970.70748 2.490 0.01276 * race[T.black] 0.395520.54739 0.723 0.46995 race[T.white] -0.862910.43517 -1.983 0.04737 * smoke 0.880070.40049 2.197 0.02798 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 234.67 on 188 degrees of freedom Residual deviance: 200.62 on 182 degrees of freedom AIC: 214.62 Number of Fisher Scoring iterations: 4 MY SAS OUTPUT IS: The LOGISTIC Procedure Analysis of Maximum Likelihood Estimates StandardWald ParameterDF Estimate Error Chi-Square Pr ChiSq Exp(Est) Label Intercept 10.92870.9326 0.9916 0.3193 2.531 Intercept: low=1 lwt 1 -0.0173 0.00699 6.1425 0.0132 0.983 ptl 11.19580.4472 7.1493 0.0075 3.306 ht11.74820.7090 6.0805 0.0137 5.745 race black 10.59630.3352 3.1643 0.0753 1.815 race black race white 1 -0.72000.2668 7.2803 0.0070 0.487 race white smoke 10.86480.4009 4.6534 0.0310 2.375 0 19 182 black 0 0 1 0 0 2523 0 33 155 other 0 0 0 1 0 2551 0 20 105 white 1 0 0 1 0 2557 0 21 108 white 1 0 1 1 0 2594 0 18 107 white 1 0 1 0 0 2600 0 21 124 other 0 0 0 0 0 2622 0 22 118 white 0 0 0 1 0 2637 0 17 103 other 0 0 0 1 0 2637 0 29 123 white 1 0 0 1 0 2663 0 26 113 white 1 0 0 0 0 2665 0 19 95 other 0 0 0 0 0 2722 0 19 150 other 0 0 0 1 0 2733 0 22 95 other 0 1 0 0 0 2750 0 30 107 other 0 0 1 1 1 2750 0 18 100 white 1 0 0 0 0 2769 0 15 98 black 0 0 0 0 0 2778 0 25 118 white 1 0 0 1 0 2782 0 20 120 other 0 0 1 0 0 2807 0 28 120 white 1 0 0 1 0 2821 0 32 101 other 0 0 0 1 0 2835 0 31 100 white 0 0 1 1 0 2835 0 36 202 white 0 0 0 1 0 2836 0 28 120 other 0 0 0 0 0 2863 0 25 120 other 0 0 1 1 0 2877 0 28 167 white 0 0 0 0 0 2877 0 17 122 white 1 0 0 0 0 2906 0 29 150 white 0 0 0 1 0 2920 0 26 168 black 1 0 0 0 0 2920 0 17 113 black 0 0 0 1 0 2920 0 24 90 white 1 0 0 1 1 2948 0 35 121 black 1 0 0 1 1 2948 0 25 155
[R] Help with Error Message
Hoping someone can offer me some assistance. I'm trying to execute a script and I keep getting this error message about Error: element 12 is empty. I'm wondering if my syntax is incorrect within legend.list. If anyone has any suggestions to sees something obvious that I am missing, I would greatly appreciate any help. Many Thanks, Patrick # These are the symbols and colors to use for each phenotype in the model and test sets # model samples: square symbols # color symbol phenotype legend.list - c(green, 22,# ALL-B + steelblue, 22,# ALL-T + red, 22,# AML + # test samples:cicle symbols + # color symbol phenotype + lightgreen,21,# ALL-B + lightblue, 21,# ALL T + orange,21,# AML + ) Error: element 12 is empty; the part of the args list of 'c' being evaluated was: (22, steelblue, 22, red, 22, lightgreen, 21, lightblue, 21, orange, 21, ) col - legend.list[seq(1, length(legend.list), 2)] Error: object legend.list not found symbs - as.numeric(legend.list[seq(2, length(legend.list), 2)]) Error: object legend.list not found __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Package Building help
List, I've used package.skeleton to build my package and am trying to check it using R CMD check . But can't seem to get anything to work. When I try to enter the R CMD command into R I get this message. R CMD check estpkg Error: syntax error, unexpected SYMBOL, expecting '\n' or ';' in R CMD I'm not sure if I'm using the wrong syntax or what but I can't get R CMD to check my package from within R. I've tried to use Rcmd in the /bin folder of the R root directory and the DOS windows flashes on my screen and disappears immediately. If someone could help me get over this, I would greatly appreciate it. Cheers, Patrick [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.