Thank David and Jim.
I got it.
-
A R learner.
--
View this message in context:
http://r.789695.n4.nabble.com/sample-and-rearrange-tp747p2223872.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
you just need the function name; the parameter is being supplied by the lapply:
t(apply(x, 1, rearrange))
On Wed, May 19, 2010 at 7:47 PM, Wu Gong wrote:
>
> I tried to use a separate function to make the code more understandable. But
> I failed. I don't know what's wrong with the code.
>
> x <
On May 19, 2010, at 7:47 PM, Wu Gong wrote:
I tried to use a separate function to make the code more
understandable. But
I failed. I don't know what's wrong with the code.
x <- as.matrix(x)
rearrange <- function(.row){
z <- do.call(rbind, strsplit(.row[-1], ''))
z.col <- t
I tried to use a separate function to make the code more understandable. But
I failed. I don't know what's wrong with the code.
x <- as.matrix(x)
rearrange <- function(.row){
z <- do.call(rbind, strsplit(.row[-1], ''))
z.col <- t(apply(z, 2, paste, collapse=''))
cbind(.ro
On May 19, 2010, at 5:01 PM, Wu Gong wrote:
It took me a day to make the sense of Jim's code :(
Hope my comments will help.
## Transform data to matrix
x <- as.matrix(x)
## Apply function to each row
## Create a function to rearrange bases
result <- apply(x, 1, function(eachrow){
## Split
It took me a day to make the sense of Jim's code :(
Hope my comments will help.
## Transform data to matrix
x <- as.matrix(x)
## Apply function to each row
## Create a function to rearrange bases
result <- apply(x, 1, function(eachrow){
## Split each gene to bases
## Exclude the fist column wh
try this:
> x <- read.table(textConnection("SampleIDA1 A2 A3 A4
+ GM920222GATTGCC GATTGCC GATAGAC GATAGAC
+ GM930040GTCATCA GAGTGCA ACTATAA GATTGCC
+ GM930040GTCATCA GAGTGCA ACTATAA GATTGCC
+ GM960023GATTGCC GTCATCA GATTGCC GATTGCC
+ GM920224
Dear Wu Gong and Peter Ehlers,
thank you very much for your help debugging my script.
Now I have a general following up question:
Is there a straightforward way to rearrange the following dataset so
that all first letters of each column will be combined in one column,
all the second letters i
8 matches
Mail list logo