Re: [R] problems installing package XML to a computer without an internet connection
On Sun, 11 Jan 2009, Bob Green wrote: Hello, I am hoping for some advice regarding how I can install the XML package which I require to run package tm. Normally I would use the install package option, however, I have to install the packages to a laptop running XP. Windows, I presume. The laptop does not have an internet connection. Firstly I tried the file - XML_1.99-0.tar.gz . Below is the error I received What does 'try' mean? That would work if you used Rcmd INSTALL on it, or install.packages(type="source"). Error in gzfile(file, "r") : cannot open the connection In addition: Warning messages: 1: In zip.unpack(pkg, tmpDir) : error 1 in extracting from zip file 2: In gzfile(file, "r") : cannot open compressed file 'XML_1.99-0.tar.gz/DESCRIPTION', probable reason 'No such file or directory' Then I tried XML 1.96-0.zip (from http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.7/). Below is the Why from 2.7? What version is your R? error I received So that worked: it is 'proxy' you are missing. From the DESCRIPTION file package: tm Title: Text Mining Package Version: 0.3-3 Date: 2008-12-20 Author: Ingo Feinerer, with contributions from Christian Buchta, Kurt Hornik, David Meyer, and Fridolin Wild Maintainer: Ingo Feinerer Depends: R (>= 2.7.0), filehash, Matrix, methods, Snowball, XML Imports: proxy Suggests: Rgraphviz, Rmpi, Rstem (>= 0.3-1), snow still you may need packages filehash, Matrix, methods, Snowball and proxy. I suggest getting those from bin/windows/contrib/2.7/ on CRAN, and installing from the 'Local zip file' menu optipn. Loading required package: XML Error in loadNamespace(i, c(lib.loc, .libPaths())) : there is no package called 'proxy' Error: package/namespace load failed for 'tm' Any suggestions are appreciated, Read the posting guide, remember to tell us what we asked for 'at a minumum' and what you actually did. Bob __ 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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] Convert date/time string to date
On Sun, 11 Jan 2009, Heston Capital wrote: I am new to R and am trying to import a text file that contains date/time and various fields. I want to sort this matrix by date and also perform calculations on the date field (difference between two dates etc). The format of the string looks as follows: x<-c("25/2/2003 0:00:00") I tried: as.Date(x,format='%d/%m/%y') [1] "2020-02-25" Obviously I am doing something wrong here. I would like to remove the You have a 4-figure date, so need %Y not %y. See ?strptime. hh:mm:ss from the end of the string if possible. Thanks for your help, I have been searching for hours and not getting anywhere. __ 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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] ftp connections for uploading files
On Fri, 9 Jan 2009, Duncan Temple Lang wrote: Hi Thomas Rather than getting into the details of libcurl options which are quite general and very flexible, I thought it was easier to write an explicit ftpUpload() function that takes care of the details. You need a new version of the package (as it contains the function and a small change to the C code), but I don't have the time to build the Windows version for the next few days. One is on CRANextras now. The function can be used as ftpUpload("path/to/file", "ftp://server/path/to/target/file";, userpwd = "login:password") and you can deal with contents in memory too rather than from a file. HTH, D. Thomas Loridan wrote: Thanks a lot Duncan Sorry to insist with my questions but I am very lost with these Rcurl commands... could you point out the few ones I need to set up an ftp connection and just upload a file ? Greatly appreciated Thomas 2009/1/8 Duncan Temple Lang : Prof Brian Ripley wrote: Try system() with curl or a decent ftp client (I don't see that package RCurl covers this, but it might despite its description only mentioning HTTP). It does support FTP, and all of the protocols that are supported in the installed libcurl, so it depends the configuration options for libcurl itself. The protocols it handles can be found via the curlVersion() function, e.g. curlVersion() $age [1] 3 $version [1] "7.16.3" $vesion_num [1] 462851 $host [1] "powerpc-apple-darwin9.0" $features ipv6 ssl libz ntlm gssnegotiate largefile 148 16 32 512 $ssl_version [1] " OpenSSL/0.9.7l" $ssl_version_num [1] 0 $libz_version [1] "1.2.3" $protocols [1] "tftp" "ftp""telnet" "dict" "ldap" "http" "file" "https" [9] "ftps" $ares [1] "" $ares_num [1] 0 $libidn [1] "" sessionInfo() R version 2.9.0 Under development (unstable) (2008-09-27 r46576) i386-apple-darwin9.5.0 locale: C attached base packages: [1] stats graphics grDevices datasets utils methods base other attached packages: [1] ROOXML_0.1-0Rcompression_0.4-0 RGoogleDocs_0.2-0 [4] SVGAnnotation_0.1-0 lattice_0.17-15 RCurl_0.92-0 [7] XML_1.99-0 RTools_0.1-0bitops_1.0-4 loaded via a namespace (and not attached): [1] grid_2.9.0 From 'man curl' curl offers a busload of useful tricks like proxy support, user authen- tication, ftp upload, HTTP post, SSL connections, cookies, file trans- fer resume and more. As you will see below, the amount of features will make your head spin! Ftp protocols (and there are more than one) are fiendishly complicated, especially if proxies are involved. BTW, this is yet another case where knowing your OS would have helped give a more precise answer. See the posting guide. On Thu, 8 Jan 2009, Thomas Loridan wrote: Hi all, I would like to upload some plots I create wth R via ftp or something similar but I don t really understand which command/syntax I should use: should I go for make.socket + write.socket or try and create environment variables like frp_proxy_user and then ftp my files? how? many thanks for your help Thomas -- Thomas Loridan King's College email: thomas.lori...@kcl.ac.uk webpage:http://geography.kcl.ac.uk/micromet/tloridan/index.htm __ 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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] Extracting File Basename without Extension
Gabor Grothendieck wrote: > On Fri, Jan 9, 2009 at 4:20 PM, Wacek Kusnierczyk > > >> right; there's a straightforward fix to my solution that accounts for >> cases such as '.bashrc': >> >> names = c("foo.bar", ".zee") >> sub("(.+)[.][^.]+$", "\\1", names) >> >> you could also use a lookbehind if possible (not in r, afaik). >> >> > > or: > > >> sub(".*[.]", ".", names) >> > [1] ".bar" ".zee" > it was "foo" that was desired... vQ __ 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] Extracting File Basename without Extension
Gabor Grothendieck wrote: > On Fri, Jan 9, 2009 at 4:28 PM, Wacek Kusnierczyk > wrote: > >> Rau, Roland wrote: >> >>> P.S. Any suggestions how to become more proficient with regular >>> expressions? The O'Reilly book ("Mastering...")? Whenever I tried >>> anything more complicated than basic usage (things like ^ $ * . ) in R, >>> I was way faster to write a new function (like above) instead of finding >>> a regex solution. >>> >>> >> the book you mention is good. >> you may also consider http://www.regular-expressions.info/ >> >> regexes are usually well explained with lots of examples in perl books. >> >> >>> By the way: it might be still possible to *write* regular expressions, >>> but what about code re-use? Are there people who can easily *read* >>> complicated regular expressions? >>> >>> >> in some cases it is possible to write regular expressions in a way that >> facilitates reading them by a human. in perl, for example, you can use >> so-called readable regexes: >> >> / >> (.+)# match and remember at least one arbitrary character >> [.] # match a dot >> [^.]+ # match at least one non-dot character >> $ # end of string anchor >> /x; >> >> you can also use within regex comments: >> >> /(.+)(?# one or more chars)[.](?# a dot)[^.]+(?# one or more >> non-dots)$(?# end of string)/ >> >> >> nothing of the sorts in r, however. >> > > Supports that if you begin the regular expression with (?x) and > use perl = TRUE. See ?regexp > cool, i see ?xism is supported. so the above can be written in r as: names = c("foo.bar", ".zee") sub("(?x) # alloow embedded comemnts (.+) # match and remember at least one arbitrary character [.] # match a dot [^.]+ # match at least one non-dot character $ # end of string anchor", "\\1", names, perl=TRUE) is this what you wanted, roland? vQ __ 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] PAW Update: Predictive analytics workshops and more case studies
Hi everyone, Predictive Analytics World's program for Feb 18-19 in San Francisco (www.predictiveanalyticsworld.com) has grown a bit since my post several weeks ago, and is looking better than ever. The conference covers today's commercial deployment of predictive analytics, across industries and across software vendors. In a nutshell, PAW is a warehouse of case studies. In breaking news, the Netflix Prize leader slated to speak at PAW has now won the Netflix Progress Prize (see www.predictiveanalyticsworld.com/agenda.php#advancedapproaches) We have two predictive analytics workshops that serve as a third-day option on Feb 20 to complement the core conference program: "The Best and the Worst of Predictive Analytics: Predictive Modeling Methods and Common Data Mining Mistakes" Instructor: John F. Elder, Ph.D., CEO and Founder, Elder Research, Inc. www.predictiveanalyticsworld.com/predictive_modeling_methods.php "Taking Action with Analytics: The Decision-Centric Enterprise - Putting Predictive Analytics to Work Improving Every Business Decision" Instructor: James Taylor, Co-Founder, Smart (enough) Systems www.predictiveanalyticsworld.com/decision_centric_enterprise.php And the list of case studies has expanded - we now have case studies from all of: 3M, Acxiom, Affiliated Computer Services, Charles Schwab, Click Forensics, Google, Linden Lab (Second Life), The National Rifle Association, Pinnacol Assurance, Reed Elsevier, San Diego Supercomputer Center, Sun, Telenor, Wells Fargo Credit Card Services, Wells Fargo Internet Services Group -- plus special examples from Anheuser-Busch, Disney, Hewlett-Packard, HSBC, IRS, Pfizer, Social Security Administration and WestWind Foundation. For more info about the program, see: www.predictiveanalyticsworld.com Be sure to register by January 18th for the Early Bird rate - save $200 at: www.predictiveanalyticsworld.com/register.php If you'd like our informative event updates, sign up at: www.predictiveanalyticsworld.com/notifications.php For a summary of business applications of predictive analytics - and a named case study for each - see the article, "Predictive Analytics Delivers Value Across Business Applications" at www.predictiveanalyticsworld.com/businessapplications.php What is predictive analytics? See the Predictive Analytics Guide: www.predictiveanalyticsworld.com/predictive_analytics.php Take the Predictive Analytics World survey (on applications) As predictive analytics quickly expands across verticals and applications, we need your help to understand what the evolving landscape looks like. Please take a few minutes, answer a handful of questions, and help us keep you informed: https://www.surveymonkey.com/s.aspx?sm=8dHx_2bFz7yxw3FPKlbi3OVg_3d_3d Available for immediate download: Free Industry Survey (on tools) Download the Rexer Analytics 2008 Data Miner Survey report, covering the most popular software tools, which verticals have embraced modeling and more, at: http://www.predictiveanalyticsworld.com/survey-signup.php And finally, let us know if you have any questions. Best, Elise Johnson Predictive Analytics World -- View this message in context: http://www.nabble.com/PAW-Update%3A-Predictive-analytics-workshops-and-more-case-studies-tp21396909p21396909.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.
Re: [R] Arguments for Rcmd BATCH
Professor Ripley, Thank you very much. I have used Rscript and it runs fine now. Your help is very much appreciated. Best wishes, Andrew hicks -Original Message- From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Sent: 11 January 2009 01:23 To: Andrew Hicks Cc: r-help@r-project.org Subject: RE: [R] Arguments for Rcmd BATCH I suggested you use Rscript, please do. R CMD BATCH is the Unix-alike notation. Rcmd BATCH is the recommended way on Windows, but R CMD BATCH is also accepted. There is nothing to reproduce here, so here is a simple example. tystie% cat foo.R args <- commandArgs(TRUE) print(args) tystie% Rscript foo.R parms=1:33 [1] "parms=1:33" You can redirect the output as you wish. On Sun, 11 Jan 2009, Andrew Hicks wrote: > Dear Professor Ripley, > > Firstly, thank you very much for your advice. I was not aware my R was so > old. Sorry I must have missed the instruction on reading the posting > guidelines. > > I have updated it and it now runs again. This is a big step forward. However > it is not running properly (or I am doing something wrong). > > There are still two problems may I ask for your help with please? > > 1. When I call the script it fails with the following message in the output > file: > >> ##First read in the arguments listed at the command line >> args <- commandArgs(TRUE) > Error in commandArgs(TRUE) : unused argument(s) (TRUE) > Execution halted > > 2. The diagnostic details (that should be going to test01b.ROUT are now > going to strange places, overwriting the test01b.R file if I do not include > the < and > redirectors. > > I am now using the following syntax, from the manual: > > Rcmd BATCH --no-save --no-restore --args parms=c(1,2,3) < test01b.R > > test01b.ROUT That's nothing like what is documented. > Currently it is writing the output to "parms=c(1,2,3).ROUT" > > This is attached but says "fatal error cannot open file "--args" > > The file test01b.ROUT is created but empty. > > I get the same results if I start it with R CMD BATCH ... > > Is the a difference between R CMD... and Rcmd... please? The manual is not > very clear on this. > > I am sorry to impose on you but guess I am still doing something wrong. I > have looked through the documentation but cannot find much on this or many > examples. > > Many thanks, > > Andrew Hicks > > > -Original Message- > From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] > Sent: 10 January 2009 18:18 > To: Andrew Hicks > Cc: r-help@r-project.org > Subject: Re: [R] Arguments for Rcmd BATCH > > Your R is far too old, and in particular too old for the example you > are trying. > > Please do you as asked in the posting guide to do before posting, and > upgrade. Then you will have Rscript, as described in the current 'An > Introduction to R' manual for this purpose (with examples). > > On Sat, 10 Jan 2009, Andrew Hicks wrote: > >> Sorry to bother you and I hope this will be easy to solve. >> >> >> I am trying to run R scripts in batch, called from another programme, > under >> Windows XP. I have R 2.4.1 >> >> >> >> I need to be able to pass a list of numeric arguments to the script as > well. >> >> >> >> The Rscript and its input data file are attached. >> >> >> >> I have been trying the syntax below but it doesn't work: >> >> >> >> Rcmd BATCH -no-save -no-restore -args parms=c(1,2,3) test01b.R >> >> >> >> (each of these BATCH options is preceded by 2 - characters, but my Outlook >> is munging them together here) >> >> >> >> The script then accesses (or tries to) the variables as parms[1], > parms[2], >> etc. >> >> >> >> I get the respose "unable to open input file" at the command line and no >> other diagnostic output. >> >> >> >> I got this syntax from p85 of the R-Intro doc and from the website >> http://quantitative-ecology.blogspot.com/search/label/scripts. I could not >> find any other illustrations or instructions of how to use args with > BATCH. >> >> >> >> Without using any parameter args it otherwise runs fine. >> >> >> >> Please can you advise what am I doing wrong and how should this command be >> structured? Do I also need to change the way the script is accessing the >> arguments? >> >> >> >> Many thanks, >> >> >> >> Andrew Hicks >> >> > > -- > Brian D. Ripley, rip...@stats.ox.ac.uk > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UKFax: +44 1865 272595 > -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help P
[R] PHP and R
Hi, I know that using PHP command exec(...) you can call a unix command that would run an R script, but how does it work on Windows platform? Basically, I have an R function which takes a file and two strings as arguments and I need to call this function and pass to it the arguments automatically from PHP (when the user hits a submit button on the webpage), any ideas?? Thanks! -- View this message in context: http://www.nabble.com/PHP-and-R-tp21397426p21397426.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.
Re: [R] PHP and R
On Sun, 11 Jan 2009, Applejus wrote: I know that using PHP command exec(...) you can call a unix command that would run an R script, but how does it work on Windows platform? Exactly the same way. Basically, I have an R function which takes a file and two strings as arguments and I need to call this function and pass to it the arguments automatically from PHP (when the user hits a submit button on the webpage), any ideas?? See Rscript[.exe], which I gave an example of only this morning. It is documented in 'An Introduction to R', amongst other places. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] upgrade R version
dear all contributors i am new R user i want to upgrade my R version from 2.7.1 to 2.8.1 i tried myself, but i could not do it as R is different from other software could anyone guide me please warm regard madan student University of Bergen Windows Live: Keep your life in sync. Check it out. Windows Live Hotmail®: Chat. Store. Share. Do more with mail. See how it works. _ [[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] Strange behaviour of paste
Hello, here I have some code, which behaves quite strange, IMHO. There is a "res.txt" which will be collected before printing it. There is a paste-statement, which has a comment at the end of the line, which is this one: "# !HERE!". If you throw out the first hash-mark "#" on that line, the printout behaves like if it is done for each of the for-loop iterations. If the hash mark will not be thrown out, it behaves, as I would expect: done *once*, after the loop is finished. I'm using "R version 2.7.1 (2008-06-23)" on Debian. Can you please show me, what is going wrong here? The code is not much, but too long (too many lines and lines too long) for pasting it here, so I have placed it here: http://www.first.in-berlin.de/trybug.R Can you show me, why the behaviour differs so much, when just removing that "#" ?! 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.
[R] Error in dyn.load()
Hi everyone! I am relatively new to writing R extensions and to C programming. I thus hope that my question is not too basic. I am trying to load a shared object into R via the command dyn.load("convertR.so") and I get the following error: Error in dyn.load("convertR.so") : unable to load shared library '/Users/hadassa2/Documents/HUJI/Thesis/Sagiv_Project/LDhat/convertR.so': dlopen(/Users/hadassa2/Documents/HUJI/Thesis/Sagiv_Project/LDhat/convertR.so, 6): Symbol not found: _cmatrix Referenced from: /Users/hadassa2/Documents/HUJI/Thesis/Sagiv_Project/LDhat/convertR.so Expected in: dynamic lookup where cmatrix is a function defined in tools.c . I am including tools.h in convertR.c . Does this error mean that I need to create a shared object tools.so as well? Or in general: including other functions into a .so means they need to be of the type .so as well? Thanks a lot for any comments. Hadassa -- Hadassa Brunschwig PhD Student Department of Statistics The Hebrew University of Jerusalem http://www.stat.huji.ac.il __ 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] upgrade R version
Since you are probably a Windows user (from the advert), see the R for Windows FAQ, at http://cran.r-project.org/bin/windows/base/rw-FAQ.html or on the menus in your existing R installation. On Sun, 11 Jan 2009, ms.com wrote: dear all contributors i am new R user i want to upgrade my R version from 2.7.1 to 2.8.1 i tried myself, but i could not do it as R is different from other software I expect you mean 'better than other software' since this is actually in the FAQ. could anyone guide me please warm regard madan student University of Bergen Windows Live?: Keep your life in sync. Check it out. Windows Live? Hotmail?: Chat. Store. Share. Do more with mail. See how it works. _ [[alternative HTML version deleted]] -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] Strange behaviour of paste
I suspect your example code is too long & complicated for anyone to bother attempting to help you. Try simplifying it to just a few lines; I've found that the simplification process itself often leads me to the solution to my own problem. On Sun, Jan 11, 2009 at 6:50 AM, Oliver Bandel wrote: > Hello, > > > here I have some code, which behaves quite strange, IMHO. > There is a "res.txt" which will be collected before printing it. > > There is a paste-statement, which has a comment at the end of the line, > which is this one: "# !HERE!". > > If you throw out the first hash-mark "#" on that line, > the printout behaves like if it is done for each of the > for-loop iterations. If the hash mark will not be thrown out, > it behaves, as I would expect: done *once*, after the loop is finished. > > I'm using "R version 2.7.1 (2008-06-23)" on Debian. > > Can you please show me, what is going wrong here? > > > The code is not much, but too long (too many lines and > lines too long) for pasting it here, so I have placed > it here: > > http://www.first.in-berlin.de/trybug.R > > Can you show me, why the behaviour differs so much, > when just removing that "#" ?! > > 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. > -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University www.thatmike.com Looking to arrange a meeting? Check my public calendar: http://www.thatmike.com/mikes-public-calendar ~ Certainty is folly... I think. ~ [[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] problems installing package XML to a computer without an internet connection
Brian, Thank you for your reply and advice. I hope that I did not give the impression that your build was the cause of the difficulties I experienced. If so, I apologise for this. Your email was helpful in alerting me to the need to install 'proxy' and I subsequently located the current version zip file at: http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.8/ Once I copied this version of the XML file that you wrote, the installation worked without problem. Thank you again, regards Bob At 06:03 PM 11/01/2009, Prof Brian Ripley wrote: On Sun, 11 Jan 2009, Bob Green wrote: Hello, I am hoping for some advice regarding how I can install the XML package which I require to run package tm. Normally I would use the install package option, however, I have to install the packages to a laptop running XP. Windows, I presume. The laptop does not have an internet connection. Firstly I tried the file - XML_1.99-0.tar.gz . Below is the error I received What does 'try' mean? That would work if you used Rcmd INSTALL on it, or install.packages(type="source"). Error in gzfile(file, "r") : cannot open the connection In addition: Warning messages: 1: In zip.unpack(pkg, tmpDir) : error 1 in extracting from zip file 2: In gzfile(file, "r") : cannot open compressed file 'XML_1.99-0.tar.gz/DESCRIPTION', probable reason 'No such file or directory' Then I tried XML 1.96-0.zip (from http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.7/). Below is the Why from 2.7? What version is your R? error I received So that worked: it is 'proxy' you are missing. From the DESCRIPTION file package: tm Title: Text Mining Package Version: 0.3-3 Date: 2008-12-20 Author: Ingo Feinerer, with contributions from Christian Buchta, Kurt Hornik, David Meyer, and Fridolin Wild Maintainer: Ingo Feinerer Depends: R (>= 2.7.0), filehash, Matrix, methods, Snowball, XML Imports: proxy Suggests: Rgraphviz, Rmpi, Rstem (>= 0.3-1), snow still you may need packages filehash, Matrix, methods, Snowball and proxy. I suggest getting those from bin/windows/contrib/2.7/ on CRAN, and installing from the 'Local zip file' menu optipn. Loading required package: XML Error in loadNamespace(i, c(lib.loc, .libPaths())) : there is no package called 'proxy' Error: package/namespace load failed for 'tm' Any suggestions are appreciated, Read the posting guide, remember to tell us what we asked for 'at a minumum' and what you actually did. Bob __ 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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] I'm looking for a book about spatial point patterns (Diggle, 2003)
Amazon lists 2 used copies for sale: http://www.amazon.com/Statistical-Analysis-Spatial-Point-Patterns/dp/0340740701 On Sun, Jan 11, 2009 at 12:04 AM, Unangu wrote: > > To understand some functions about spatial point patterns in "spatstat" ,I > should know some background about it, and the best way is to read the > monograph, and "Statistical Analysis of Spatial Point Patterns" (2nd edt.) > is a better choise. But I can not find it anywhere I can. Who can help me? > Thank you! > > - > una...@gmail.com > -- > View this message in context: > http://www.nabble.com/I%27m-looking-for-a-book-about-spatial-point-patterns-%28Diggle%2C2003%29-tp21395908p21395908.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. > -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University www.thatmike.com Looking to arrange a meeting? Check my public calendar: http://www.thatmike.com/mikes-public-calendar ~ Certainty is folly... I think. ~ __ 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] How to get solution of following polynomial?
On Sun, Jan 11, 2009 at 6:03 AM, RON70 wrote: > > Hi, I want find all roots for the following polynomial : > > a <- c(-0.07, 0.17); b <- c(1, -4); cc <- matrix(c(0.24, 0.00, -0.08, > -0.31), 2); d <- matrix(c(0, 0, -0.13, -0.37), 2); e <- matrix(c(0.2, 0, > -0.06, -0.34), 2) > A1 <- diag(2) + a %*% t(b) + cc; A2 <- -cc + d; A3 <- -d + e; A4 <- -e > fn <- function(z) > { >y <- diag(2) - A1*z - A2*z^2 - A3*z^3 - A4*z^4 >return(det(y)) > }; uniroot(fn, c(-10, 1)) > > Using uniroot function, I got only one solution of that. Is there any > function to get all four solutions? I looked at polyroot() function, but I > do not think it will work for my problem, because, my coef. are matrix, nor > number Use curve to plot the curve of your function. Then, see where the roots are, and use uniroot with a small interval around the roots to determine their exact value. Example: f <- function(x) x^2-1 curve(f,-5,5) uniroot(f,c(-2,-0.2)) uniroot(f,c(0.2,2)) Paul __ 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] Makevars
Hi I have sent a previous email "Error in dyn.load()" for which, shame on me, I later found a partial answer. I have been trying to look into what I exactly need to include into Makevars and where it needs to be located and have not found a satisfying answer yet. Maybe the following questions are helpful for other people as well. Again, I am trying to include a C function tools.c into a main.c file which needs to be run via R. I include the header file via #include tools.h . What I understood is that I need another file which specifically links the header file with the tools.c files (or .o file?). My questions are thus: 1. Can I just create a file Makevars with the variable PKG_LIBS=-L/directory_of_tools -l/tools? 2. Does this file need to be located in the same directory as main.c? 3. When I then run the command R CMD SHLIB it does not make use of Makevars. So what do I need to add? 4. Does tools.c need to be a shared object as well? Thanks a lot! Hadassa -- Hadassa Brunschwig PhD Student Department of Statistics The Hebrew University of Jerusalem http://www.stat.huji.ac.il __ 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] Strange behaviour of paste
Mike Lawrence thatmike.com> writes: > > I suspect your example code is too long & complicated for anyone to bother > attempting to help you. [...] Because of that I marked the line, where the error occured, I thought it was easy to find out for experienced users. But I just found the problem. It seems the behaviour is correct, but very unusual. R has some peculiarities that aren't intuitive, if you are coming from other languages. It's power is also it's unusual-ness. The problem was, that sample_times was not the number of samples, but an array containing 1:(number-1). And paste did not just add it, it makes something like an expand.grid-like way of blowing up the data. It seems that does also contained the arguments, that followed the sample_times-array, not only those before, but that I have to explore in more detail. Yes, R is so powerful, but some behaviour is really strange because of that. But I can admit, that it was my limited knowldege on paste() that brought me to the conclusion that there might be a bug. It seems with R one has to rethink a lot of assumed behaviour one knows from other languages. So, reading the manual more then one time might be necessary... ;-) BTW: Is there a way to make pdf's out of the help-pages for a function? I know there is a big pdf-file as reference. But the begin of the description of the functions do not fit to one page. I would like to have each function beginning on a seperate page. How to achieve this? Do you know this? (Maybe I should start a new thread with that topic...?!) 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.
[R] calibrate function
Hi all, I have a question on the package « survey I have some difficulties to use the function calibrate. Although it works well with one single factor variable, I cannot use it for 2 and get the message Erreur dans regcalibrate.survey.design2(design, formula, population, aggregate.stage = aggregate.stage, : Population and sample totals are not the same length. Here is the format I use as a data.frame: ecodiaMG[1:10, 71:73] age_cl1 sexe1 region1 1MG_54 MG_H MG_NE 2MG_54 MG_H MG_NE 3MG_54 MG_H MG_NE 4MG_54 MG_H MG_NE 5MG_54 MG_H MG_NE 6MG_54 MG_H MG_NE 7MG_54 MG_H MG_NE 8MG_54 MG_H MG_NE 9MG_54 MG_H MG_NE 10 MG_54 MG_H MG_NE My program is: grap<-svydesign(id=~1, data=ecodiaMG) regMG <-c(region1MG_NE =852, region1MG_NO=662, region1MG_P=636, region1MG_SE=961, region1MG_SO=545) sexMG <-c(sexe1MG_F =976, sexe1MG_H=2680) ageMG <-c(age_cl1MG_40 =380, age_cl1MG_4054=2099, age_cl1MG_54=1177) grap2<- calibrate(grap, formula= ~ age_cl1-1, c(ageMG)) grap3<- calibrate(grap2, formula= ~ sexe1-1, c(sexMG)) grap4<- calibrate(grap3, formula= ~region1-1, c(regMG)) I can calibrate the variables one by one, which is wrong, so I would like to do it all in once: grap2<- calibrate(grap, formula= ~ age_cl1+ sexe1+ regMG -1, c(ageMG, sexMG, regMG )) This line does not work, but I cannot find the correct one Thank you for your help Stéphane [[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] How to get solution of following polynomial?
In theory, you could define the following 2 functions powermat <- function(myvec) { powervec <- function(x,maxpower) sapply(0:maxpower,function(n)x^n) sapply(myvec,function(x)powervec(x,length(myvec)-1)) } polycoeffs <- function(fn,order,support=0:order) solve(t(powermat(support)),sapply(support,Vectorize(fn))) and then use polycoeffs(fn,4) with your function fn to extract the coefficients of the polynomial. polycoeffs takes a function and the order of a polynomial as its input and computes the coefficients of the polynomial or the given order with the same values as the function at the points 0:order. If the function is a polynomial of the given order, it gives you exactly the coefficients you need. You may use another set of support points (points where the function is evaluated) as an optional argument. Still, this method is not extremely reliable. If the support points are not chosen well, you might get rather unreliable results. A safer way would be to use a computer algebra system to extract the coefficients of your polynomial. You could use Ryacas to do this from R. But you still would have to grasp the syntax of yacas. Paul Smith wrote: > On Sun, Jan 11, 2009 at 6:03 AM, RON70 wrote: >> Hi, I want find all roots for the following polynomial : >> >> a <- c(-0.07, 0.17); b <- c(1, -4); cc <- matrix(c(0.24, 0.00, -0.08, >> -0.31), 2); d <- matrix(c(0, 0, -0.13, -0.37), 2); e <- matrix(c(0.2, 0, >> -0.06, -0.34), 2) >> A1 <- diag(2) + a %*% t(b) + cc; A2 <- -cc + d; A3 <- -d + e; A4 <- -e >> fn <- function(z) >> { >>y <- diag(2) - A1*z - A2*z^2 - A3*z^3 - A4*z^4 >>return(det(y)) >> }; uniroot(fn, c(-10, 1)) >> >> Using uniroot function, I got only one solution of that. Is there any >> function to get all four solutions? I looked at polyroot() function, but I >> do not think it will work for my problem, because, my coef. are matrix, nor >> number > > Use curve to plot the curve of your function. Then, see where the > roots are, and use uniroot with a small interval around the roots to > determine their exact value. > > Example: > > f <- function(x) x^2-1 > curve(f,-5,5) > uniroot(f,c(-2,-0.2)) > uniroot(f,c(0.2,2)) > > Paul > > __ > 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. > > > > > > No virus found in this incoming message. > Checked by AVG - http://www.avg.com > Version: 8.0.176 / Virus Database: 270.10.5/1886 - Release Date: 1/10/2009 > 6:01 PM > -- Erich Neuwirth, University of Vienna Faculty of Computer Science Computer Supported Didactics Working Group Visit our SunSITE at http://sunsite.univie.ac.at Phone: +43-1-4277-39464 Fax: +43-1-4277-39459 __ 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] Convert date/time string to date
If the file represents a time series then you might want to look at the zoo package. See read.zoo, in particular and ?strptime and R News 4/1 for the % codes and other date/time info. Also ?lag.zoo On Sun, Jan 11, 2009 at 12:22 AM, Heston Capital wrote: > I am new to R and am trying to import a text file that contains > date/time and various fields. I want to sort this matrix by date and > also perform calculations on the date field (difference between two > dates etc). > > The format of the string looks as follows: > > x<-c("25/2/2003 0:00:00") > > I tried: > > as.Date(x,format='%d/%m/%y') > [1] "2020-02-25" > > Obviously I am doing something wrong here. I would like to remove the > hh:mm:ss from the end of the string if possible. > > Thanks for your help, I have been searching for hours and not getting > anywhere. > > __ > 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] Reference-pages: each function beginning on seperate page?
Hello, is the reference manual also available with each explained function beginning on a seperate page? Or can this somehow be done easily? I prefer reading documentation on paper, but printing makes more sense, when each function can be printed seperated (like in man-pages). Any idea, how to achieve this? TIA, 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.
[R] Problem using odfWeave
Hi everybody, I don't get odfWeave to run properly. My odt file is as a simple as: Some text. <>= print(1:10) @ --- The output I get ist the following: --- > odfWeave("roffice.odt", "rofficeOUT.odt") Copying roffice.odt Setting wd to D:\DOKUME~1\Peter\LOKALE~1\Temp\RtmpNcNDxY/odfWeave11041520167 Unzipping ODF file using unzip -o "roffice.odt" Archive: roffice.odt extracting: mimetype creating: Configurations2/statusbar/ inflating: Configurations2/accelerator/current.xml creating: Configurations2/floater/ creating: Configurations2/popupmenu/ creating: Configurations2/progressbar/ creating: Configurations2/menubar/ creating: Configurations2/toolbar/ creating: Configurations2/images/Bitmaps/ inflating: content.xml inflating: styles.xml extracting: meta.xml inflating: Thumbnails/thumbnail.png inflating: settings.xml inflating: META-INF/manifest.xml Removing roffice.odt Creating a Pictures directory Pre-processing the contents Sweaving content.Rnw Writing to file content_1.xml Processing code chunks ... 1 : term verbatim 'content_1.xml' has been Sweaved Removing content.xml Post-processing the contents Premature end of data in tag office:text line 2 Premature end of data in tag office:body line 2 Premature end of data in tag office:document-content line 2 Error: 1: Premature end of data in tag office:text line 2 2: Premature end of data in tag office:body line 2 3: Premature end of data in tag office:document-content line 2 In addition: Warning message: closing unused connection 5 (content.xml) --- No rofficeOUT.odt is rendered. What can I do about it? TIA, Mark -- Mark Heckmann (Dipl. Wirt.-Ing.) phone +49 (0) 421/1614618 __ 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] Boxplot from matrices
Hii, I will create boxplots from matrices. I have the following data sets: 5.0 1.78 2.99 2.019 0 10.0 1.79 3.00 1.744 0 15.0 1.78 2.98 1.936 0 20.0 1.78 2.99 1.975 0 25.0 1.73 2.91 3.591 0 30.0 1.79 3.00 1.966 0 35.0 1.79 3.00 2.451 0 40.0 1.79 3.00 1.853 0 45.0 1.79 3.00 2.077 0 50.0 1.79 3.00 1.943 0 55.0 1.79 3.00 2.608 0 60.0 1.79 3.00 1.790 0 65.0 1.79 3.00 1.893 0 70.0 1.79 3.00 2.079 0 75.0 1.77 2.97 2.200 0 80.0 1.79 3.01 1.868 0 85.0 1.78 2.99 2.179 0 90.0 1.70 2.85 2.305 0 95.0 1.71 2.87 1.854 0 100.0 1.79 3.00 2.362 0 105.0 1.79 3.00 3.634 0 110.0 1.79 3.00 1.578 0 115.0 1.79 3.00 1.835 0 120.0 1.79 3.00 2.359 0 125.0 1.79 3.00 2.542 0 130.0 1.76 2.95 2.620 0 135.0 1.79 3.00 4.181 0 140.0 1.79 3.00 1.375 0 145.0 1.79 3.00 2.872 0 150.0 1.79 3.00 3.002 0 155.0 1.79 3.00 3.712 0 160.0 1.79 3.01 3.175 0 165.0 1.79 3.00 2.821 0 170.0 1.79 3.00 3.320 0.078 175.0 1.79 3.00 2.076 0 180.0 1.77 2.97 2.186 0 185.0 1.78 2.99 4.652 0 190.0 1.79 3.01 2.051 0 195.0 1.79 3.00 1.922 0 200.0 1.79 3.00 1.945 0 The first thing I do is, to run the command y<-matrix(c(test$V3),ncol=8) to divide the third column in 8 matrices to create 8 boxplots. The I run the command w<-summary(y) to get the values min, max, mean, median, 1.Quan, 3.Quan My problem is, I cann't run the plot command to create the 8 boxplots in a graph... The command plot(y) gives me an error.. Can anybody help me to create the boxplot from matrices in a graph ? greetings, j -- View this message in context: http://www.nabble.com/Boxplot-from-matrices-tp21399085p21399085.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] Sweave removes \end{table}
Hi, I have found that when I run my .rnw file through Sweave it removes the \end{table} LaTeX command after the table that was not generated using R.: excerpt from my .rnw file ... 6.000 -- 6.003 & 3 &0.6 \\ \hline 8.500 -- 8.505 & 4 &0.8 \\ \hline Grand Total &493 &\\ \hline \end{tabular} \label{tbl:sbbs} \end{table} \section{Recommendations} excerpt from the .tex file generated by Sweave ... 6.000 -- 6.003 & 3 &0.6 \\ \hline 8.500 -- 8.505 & 4 &0.8 \\ \hline Grand Total &493 &\\ \hline \end{tabular} \label{tbl:sbbs} \section{Recommendations} If I put two \end{table} commands in the table only one is removed by Sweave. Has anyone else seen this? Thanks, Keith Jones, Ph.D. VTS Pumps __ 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] Boxplot from matrices
Hello, The following code may help you: > my.matrix <- matrix( rnorm(16), ncol = 4 ) > boxplot( my.matrix ~ col( my.matrix ) ) Best regards, Carlos J. Gil Bellosta http://www.datanalytics.com On Sun, 2009-01-11 at 05:23 -0800, johnhj wrote: > Hii, > > I will create boxplots from matrices. I have the following data sets: > 5.0 1.78 2.99 2.019 0 > 10.0 1.79 3.00 1.744 0 > 15.0 1.78 2.98 1.936 0 > 20.0 1.78 2.99 1.975 0 > 25.0 1.73 2.91 3.591 0 > 30.0 1.79 3.00 1.966 0 > 35.0 1.79 3.00 2.451 0 > 40.0 1.79 3.00 1.853 0 > 45.0 1.79 3.00 2.077 0 > 50.0 1.79 3.00 1.943 0 > 55.0 1.79 3.00 2.608 0 > 60.0 1.79 3.00 1.790 0 > 65.0 1.79 3.00 1.893 0 > 70.0 1.79 3.00 2.079 0 > 75.0 1.77 2.97 2.200 0 > 80.0 1.79 3.01 1.868 0 > 85.0 1.78 2.99 2.179 0 > 90.0 1.70 2.85 2.305 0 > 95.0 1.71 2.87 1.854 0 > 100.0 1.79 3.00 2.362 0 > 105.0 1.79 3.00 3.634 0 > 110.0 1.79 3.00 1.578 0 > 115.0 1.79 3.00 1.835 0 > 120.0 1.79 3.00 2.359 0 > 125.0 1.79 3.00 2.542 0 > 130.0 1.76 2.95 2.620 0 > 135.0 1.79 3.00 4.181 0 > 140.0 1.79 3.00 1.375 0 > 145.0 1.79 3.00 2.872 0 > 150.0 1.79 3.00 3.002 0 > 155.0 1.79 3.00 3.712 0 > 160.0 1.79 3.01 3.175 0 > 165.0 1.79 3.00 2.821 0 > 170.0 1.79 3.00 3.320 0.078 > 175.0 1.79 3.00 2.076 0 > 180.0 1.77 2.97 2.186 0 > 185.0 1.78 2.99 4.652 0 > 190.0 1.79 3.01 2.051 0 > 195.0 1.79 3.00 1.922 0 > 200.0 1.79 3.00 1.945 0 > > The first thing I do is, to run the command > y<-matrix(c(test$V3),ncol=8) > to divide the third column in 8 matrices to create 8 boxplots. > The I run the command > w<-summary(y) > to get the values min, max, mean, median, 1.Quan, 3.Quan > > My problem is, I cann't run the plot command to create the 8 boxplots in a > graph... > The command > plot(y) > gives me an error.. > > Can anybody help me to create the boxplot from matrices in a graph ? > > greetings, > j > __ 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] Converting Numerical Matrix to List of Strings
Hi all, Given a matrix: > mat [,1] [,2] [,3] [1,]000 [2,]333 [3,]111 [4,]211 How can I convert it to a list of strings: > desired_output [1] "aaa" "ttt" "ccc" "gcc" In principle: 1. Number of Column in matrix = length of string (= 3) 2. Number of Row in matrix = length of vector ( = 4). 3. Character "a" encode as "0", "c" -> "1", "g" -> "2", "t" -> "3" Length of strings are assumed to be uniform within the vector, and it can be greater than 3 (up to 40 characters). - Gundala Viswanath Jakarta - Indonesia __ 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] Makevars
Hadassa, On 11 January 2009 at 15:29, Hadassa Brunschwig wrote: | Again, I am trying to include a C function tools.c into a main.c file | which needs to be run via R. | I include the header file via #include tools.h . | What I understood is that I need another file which specifically links | the header file | with the tools.c files (or .o file?). My questions are thus: | | 1. Can I just create a file Makevars with the variable | PKG_LIBS=-L/directory_of_tools -l/tools? Yes... | 2. Does this file need to be located in the same directory as main.c? Yes... | 3. When I then run the command R CMD SHLIB it does not make use of | Makevars. So what do I need to add? ... but Makevars is for R package building. See the 'R Extensions' manual for documentation, and literally hundreds of packages on CRAN for live examples to look at _in source_ on how to link C code to R code. | 4. Does tools.c need to be a shared object as well? tools.c is source code, tools.o would be object code. If you want to dynamically load it, then it needs to be a shared object too. Worked examples are also in my 'introduction to high-performance computing with R' slides from August and December. It covers added compiled code to R on a few slides with worked examples using the inline and Rcpp packages. Dirk -- Three out of two people have difficulties with fractions. __ 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] I'm looking for a book about spatial point patterns (Diggle, 2003)
Thank you very much! Mike Lawrence-7 wrote: > > Amazon lists 2 used copies for sale: > http://www.amazon.com/Statistical-Analysis-Spatial-Point-Patterns/dp/0340740701 > > > On Sun, Jan 11, 2009 at 12:04 AM, Unangu wrote: >> >> To understand some functions about spatial point patterns in "spatstat" >> ,I >> should know some background about it, and the best way is to read the >> monograph, and "Statistical Analysis of Spatial Point Patterns" (2nd >> edt.) >> is a better choise. But I can not find it anywhere I can. Who can help >> me? >> Thank you! >> >> - >> una...@gmail.com >> -- >> View this message in context: >> http://www.nabble.com/I%27m-looking-for-a-book-about-spatial-point-patterns-%28Diggle%2C2003%29-tp21395908p21395908.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. >> > > > > -- > Mike Lawrence > Graduate Student > Department of Psychology > Dalhousie University > www.thatmike.com > > Looking to arrange a meeting? Check my public calendar: > http://www.thatmike.com/mikes-public-calendar > > ~ Certainty is folly... I think. ~ > > __ > 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. > > - una...@gmail.com -- View this message in context: http://www.nabble.com/I%27m-looking-for-a-book-about-spatial-point-patterns-%28Diggle%2C2003%29-tp21395908p21400640.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.
Re: [R] Reference-pages: each function beginning on seperate page?
On 11/01/2009 10:06 AM, Oliver wrote: Hello, is the reference manual also available with each explained function beginning on a seperate page? Or can this somehow be done easily? I prefer reading documentation on paper, but printing makes more sense, when each function can be printed seperated (like in man-pages). Any idea, how to achieve this? It doesn't offer that, but it sounds like it would be an easy modification, if you know where to do it. The reference manual is built by commands listed in the RHOME/doc/manual/Makefile.win file on Windows, and the Makefile on other platforms. The sort of change you want could likely be made to the RHOME/tools/pkg2tex.pl Perl script, but do note that the documentation production tools are being overhauled for R 2.9.0 (due in March or April), and I expect this will be an easier change after that's done than before. Duncan Murdoch __ 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 me
Hello, Can You help me? How to save this functions in cd: install.packages("Ryacas", dep = TRUE) library(Ryacas) yacasInstall() yacas("Integrate(z,1,2-x-y)1") yacas("Integrate(y,0,1-x)2 - x - y - 1") yacas("Integrate(x,0,1)(1 - x)^2 - (1 - x)^2/2") Thanks You, Sincerely, Jolka __ 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] Problem using odfWeave
You need to cat the results using odfCAt, otherwise you are just writing the output with no XML around it. Max On Jan 11, 2009, at 8:42 AM, "Mark Heckmann" wrote: Hi everybody, I don't get odfWeave to run properly. My odt file is as a simple as: Some text. <>= print(1:10) @ --- The output I get ist the following: --- odfWeave("roffice.odt", "rofficeOUT.odt") Copying roffice.odt Setting wd to D:\DOKUME~1\Peter\LOKALE~1\Temp\RtmpNcNDxY/ odfWeave11041520167 Unzipping ODF file using unzip -o "roffice.odt" Archive: roffice.odt extracting: mimetype creating: Configurations2/statusbar/ inflating: Configurations2/accelerator/current.xml creating: Configurations2/floater/ creating: Configurations2/popupmenu/ creating: Configurations2/progressbar/ creating: Configurations2/menubar/ creating: Configurations2/toolbar/ creating: Configurations2/images/Bitmaps/ inflating: content.xml inflating: styles.xml extracting: meta.xml inflating: Thumbnails/thumbnail.png inflating: settings.xml inflating: META-INF/manifest.xml Removing roffice.odt Creating a Pictures directory Pre-processing the contents Sweaving content.Rnw Writing to file content_1.xml Processing code chunks ... 1 : term verbatim 'content_1.xml' has been Sweaved Removing content.xml Post-processing the contents Premature end of data in tag office:text line 2 Premature end of data in tag office:body line 2 Premature end of data in tag office:document-content line 2 Error: 1: Premature end of data in tag office:text line 2 2: Premature end of data in tag office:body line 2 3: Premature end of data in tag office:document-content line 2 In addition: Warning message: closing unused connection 5 (content.xml) --- No rofficeOUT.odt is rendered. What can I do about it? TIA, Mark -- Mark Heckmann (Dipl. Wirt.-Ing.) phone +49 (0) 421/1614618 __ 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] Converting Numerical Matrix to List of Strings
try this: > mapping <- c('0'='a', '1'='c', '2'='g', '3'='t') > x <- matrix(sample(0:3, 30, TRUE), ncol=3) > x [,1] [,2] [,3] [1,]311 [2,]132 [3,]111 [4,]111 [5,]213 [6,]130 [7,]132 [8,]310 [9,]030 [10,]330 > apply(x, 1, function(z){ + paste(mapping[as.character(z)], collapse='') + }) [1] "tcc" "ctg" "ccc" "ccc" "gct" "cta" "ctg" "tca" "ata" "tta" > > On Sun, Jan 11, 2009 at 10:38 AM, Gundala Viswanath wrote: > Hi all, > > Given a matrix: > >> mat > >[,1] [,2] [,3] > [1,]000 > [2,]333 > [3,]111 > [4,]211 > > > How can I convert it to a list of strings: > >> desired_output > [1] "aaa" "ttt" "ccc" "gcc" > > > In principle: > > 1. Number of Column in matrix = length of string (= 3) > 2. Number of Row in matrix = length of vector ( = 4). > 3. Character "a" encode as "0", > "c" -> "1", > "g" -> "2", > "t" -> "3" > > > Length of strings are assumed to be uniform within the vector, > and it can be greater than 3 (up to 40 characters). > > > - Gundala Viswanath > Jakarta - Indonesia > > __ > 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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] Converting Numerical Matrix to List of Strings
one way is the following: mat <- matrix(sample(0:3, 12, TRUE), 4, 3) strg <- c("a", "c", "g", "t") out <- strg[mat + 1] dim(out) <- dim(mat) apply(out, 1, paste, collapse = "") I hope it helps. Best, Dimitris Gundala Viswanath wrote: Hi all, Given a matrix: mat [,1] [,2] [,3] [1,]000 [2,]333 [3,]111 [4,]211 How can I convert it to a list of strings: desired_output [1] "aaa" "ttt" "ccc" "gcc" In principle: 1. Number of Column in matrix = length of string (= 3) 2. Number of Row in matrix = length of vector ( = 4). 3. Character "a" encode as "0", "c" -> "1", "g" -> "2", "t" -> "3" Length of strings are assumed to be uniform within the vector, and it can be greater than 3 (up to 40 characters). - Gundala Viswanath Jakarta - Indonesia __ 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. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ 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] Converting Numerical Matrix to List of Strings
On Sun, Jan 11, 2009 at 9:38 AM, Gundala Viswanath wrote: > Hi all, > > Given a matrix: > >> mat > >[,1] [,2] [,3] > [1,]000 > [2,]333 > [3,]111 > [4,]211 > How can I convert it to a list of strings: >> desired_output > [1] "aaa" "ttt" "ccc" "gcc" Are you looking for a general solution or do you want something specific for these 64 potential codon-like patterns? If you just want the patterns corresponding to all possible triplets of A, C, G, T then colSums(4^(0:2) * t(mat)) + 1 gives you a set of indices between 1 and 64. Then you need to create the 64 possible patterns. Here is one way > bases <- factor(c("A","C","G","T")) > head(patterns <- do.call(paste, expand.grid(bases, bases, bases))) [1] "A A A" "C A A" "G A A" "T A A" "A C A" "C C A" > (mat <- matrix(c(0,3,1,2,0,3,1,1,0,3,1,1), ncol = 3)) [,1] [,2] [,3] [1,]000 [2,]333 [3,]111 [4,]211 > colSums(4^(0:2) * t(mat)) + 1 [1] 1 64 22 23 > patterns[colSums(4^(0:2) * t(mat)) + 1] [1] "A A A" "T T T" "C C C" "G C C" We will leave the elimination of the blanks in the patterns as an exercise for the reader. > > In principle: > > 1. Number of Column in matrix = length of string (= 3) > 2. Number of Row in matrix = length of vector ( = 4). > 3. Character "a" encode as "0", > "c" -> "1", > "g" -> "2", > "t" -> "3" > > > Length of strings are assumed to be uniform within the vector, > and it can be greater than 3 (up to 40 characters). > > > - Gundala Viswanath > Jakarta - Indonesia > > __ > 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] help me
Do you mean how to create an R function, CD, that represents the resulting function of x? If that's it then try this: > CD <- function(x) {} > body(CD) <- yacas("Integrate(y,0,1-x)2 - x - y - 1")[[1]] > CD function (x) (1 - x)^2 - (1 - x)^2/2 See ?bodyAsExpression for more info. Also try: demo("Ryacas-Function") On Sun, Jan 11, 2009 at 11:13 AM, jolka sukyte wrote: > Hello, > > Can You help me? How to save this functions in cd: > > install.packages("Ryacas", dep = TRUE) > library(Ryacas) > yacasInstall() > yacas("Integrate(z,1,2-x-y)1") > yacas("Integrate(y,0,1-x)2 - x - y - 1") > yacas("Integrate(x,0,1)(1 - x)^2 - (1 - x)^2/2") > > Thanks You, > Sincerely, Jolka > > __ > 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] upgrade R version
ms.com hotmail.com> writes: > i want to upgrade my R version from 2.7.1 to 2.8.1 Gabor's http://code.google.com/p/batchfiles/ can help you getting the libraries right after an upgrade. Dieter __ 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] R in the NY Times
on 01/10/2009 01:50 PM Kingsford Jones wrote: > The reactions to the NYT article have certainly made for some > interesting reading. > > Here are some of the links: > > http://overdetermined.net/site/content/new-york-times-article-r > > http://jackman.stanford.edu/blog/?p=1053 > > http://ggorjan.blogspot.com/2009/01/new-york-times-on-r.html > > several posts on Andrew Gelman's blog: > http://www.stat.columbia.edu/~gelman/blog/ > > http://www.reddit.com/r/programming/comments/7nwgq/the_new_york_times_notices_the_r_programming/ > > comments here: http://bits.blogs.nytimes.com/2009/01/08/r-you-ready-for-r/ > > > It's too bad that SAS has reacted to the negative reactions to their > NYT quote with more FUD. The quote that Tony posted is just a > thinly-veiled jab at R (veiled by a disingenuous "we value open > source" veneer). Perhaps SAS is shooting themselves in the foot with > their reactions; aren't they making it harder if they should ever > decide the best thing to do is to embrace R and the philosophies > behind it? Four years ago, Marc Schwartz posted interesting comments > realted to this: > > http://tolstoy.newcastle.edu.au/R/help/04/12/9497.html Thanks for pointing this out Kingsford. The books referenced there are excellent for providing an understanding of the dynamics that have been the subject of many of these threads here since the NYT article was published. There is a natural tension between leading edge adopters, the "main stream" and the laggards. Moore's "Crossing the Chasm" provides good insights into this tension and the acceptance of new products and technology. Grove's "Only the Paranoid Survive" shows how individual companies and even entire industries (think banking and autos today) can suddenly face an unexpected risk to their survival when they fail to comprehend marketplace dynamics and take appropriate action. Microsoft's mis-steps vis-a-vis Vista opened the door for Apple and Linux to increase their respective marketshare and for open source more generally (eg. Firefox). BTW, readers might find this commentary of interest: Commentary: Create a tech-friendly U.S. government By Jimmy Wales and Andrea Weckerle http://www.cnn.com/2009/TECH/01/07/wales.obama.cto/index.html > On another note, I wonder why in the various conversations there seems > to be pervasive views that a) the FDA won't accept work done in R, and > b) SAS is the only way to effectively handle data? I strongly believe that the comments regarding R and the FDA are overly negative and pessimistic. The hurdles to the use of R for clinical trials are shrinking. There has been substantive activity over the past several years, both internally at the FDA and within the R community to increase R's acceptance in this domain. At the Joint Statistical Meetings in 2006, Sue Bell from the FDA spoke during a session with a presentation entitled Times 'R' A Changing: FDA Perspectives on Use of "Open Source". A copy of this presentation is available here: http://www.fda.gov/cder/Offices/Biostatistics/Bell.pdf In 2007, during an FDA committee meeting reviewing the safety profile of Avandia (Rosiglitazone), the internal FDA meta-analysis performed by Joy Mele, the FDA statistician, was done using R. A copy of this presentation is available here: http://www.fda.gov/ohrms/dockets/ac/07/slides/2007-4308s1-05-fda-mele.ppt Given the high profile nature of drug safety issues today, that R was used for this analysis by the FDA itself speaks volumes. Also in 2007, at the annual R user meeting at Iowa State University, I had the pleasure and privilege of Chairing a session on the use of R for clinical trials. The speakers included Frank Harrell (well known to R users here), Tony Rossini and David James (Novartis Pharmaceuticals) and Mat Soukup (FDA statistician). Copies of our presentations are available here, a little more than half way down the page: http://user2007.org/program/ At that meeting, we also introduced a document that has been updated since then and approved formally by the R Foundation for Statistical Computing. The document provides guidance for the use of R in the regulated clinical trials domain, addresses R's compliance with the relevant regulations (eg. 21 CFR 11) as well as describing the development, testing and quality processes in place for R, also known as the Software Development Life Cycle. That document is available here: http://www.r-project.org/doc/R-FDA.pdf I have heard directly from colleagues in industry that this document has provided significant value in their internal discussions regarding implementing the use of R within their respective environments and assuaging many fears regarding R's use. Additionally, presentations regarding the use of open source software and R specifically for clinical trials have been made at DIA and other industry meetings. This fall, there is a session on the use of R scheduled for the FDA's Industry Statistics Workshop in Washington,
Re: [R] I'm looking for a book about spatial point patterns (Diggle, 2003)
Unangu, If you haven't seen the 200pg workshop notes that Adrian Baddeley has made available from his spatstat webpage, I highly recommend them: http://www.csiro.au/files/files/pn0y.pdf hth, Kingsford Jones On Sat, Jan 10, 2009 at 9:04 PM, Unangu wrote: > > To understand some functions about spatial point patterns in "spatstat" ,I > should know some background about it, and the best way is to read the > monograph, and "Statistical Analysis of Spatial Point Patterns" (2nd edt.) > is a better choise. But I can not find it anywhere I can. Who can help me? > Thank you! > > - > una...@gmail.com > -- > View this message in context: > http://www.nabble.com/I%27m-looking-for-a-book-about-spatial-point-patterns-%28Diggle%2C2003%29-tp21395908p21395908.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.
Re: [R] I'm looking for a book about spatial point patterns (Diggle, 2003)
Hi Unangu I also put my two cents on the Kingsford´s suggestion. The "BOOK" the Adrian turned available are very very well informative! I enjoyed so much! Best wishes miltinho, brazil On Sun, Jan 11, 2009 at 3:48 PM, Kingsford Jones wrote: > Unangu, > > If you haven't seen the 200pg workshop notes that Adrian Baddeley has > made available from his spatstat webpage, I highly recommend them: > > http://www.csiro.au/files/files/pn0y.pdf > > > hth, > Kingsford Jones > > On Sat, Jan 10, 2009 at 9:04 PM, Unangu wrote: > > > > To understand some functions about spatial point patterns in "spatstat" > ,I > > should know some background about it, and the best way is to read the > > monograph, and "Statistical Analysis of Spatial Point Patterns" (2nd > edt.) > > is a better choise. But I can not find it anywhere I can. Who can help > me? > > Thank you! > > > > - > > una...@gmail.com > > -- > > View this message in context: > http://www.nabble.com/I%27m-looking-for-a-book-about-spatial-point-patterns-%28Diggle%2C2003%29-tp21395908p21395908.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. > [[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] R, clinical trials and the FDA
I hope that Marc doesn't mind, but I felt that part of his recent post was important enough to deserve it's own subject line rather then being lost in a 60-msg-long thread... On Sun, Jan 11, 2009 at 10:08 AM, Marc Schwartz wrote: ... I strongly believe that the comments regarding R and the FDA are overly negative and pessimistic. The hurdles to the use of R for clinical trials are shrinking. There has been substantive activity over the past several years, both internally at the FDA and within the R community to increase R's acceptance in this domain. At the Joint Statistical Meetings in 2006, Sue Bell from the FDA spoke during a session with a presentation entitled Times 'R' A Changing: FDA Perspectives on Use of "Open Source". A copy of this presentation is available here: http://www.fda.gov/cder/Offices/Biostatistics/Bell.pdf In 2007, during an FDA committee meeting reviewing the safety profile of Avandia (Rosiglitazone), the internal FDA meta-analysis performed by Joy Mele, the FDA statistician, was done using R. A copy of this presentation is available here: http://www.fda.gov/ohrms/dockets/ac/07/slides/2007-4308s1-05-fda-mele.ppt Given the high profile nature of drug safety issues today, that R was used for this analysis by the FDA itself speaks volumes. Also in 2007, at the annual R user meeting at Iowa State University, I had the pleasure and privilege of Chairing a session on the use of R for clinical trials. The speakers included Frank Harrell (well known to R users here), Tony Rossini and David James (Novartis Pharmaceuticals) and Mat Soukup (FDA statistician). Copies of our presentations are available here, a little more than half way down the page: http://user2007.org/program/ At that meeting, we also introduced a document that has been updated since then and approved formally by the R Foundation for Statistical Computing. The document provides guidance for the use of R in the regulated clinical trials domain, addresses R's compliance with the relevant regulations (eg. 21 CFR 11) as well as describing the development, testing and quality processes in place for R, also known as the Software Development Life Cycle. That document is available here: http://www.r-project.org/doc/R-FDA.pdf I have heard directly from colleagues in industry that this document has provided significant value in their internal discussions regarding implementing the use of R within their respective environments and assuaging many fears regarding R's use. Additionally, presentations regarding the use of open source software and R specifically for clinical trials have been made at DIA and other industry meetings. This fall, there is a session on the use of R scheduled for the FDA's Industry Statistics Workshop in Washington, D.C. For those unfamiliar, I would also point out the membership and financial donors to the R Foundation for Statistical Computing and take note of the plethora of large pharma companies and clinical research institutions: http://www.r-project.org/foundation/memberlist.html The use of R within this domain is increasing and will only continue to progress as R's value becomes increasingly clear to even risk averse industry decision makers. Regards, Marc Schwartz __ 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] R, clinical trials and the FDA
I don't mind at all. Very kind of you Kingsford. Thanks, Marc on 01/11/2009 01:05 PM Kingsford Jones wrote: > I hope that Marc doesn't mind, but I felt that part of his recent post > was important enough to deserve it's own subject line rather then > being lost in a 60-msg-long thread... > > > > On Sun, Jan 11, 2009 at 10:08 AM, Marc Schwartz > wrote: > > ... > > I strongly believe that the comments regarding R and the FDA are overly > negative and pessimistic. > > The hurdles to the use of R for clinical trials are shrinking. There has > been substantive activity over the past several years, both internally > at the FDA and within the R community to increase R's acceptance in this > domain. > > At the Joint Statistical Meetings in 2006, Sue Bell from the FDA spoke > during a session with a presentation entitled Times 'R' A Changing: FDA > Perspectives on Use of "Open Source". A copy of this presentation is > available here: > > http://www.fda.gov/cder/Offices/Biostatistics/Bell.pdf > > In 2007, during an FDA committee meeting reviewing the safety profile of > Avandia (Rosiglitazone), the internal FDA meta-analysis performed by Joy > Mele, the FDA statistician, was done using R. A copy of this > presentation is available here: > http://www.fda.gov/ohrms/dockets/ac/07/slides/2007-4308s1-05-fda-mele.ppt > > Given the high profile nature of drug safety issues today, that R was > used for this analysis by the FDA itself speaks volumes. > > Also in 2007, at the annual R user meeting at Iowa State University, I > had the pleasure and privilege of Chairing a session on the use of R for > clinical trials. The speakers included Frank Harrell (well known to R > users here), Tony Rossini and David James (Novartis Pharmaceuticals) and > Mat Soukup (FDA statistician). Copies of our presentations are available > here, a little more than half way down the page: > > http://user2007.org/program/ > > At that meeting, we also introduced a document that has been updated > since then and approved formally by the R Foundation for Statistical > Computing. The document provides guidance for the use of R in the > regulated clinical trials domain, addresses R's compliance with the > relevant regulations (eg. 21 CFR 11) as well as describing the > development, testing and quality processes in place for R, also known as > the Software Development Life Cycle. > > That document is available here: > > http://www.r-project.org/doc/R-FDA.pdf > > I have heard directly from colleagues in industry that this document has > provided significant value in their internal discussions regarding > implementing the use of R within their respective environments and > assuaging many fears regarding R's use. > > Additionally, presentations regarding the use of open source software > and R specifically for clinical trials have been made at DIA and other > industry meetings. This fall, there is a session on the use of R > scheduled for the FDA's Industry Statistics Workshop in Washington, D.C. > > For those unfamiliar, I would also point out the membership and > financial donors to the R Foundation for Statistical Computing and take > note of the plethora of large pharma companies and clinical research > institutions: > > http://www.r-project.org/foundation/memberlist.html > > The use of R within this domain is increasing and will only continue to > progress as R's value becomes increasingly clear to even risk averse > industry decision makers. > > > Regards, > > Marc Schwartz > __ 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] How to get solution of following polynomial?
Hi, You can use the "polynomial" package to solve your problem. The key step is to find the exact polynomial representation of fn(). Noting that it is a 8-th degree polynomial, we can get its exact form using the poly.calc() function. Once we have that, it is a simple matter of finding the roots using the solve() function. require(polynomial) a <- c(-0.07, 0.17) b <- c(1, -4) cc <- matrix(c(0.24, 0.00, -0.08, -0.31), 2) d <- matrix(c(0, 0, -0.13, -0.37), 2) e <- matrix(c(0.2, 0, -0.06, -0.34), 2) A1 <- diag(2) + a %*% t(b) + cc A2 <- -cc + d A3 <- -d + e A4 <- -e # I am vectorizing your function fn <- function(z) { sapply(z, function(z) { y <- diag(2) - A1*z - A2*z^2 - A3*z^3 - A4*z^4 det(y) }) } x <- seq(-5, 5, length=9) # note we need 9 points to exactly determine a 8-th degree polynomial y <- fn(x) p <- poly.calc(x, y) # uses Lagrange interpolation to determine polynomial form p > 1 - 1.18*x + 0.2777*x^2 - 0.2941*x^3 - 0.1004*x^4 + 0.3664*x^5 - 0.0636*x^6 + > 0.062*x^7 - 0.068*x^8 # plot showing that p is the exact polynomial representation of fn(z) pfunc <- as.function(p) x1 <-seq(-5, 5, length=100) plot(x1, fn(x1),type="l") lines(x1, pfunc(x1), col=2, lty=2) solve(p) # gives you the roots (some are, of course, complex) Hope this helps, Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: RON70 Date: Sunday, January 11, 2009 1:05 am Subject: [R] How to get solution of following polynomial? To: r-help@r-project.org > Hi, I want find all roots for the following polynomial : > > a <- c(-0.07, 0.17); b <- c(1, -4); cc <- matrix(c(0.24, 0.00, -0.08, > -0.31), 2); d <- matrix(c(0, 0, -0.13, -0.37), 2); e <- matrix(c(0.2, > 0, > -0.06, -0.34), 2) > A1 <- diag(2) + a %*% t(b) + cc; A2 <- -cc + d; A3 <- -d + e; A4 <- -e > fn <- function(z) > { > y <- diag(2) - A1*z - A2*z^2 - A3*z^3 - A4*z^4 > return(det(y)) > }; uniroot(fn, c(-10, 1)) > > Using uniroot function, I got only one solution of that. Is there any > function to get all four solutions? I looked at polyroot() function, > but I > do not think it will work for my problem, because, my coef. are > matrix, nor > number > > Thanks > > > > -- > View this message in context: > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@r-project.org mailing list > > PLEASE do read the posting guide > 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] summary with variance / sd
Hi, I have a data frame and would like to have summary statistics for grouped data. With summary() I get the central tendencies for the overall data. How can I get descriptive statistics with variances and standard deviations? for example my data.frame: group x y exp 2 4 exp 3 5 exp 2 4 control 1 2 control 2 3 control 1 2 now I want tables with summary statistics (variances included) for each group. Is there an easy way to get this? __ 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] summary with variance / sd
Hi Jörg, ?by here probably something like by(data=mydata,INDICES=mydata$group, FUN=sd, ...) HTH, Stephan Jörg Groß schrieb: Hi, I have a data frame and would like to have summary statistics for grouped data. With summary() I get the central tendencies for the overall data. How can I get descriptive statistics with variances and standard deviations? for example my data.frame: groupxy exp24 exp35 exp24 control12 control23 control12 now I want tables with summary statistics (variances included) for each group. Is there an easy way to get this? __ 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] boxplots: yaxp does not work
Hi, I'd like to change the y-tickmarks of a boxplot. But it doesn't work with yaxp (like I would do it in a plot-function). Can someone help me out? __ 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] summary with variance / sd
You can use summaryBy() in the doBy package: summaryBy(y+x~group, data=mydata, FUN=c(mean,sd)) Søren Fra: r-help-boun...@r-project.org på vegne af Jörg Groß Sendt: sø 11-01-2009 22:38 Til: r-help@r-project.org Emne: [R] summary with variance / sd Hi, I have a data frame and would like to have summary statistics for grouped data. With summary() I get the central tendencies for the overall data. How can I get descriptive statistics with variances and standard deviations? for example my data.frame: group x y exp 2 4 exp 3 5 exp 2 4 control 1 2 control 2 3 control 1 2 now I want tables with summary statistics (variances included) for each group. Is there an easy way to get this? __ 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] summary with variance / sd
On Jan 11, 2009, at 4:38 PM, Jörg Groß wrote: Hi, I have a data frame and would like to have summary statistics for grouped data. With summary() I get the central tendencies for the overall data. How can I get descriptive statistics with variances and standard deviations? In the future, you really should do your own searching before posting this sort of basic question. help.search("standard deviation") produced reference to a function with the obvious name "sd" Using the same strategy for variance produces a longer list but "var" is among them. for example my data.frame: group x y exp 2 4 exp 3 5 exp 2 4 control 1 2 control 2 3 control 1 2 #Create dataframe ( and please note that you are asked to offer examples in a form that does not require responders to create the objects for you): df1 <- read.table(stdin(), header=TRUE) #Paste in the data: 0: groupxy 1: exp24 2: exp35 3: exp24 4: control12 5: control23 6: control12 # empty line stops input. by(data=df1, df1$group, summary) by(data=df1, df1$group, sd) by(data=df1, df1$group, var) Or use negative indexing to exclude the first column, and add some annotation to do it in one step by(data=df1[-1], df1$group, function(x){ list(summary(x), "Group S.D.s are ...", sd(x), "Group Variances are ...", var(x) )} ) You could also look at how the pro's do constructed summary() by reviewing the code of: base:::summary.default base:::summary.data.frame -- David Winsemius now I want tables with summary statistics (variances included) for each group. Is there an easy way to get this? __ 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] Boxplot from matrices
Thank you very much for you help... Carlos J. Gil Bellosta wrote: > > Hello, > > The following code may help you: > >> my.matrix <- matrix( rnorm(16), ncol = 4 ) >> boxplot( my.matrix ~ col( my.matrix ) ) > > Best regards, > > Carlos J. Gil Bellosta > http://www.datanalytics.com > > > > On Sun, 2009-01-11 at 05:23 -0800, johnhj wrote: >> Hii, >> >> I will create boxplots from matrices. I have the following data sets: >> 5.0 1.78 2.99 2.019 0 >> 10.0 1.79 3.00 1.744 0 >> 15.0 1.78 2.98 1.936 0 >> 20.0 1.78 2.99 1.975 0 >> 25.0 1.73 2.91 3.591 0 >> 30.0 1.79 3.00 1.966 0 >> 35.0 1.79 3.00 2.451 0 >> 40.0 1.79 3.00 1.853 0 >> 45.0 1.79 3.00 2.077 0 >> 50.0 1.79 3.00 1.943 0 >> 55.0 1.79 3.00 2.608 0 >> 60.0 1.79 3.00 1.790 0 >> 65.0 1.79 3.00 1.893 0 >> 70.0 1.79 3.00 2.079 0 >> 75.0 1.77 2.97 2.200 0 >> 80.0 1.79 3.01 1.868 0 >> 85.0 1.78 2.99 2.179 0 >> 90.0 1.70 2.85 2.305 0 >> 95.0 1.71 2.87 1.854 0 >> 100.0 1.79 3.00 2.362 0 >> 105.0 1.79 3.00 3.634 0 >> 110.0 1.79 3.00 1.578 0 >> 115.0 1.79 3.00 1.835 0 >> 120.0 1.79 3.00 2.359 0 >> 125.0 1.79 3.00 2.542 0 >> 130.0 1.76 2.95 2.620 0 >> 135.0 1.79 3.00 4.181 0 >> 140.0 1.79 3.00 1.375 0 >> 145.0 1.79 3.00 2.872 0 >> 150.0 1.79 3.00 3.002 0 >> 155.0 1.79 3.00 3.712 0 >> 160.0 1.79 3.01 3.175 0 >> 165.0 1.79 3.00 2.821 0 >> 170.0 1.79 3.00 3.320 0.078 >> 175.0 1.79 3.00 2.076 0 >> 180.0 1.77 2.97 2.186 0 >> 185.0 1.78 2.99 4.652 0 >> 190.0 1.79 3.01 2.051 0 >> 195.0 1.79 3.00 1.922 0 >> 200.0 1.79 3.00 1.945 0 >> >> The first thing I do is, to run the command >> y<-matrix(c(test$V3),ncol=8) >> to divide the third column in 8 matrices to create 8 boxplots. >> The I run the command >> w<-summary(y) >> to get the values min, max, mean, median, 1.Quan, 3.Quan >> >> My problem is, I cann't run the plot command to create the 8 boxplots in >> a >> graph... >> The command >> plot(y) >> gives me an error.. >> >> Can anybody help me to create the boxplot from matrices in a graph ? >> >> greetings, >> j >> > > __ > 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. > > -- View this message in context: http://www.nabble.com/Boxplot-from-matrices-tp21399085p21405169.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] connecting boxplots
Hii, I created some boxplots with this commands: x <-read.table(file="test.txt") x$group <- rep(1:8, each=5) boxplot(V3~gruppe, data=x) Now, I will connect the boxplots to each other to the min, max and median values. Can anybody help me how to do it ? greetings, J -- View this message in context: http://www.nabble.com/connecting-boxplots-tp21405459p21405459.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.
Re: [R] How to get solution of following polynomial?
Hi Ravi, Thanks for this reply. However I could not understand meaning of "vectorizing the function". Can you please be little bit elaborate on that? Secondly the package "polynomial" is not available in CRAN it seems. What is the alternate package? Thanks, Ravi Varadhan wrote: > > Hi, > > You can use the "polynomial" package to solve your problem. > > The key step is to find the exact polynomial representation of fn(). > Noting that it is a 8-th degree polynomial, we can get its exact form > using the poly.calc() function. Once we have that, it is a simple matter > of finding the roots using the solve() function. > > require(polynomial) > > a <- c(-0.07, 0.17) > b <- c(1, -4) > cc <- matrix(c(0.24, 0.00, -0.08, -0.31), 2) > d <- matrix(c(0, 0, -0.13, -0.37), 2) > e <- matrix(c(0.2, 0, -0.06, -0.34), 2) > A1 <- diag(2) + a %*% t(b) + cc > A2 <- -cc + d > A3 <- -d + e > A4 <- -e > > # I am vectorizing your function > fn <- function(z) >{ > sapply(z, function(z) { > y <- diag(2) - A1*z - A2*z^2 - A3*z^3 - A4*z^4 > det(y) > }) >} > > > x <- seq(-5, 5, length=9) # note we need 9 points to exactly determine a > 8-th degree polynomial > y <- fn(x) > > p <- poly.calc(x, y) # uses Lagrange interpolation to determine > polynomial form > p >> 1 - 1.18*x + 0.2777*x^2 - 0.2941*x^3 - 0.1004*x^4 + 0.3664*x^5 - >> 0.0636*x^6 + 0.062*x^7 - 0.068*x^8 > > # plot showing that p is the exact polynomial representation of fn(z) > pfunc <- as.function(p) > x1 <-seq(-5, 5, length=100) > plot(x1, fn(x1),type="l") > lines(x1, pfunc(x1), col=2, lty=2) > > solve(p) # gives you the roots (some are, of course, complex) > > > Hope this helps, > Ravi. > > > > > > Ravi Varadhan, Ph.D. > Assistant Professor, > Division of Geriatric Medicine and Gerontology > School of Medicine > Johns Hopkins University > > Ph. (410) 502-2619 > email: rvarad...@jhmi.edu > > > - Original Message - > From: RON70 > Date: Sunday, January 11, 2009 1:05 am > Subject: [R] How to get solution of following polynomial? > To: r-help@r-project.org > > >> Hi, I want find all roots for the following polynomial : >> >> a <- c(-0.07, 0.17); b <- c(1, -4); cc <- matrix(c(0.24, 0.00, -0.08, >> -0.31), 2); d <- matrix(c(0, 0, -0.13, -0.37), 2); e <- matrix(c(0.2, >> 0, >> -0.06, -0.34), 2) >> A1 <- diag(2) + a %*% t(b) + cc; A2 <- -cc + d; A3 <- -d + e; A4 <- -e >> fn <- function(z) >> { >> y <- diag(2) - A1*z - A2*z^2 - A3*z^3 - A4*z^4 >> return(det(y)) >> }; uniroot(fn, c(-10, 1)) >> >> Using uniroot function, I got only one solution of that. Is there any >> function to get all four solutions? I looked at polyroot() function, >> but I >> do not think it will work for my problem, because, my coef. are >> matrix, nor >> number >> >> Thanks >> >> >> >> -- >> View this message in context: >> Sent from the R help mailing list archive at Nabble.com. >> >> __ >> R-help@r-project.org mailing list >> >> PLEASE do read the posting guide >> 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. > > -- View this message in context: http://www.nabble.com/How-to-get-solution-of-following-polynomial--tp21396441p21406350.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.
Re: [R] boxplots: yaxp does not work
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. I have no idea of what you would like to do with the tick marks. I assume you can always use 'axis' to label your axis: boxplot(len ~ dose, data = ToothGrowth, boxwex = 0.25, at = 1:3 + 0.2, yaxt='n', subset = supp == "OJ", col = "orange") axis(2, at=7:31, labels=rep("",25)) # put tick mark every number axis(2, at=seq(7,31,5)) # put labels on some On Sun, Jan 11, 2009 at 5:38 PM, Jörg Groß wrote: > Hi, > > I'd like to change the y-tickmarks of a boxplot. > But it doesn't work with yaxp (like I would do it in a plot-function). > > Can someone help me out? > > __ > 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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] Orthogonal Complement
Is there any R function which calculate the Orthogonal Complement of a mxn matrix (with full column rank)? Thanks in advance -- View this message in context: http://www.nabble.com/Orthogonal-Complement-tp21406355p21406355.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.
Re: [R] Orthogonal Complement
Yes, download the HH package from CRAN and then see ?HH::orthog.complete for the function description and several examples. Rich -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of megh Sent: Sunday, January 11, 2009 19:29 To: r-help@r-project.org Subject: [R] Orthogonal Complement Is there any R function which calculate the Orthogonal Complement of a mxn matrix (with full column rank)? Thanks in advance -- View this message in context: http://www.nabble.com/Orthogonal-Complement-tp21406355p21406355.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] R "Threatens" SAS According to The NYT
The article was dugg on Digg. http://digg.com/software/Data_Analysts_Captivated_by_R_s_Power_3 If you Digg, why not digg this. Farrel Buchinsky __ 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] writing an own function - is.factor
Hi, I try to write an own function in R. I want a summary table with descriptive statistics. For example, I have this data.frame: d <- data.frame(c(rep("m",5), rep("f",5)), c(1:10)) names(d) <- c("x", "y") d x y 1 m 1 2 m 2 3 m 3 4 m 4 5 m 5 6 f 6 7 f 7 8 f 8 9 f 9 10 f 10 now I want to get the mean and sd, as long as the column is not of type factor. So the function should skip the first column. But how can I check this, if I don't know the column name? Because is.factor(d[1]) produces "FALSE". Only is.factor(d$x) gives the correct result. But how can I check the column if I don't know the column name? I tried s.th. like this; is.factor(d$names(d[1])) but that kind of structure is not possible. Can someone help me with that problem? __ 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] Spitting a df Column Name
Hi, If I have the following column names: names(data) [1] "count.run" "count.walk" "count.drive" How do I split these so i get names(datanamessplit) [1] "run" "walk" "drive" Thanks for your help, Jim -- View this message in context: http://www.nabble.com/Spitting-a-df-Column-Name-tp21407294p21407294.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] fitting curve to data
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I have the following data: > y [1] 0.000 0.004 0.008 0.016 0.024 0.032 0.044 0.064 0.072 0.088 0.108 0.140 [13] 0.156 0.180 0.208 0.236 0.264 0.296 0.320 0.360 0.408 0.444 0.472 0.524 [25] 0.576 > x [1] 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 [16] 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 I'd like to plot the points and calculate a curved line of best fit. I know I need to use nls(), but I'm unsure how to beginany pointers? Cheers, Nathan - -- - Dr. Nathan S. Watson-Haigh OCE Post Doctoral Fellow CSIRO Livestock Industries Queensland Bioscience Precinct St Lucia, QLD 4067 Australia Tel: +61 (0)7 3214 2922 Fax: +61 (0)7 3214 2900 Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html - -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAklqqJsACgkQ9gTv6QYzVL4gCgCgy4qShoFX/9QWgKsBqHPhLCDS r+AAnRD3kbkImG3rVaBN6d4BP2cUmqYZ =yVLj -END PGP SIGNATURE- __ 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] Spitting a df Column Name
names(datanamessplit) <- gsub("count.", "", names(data)) On Sun, 2009-01-11 at 18:13 -0800, jimdare wrote: > Hi, > > If I have the following column names: > > names(data) > [1] "count.run" "count.walk" "count.drive" > > How do I split these so i get > > names(datanamessplit) > [1] "run" "walk" "drive" > > Thanks for your help, > Jim -- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320 Goddard Building (8) T: +61 7 3365 2506 http://www.uq.edu.au/~uqsblomb email: S.Blomberg1_at_uq.edu.au Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. __ 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] writing an own function - is.factor
try this: > d <- data.frame(c(rep("m",5), rep("f",5)), c(1:10)) > names(d) <- c("x", "y") > d x y 1 m 1 2 m 2 3 m 3 4 m 4 5 m 5 6 f 6 7 f 7 8 f 8 9 f 9 10 f 10 > lapply(d, function(x) if (is.numeric(x)) c(mean=mean(x), sd=sd(x))) $x NULL $y mean sd 5.50 3.027650 > On Sun, Jan 11, 2009 at 9:04 PM, Jörg Groß wrote: > Hi, > > I try to write an own function in R. > I want a summary table with descriptive statistics. > > > For example, I have this data.frame: > > > d <- data.frame(c(rep("m",5), rep("f",5)), c(1:10)) > names(d) <- c("x", "y") > d > x y > 1 m 1 > 2 m 2 > 3 m 3 > 4 m 4 > 5 m 5 > 6 f 6 > 7 f 7 > 8 f 8 > 9 f 9 > 10 f 10 > > > now I want to get the mean and sd, as long as the column is not of type > factor. > So the function should skip the first column. > > > But how can I check this, if I don't know the column name? > > Because > > is.factor(d[1]) > produces "FALSE". > > Only > is.factor(d$x) > gives the correct result. > > > But how can I check the column if I don't know the column name? > > > I tried s.th. like this; > > is.factor(d$names(d[1])) > > > but that kind of structure is not possible. > > > > Can someone help me with that problem? > > __ > 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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] fitting curve to data
First, try plot(x,y) If you want to use nls, you have to specify a nonlinear function to fit to your data. See ?nls. If you are really stuck on how to fit regression models, you should consult a statistician (CSIRO has a lot of expertise). Simon. On Mon, 2009-01-12 at 12:19 +1000, Nathan S. Watson-Haigh wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > I have the following data: > > > y > [1] 0.000 0.004 0.008 0.016 0.024 0.032 0.044 0.064 0.072 0.088 0.108 0.140 > [13] 0.156 0.180 0.208 0.236 0.264 0.296 0.320 0.360 0.408 0.444 0.472 0.524 > [25] 0.576 > > x > [1] 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 > 1500 > [16] 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 > > I'd like to plot the points and calculate a curved line of best fit. I know I > need to use nls(), but > I'm unsure how to beginany pointers? > > Cheers, > Nathan > > > - -- > - > Dr. Nathan S. Watson-Haigh > OCE Post Doctoral Fellow > CSIRO Livestock Industries > Queensland Bioscience Precinct > St Lucia, QLD 4067 > Australia > > Tel: +61 (0)7 3214 2922 > Fax: +61 (0)7 3214 2900 > Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html > - > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.9 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAklqqJsACgkQ9gTv6QYzVL4gCgCgy4qShoFX/9QWgKsBqHPhLCDS > r+AAnRD3kbkImG3rVaBN6d4BP2cUmqYZ > =yVLj > -END PGP SIGNATURE- > > __ > 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. -- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320 Goddard Building (8) T: +61 7 3365 2506 http://www.uq.edu.au/~uqsblomb email: S.Blomberg1_at_uq.edu.au Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. __ 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] fitting curve to data
As x goes from 200 to 400, y goes from ,004 to .016 so y is quadrupling while x doubles -- quadratic growth.Fitting to a quadratic and plotting shows this to be the case. Note that for y to be quadratic in x it must be linear in the coefficients of x so we can just use lm and don't need nls: plot(y ~ x) y.lm <- lm(y ~ poly(x, 2)) lines(x, fitted(y.lm)) y.lm On Sun, Jan 11, 2009 at 9:19 PM, Nathan S. Watson-Haigh wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > I have the following data: > >> y > [1] 0.000 0.004 0.008 0.016 0.024 0.032 0.044 0.064 0.072 0.088 0.108 0.140 > [13] 0.156 0.180 0.208 0.236 0.264 0.296 0.320 0.360 0.408 0.444 0.472 0.524 > [25] 0.576 >> x > [1] 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 > 1500 > [16] 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 > > I'd like to plot the points and calculate a curved line of best fit. I know I > need to use nls(), but > I'm unsure how to beginany pointers? > > Cheers, > Nathan > > > - -- > - > Dr. Nathan S. Watson-Haigh > OCE Post Doctoral Fellow > CSIRO Livestock Industries > Queensland Bioscience Precinct > St Lucia, QLD 4067 > Australia > > Tel: +61 (0)7 3214 2922 > Fax: +61 (0)7 3214 2900 > Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html > - > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.9 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAklqqJsACgkQ9gTv6QYzVL4gCgCgy4qShoFX/9QWgKsBqHPhLCDS > r+AAnRD3kbkImG3rVaBN6d4BP2cUmqYZ > =yVLj > -END PGP SIGNATURE- > > __ > 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] fitting curve to data
Just 'cos it's bent doesn't mean you need nls. With your data, lm fits (suspicously!) well... y<-c(0.000,0.004,0.008,0.016,0.024,0.032,0.044,0.064,0.072,0.088,0.108,0.140 ,0.156,0.180,0.208,0.236,0.264,0.296,0.320,0.360,0.408,0.444,0.472,0.524 ,0.576) x<-c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500 ,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500) plot(x,y) lines(x, predict(lm(y~I(x^2 >>> "Nathan S. Watson-Haigh" 01/12/09 2:19 AM >>> -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I have the following data: > y [1] 0.000 0.004 0.008 0.016 0.024 0.032 0.044 0.064 0.072 0.088 0.108 0.140 [13] 0.156 0.180 0.208 0.236 0.264 0.296 0.320 0.360 0.408 0.444 0.472 0.524 [25] 0.576 > x [1] 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 [16] 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 I'd like to plot the points and calculate a curved line of best fit. I know I need to use nls(), but I'm unsure how to beginany pointers? Cheers, Nathan - -- - Dr. Nathan S. Watson-Haigh OCE Post Doctoral Fellow CSIRO Livestock Industries Queensland Bioscience Precinct St Lucia, QLD 4067 Australia Tel: +61 (0)7 3214 2922 Fax: +61 (0)7 3214 2900 Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html - -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAklqqJsACgkQ9gTv6QYzVL4gCgCgy4qShoFX/9QWgKsBqHPhLCDS r+AAnRD3kbkImG3rVaBN6d4BP2cUmqYZ =yVLj -END PGP SIGNATURE- __ 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. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ 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] writing an own function - is.factor
On Sun, Jan 11, 2009 at 9:04 PM, Jörg Groß wrote: > ...now I want to get the mean and sd, as long as the column is not of type > factor. > ...But how can I check this, if I don't know the column name? > ... > is.factor(d[1]) > produces "FALSE". > Try is.factor(d[[1]]). Remember that in R, x[...] selects a *subsequence*, not an *element*. Only x[[...]] selects an element. What makes this confusing to learn is that for vectors, a subsequence of length 1 is treated the same as an element. But for lists, they are not the same thing. You can iterate over the columns in various ways, e.g. for (i in 1:length(d)) ... d[[i]] ... for (i in names(d)) ... d[[i]] ... > > Only > is.factor(d$x) > gives the correct result. > Remember that d$x == d[["x"]] Hope this helps, -s [[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] connecting boxplots
In other words: I will connect the median, min and the max area of the boxplot with a line. The function lines() could help me, but I don't know which parameters the lines() function should have. johnhj wrote: > > Hii, > > I created some boxplots with this commands: > > x <-read.table(file="test.txt") > x$group <- rep(1:8, each=5) > boxplot(V3~gruppe, data=x) > > Now, I will connect the boxplots to each other to the min, max and median > values. > Can anybody help me how to do it ? > > greetings, > J > -- View this message in context: http://www.nabble.com/connecting-boxplots-tp21405459p21406749.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.
Re: [R] I'm looking for a book about spatial point patterns (Diggle, 2003)
Hi,Jones, Got it! And only pn0y is enough? Best wishes and Happy New Year! Kingsford Jones wrote: > > Unangu, > > If you haven't seen the 200pg workshop notes that Adrian Baddeley has > made available from his spatstat webpage, I highly recommend them: > > http://www.csiro.au/files/files/pn0y.pdf > > > hth, > Kingsford Jones > > On Sat, Jan 10, 2009 at 9:04 PM, Unangu wrote: >> >> To understand some functions about spatial point patterns in "spatstat" >> ,I >> should know some background about it, and the best way is to read the >> monograph, and "Statistical Analysis of Spatial Point Patterns" (2nd >> edt.) >> is a better choise. But I can not find it anywhere I can. Who can help >> me? >> Thank you! >> >> - >> una...@gmail.com >> -- >> View this message in context: >> http://www.nabble.com/I%27m-looking-for-a-book-about-spatial-point-patterns-%28Diggle%2C2003%29-tp21395908p21395908.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. > > - una...@gmail.com -- View this message in context: http://www.nabble.com/I%27m-looking-for-a-book-about-spatial-point-patterns-%28Diggle%2C2003%29-tp21395908p21408140.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.
Re: [R] fitting curve to data
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 S Ellison wrote: > Just 'cos it's bent doesn't mean you need nls. Sorry, my bad! :o( > With your data, lm fits (suspicously!) well... Nothing suspiciousjust benchmarking some functions with different sized inputs! Thanks for the help! Nathan > > y<-c(0.000,0.004,0.008,0.016,0.024,0.032,0.044,0.064,0.072,0.088,0.108,0.140 > ,0.156,0.180,0.208,0.236,0.264,0.296,0.320,0.360,0.408,0.444,0.472,0.524 > ,0.576) > x<-c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500 > ,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500) > plot(x,y) > lines(x, predict(lm(y~I(x^2 > > "Nathan S. Watson-Haigh" 01/12/09 > 2:19 AM >>> > I have the following data: > >> y > [1] 0.000 0.004 0.008 0.016 0.024 0.032 0.044 0.064 0.072 0.088 0.108 > 0.140 > [13] 0.156 0.180 0.208 0.236 0.264 0.296 0.320 0.360 0.408 0.444 0.472 > 0.524 > [25] 0.576 >> x > [1] 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 > 1400 1500 > [16] 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 > > I'd like to plot the points and calculate a curved line of best fit. I > know I need to use nls(), but > I'm unsure how to beginany pointers? > > Cheers, > Nathan > > __ 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. *** This email and any attachments are confidential. Any use, copying or disclosure other than by the intended recipient is unauthorised. If you have received this message in error, please notify the sender immediately via +44(0)20 8943 7000 or notify postmas...@lgc.co.uk and delete this message and any copies from your computer and network. LGC Limited. Registered in England 2991879. Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK - -- - Dr. Nathan S. Watson-Haigh OCE Post Doctoral Fellow CSIRO Livestock Industries Queensland Bioscience Precinct St Lucia, QLD 4067 Australia Tel: +61 (0)7 3214 2922 Fax: +61 (0)7 3214 2900 Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html - -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAklqxy0ACgkQ9gTv6QYzVL76HwCeIQlVwHX53uPJ8YHMq9djNUuR ATsAn1otbhcmjUZDxe8iatQMzo+7fv8v =Jra2 -END PGP SIGNATURE- __ 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] I'm looking for a book about spatial point patterns (Diggle, 2003)
Hi miltinho, The book "Analysing Spatial Point Pattern Data" is still coming soon. I concerned it for a long time. Do you get it? Just like you said, I think it will be very very well informative! Thank you! I have some 100m*100m plot data about almost one tree species, but I do not know how to explain it well. Only the analysing result is not enough, the ecological background is important. Perhaps, I can image the process of the forest... ... Seedlings, juniors, small trees, and big trees, then/with competition and death.. with the patterns changing. Oh, complex problem. milton ruser wrote: > > Hi Unangu > I also put my two cents on the Kingsford´s suggestion. > The "BOOK" the Adrian turned available are very very well informative! > I enjoyed so much! > > Best wishes > > miltinho, > > brazil > > On Sun, Jan 11, 2009 at 3:48 PM, Kingsford Jones > wrote: > >> Unangu, >> >> If you haven't seen the 200pg workshop notes that Adrian Baddeley has >> made available from his spatstat webpage, I highly recommend them: >> >> http://www.csiro.au/files/files/pn0y.pdf >> >> >> hth, >> Kingsford Jones >> >> On Sat, Jan 10, 2009 at 9:04 PM, Unangu wrote: >> > >> > To understand some functions about spatial point patterns in "spatstat" >> ,I >> > should know some background about it, and the best way is to read the >> > monograph, and "Statistical Analysis of Spatial Point Patterns" (2nd >> edt.) >> > is a better choise. But I can not find it anywhere I can. Who can help >> me? >> > Thank you! >> > >> > - >> > una...@gmail.com >> > -- >> > View this message in context: >> http://www.nabble.com/I%27m-looking-for-a-book-about-spatial-point-patterns-%28Diggle%2C2003%29-tp21395908p21395908.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. >> > > [[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. > > - una...@gmail.com -- View this message in context: http://www.nabble.com/I%27m-looking-for-a-book-about-spatial-point-patterns-%28Diggle%2C2003%29-tp21395908p21408372.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] merge table rows (\multirow)
Hi: I need help merging rows. I am trying to merge the 'Month' column using \multirow. For example for the column 'Week' I want July to be merged into one row(weeks 27,28,29,30) and so on for the following weeks. Below, I am creating a PDF using Sweave, MikTex,R-2.8.1 and windows XP to show an example. \documentclass[11pt]{article} \usepackage{longtable,verbatim} \title{How to implement multirow with Sweave} \begin{document} \maketitle <>= sampDat <- "Month, Week, Est.passage, Med.FL July 27665 34 July 282,232 35 July 299,241 35 July 3028,464 35 Aug 3141,049 35 Aug 32 82,216 35 Aug 33 230,411 35 Aug 34 358,541 35 Sept 35747,839 35 Sept 36459,682 36 Sept 37609,567 36 Sept 38979,475 36 Sept 39837,189 36" DF <- read.table(textConnection(sampDat), header = TRUE) attach(DF) @ \begin{verbatim} Using Hmisc. \end{verbatim} <>= library(Hmisc) mytab <- data.frame(DF) latex(DF,label="tab:hola",longtable=FALSE,caption='Sample table.') @ \begin{verbatim} Or with xtable \end{verbatim} <>= library(xtable) table2 <- data.frame(DF) table2 <- xtable(DF,label='tab2',caption='table 2 with xtable',digits=0) print(table2,floating=FALSE) @ \end{document} Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish & Wildlife Service California, USA __ 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] Help needed for Loading "tm" package
Thank Prof. Brian Ripley for your comments. Based on Prof Brian Ripley's comments, I checked Java environments in my PC. But I have not solved a "tm" package problem in Win R software. I am not sure but my current conclusion is that the Win-based R binary software has definitely a problem with Rweka package or subpackage. Should I wait for another upgraded R binary version under the window XP, "tm' package or Rweka ets? Or I'd better migrate to non-window OS such as Linux, etc? Kum Hwang, Ph.D. On Sat, Jan 10, 2009 at 8:06 PM, Prof Brian Ripley wrote: > On Sat, 10 Jan 2009, Kum-Hoe Hwang wrote: > >> Howdy Gurus again >> >> Thanks to Tony.Breyal, I was able to writing the following script for >> analyzing a text document. >> But I got an error with "tm' package. I don't why I got the error from the >> R >> script below. I think I followed proccess of R tm manual. > > Please do read the messages you got. I see > >> Error in .jinit(system.file("jar", c("weka.jar", "RWeka.jar"), package = >> pkgname, : >> Cannot create Java virtual machine (-1) > > so the problem is with your Java installation and RWeka, not 'tm'. > > First make sure you have a working installation of RWeka -- I suspect you do > not even have Java installed, but it could be a version or path issue (but > very unlikely to be an R issue). > >> >> I use R v2.8.1. and tm_0.3-3.zip under Win XP. >> >> Thanks in advance, >> >> Kum Hwang >> >>> # setting directory >>> my.path <-'C:\\_work\\Daddy"s\\myProjects\\2009 >> >> defaultProject\\R\\textfile\\' >>> >>> # text miner pakacge >>> library(tm) >> >> Loading required package: Snowball >> Loading required package: RWeka >> - >> Error in .jinit(system.file("jar", c("weka.jar", "RWeka.jar"), package = >> pkgname, : >> Cannot create Java virtual machine (-1) >> Error : .onLoad failed in 'loadNamespace' for 'RWeka' >> Error: package 'RWeka' could not be loaded >>> >>> my.corpurs <-Corpus(DirSource(my.path), readerControl = >> >> list(reader=readPlain)) >> Error: could not find function "Corpus" >>> >>> my.tdm <- TermDocMatrix(my.corpus) >> >> Error: could not find function "TermDocMatrix" >>> >>> my.tdm[1,] >> >> Error: object "my.tdm" not found >> >> >> -- >> Kum-Hoe Hwang, Ph.D. >> >> Phone : 82-31-250-3516 >> Email : phdhw...@gmail.com >> >>[[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. >> > > -- > Brian D. Ripley, rip...@stats.ox.ac.uk > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UKFax: +44 1865 272595 > -- Kum-Hoe Hwang, Ph.D. Phone : 82-31-250-3516 Email : phdhw...@gmail.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] [R} how to build TermDocMatrix in tm text mining package of R
Thank your comments very much. Thank to your help, I understood a flow for a text analysis. However, I could not run the above R scripts because tm package does not work in my PC that is a critical error. Kum Hwang Ph.D. On Sat, Jan 10, 2009 at 12:39 AM, Tony Breyal wrote: > Hi there, I think something like the following is what you want: > > ### R start... > # if you put your plain text files in a folder like this > my.path <- 'C:\\Documents and Settings\\tony\\Desktop\\texts\\' > > # then you can construct a simple tdm like this > library(tm) > my.corpus <- Corpus(DirSource(my.path), readerControl = list > (reader=readPlain)) > my.tdm <- TermDocMatrix(my.corpus) > > # this show show how words are distributed in the first text document > my.tdm[1, ] > ### R end. > > by the way, there are some nice examples of using the tm package in > the last Rnews letter (Volume 8/2, October 2008), under the section > 'An Introduction to Text Mining in R': > http://cran.r-project.org/doc/Rnews/Rnews_2008-2.pdf > > Hope that helps a little bit, > Tony Breyal > > On 9 Jan, 14:21, "Kum-Hoe Hwang" wrote: >> Howdy Gurus >> >> I 'd like to ask a question about how to build TermDocMatrix in tm text >> mining package. >> >> It is not clear about importing a plain text file, and them converting that >> text file into TermDocMatrix file, etc to me. >> How can I build a TermDocMatrix of " a plain text document file for text >> association? >> Or are there any good manuals? >> >> Thank you in advance, >> >> -- >> Kum-Hoe Hwang, Ph.D. >> >> Phone : 82-31-250-3516 >> Email : phdhw...@gmail.com >> >> [[alternative HTML version deleted]] >> >> __ >> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guidehttp://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. > -- Kum-Hoe Hwang, Ph.D. Phone : 82-31-250-3516 Email : phdhw...@gmail.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] connecting boxplots
You do not provide a workable example and it appears you may be conflating the German and English spellings of "group", but perhaps this code fragment using the first example in boxplots help menu will move you along. It results in drawing the connecting lines to the minimum value in each group. > boxplot(count ~ spray, data = InsectSprays, col = "lightgray") #draws the plot > str(boxplot(count ~ spray, data = InsectSprays, col = "lightgray") ) List of 6 $ stats: num [1:5, 1:6] 7 11 14 18.5 23 7 12 16.5 18 21 ... # Notice that the "stats" element is a matrix that has the first row as the minimums, third as the medians, and maxs are fifth. $ n: num [1:6] 12 12 12 12 12 12 $ conf : num [1:2, 1:6] 10.579 17.421 13.763 19.237 0.588 ... $ out : num [1:2] 7 12 $ group: num [1:2] 3 4 $ names: chr [1:6] "A" "B" "C" "D" ... > boxplot(count ~ spray, data = InsectSprays, col = "lightgray") $stats[c(1,5),] [,1] [,2] [,3] [,4] [,5] [,6] [1,]770219 # minimums [2,] 23 21466 26 # maximumns > lines(boxplot(count ~ spray, data = InsectSprays, col = "lightgray") $stats[c(1),] ) #adds the lines through minimums -- David Winsemius On Jan 11, 2009, at 8:00 PM, johnhj wrote: In other words: I will connect the median, min and the max area of the boxplot with a line. The function lines() could help me, but I don't know which parameters the lines() function should have. johnhj wrote: Hii, I created some boxplots with this commands: x <-read.table(file="test.txt") x$group <- rep(1:8, each=5) boxplot(V3~gruppe, data=x) Now, I will connect the boxplots to each other to the min, max and median values. Can anybody help me how to do it ? greetings, J __ 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] How to reference previous row?
I am trying to write some code where the factor references its previous value, but can't find a solution searching through the archive. > X first second 1 A 1 2 A 2 3 B 3 4 B 4 5 B 5 6 C 6 7 C 7 I need a third column, in pseudo code- If value of first=previous value of first: third=previous value of third else third = second So the third column would look like: 0 0 3 3 3 6 6 Thanks! __ 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.