[R] moving data and output?

Jason Turner jasont at indigoindustrial.co.nz
Fri Jun 11 05:28:15 CEST 2004


> Hello,
>
> I have a few questions now:

Yes.  Since the mail is archived to help other people, in future please
send a small mail for each question, with a descriptive subject line for
each.  This makes it easier for everyone.

> 1.  How can I move data the following way:
>
> I have 2 variables:
>
> one	two
> 1	5  ^
> 3	4  |
> 1	3  |
> 4	4  |
>
> Now I want to move the two one arround (sorry I don't know how to say
> that in english).  That means:  I want to move the first item at the
> end of my column and move the second at the first place, the third at
> the second, and so on.  You can see it at the arrow next to the 'two'
> column.  The colum named 'one' should be as it is.

By using indexing.  If this is a matrix called mymatrix:

mymatrix[,2] <- mymatrix[c(4,1:3),2]

If it's a data frame called mydf:

mydf$two <- mydf$two[c(4,1:3)]



> 2. How can I make outputs of the grafics (plot, hist, ...) into a file?

See the help pages and examples...

?postscript
?Devices
?pdf

> 3. Can I make latex output of the grafics (any tool, like texdraw or
> pictex ...)?

I use either eps or pdf for inclusion into LaTeX.  You also have the fig
file format, so you can use xfig to edit before inclusion.

> 4. I know about sink().  But can I format the output for LaTeX, like a
> \begin{tabular} ... \end{tabular} for a dist() matrix or similar?

Two ways:
1) Install the Hmisc package, and see ?latex
2) Install the xtable package, and see ?xtable.

> 5. Acording to the other questions, where can I find answers for this
> questions, if I'm not the first one who is asking?

1) help.search("some keyword")
2) go to http://cran.r-project.org, and follow the "Search" link to search
the mail archives.

Cheers

Jason




More information about the R-help mailing list