Re: [R] More elegant way of excluding rows with equal values in any 2columns?
Assuming your real dataset isn't the one you showed (for which e1071::permutation(4) works well) you can sort each row and then quickly check for duplicates by comparing each column to the previous column. E.g., f - function(index){ rowSort - function(x){ x - t(as.matrix(x)) x[] - x[order(col(x), x)] t(x) } tmp - rowSort(index) keep - rep(T, nrow(tmp)) if(ncol(tmp)1) for(i in 2:ncol(tmp)) keep - keep tmp[,i] != tmp[,i-1] index[keep,] } f(index) Some package probably has a row sorting function but the above works pretty well. Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Dimitri Liakhovitski Sent: Monday, September 21, 2009 11:14 AM To: R-Help List Subject: [R] More elegant way of excluding rows with equal values in any 2columns? Hello, dear R-ers! I built a data frame grid (below) with 4 columns. I want to exclude all rows that have equal values in ANY 2 columns. Here is how I am doing it: index-expand.grid(1:4,1:4,1:4,1:4) dim(index) # Deleting rows that have identical values in any two columns (1 line of code): index-index[!(index$Var1==index$Var2)!(index$Var1==index$Var 3)!(index$Var1==index$Var4)!(index$Var2==index$Var3)!(index $Var2==index$Var4)!(index$Var3==index$Var4),] dim(index) index I was wondering if there is a more elegant way of doing it - because as the number of columns increases, the amount of code one would have to write increases A LOT. Thank you very much for any suggestion! -- Dimitri Liakhovitski Ninah.com dimitri.liakhovit...@ninah.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-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.
Re: [R] logarithmic seq() ?
On 21-Sep-09 18:47:50, Oliver Bandel wrote: Hello, in scilab /Matlab there are functions that can create linear sequences (like R's seq()) as well as logarithmic sequences. Is there a logarithmic aequivalent of seq()? Or maybe this would be an idea for newer R-releases, maybe a type-option with linear and logarithmic as parameters?! Ciao, Oliver If you mean going from a to b by logarithmically equal steps, then you can quite readily implement it yourself. For example: exp(log(10)*seq(log10(1),log10(100),by=0.25) [1] 1.00 1.778279 3.162278 5.623413 10.00 [6] 17.782794 31.622777 56.234133 100.00 One could turn this sort of thing into a function, though a function which includes the various ways of doing it that are encapsulated in plain seq() would be quite complicated for a normal user to write, so I think there is an argument for your proposal! Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 21-Sep-09 Time: 20:32:22 -- XFMail -- __ 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.
Re: [R] logarithmic seq() ?
On Sep 21, 2009, at 2:47 PM, Oliver Bandel wrote: Hello, in scilab /Matlab there are functions that can create linear sequences (like R's seq()) as well as logarithmic sequences. Is there a logarithmic aequivalent of seq()? Or maybe this would be an idea for newer R-releases, maybe a type-option with linear and logarithmic as parameters?! A question came up recently to which the answer something along the lines of: exp( seq(log(x[1], log(x[length(x)]), length.out=6) ) Is that what you meant by a logarithmic sequence? Or would it be: log(1:10) # ? David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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.
Re: [R] Regarding information on writing R scripts
On Mon, 21-Sep-2009 at 11:34PM +0530, Manuj Sharma wrote: | I need to run a set of R commands in batch mode. Can somebody | please provide pointers to information on how to write R scripts to | execute commands in batch mode? ?BATCH | Thanks, | | Manuj | | | | Try the new Yahoo! India Homepage. Click here. http://in.yahoo.com/trynew | [[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. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ 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] Working around 256 byte variable names? + trouble opening large file
Dear R users, I am trying to read in a file with 105 columns, and when trying to attach it, get an error as follows: vc1-read.table(P:\\R\\Everything-I.txt, header=T, sep= , dec=., na.strings=NA, strip.white=T) attach(vc1) Error in attach(vc1) : variable names are limited to 256 bytes Is there a way to get around this, and make R accept the given variable names? Or will I have to shorten them? Also, when I try to read in a much larger file with 430 columns, I get the error: Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 397 did not have 431 elements Is it that R isn't dealing too well with Excel-converted-to-text files? Is it a function of file size? I have double-checked the 430 column file and all data seems to be in place. Thanks for your help! Aditi -- A Singh aditi.si...@bristol.ac.uk School of Biological Sciences University of Bristol __ 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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
Well the first suspicious thing seems to be the 256 byte variable names. Do you really have a 256 byte variable name? If so, why? It sounds like R is reading the entire header line as one variable. Why not try exporting the Exce file as a csv file and loading that? --- On Mon, 9/21/09, A Singh aditi.si...@bristol.ac.uk wrote: From: A Singh aditi.si...@bristol.ac.uk Subject: [R] Working around 256 byte variable names? + trouble opening large file To: r-help@r-project.org Received: Monday, September 21, 2009, 4:04 PM Dear R users, I am trying to read in a file with 105 columns, and when trying to attach it, get an error as follows: vc1-read.table(P:\\R\\Everything-I.txt, header=T, sep= , dec=., na.strings=NA, strip.white=T) attach(vc1) Error in attach(vc1) : variable names are limited to 256 bytes Is there a way to get around this, and make R accept the given variable names? Or will I have to shorten them? Also, when I try to read in a much larger file with 430 columns, I get the error: Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 397 did not have 431 elements Is it that R isn't dealing too well with Excel-converted-to-text files? Is it a function of file size? I have double-checked the 430 column file and all data seems to be in place. Thanks for your help! Aditi -- A Singh aditi.si...@bristol.ac.uk School of Biological Sciences University of Bristol __ 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-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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
On Sep 21, 2009, at 4:04 PM, A Singh wrote: Dear R users, I am trying to read in a file with 105 columns, and when trying to attach it, get an error as follows: vc1-read.table(P:\\R\\Everything-I.txt, header=T, sep= , dec=., na.strings=NA, strip.white=T) attach(vc1) Error in attach(vc1) : variable names are limited to 256 bytes Is there a way to get around this, and make R accept the given variable names? Or will I have to shorten them? It's my guess that you have an unmatched quote in your header somewhere. The error is reported when the length of a SINGLE variable name is over the 256 character limit, and not when the total number of characters in all of the variable names is over 256. Shirley, you cannot have a variable name that want to be that long. Also, when I try to read in a much larger file with 430 columns, I get the error: Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 397 did not have 431 elements Is it that R isn't dealing too well with Excel-converted-to-text files? Is it a function of file size? R is not the problem. It is capable of filling. I have double-checked the 430 column file and all data seems to be in place. Again, probably a misplaced quote character. -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
Dear John, I did just try to do that, and it is still returning the same error when I try to attach the csv file.. vc1-read.table(P:\\R\\Everything-I.csv,header=T, sep= , dec=., na.strings=NA, strip.white=T) attach(vc1) Error in attach(vc1) : variable names are limited to 256 bytes Each variable name is only 5 to 6 characters long, but I'm sure you're right about R reading the entire header line as one variable. I cannot figure out though, how to stop it from doing so. sep= , or sep=, do not seem to work either, though I don't know if it is the right thing to be trying. --On 21 September 2009 13:11 -0700 John Kane jrkrid...@yahoo.ca wrote: Well the first suspicious thing seems to be the 256 byte variable names. Do you really have a 256 byte variable name? If so, why? It sounds like R is reading the entire header line as one variable. Why not try exporting the Exce file as a csv file and loading that? --- On Mon, 9/21/09, A Singh aditi.si...@bristol.ac.uk wrote: From: A Singh aditi.si...@bristol.ac.uk Subject: [R] Working around 256 byte variable names? + trouble opening large file To: r-help@r-project.org Received: Monday, September 21, 2009, 4:04 PM Dear R users, I am trying to read in a file with 105 columns, and when trying to attach it, get an error as follows: vc1-read.table(P:\\R\\Everything-I.txt, header=T, sep= , dec=., na.strings=NA, strip.white=T) attach(vc1) Error in attach(vc1) : variable names are limited to 256 bytes Is there a way to get around this, and make R accept the given variable names? Or will I have to shorten them? Also, when I try to read in a much larger file with 430 columns, I get the error: Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 397 did not have 431 elements Is it that R isn't dealing too well with Excel-converted-to-text files? Is it a function of file size? I have double-checked the 430 column file and all data seems to be in place. Thanks for your help! Aditi -- A Singh aditi.si...@bristol.ac.uk School of Biological Sciences University of Bristol __ 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. __ Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail. Click on Options in Mail and switch to New Mail today or register for free at http://mail.yahoo.ca -- A Singh aditi.si...@bristol.ac.uk School of Biological Sciences University of Bristol __ 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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
:) Well that does make even more sense. Is there a way of fixing the unmatched quote problem though? I do not have any clue as to how it can be done. Will remaking the original file, and then re-reading it in help? --On 21 September 2009 16:17 -0400 David Winsemius dwinsem...@comcast.net wrote: On Sep 21, 2009, at 4:04 PM, A Singh wrote: Dear R users, I am trying to read in a file with 105 columns, and when trying to attach it, get an error as follows: vc1-read.table(P:\\R\\Everything-I.txt, header=T, sep= , dec=., na.strings=NA, strip.white=T) attach(vc1) Error in attach(vc1) : variable names are limited to 256 bytes Is there a way to get around this, and make R accept the given variable names? Or will I have to shorten them? It's my guess that you have an unmatched quote in your header somewhere. The error is reported when the length of a SINGLE variable name is over the 256 character limit, and not when the total number of characters in all of the variable names is over 256. Shirley, you cannot have a variable name that want to be that long. Also, when I try to read in a much larger file with 430 columns, I get the error: Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 397 did not have 431 elements Is it that R isn't dealing too well with Excel-converted-to-text files? Is it a function of file size? R is not the problem. It is capable of filling. I have double-checked the 430 column file and all data seems to be in place. Again, probably a misplaced quote character. -- David Winsemius, MD Heritage Laboratories West Hartford, CT -- A Singh aditi.si...@bristol.ac.uk School of Biological Sciences University of Bristol __ 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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
Hi Aditi, On Sep 21, 2009, at 4:04 PM, A Singh wrote: Dear R users, I am trying to read in a file with 105 columns, and when trying to attach it, get an error as follows: vc1-read.table(P:\\R\\Everything-I.txt, header=T, sep= , dec=., na.strings=NA, strip.white=T) attach(vc1) Error in attach(vc1) : variable names are limited to 256 bytes Is there a way to get around this, and make R accept the given variable names? Or will I have to shorten them? 1. Don't use `attach`. Here's a good starting point to help you develop your R coding style, I'm sending you straight to the section about using attach :-) http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html#attach 2. what do you get when you run names(vc1)? Also, when I try to read in a much larger file with 430 columns, I get the error: Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 397 did not have 431 elements Is it that R isn't dealing too well with Excel-converted-to-text files? Is it a function of file size? It's not a function of file size, but rather due to the fact that line 397 does not have as many data entries as the other lines .. maybe this is a function of how excel is exporting the data? I have double-checked the 430 column file and all data seems to be in place. How did you check the column to verify that? In Excel? I'm not an excel guru, so I don't know how it handles data export when certain cells are missing in a row -- each row should have as many demarcated data points as any other. So if its a CSV, there should be just as many ,'s in line 397 as there are in the preceding lines. HTH, -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ 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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
I did just try to do that, and it is still returning the same error when I try to attach the csv file.. vc1-read.table(P:\\R\\Everything-I.csv,header=T, sep= , dec=., na.strings=NA, strip.white=T) attach(vc1) Error in attach(vc1) : variable names are limited to 256 bytes Each variable name is only 5 to 6 characters long, but I'm sure you're right about R reading the entire header line as one variable. I cannot figure out though, how to stop it from doing so. sep= , or sep=, do not seem to work either, though I don't know if it is the right thing to be trying. You will certainly need to specify the correct sep argument, and if it is truly a CSV file, that is NOT , but , Why don't you paste/attach the first few lines of your .csv file for inspection if all else fails? What about the unmatched quote idea from a previous post?? __ 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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
On Mon, Sep 21, 2009 at 3:04 PM, A Singh aditi.si...@bristol.ac.uk wrote: Dear R users, I am trying to read in a file with 105 columns, and when trying to attach it, get an error as follows: vc1-read.table(P:\\R\\Everything-I.txt, header=T, sep= , dec=., na.strings=NA, strip.white=T) attach(vc1) Error in attach(vc1) : variable names are limited to 256 bytes Is there a way to get around this, and make R accept the given variable names? Or will I have to shorten them? Don't use attach? Hadley -- http://had.co.nz/ __ 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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
Read in the first few lines with readLines, try to eyeball the errors and if not successful, then supply them to read.table through a textConnection. Remember that single quotes do not match double quotes. Also watch out for smart-quotes. I don't think they match anything. ?readLines ?textConnection ?make.names Also use the count.fields function to identify malformed lines later in the file. -- David Winsemius On Sep 21, 2009, at 4:24 PM, A Singh wrote: :) Well that does make even more sense. Is there a way of fixing the unmatched quote problem though? I do not have any clue as to how it can be done. Will remaking the original file, and then re-reading it in help? --On 21 September 2009 16:17 -0400 David Winsemius dwinsem...@comcast.net wrote: On Sep 21, 2009, at 4:04 PM, A Singh wrote: Dear R users, I am trying to read in a file with 105 columns, and when trying to attach it, get an error as follows: vc1-read.table(P:\\R\\Everything-I.txt, header=T, sep= , dec=., na.strings=NA, strip.white=T) attach(vc1) Error in attach(vc1) : variable names are limited to 256 bytes Is there a way to get around this, and make R accept the given variable names? Or will I have to shorten them? It's my guess that you have an unmatched quote in your header somewhere. The error is reported when the length of a SINGLE variable name is over the 256 character limit, and not when the total number of characters in all of the variable names is over 256. Shirley, you cannot have a variable name that want to be that long. Also, when I try to read in a much larger file with 430 columns, I get the error: Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 397 did not have 431 elements Is it that R isn't dealing too well with Excel-converted-to-text files? Is it a function of file size? R is not the problem. It is capable of filling. I have double-checked the 430 column file and all data seems to be in place. Again, probably a misplaced quote character. -- David Winsemius, MD Heritage Laboratories West Hartford, CT -- A Singh aditi.si...@bristol.ac.uk School of Biological Sciences University of Bristol David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
Sometimes getting a file into R can seem like the longest part of the project :( Okay I seem to have misread your first message. If I understand you correctly the file vcl is being read in? It is only when you try to attach the file that you have the problem? If this is so, have a look at vcl. Try head(vcl) str((vcl) class(vcl) and see if you can display the file (head()) and get some idea of the structure from str() and class() --- On Mon, 9/21/09, A Singh aditi.si...@bristol.ac.uk wrote: From: A Singh aditi.si...@bristol.ac.uk Subject: Re: [R] Working around 256 byte variable names? + trouble opening large file To: John Kane jrkrid...@yahoo.ca, r-help@r-project.org, A Singh aditi.si...@bristol.ac.uk Received: Monday, September 21, 2009, 4:19 PM Dear John, I did just try to do that, and it is still returning the same error when I try to attach the csv file.. vc1-read.table(P:\\R\\Everything-I.csv,header=T, sep= , dec=., na.strings=NA, strip.white=T) attach(vc1) Error in attach(vc1) : variable names are limited to 256 bytes Each variable name is only 5 to 6 characters long, but I'm sure you're right about R reading the entire header line as one variable. I cannot figure out though, how to stop it from doing so. sep= , or sep=, do not seem to work either, though I don't know if it is the right thing to be trying. --On 21 September 2009 13:11 -0700 John Kane jrkrid...@yahoo.ca wrote: Well the first suspicious thing seems to be the 256 byte variable names. Do you really have a 256 byte variable name? If so, why? It sounds like R is reading the entire header line as one variable. Why not try exporting the Exce file as a csv file and loading that? --- On Mon, 9/21/09, A Singh aditi.si...@bristol.ac.uk wrote: From: A Singh aditi.si...@bristol.ac.uk Subject: [R] Working around 256 byte variable names? + trouble opening large file To: r-help@r-project.org Received: Monday, September 21, 2009, 4:04 PM Dear R users, I am trying to read in a file with 105 columns, and when trying to attach it, get an error as follows: vc1-read.table(P:\\R\\Everything-I.txt, header=T, sep= , dec=., na.strings=NA, strip.white=T) attach(vc1) Error in attach(vc1) : variable names are limited to 256 bytes Is there a way to get around this, and make R accept the given variable names? Or will I have to shorten them? Also, when I try to read in a much larger file with 430 columns, I get the error: Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 397 did not have 431 elements Is it that R isn't dealing too well with Excel-converted-to-text files? Is it a function of file size? I have double-checked the 430 column file and all data seems to be in place. Thanks for your help! Aditi -- A Singh aditi.si...@bristol.ac.uk School of Biological Sciences University of Bristol __ 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. __ Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail. Click on Options in Mail and switch to New Mail today or - A Singh aditi.si...@bristol.ac.uk School of Biological Sciences University of Bristol __ The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! G __ 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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
--- On Mon, 9/21/09, hadley wickham h.wick...@gmail.com wrote: From: hadley wickham h.wick...@gmail.com Don't use attach? Obvously good advice but why? __ The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! __ 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.
Re: [R] Handling missing data
No, this is part of my dataset. Anyway, this is unlikely to cause the problem. If there are few data, impute.knn actually uses mean imputation (and returns a warning). - Original Message - From: Martin Morgan mtmor...@fhcrc.org To: Vassilis Golfinopoulos vassilis.golfinopou...@gmail.com Cc: Greg Snow greg.s...@imail.org; r-help@r-project.org; premmad mtechp...@gmail.com Sent: Monday, September 21, 2009 7:20 PM Subject: Re: [R] Handling missing data Vassilis Golfinopoulos wrote: Consider this sample dataset (displayed [1:3, 1:3]): T1053B T1102A T1129A AKT1 -0.02412174 0.1986057 NA AURKA -0.37109748 -0.4418542 0.04967051 BRAF -0.14589269 -0.1590310 -0.35483226 is.na(dataset[1, 3]) TRUE library(impute) library(GeneMeta) imputed.dataset - impute.knn(as.matrix(dataset)) impute.knn has a second parameter k with default value 10, the number of nearest neighbors to use, in gene space, for imputation. For the example above, there are not 10 nearest neighbors, and unfortunately impute.knn does not check for this. Is this the case with your real data? This might address your problem with impute.knn, a GeneMeta example would help for progress on that front. Martin CRASH! 2009/9/21 Greg Snow greg.s...@imail.org: Help us to help you, show us the code that you tried, what you expected, and what you saw. Does using NA condition mean: x == NA Which does not work Or is.na(x) Which should. -Original Message- From: premmad mtechp...@gmail.com To: r-help@r-project.org r-help@r-project.org Sent: 9/21/09 12:38 AM Subject: [R] Handling missing data I have to remove missing data both in character and numeric datatype.I tried using NA condition but it is not working ,please help me to solve this. -- View this message in context: http://www.nabble.com/Handling-missing-data-tp25530192p25530192.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-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-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-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] Linear Model NA Value Test
Hello, I am deriving near real-time liner relationships based on 5-min precipitation data, sometimes the non-qced data result in a slope of NA. I am trying to read the coefficient (in this example x) to see if it is equal to NA, if it is equal to NA assign it a value of 1. I am having trouble with the if statement not recognizing the coefficient or NA value in the test. Any thoughts, I supplied a really basic example below. Thank you, Doug # ## Example ## # x=c(1,1,1) y=c(1,1,1) fit - lm(y~x) fit Call: lm(formula = y ~ x) Coefficients: (Intercept)x 1 NA coef - coef(fit) fit$coef[[2]] [1] NA if(fit$coef[[2]] == NA) {.cw = 1} -- - Douglas M. Hultstrand, MS Senior Hydrometeorologist Metstat, Inc. Windsor, Colorado voice: 970.686.1253 email: dmhul...@metstat.com web: http://www.metstat.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.
Re: [R] Linear Model NA Value Test
if(fit$coef[[2]] == NA) {.cw = 1} See ?is.na __ 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.
Re: [R] Linear Model NA Value Test
On Sep 21, 2009, at 4:38 PM, Douglas M. Hultstrand wrote: Hello, I am deriving near real-time liner relationships based on 5-min precipitation data, sometimes the non-qced data result in a slope of NA. I am trying to read the coefficient (in this example x) to see if it is equal to NA, if it is equal to NA assign it a value of 1. I am having trouble with the if statement not recognizing the coefficient or NA value in the test. Any thoughts, I supplied a really basic example below. Thank you, Doug # ## Example ## # x=c(1,1,1) y=c(1,1,1) fit - lm(y~x) fit Call: lm(formula = y ~ x) Coefficients: (Intercept)x 1 NA coef - coef(fit) fit$coef[[2]] [1] NA if(fit$coef[[2]] == NA) {.cw = 1} . That would test for equality to the string composed of N and A but not for NA. (Nothing equals NA. ) ?is.na -- - Douglas M. Hultstrand, MS Senior Hydrometeorologist Metstat, Inc. Windsor, Colorado voice: 970.686.1253 email: dmhul...@metstat.com web: http://www.metstat.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. David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] RWeb javascript version
Hi, Does the general public have access to RWeb at the following URL: http://www.math.montana.edu/Rweb/codeWindow.html Or do we need a special username and password? If so, how do I go about obtaining that username and password, please? Cheers, Natalie Natalie O'Toole Data Information Specialist Mount Royal University Library Calgary, AB noto...@mtroyal.ca 403-440-6794 (Embedded image moved to file: pic01655.gif) This communication is intended for the use of the recipient to which it is addressed, and may contain confidential, personal, and or privileged information. Please contact the sender immediately if you are not the intended recipient of this communication, and do not copy, distribute, or take action relying on it. Any communication received in error, or subsequent reply, should be deleted or destroyed.__ 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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
Thanks a huge bunch John, David, Steve, Hadley and Erik! I don't know how acceptable it is to mass thank everyone :), but seemed like a good idea as everyone was in on the thread and here's how it worked: Unmatched quotes was probably correct. When exporting from excel, it did warn me that there were things incompatible with .txt, which could cause problems with the file, and I think that is what happened with trying to read in the .txt version. The csv versions didn't run for the broken down smaller files but when I tried it with Everything.csv (430 columns), it worked. names(vc) gave me: [1] id family P1L55 P1L73 P1L74 [6] P1L77 P1L91 P1L96 P1L98 P1L100 ... (...sep=,.. ) also worked, and I just finished running a loop over 430 columns for an hierarchical model. W... I would like to find out why attach() is advised against, and thanks again for a list of useful commands that I can explore in the future. Cheers! :) Aditi -- A Singh aditi.si...@bristol.ac.uk School of Biological Sciences University of Bristol __ 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.
Re: [R] Linear Model NA Value Test
On Sep 21, 2009, at 4:50 PM, David Winsemius wrote: On Sep 21, 2009, at 4:38 PM, Douglas M. Hultstrand wrote: Hello, I am deriving near real-time liner relationships based on 5-min precipitation data, sometimes the non-qced data result in a slope of NA. I am trying to read the coefficient (in this example x) to see if it is equal to NA, if it is equal to NA assign it a value of 1. I am having trouble with the if statement not recognizing the coefficient or NA value in the test. Any thoughts, I supplied a really basic example below. Thank you, Doug # ## Example ## # x=c(1,1,1) y=c(1,1,1) fit - lm(y~x) fit Call: lm(formula = y ~ x) Coefficients: (Intercept)x 1 NA coef - coef(fit) fit$coef[[2]] [1] NA if(fit$coef[[2]] == NA) {.cw = 1} And furthermore, don't surround your expressions with quotes unless that exactly what you wnat to test. Almost surely you wanted to see if fit$coef[[2]] were equal to something rather than fit$coef[[2]]. That would test for equality to the string composed of N and A but not for NA. (Nothing equals NA. ) ?is.na David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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.
Re: [R] correlation help
library(psych) corr.test(d6) ? --- On Sun, 9/20/09, Adrian Johnson oriolebaltim...@gmail.com wrote: From: Adrian Johnson oriolebaltim...@gmail.com Subject: Re: [R] correlation help To: r-help@r-project.org Received: Sunday, September 20, 2009, 6:19 PM thank you john. however, I am finding it difficult to automate on a matrix. Pardon my ignorance in R computing: I do not know how to automate on a matrix. If I do the following it works: x = cor.test(d6[1,],d6[2,]) x Pearson's product-moment correlation data: d6[1, ] and d6[2, ] t = 10.5196, df = 10, p-value = 9.973e-07 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: 0.8520623 0.9883592 sample estimates: cor 0.9576655 If I want to run it on all rows, I do not know how to do it. I tried following, lapply(d6,cor.test) Error in cor.test.default(X[[1L]], ...) : element 1 is empty; the part of the args list of 'length' being evaluated was: (y) sapply(d6,cor.test) Error in cor.test.default(X[[1L]], ...) : element 1 is empty; the part of the args list of 'length' being evaluated was: (y) for(i in 1:14659){ + k = i+1 + cor.test(d6[i,],d6[k,]) + x = cor.test(d6[i,],d6[k,]) + return(x)} Error: no function to return from, jumping to top level I appreciate your help. thank you. Adrian On Sun, Sep 20, 2009 at 6:17 PM, Adrian Johnson oriolebaltim...@gmail.com wrote: thank you john. however, I am finding it difficult to automate on a matrix. Pardon my ignorance in R computing: I do not know how to automate on a matrix. If I do the following it works: x = cor.test(d6[1,],d6[2,]) x Pearson's product-moment correlation data: d6[1, ] and d6[2, ] t = 10.5196, df = 10, p-value = 9.973e-07 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: 0.8520623 0.9883592 sample estimates: cor 0.9576655 If I want to run it on all rows, I do not know how to do it. I tried following, lapply(d6,cor.test) Error in cor.test.default(X[[1L]], ...) : element 1 is empty; the part of the args list of 'length' being evaluated was: (y) sapply(d6,cor.test) Error in cor.test.default(X[[1L]], ...) : element 1 is empty; the part of the args list of 'length' being evaluated was: (y) for(i in 1:14659){ + k = i+1 + cor.test(d6[i,],d6[k,]) + x = cor.test(d6[i,],d6[k,]) + return(x)} Error: no function to return from, jumping to top level I appreciate your help. thank you. Adrian On Sun, Sep 20, 2009 at 5:13 PM, John Kane jrkrid...@yahoo.ca wrote: ?cor ?cor.test --- On Sun, 9/20/09, Adrian Johnson oriolebaltim...@gmail.com wrote: From: Adrian Johnson oriolebaltim...@gmail.com Subject: [R] correlation help To: r-help@r-project.org Received: Sunday, September 20, 2009, 5:00 PM Dear group, I have a matrix like the following: Name Sample1 sample2 sample3 sample4 . sample(n) nm1 10.5 13.5 30 31 nm2 8 11 34 29 nm3 9 10.3 27.8 35 nm(j) I want to be able to calculate correlation between all pairs of names. For example (nm1,nm2), (nm1,nm3), (nm1,nmj), (nm2,nm3), (nm2,nmj) Then I want to calculate the significance of correlation using t-score or p-value. I can calculate correlation coeffecient in excel but not significance in both excel and R. I want to be able to do it in R, I appreciate your help. thank you. Ad. __ 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. __ Be smarter than spam. See how smart SpamGu Click on Options in Mail and switch to New Mail today or register fo 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. __ Make your browsing faster, safer, and easier with the new Internet Explorer® 8. Optimize explorer/ __ 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.
Re: [R] Linear Model NA Value Test
On 21-Sep-09 20:38:25, Douglas M. Hultstrand wrote: Hello, I am deriving near real-time liner relationships based on 5-min precipitation data, sometimes the non-qced data result in a slope of NA. I am trying to read the coefficient (in this example x) to see if it is equal to NA, if it is equal to NA assign it a value of 1. I am having trouble with the if statement not recognizing the coefficient or NA value in the test. Any thoughts, I supplied a really basic example below. Thank you, Doug # ## Example ## # x=c(1,1,1) y=c(1,1,1) fit - lm(y~x) fit Call: lm(formula = y ~ x) Coefficients: (Intercept)x 1 NA coef - coef(fit) fit$coef[[2]] [1] NA if(fit$coef[[2]] == NA) {.cw = 1} I take it you know why you are getting the NA in that example (i.e. because the routine evaluates 0/0 with result NA). But the test for NA is not == NA, which itself always ireturns NA. == is a test for equality of value. NA is not a value. The best way to test whether something is NA is to use is.na(something) which returns TRUE if something is NA. The logic of NA is that it can be interpreted as could be anything, and we don't know what. So if x - NA ; y - NA then x == y will return NA because a) x could be anything; y could be the same anything or a different one. b) Depending on what the unkown values of x and y really are, x == y could be TRUE or FALSE, but we don't know which. So, withing the domain of logical values, x == y could be either TRUE or FALSE and we don't know which, so it could be anything in that domain. Hence x == y returns NA. That's logical ... Ted. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 21-Sep-09 Time: 22:02:42 -- XFMail -- __ 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.
Re: [R] correlation help
On 9/21/09, William Revelle li...@revelle.net wrote: correlations) use either the rcorr function in the Hmisc package or the corr.test function in the psych package. Also, check the graphical interfaces in Rcmdr and Deducer. Liviu __ 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] xtable - print - suppress output
hi, I use xtable to convert data.frames to html tables. But when I use the print-command I always get the whole output printed even if I just want to save the html table into a variable; table - print(xtable(CERAT), type=html) How can I suppress that output is printed? thanks! [[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.
Re: [R] xtable - print - suppress output
On 22/09/2009, at 9:52 AM, Martin Batholdy wrote: hi, I use xtable to convert data.frames to html tables. But when I use the print-command I always get the whole output printed even if I just want to save the html table into a variable; table - print(xtable(CERAT), type=html) How can I suppress that output is printed? If you don't want it printed, then why the expletive deleted are you (explicitly!) using print??? Words fail me!!! cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ 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.
Re: [R] xtable - print - suppress output
On Sep 21, 2009, at 5:52 PM, Martin Batholdy wrote: I use xtable to convert data.frames to html tables. But when I use the print-command I always get the whole output printed even if I just want to save the html table into a variable; table - print(xtable(CERAT), type=html) How can I suppress that output is printed? Perhaps by diverting it somewhere else? (after the example in xtable's help page) capture.output(print(tli.table, type=html), file=HTout.html) R is not an HTML editor, so it would seem less than intuitive to send it to a character variable. It would not work to assign the value of capture.output since that is an invisible NULL. -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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.
Re: [R] problems with Stackpoly, package Plotrix
On 09/21/2009 09:15 AM, Václav Varvařovský wrote: Dear all, I am fairly new to package Plotrix and I would like to ask you, if any of you could help me with following. a) I don't know how to set up border line width in the Stackpoly function (seems that lwd from par doesn't work, or at least not in the way I have written) b) I don't know, how to rotate the x axis labels (I used srt=45, but same problem as before). c) Could anyone clarify to me, what does e.g. col= par(col) stand for in the usage explanation? Does it somehow change the way I should call such parameter? d) the three dots in stackpoly usage are calling other parameters from plot, however if in plot there are the three dots calling parameters from par, am I able to call parameters from par directly in stackpoly? Hi Vaclav, You have identified several missing bits in stackpoly. Let's take them one by one. a) There is no way to specify border width at the moment. stackpoly is a fairly new function, and I usually program these with minimal options and let the users tell me what is missing. In the modified function below, there is a lwd argument that allows the user to specify this. b) If you want to have angled tick labels, you will have to roll your own with text(). First set par(xpd=TRUE), then display the labels, then set par(xpd=FALSE). Unfortunately axis() doesn't obey the srt argument. c) I can't find the reference to col=par(col) in the help page (stackpoly uses col=NA). par(col) returns the current drawing color (default is black) and would be unlikely to be useful as you would get one big black polygon. The default is to use rainbow() to specify the colors, or the user can pass one or more colors that will define the fill colors for the polygons. d) I think so. If the ... arguments are after any arguments that plot() recognizes, I think they will be passed to par(), but I can't say for sure. The modified stackpoly function will appear in plotrix 2.7-1. Jim stackpoly-function(x,y=NULL,main=,xlab=,ylab=,xat=NA,xaxlab=NA, xlim=NA,ylim=NA,lty=1,lwd=1,border=NA,col=NA,staxx=FALSE,stack=FALSE, axis4=TRUE,...) { ydim-dim(y) if(is.null(y[1])) { y-x ydim-dim(y) if(is.null(ydim)) x-1:length(y) else x-matrix(rep(1:ydim[1],ydim[2]),ncol=ydim[2]) } if(stack) y-t(unlist(apply(as.matrix(y),1,cumsum))) if(is.na(xlim[1])) xlim-range(x) if(is.na(ylim[1])) ylim-range(y) plot(0,main=main,xlab=xlab,ylab=ylab,xlim=xlim,ylim=ylim,type=n, xaxs=i,yaxs=i,axes=FALSE,...) box() if(is.matrix(y) || is.list(y)) { plotlim-par(usr) if(is.na(xat[1])) { xat-x[,1] if(is.na(xaxlab[1])) xaxlab-xat } if(staxx) staxlab(at=xat,labels=xaxlab) else axis(1,at=xat,labels=xaxlab) axis(2) if(axis4) axis(4) if(is.na(col[1])) col=rainbow(ydim[2]) else if(length(col)ydim[2]) col-rep(col,length.out=ydim[2]) if(length(lty)ydim[2]) lty-rep(lty,length.out=ydim[2]) if(length(lwd)ydim[2]) lwd-rep(lwd,length.out=ydim[2]) for(pline in seq(ydim[2],1,by=-1)) { if(pline==1) { polygon(c(x[1],x[,pline],x[ydim[1]]), c(plotlim[3],y[,pline],plotlim[3]), border=border,col=col[pline],lty=lty[pline],lwd=lwd[pline]) } else polygon(c(x[,pline],rev(x[,pline-1])),c(y[,pline],rev(y[,pline-1])), border=border,col=col[pline],lty=lty[pline],lwd=lwd[pline]) } } else { polygon(c(min(x),x,max(x),0),c(0,y,0,0),border=border,col=col,lty=lty, lwd=lwd) if(is.na(xat[1])) { xat-x if(is.na(xaxlab[1])) xaxlab-xat } if(staxx) staxlab(at=xat,labels=xaxlab) else axis(1,at=xat,labels=xaxlab) axis(2) if(axis4) axis(4) } } __ 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.
Re: [R] xtable - print - suppress output
Am 21.09.2009 um 23:59 schrieb Rolf Turner: On 22/09/2009, at 9:52 AM, Martin Batholdy wrote: hi, I use xtable to convert data.frames to html tables. But when I use the print-command I always get the whole output printed even if I just want to save the html table into a variable; table - print(xtable(CERAT), type=html) How can I suppress that output is printed? If you don't want it printed, then why the expletive deleted are you (explicitly!) using print??? Words fail me!!! cheers, Rolf Turner Because I don't get html code when I only use xtable(xy) ## Attention: This e-mail message is privileged and confidential. If you are not the intended recipient please delete the message and notify the sender. Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshal www.marshalsoftware.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.
Re: [R] xtable - print - suppress output
On 22/09/2009, at 10:13 AM, Martin Batholdy wrote: Am 21.09.2009 um 23:59 schrieb Rolf Turner: On 22/09/2009, at 9:52 AM, Martin Batholdy wrote: hi, I use xtable to convert data.frames to html tables. But when I use the print-command I always get the whole output printed even if I just want to save the html table into a variable; table - print(xtable(CERAT), type=html) How can I suppress that output is printed? If you don't want it printed, then why the expletive deleted are you (explicitly!) using print??? Words fail me!!! cheers, Rolf Turner Because I don't get html code when I only use xtable(xy) Why would you want html code stored in an R object??? I believe, although there is no telling, that what you want to do is something like: mung - xtable(CERAT) print(mung,file=gorp,type=html) This will create a *file* of html code that a web browser can use. cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ 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.
Re: [R] xtable - print - suppress output
On Sep 21, 2009, at 6:13 PM, Martin Batholdy wrote: Am 21.09.2009 um 23:59 schrieb Rolf Turner: On 22/09/2009, at 9:52 AM, Martin Batholdy wrote: I use xtable to convert data.frames to html tables. But when I use the print-command I always get the whole output printed even if I just want to save the html table into a variable; table - print(xtable(CERAT), type=html) How can I suppress that output is printed? If you don't want it printed, then why the expletive deleted are you (explicitly!) using print??? Words fail me!!! cheers, Rolf Turner Because I don't get html code when I only use xtable(xy) One further alternative that is quieter is the html function in Hmisc, however this produces a browser page display rather than an R console output. It does not output h to the console upon creation data(tli) h - html(tli) h# the print.html method is part of Hmisc -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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.
Re: [R] xtable - print - suppress output
I think there is a conceptual issue here. The xtable() function does not actually create html. What it does is add some attributes to the dataframe that is given to it. Here's an example: tmp - data.frame( a =1:3, b= c('a','b','c') ) foo - xtable(tmp) class(foo) [1] xtable data.frame unclass(foo) $a [1] 1 2 3 $b [1] a b c Levels: a b c attr(,row.names) [1] 1 2 3 attr(,align) [1] r r l attr(,digits) [1] 0 2 2 attr(,display) [1] s d s The output of class(foo) tells us that foo is still a dataframe. It has two columns, a and b, just like tmp did. What it also has are some additional attributes, in this case some alignment information, some digits information, and some display information. And that is *all* that xtable() did. The real work is done by the function print.xtable(). This takes the dataframe and its additional attributes and prints it using either html or LaTeX syntax, depending on the 'type' argument. This is why xtable() has relatively few optional arguments, but print.xtable() has many. xtable() does not create html. print.xtable() creates html. In other words, there is no such thing as saving the html table into a variable. It just doesn't work that way. All that is possible is to write it (print it) to either the screen or a file. Which leads back to the question that one of the other responses asked ... what is the reason for saving it to an R object? What do you hope to accomplish by doing that, that you can't accomplish using print() ? Hope this helps -Don p.s. Besides xtable, other packages that help write html include Hmisc (already mentioned), hwriter, HTMLUtils, and R2HTML. Maybe one of them does things enough differently to do whatever it is you're looking for. At 12:13 AM +0200 9/22/09, Martin Batholdy wrote: Am 21.09.2009 um 23:59 schrieb Rolf Turner: On 22/09/2009, at 9:52 AM, Martin Batholdy wrote: hi, I use xtable to convert data.frames to html tables. But when I use the print-command I always get the whole output printed even if I just want to save the html table into a variable; table - print(xtable(CERAT), type=html) How can I suppress that output is printed? If you don't want it printed, then why the expletive deleted are you (explicitly!) using print??? Words fail me!!! cheers, Rolf Turner Because I don't get html code when I only use xtable(xy) ## Attention: This e-mail message is privileged and confidential. If you are not the intended recipient please delete the message and notify the sender. Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshal www.*marshalsoftware.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. -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062 __ 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.
Re: [R] RODBC : using and passing queries that use in some arguments
Start by using single quotes in your paste() command. dumb example: sql - paste(' select x = 3 ') (the query is nonsense, I just wrote it to show how to get double quotes into the query) -Don At 6:45 PM +0200 9/21/09, BOISSON, Pascal wrote: Dear R users, I am trying to connect R to data that is in a Access Database but I have problem with the construction of queries using special characters. I am using RODBC package. The following is working : MyQuery-paste(SELECT first( (DateHeure) ) , avg(NNO3_AT322_OUT_moy) AS Cond FROM Colonne_3 ) Col3-sqlQuery(con, query=MyQuery) Col3 Expr1000 Cond 1 2009-06-23 10:15:02 579.9562 MyQuery-paste(SELECT first( format (DateHeure) ) , avg(NNO3_AT322_OUT_moy) AS Cond FROM Colonne_3 ) Col3-sqlQuery(con, query=MyQuery) Col3 Expr1000 Cond 1 23/06/2009 10:15:02 579.9562 But I have problems as soon as I want to use SQL functions in my query that use a double quote (eg FORMAT() function). I have no idea on how to build my sql instruction containing since the escape code \ does not seem to work/be sufficient in this case. (Nota : the argument I would like to use in the following call to format is 00 ) #Obvious error : MyQuery-paste(SELECT first( format(DateHeure, 00)) ) , avg(NNO3_AT322_OUT_moy) AS Cond FROM Colonne_3 ) Erreur : constante numérique inattendu(e) dans MyQuery-paste(SELECT first( format(DateHeure, 00 Expr1000 Cond 1 23/06/2009 10:15:02 492.0594 #Trying to solve the error using the escape code \ : MyQuery-paste(SELECT first( format(DateHeure, \00\)) ) , avg(NNO3_AT322_OUT_moy) AS Cond FROM Colonne_3 ) Col3-sqlQuery(con, query=cat(MyQuery)) SELECT first( format(DateHeure, 00)) ) , avg(NNO3_AT322_OUT_moy) AS Cond FROM Colonne_3 Erreur dans odbcQuery(channel, query, rows_at_time) : 'getEncChar' doit être appelé sur un CHARSXP Do you have any idea on how to proceed? With Best regards Pascal Boisson ___ Protegeons ensemble l'environnement : avez-vous besoin d'imprimer ce courrier electronique ? ___ Les informations figurant sur cet e-mail ont un caractere strictement confidentiel et sont exclusivement adressees au destinataire mentionne ci-dessus.Tout usage, reproduction ou divulgation de cet e-mail est strictement interdit si vous n'en etes pas le destinataire. Dans ce cas, veuillez nous en avertir immediatement par la meme voie et detruire l'original. Merci. This e-mail is intended only for use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Any use, distribution or copying of this e-mail communication is strictly prohibited if you are not the addressee. If so, please notify us immediately by e-mail, and destroy the original. Thank you. __ 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. -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062 __ 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] Read-in TSV file
Is there a standard command that I can use to read a TSV file into R? Thanks Andy __ 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.
Re: [R] problems with Stackpoly, package Plotrix
On 09/21/2009 09:31 AM, Václav Varvařovský wrote: xpopis-c(0.9,0.99,0.999) paste(1 in,round(1/(1-xpopis),1),sep= ) #n as number of subjects is 4 result-c(0.3,0.15,0.4,0.15,0.5,0.1,0.12,0.28,0.45,0.25,0.2,0.1) stackpoly(x=matrix(nrow=3,ncol=4,xpopis),y=matrix(nrow=3,ncol=4,result,byrow=T), xlim=c(0.85,1),ylim=c(0,1), xaxlab=paste(1 in,round(1/(1-xpopis),1),sep= ),xat=xpopis, col=c(blue,red,green,cyan), border=gray(0.4),lty=dotted,lwd=0.1,stack=T,srt=45) Hi again, This gives me a better idea of what you want. If you make your third line in the call: xaxlab=c(,,),xat=xpopis, and then: par(xpd=TRUE) text(c(0.9,0.99,1),c(-0.06,-0.06,0.06), c(1 in 10,1 in 100,1 in 1000),srt=45) I think you will get what you want. Jim __ 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.
Re: [R] logarithmic seq() ?
Ted.Harding at manchester.ac.uk writes: On 21-Sep-09 18:47:50, Oliver Bandel wrote: Hello, in scilab /Matlab there are functions that can create linear sequences (like R's seq()) as well as logarithmic sequences. Is there a logarithmic aequivalent of seq()? Or maybe this would be an idea for newer R-releases, maybe a type-option with linear and logarithmic as parameters?! Ciao, Oliver If you mean going from a to b by logarithmically equal steps, then you can quite readily implement it yourself. For example: exp(log(10)*seq(log10(1),log10(100),by=0.25) [1] 1.00 1.778279 3.162278 5.623413 10.00 [6] 17.782794 31.622777 56.234133 100.00 [...] OK, thanks for the hint. I adapted your example... ...to create a function that offers what scilab's logspace() offers: logspace - function( d1, d2, n) exp(log(10)*seq(d1, d2, length.out=n)) logspace( 1, 2, 10 ) [1] 10.0 12.91550 16.68101 21.54435 27.82559 35.93814 46.41589 [8] 59.94843 77.42637 100.0 logspace( 1, 7.2, 10 ) [1] 1.00e+01 4.885274e+01 2.386590e+02 1.165914e+03 5.695811e+03 [6] 2.782559e+04 1.359356e+05 6.640828e+05 3.244226e+06 1.584893e+07 But maybe your example (with the logarithms of the arguments) make even more sense... :-) Ciao, Oliver __ 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.
Re: [R] Read-in TSV file
Andy, If TSV = tab separated file, then ?read.delim HTH, Jim Porzak Ancestry.com San Francisco, CA www.linkedin.com/in/jimporzak use R! Group SF: www.meetup.com/R-Users/ On Mon, Sep 21, 2009 at 4:00 PM, Andrew Wang hellangel_...@yahoo.comwrote: Is there a standard command that I can use to read a TSV file into R? Thanks Andy __ 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. [[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.
Re: [R] Selecting data based on date-Data manupulation
On 09/21/2009 03:55 PM, premmad wrote: I have 70 columns and more than 400k rows .In the data date column will have values from 1900(01/01/1900) .How do i select only the data of recent two years?Help me in this regard Hi premmad, First, find out what the two most recent dates are: two_recent_dates- sort(strptime(mydata$date,format=%d/%m/%Y)),TRUE)[1:2] then get the row indices of those dates. which(strptime(mydata$date,format=%d/%m/%Y) %in% two_recent_dates) then select your rows: mydata[two_recent_dates,] Jim __ 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.
Re: [R] Putting a text box in a plot
On 09/21/2009 07:42 PM, Sergey Goriatchev wrote: Hello everyone, I have a plot and I want to but a (formatted) box containing text and numbers, say: Mean: 0.1 St.Deviation: 1.1 Skewness: 1.1 Kurtosis: 0.5 I know there is a way to do this, there is a function in some library, but it's been years since I used this function, and I do not remember where I found it. Could anyone help out? Thank you in advance! Sergey Hi Sergey, Maybe addtable2plot in the plotrix package will do what you want. Jim __ 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.
Re: [R] Printing column names before each block of output (fwd)
On 09/21/2009 11:32 PM, A Singh wrote: Dear All, I need to print the column names of variables before each block of output, for a nested model with 2 levels (3 phenotypes * 10 markers). This is so that my output is labeled, and I know which combination of factors produces which set of REML estimates. Currently my output looks like this: [1] Phenotype NULL##this is where I want to insert colnames OR numbers 1-3 [1] Marker NULL ##insert colnames again OR numbers 1-10 Linear mixed model fit by REML - (data) - (data) Random effects: -(data) . . [1] Marker NULL Linear mixed model fit by REML - (data) - (data) Random effects: . . (3*10 combinations) My code is as follows: vc-read.table(...,header=T) vcdf-data.frame(vc) vcdf[2:13]-lapply(vcdf[2:13,factor) colms-(vcdf)[4:13] ## these are the 10 markers. I put them in a new variable to make running the loop simple. phen-(vcdf)[14:16] ##these are the 3 phenotypes for( c in phen) { print(Phenotype) print(colnames(c)) for( f in colms) { print(Marker) print(colnames(f)) fit-lmer(data=vcdf, c~1 + (1|family/f)) print(summary(fit)) }} Any pointers on how to print either column names, or a sequence of numbers? Hi Aditi, First check whether your data frame already has names: names(vcdf) if not, give it names: names(vcdf)-paste(V,1:length(vcdf),sep=) substituting whatever you like for V. Then: cat(names(c),\n) ... cat(names(f),\n) Jim __ 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.
Re: [R] xtable - print - suppress output
On Mon, Sep 21, 2009 at 3:52 PM, Don MacQueen m...@llnl.gov wrote: snip... In other words, there is no such thing as saving the html table into a variable. It just doesn't work that way. All that is possible is to write it (print it) to either the screen or a file. Which leads back to the question that one of the other responses asked ... what is the reason for saving it to an R object? What do you hope to accomplish by doing that, that you can't accomplish using print() ? Hope this helps -Don Actually, I find myself doing this all the time with xtable output. xtable() is a very nice piece of code and it has saved me a lot of time-- but in some cases I have found the defaults/options available for output formatting rather... inflexible. The quickest solution for me has always been to capture the output of print.xtable() as an R character vector, do some editing/splicing/tweaking and then re-emit the code. I use a tweaked version of the print.xtable function that omits the final print() statement (which is what causes all the output to hit the console, or your LaTeX document or wherever else you don't want it to go) and reorganizes the output for easy editing. You can make your own using: myXtable - edit( xtable:::print.xtable ) Then replace the lines: print(result) return(invisible(result$text)) With: result$text - strsplit( result$text, '\n' )[[1]] return( result$text ) Now, you can use output - myXtable( xtableObject, type = 'html' ) To capture the output as a character vector and edit it as you wish. Hope that helps! -Charlie [[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.
[R] AIC vs. extractAIC
Dear list, I am confused about two functions in R: AIC(fm) and extractAIC(fm). What is the difference between two and when do I have to use one over the other? I have found the similar question previously and still not clear for me to understand. I also looked at '?AIC' and '?extractAIC' in R, which is also unclear. I pasted faked data set, fitting summary, and AICs. Thank you very much in advance! Steve y - rnorm(100, 10,3) x1 - y + rnorm(100, 5,3) x2 - y + rnorm(100, 10, 5) fm - lm(y ~ x1+x2) summary(fm) Call: lm(formula = y ~ x1 + x2) Residuals: Min 1Q Median 3Q Max -4.15818 -1.28600 -0.09738 1.34688 4.61042 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) -0.064310.77240 -0.0830.934 x1 0.432080.04334 9.970 2e-16 *** x2 0.169260.03357 5.043 2.13e-06 *** --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Residual standard error: 1.856 on 97 degrees of freedom Multiple R-squared: 0.6462, Adjusted R-squared: 0.639 F-statistic: 88.6 on 2 and 97 DF, p-value: 2.2e-16 AIC(fm) [1] 412.4119 extractAIC(fm) [1] 3. 126.6242 [[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.
Re: [R] xtable - print - suppress output
Note that R has a capture.output function, e.g. s - capture.output(print(xtable(BOD), type = html)) On Mon, Sep 21, 2009 at 9:21 PM, Charlie Sharpsteen ch...@sharpsteen.net wrote: On Mon, Sep 21, 2009 at 3:52 PM, Don MacQueen m...@llnl.gov wrote: snip... In other words, there is no such thing as saving the html table into a variable. It just doesn't work that way. All that is possible is to write it (print it) to either the screen or a file. Which leads back to the question that one of the other responses asked ... what is the reason for saving it to an R object? What do you hope to accomplish by doing that, that you can't accomplish using print() ? Hope this helps -Don Actually, I find myself doing this all the time with xtable output. xtable() is a very nice piece of code and it has saved me a lot of time-- but in some cases I have found the defaults/options available for output formatting rather... inflexible. The quickest solution for me has always been to capture the output of print.xtable() as an R character vector, do some editing/splicing/tweaking and then re-emit the code. I use a tweaked version of the print.xtable function that omits the final print() statement (which is what causes all the output to hit the console, or your LaTeX document or wherever else you don't want it to go) and reorganizes the output for easy editing. You can make your own using: myXtable - edit( xtable:::print.xtable ) Then replace the lines: print(result) return(invisible(result$text)) With: result$text - strsplit( result$text, '\n' )[[1]] return( result$text ) Now, you can use output - myXtable( xtableObject, type = 'html' ) To capture the output as a character vector and edit it as you wish. Hope that helps! -Charlie [[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. __ 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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
If you are starting with an Excel file, then you should have R read the xls file directly. You should avoid the distortions often introduced by an intermediate format such as .txt or .csv files. I recommend using RExcel. You can get it from CRAN with install.packages(RExcelInstaller) library(RExcelInstaller) installRExcel() For more details, go to http://rcom.univie.ac.at and click on the Wiki. There are about 5 other packages that are also able to read xls files directly into R. Some of them can read Excel .xls files on operating systems that don't have Excel. Rich __ 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] Weird read.table error? (line `n' did not have `m' elements)
Hi, I have the following commands. It says line 5205 does not have 22 elements. But I use my 'vim' checked that line in the file. It has 22 fields. Can somebody let me know how to further debug this case? Regards, Peng annotation = read.table(../EC_results/Juan_15wks_gene_core.xls, header=T, sep='\t',quote='') Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 5204 did not have 22 elements annotation = count.fields(../EC_results/Juan_15wks_gene_core.xls, sep='\t',quote='') which(annotation!=22) [1] 5205 __ 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.
Re: [R] Weird read.table error? (line `n' did not have `m' elements)
On Mon, Sep 21, 2009 at 9:12 PM, Peng Yu pengyu...@gmail.com wrote: Hi, I have the following commands. It says line 5205 does not have 22 elements. But I use my 'vim' checked that line in the file. It has 22 fields. Can somebody let me know how to further debug this case? Regards, Peng annotation = read.table(../EC_results/Juan_15wks_gene_core.xls, header=T, sep='\t',quote='') Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 5204 did not have 22 elements annotation = count.fields(../EC_results/Juan_15wks_gene_core.xls, sep='\t',quote='') which(annotation!=22) [1] 5205 I also run the following command to test, which confirms that line 5205 has 22 elements. Is it a bug in read.table? scanned_file = scan(../EC_results/Juan_15wks_gene_core.xls, what=character(),sep='\n',quote='') Read 2 items length(strsplit(scanned_file[5205],'\t')[[1]]) [1] 22 Regards, Peng __ 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.
Re: [R] Weird read.table error? (line `n' did not have `m' elements)
Its highly unusual to use xls as the extension for a text file. Use something more suggestive. print out the line in question. For example, note that scan and read.table have different defaults for the comment character, namely, none and #. On Mon, Sep 21, 2009 at 10:23 PM, Peng Yu pengyu...@gmail.com wrote: On Mon, Sep 21, 2009 at 9:12 PM, Peng Yu pengyu...@gmail.com wrote: Hi, I have the following commands. It says line 5205 does not have 22 elements. But I use my 'vim' checked that line in the file. It has 22 fields. Can somebody let me know how to further debug this case? Regards, Peng annotation = read.table(../EC_results/Juan_15wks_gene_core.xls, header=T, sep='\t',quote='') Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 5204 did not have 22 elements annotation = count.fields(../EC_results/Juan_15wks_gene_core.xls, sep='\t',quote='') which(annotation!=22) [1] 5205 I also run the following command to test, which confirms that line 5205 has 22 elements. Is it a bug in read.table? scanned_file = scan(../EC_results/Juan_15wks_gene_core.xls, what=character(),sep='\n',quote='') Read 2 items length(strsplit(scanned_file[5205],'\t')[[1]]) [1] 22 Regards, Peng __ 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-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] Pull Coefficients from MCMCpack models
Hi, I've been testing some models with the MCMCpack library. I can run the process and get a nice model object. I can easily see the summary and even plot it. I can't seem to figure out how to: 1) Access the final coefficients in the model 2) Turn the coefficients into a model so I can then run predictions using them. A summary command will SHOW Me the coefficients, but I can't run a predict with them. Can someone suggest how to pull them out and format them so that I can run some predictions to test the quality. I thought something like as.model would be there, but isn't. For example. foo - MCMClogit(label ~ x1 + x2) summary(foo) plot(foo) foo has all the info. How do I pull out the coefficients and format them into a standard logit model?? Thanks! -N __ 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.
Re: [R] Weird read.table error? (line `n' did not have `m' elements)
Here are the outputs. strsplit(scanned_file[5205],'\t')[[1]] [1] 6836237 [2] 8.146431 [3] 8.197432 [4] 8.156005 [5] 7.98905 [6] 8.327593 [7] 7.673796 [8] 8.119687 [9] 8.077252 [10] Asap1 [11] NM_010026 [12] RefSeq [13] Mus musculus ArfGAP with SH# domain, ankyrin repeat and PH domain1 (Asap1), mRNA. [14] FALSE [15] GO:0032312 [16] regulation of ARF GTPase activity [17] GO:0005737 // GO:0016020 [18] cytoplasm // membrane [19] GO:0005096 // GO:0005515 // GO:0008060 // GO:0008270 // GO:0046872 [20] GTPase activator activity // protein binding // ARF GTPase activator activity // zinc ion binding // metal ion binding [21] --- [22] --- scanned_file[5205] [1] 6836237\t8.146431\t8.197432\t8.156005\t7.98905\t8.327593\t7.673796\t8.119687\t8.077252\tAsap1 \tNM_010026 \tRefSeq \tMus musculus ArfGAP with SH# domain, ankyrin repeat and PH domain1 (Asap1), mRNA. \tFALSE\tGO:0032312 \tregulation of ARF GTPase activity \tGO:0005737 // GO:0016020 \tcytoplasm // membrane \tGO:0005096 // GO:0005515 // GO:0008060 // GO:0008270 // GO:0046872 \tGTPase activator activity // protein binding // ARF GTPase activator activity // zinc ion binding // metal ion binding \t---\t--- On Mon, Sep 21, 2009 at 9:34 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Its highly unusual to use xls as the extension for a text file. Use something more suggestive. print out the line in question. For example, note that scan and read.table have different defaults for the comment character, namely, none and #. On Mon, Sep 21, 2009 at 10:23 PM, Peng Yu pengyu...@gmail.com wrote: On Mon, Sep 21, 2009 at 9:12 PM, Peng Yu pengyu...@gmail.com wrote: Hi, I have the following commands. It says line 5205 does not have 22 elements. But I use my 'vim' checked that line in the file. It has 22 fields. Can somebody let me know how to further debug this case? Regards, Peng annotation = read.table(../EC_results/Juan_15wks_gene_core.xls, header=T, sep='\t',quote='') Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 5204 did not have 22 elements annotation = count.fields(../EC_results/Juan_15wks_gene_core.xls, sep='\t',quote='') which(annotation!=22) [1] 5205 I also run the following command to test, which confirms that line 5205 has 22 elements. Is it a bug in read.table? scanned_file = scan(../EC_results/Juan_15wks_gene_core.xls, what=character(),sep='\n',quote='') Read 2 items length(strsplit(scanned_file[5205],'\t')[[1]]) [1] 22 Regards, Peng __ 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-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.
Re: [R] Weird read.table error? (line `n' did not have `m' elements)
It has a # in it as I previously suggested. On Mon, Sep 21, 2009 at 11:08 PM, Peng Yu pengyu...@gmail.com wrote: Here are the outputs. strsplit(scanned_file[5205],'\t')[[1]] [1] 6836237 [2] 8.146431 [3] 8.197432 [4] 8.156005 [5] 7.98905 [6] 8.327593 [7] 7.673796 [8] 8.119687 [9] 8.077252 [10] Asap1 [11] NM_010026 [12] RefSeq [13] Mus musculus ArfGAP with SH# domain, ankyrin repeat and PH domain1 (Asap1), mRNA. [14] FALSE [15] GO:0032312 [16] regulation of ARF GTPase activity [17] GO:0005737 // GO:0016020 [18] cytoplasm // membrane [19] GO:0005096 // GO:0005515 // GO:0008060 // GO:0008270 // GO:0046872 [20] GTPase activator activity // protein binding // ARF GTPase activator activity // zinc ion binding // metal ion binding [21] --- [22] --- scanned_file[5205] [1] 6836237\t8.146431\t8.197432\t8.156005\t7.98905\t8.327593\t7.673796\t8.119687\t8.077252\tAsap1 \tNM_010026 \tRefSeq \tMus musculus ArfGAP with SH# domain, ankyrin repeat and PH domain1 (Asap1), mRNA. \tFALSE\tGO:0032312 \tregulation of ARF GTPase activity \tGO:0005737 // GO:0016020 \tcytoplasm // membrane \tGO:0005096 // GO:0005515 // GO:0008060 // GO:0008270 // GO:0046872 \tGTPase activator activity // protein binding // ARF GTPase activator activity // zinc ion binding // metal ion binding \t---\t--- On Mon, Sep 21, 2009 at 9:34 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Its highly unusual to use xls as the extension for a text file. Use something more suggestive. print out the line in question. For example, note that scan and read.table have different defaults for the comment character, namely, none and #. On Mon, Sep 21, 2009 at 10:23 PM, Peng Yu pengyu...@gmail.com wrote: On Mon, Sep 21, 2009 at 9:12 PM, Peng Yu pengyu...@gmail.com wrote: Hi, I have the following commands. It says line 5205 does not have 22 elements. But I use my 'vim' checked that line in the file. It has 22 fields. Can somebody let me know how to further debug this case? Regards, Peng annotation = read.table(../EC_results/Juan_15wks_gene_core.xls, header=T, sep='\t',quote='') Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 5204 did not have 22 elements annotation = count.fields(../EC_results/Juan_15wks_gene_core.xls, sep='\t',quote='') which(annotation!=22) [1] 5205 I also run the following command to test, which confirms that line 5205 has 22 elements. Is it a bug in read.table? scanned_file = scan(../EC_results/Juan_15wks_gene_core.xls, what=character(),sep='\n',quote='') Read 2 items length(strsplit(scanned_file[5205],'\t')[[1]]) [1] 22 Regards, Peng __ 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-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-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.
Re: [R] Weird read.table error? (line `n' did not have `m' elements)
Read Gabor's advice more closely: Especially unlucky # (hint, hint) 13. On Sep 21, 2009, at 11:08 PM, Peng Yu wrote: Here are the outputs. strsplit(scanned_file[5205],'\t')[[1]] [1] 6836237 [2] 8.146431 [3] 8.197432 [4] 8.156005 [5] 7.98905 [6] 8.327593 [7] 7.673796 [8] 8.119687 [9] 8.077252 [10] Asap1 [11] NM_010026 [12] RefSeq [13] Mus musculus ArfGAP with SH# domain, ankyrin repeat and PH domain1 (Asap1), mRNA. [14] FALSE [15] GO:0032312 [16] regulation of ARF GTPase activity [17] GO:0005737 // GO:0016020 [18] cytoplasm // membrane [19] GO:0005096 // GO:0005515 // GO:0008060 // GO:0008270 // GO:0046872 [20] GTPase activator activity // protein binding // ARF GTPase activator activity // zinc ion binding // metal ion binding [21] --- [22] --- scanned_file[5205] [1] 6836237 \t8.146431 \t8.197432 \t8.156005\t7.98905\t8.327593\t7.673796\t8.119687\t8.077252\tAsap1 \tNM_010026 \tRefSeq \tMus musculus ArfGAP with SH# domain, ankyrin repeat and PH domain1 (Asap1), mRNA. \tFALSE\tGO:0032312 \tregulation of ARF GTPase activity \tGO:0005737 // GO:0016020 \tcytoplasm // membrane \tGO:0005096 // GO:0005515 // GO:0008060 // GO:0008270 // GO:0046872 \tGTPase activator activity // protein binding // ARF GTPase activator activity // zinc ion binding // metal ion binding \t---\t--- On Mon, Sep 21, 2009 at 9:34 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Its highly unusual to use xls as the extension for a text file. Use something more suggestive. print out the line in question. For example, note that scan and read.table have different defaults for the comment character, namely, none and #. On Mon, Sep 21, 2009 at 10:23 PM, Peng Yu pengyu...@gmail.com wrote: On Mon, Sep 21, 2009 at 9:12 PM, Peng Yu pengyu...@gmail.com wrote: Hi, I have the following commands. It says line 5205 does not have 22 elements. But I use my 'vim' checked that line in the file. It has 22 fields. Can somebody let me know how to further debug this case? Regards, Peng annotation = read.table(../EC_results/ Juan_15wks_gene_core.xls, header=T, sep='\t',quote='') Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 5204 did not have 22 elements annotation = count.fields(../EC_results/ Juan_15wks_gene_core.xls, sep='\t',quote='') which(annotation!=22) [1] 5205 I also run the following command to test, which confirms that line 5205 has 22 elements. Is it a bug in read.table? scanned_file = scan(../EC_results/Juan_15wks_gene_core.xls, what=character(),sep='\n',quote='') Read 2 items length(strsplit(scanned_file[5205],'\t')[[1]]) [1] 22 Regards, Peng __ 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-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. David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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.
Re: [R] Pull Coefficients from MCMCpack models
Deb, That's great!!! But, then how to I convert those values to a model so I can use a predict function. I can see: bar - apply(foo,2,mean) That creates an object, bar, with the coefficients. But, I can't call predict on bar... -N On 9/21/09 7:58 PM, Debabrata Midya wrote: Try this: apply(foo, 2, mean) or apply(foo, 2, median) Thanks, Deb Noah Silverman n...@smartmediacorp.com 22/09/2009 12:34 pm Hi, I've been testing some models with the MCMCpack library. I can run the process and get a nice model object. I can easily see the summary and even plot it. I can't seem to figure out how to: 1) Access the final coefficients in the model 2) Turn the coefficients into a model so I can then run predictions using them. A summary command will SHOW Me the coefficients, but I can't run a predict with them. Can someone suggest how to pull them out and format them so that I can run some predictions to test the quality. I thought something like as.model would be there, but isn't. For example. foo - MCMClogit(label ~ x1 + x2) summary(foo) plot(foo) foo has all the info. How do I pull out the coefficients and format them into a standard logit model?? Thanks! -N __ 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. [[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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
From: hadley wickham h.wick...@gmail.com Don't use attach? Obvously good advice but why? Philosophically, it's better to be explicit than implicit, and the extremely non-local effects of attach can make debugging difficult. Hadley -- http://had.co.nz/ __ 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.
Re: [R] Working around 256 byte variable names? + trouble opening large file
Also you have to be very careful. e.g. BOD Time demand 118.3 22 10.3 33 19.0 44 16.0 55 15.6 67 19.8 attach(BOD) Time - Time + 1 BOD # oops! BOD was not changed Time demand 118.3 22 10.3 33 19.0 44 16.0 55 15.6 67 19.8 On Tue, Sep 22, 2009 at 12:18 AM, hadley wickham h.wick...@gmail.com wrote: From: hadley wickham h.wick...@gmail.com Don't use attach? Obvously good advice but why? Philosophically, it's better to be explicit than implicit, and the extremely non-local effects of attach can make debugging difficult. Hadley -- http://had.co.nz/ __ 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-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.