R Language Module for TextWrangler (and a lot of other editors)
Via this page, I just learned that there is a TextWrangler Language Module for R. The file itself is available here.
To install, copy the .plist file to the following directory
Username/Library/Application Support/TextWrangler/Language Modules
I also recommend going into TextWrangler’s preferences and changing the color for comments. The default is a gray color that doesn’t provide a lot of contrast compared to normal black screen text.
Also, check out the via page from SciViews.com. It has links to R syntax highlighting files for many editors on many platforms.
New website design
Be sure to check out how GGobi got its name and the new demo of the parallel coordinates plot.
We know that a lot of people have been having problems viewing the movies, and we are working on a solution. Stay tuned!
Basic factor analysis in R
The call to perform factor analysis on a set of variables in R is:
fact1<- factanal(x,factors,scores=c(“regression”),rotation=”varimax”)
where “x” is a dataframe containing the appropriate variables, and “factors” is the number of factors to be extracted.
socres=”…” and rotation=”…” are optional, and varimax is the default rotation.
The factanal function doesn’t seem to handle missing observations well, so it’s easier to create a new dataframe based on your original, with the missing values omitted:
x1<-na.omit(x)
To view the summary of the factor analysis, simply type the name of the object under which the analysis was saved.
fact1
To view the scores, use
fact1$scores
To view a scree plot, install the “psy” package load it
install.packages(“psy”)
library(psy)
Then type
scree.plot(fact1$correlations)
The above commands and options are only the very basics. For more information, view the documentation for the factanal function. For more information about factor analysis in general, here is a nice nontechnical introduction.
GGobi2 beta for Windows!
We have made a huge number of changes since the last version:
* much much more stable (thanks to Michael's hard work)
* now much prettier looking (thanks to the move to Gtk2)
* just about every area of the interface has been refined or redesigned
* csv import should now handle any thing you can throw at it
* Rggobi2 has had a major revamp (still ongoing)
* a new development site and bug tracker
* lots of bugs fixes to the barchart, and many of the tools
A big thanks goes to the whole GGobi team for making this happen: Debby Swayne, Michael Lawrence, Di Cook, Heike Hofmann, Hadley Wickham Duncan Temple-Lang and Andreas Buja.
If you do encounter any problems please send an email the mailing list or file a bug report - your feedback is appreciated and we are especially keen to eliminate any bugs that crash GGobi before the official release.
Getting tables from R output
Turning plain-text output into well-formatted tables can be a repetitive task, especially when many tests or models are being incorporated into a paper.
For R users, there are several methods that can make this task easier (though not much less repetitive), regardless of what typesetting system you use.
LaTeX tables
The xtable package produces LaTeX-formatted tables. Using xtable, specific kinds of R objects, such as linear model summaries, can be turned into "xtables", which can in turn be output to either LaTeX or HTML.
To use:
- Install the xtable package: install.packages("xtable")
- Load the xtable package: library(xtable)
- Create an xtable for the object that you want to export: newobject<-xtable(object)
- Export your xtabled object to LaTeX: print.xtable(newobject, type="latex", file="filename.tex")
Options
- To export to HTML instead of LaTeX, use type="html" and use the .html extension in the filename
- To have R produce the proper markup in the console (instead of writing in to a file) omit the file=filename option
Other word processors
If, instead of LaTeX, you are using Word, OpenOffice, NeoOffice, etc., there is a way to produce more easily formatted tables. Just follow these steps:
- Create an xtable, as above, and print the output to an HTML file: print.xtable(newobject, type="html", file="filename.html")
- Open the generated HTML file in your browser (may I recommend Firefox)
- Copy the table contents and paste them into your word processor
- Convert the text to a table: In OpenOffice or NeoOffice: Select the text and go to Tools: Text <-> Table and select "Tabs" as the delimiter. In Word: Select the text and go to Table: Convert: Convert Text to Table, and use separate text at tabs
This technique is somewhat more convoluted than creating pure LaTeX output, but it is probably quicker than entering the output by hand.
Note: An alternative to xtable is the R2HTML package, which works similarly, but does not require xtable objects to be created in order to generate HTML output.
