Is there any way to force a slice of a matrix to stay a matrix? R
tends to convert a single row of a matrix into a vector.
Example:
z<-matrix (rnorm(20), ncol=5)
zz<-z[1,]
is.matrix(zz) #FALSE
I usually resort to:
zz<-matrix(z[1,], ncol=dim(z)[2], dimnames=list(rownames(z)[1],
colnames(z))
On Jul 21, 2009, at 6:40 PM, Duncan Murdoch wrote:
> On 21/07/2009 5:03 PM, Jim Nemesh wrote:
>> Hi! I'm wondering if there's a smart way around this:
>> fileName= (some valid file on your system)
>> >fileCon=file(fileName, open="rt")
>>
Hi! I'm wondering if there's a smart way around this:
fileName= (some valid file on your system)
>fileCon=file(fileName, open="rt")
>l<-readLines (fileCon, n= 1)
>
> isOpen(fileCon)
[1] TRUE
>close(fileCon)
> isOpen(fileCon)
Error in isOpen(fileCon) : invalid connection
How do you
first time I try to construct the object it fails,
and the second time it seems to work just fine? Is there something I
should be doing between declaring the constructor and using the object
(besides adding S3 methods?)
Thanks for any help, I find this entirely confusing.
-Jim Nemesh
A simple way to do it would be:
mat<-mat[,c(2,1)]
Slightly more fancy (for any number of columns):
mat<-mat[,dim(mat)[2]:1]
I'm sure there are prettier ways to do it.
-Jim
On Jun 18, 2009, at 4:14 PM, RON70 wrote:
Hi,
Suppose I have following dataset :
mat <- matrix(rnorm(100), 50)
Now
enotypes/2008-07_phaseIII/hapmap_format/forward
", outRootDir="/humgen/cnp04/sandbox/data/snpTagging")'
Thanks for the pointer on getopt - it's much nicer than my homebrew
solution.
-Jim
On Jun 18, 2009, at 1:54 PM, Jim Nemesh wrote:
I did look at ?Rscript. My question there
and have a look at ?Rscript
Also on Windows see Rscript.bat and #Rscript.bat in
http://batchfiles.googlecode.com
and on Linux see:
http://dirk.eddelbuettel.com/code/littler.html
On Thu, Jun 18, 2009 at 1:25 PM, Jim Nemesh
wrote:
I develop quite a bit of R code that I tend to distribute, or
ke each expression is evaluated separately.
Is there a way to evaluate multiple expressions in the same
environment to make the above work? If so, I could then wrap R in
whatever language of choice I'd like, and only have to make a user
install a library.
8 matches
Mail list logo