Re: [R] Faster union of polygons?

2010-06-04 Thread Remko Duursma
Martin,

thanks a lot! This speeds things up so much 

Do you mind if I bundle your punion function in a package I am
developing (but of course I will name you the author of the function)?

greetings,
Remko



On Fri, Jun 4, 2010 at 12:17 PM, Martin Morgan mtmor...@fhcrc.org wrote:
 On 06/03/2010 04:54 PM, Remko Duursma wrote:
 Thanks for the tip - this cleans up the code a lot!
 Unfortunately, there is no gain in speed.

 Playing a little bit dirty,

 punion -
    function(...)
 {
    n - nargs()
    if (0L == n) new(gpc.poly)
    else if (1L == n  is(..1, gpc.poly)) ..1
    else {
        polygons - list(...)
        if (!all(sapply(polygons, is, gpc.poly)))
            stop('...' must all be 'gpc.poly')
        ## avoid method look-up
        to_numeric - selectMethod(coerce, c(gpc.poly, numeric))
        vec - to_numeric(polygons[[1]])
        for (p in polygons[-1]) {
            clip - to_numeric(p)
            vec - .Call(Rgpc_polygon_clip, vec, clip, 3,
                         PACKAGE=gpclib)
        }
        if (identical(vec, 0))
            new(gpc.poly)
        else
            as(vec, gpc.poly)
    }
 }

 is about 4x faster on your example

 replicate(5, system.time(Reduce(union, leaves)))
            [,1]  [,2]  [,3]  [,4]  [,5]
 user.self  1.272 1.272 1.272 1.268 1.268
 sys.self   0.000 0.000 0.000 0.000 0.000
 elapsed    1.271 1.272 1.272 1.273 1.281
 user.child 0.000 0.000 0.000 0.000 0.000
 sys.child  0.000 0.000 0.000 0.000 0.000
 replicate(5, system.time(do.call(punion, leaves)))
            [,1]  [,2]  [,3]  [,4]  [,5]
 user.self  0.308 0.312 0.304 0.308 0.312
 sys.self   0.004 0.000 0.004 0.004 0.000
 elapsed    0.311 0.311 0.309 0.314 0.317
 user.child 0.000 0.000 0.000 0.000 0.000
 sys.child  0.000 0.000 0.000 0.000 0.000

 Rprof suggests that most of the time is now in the C code

 Rprof(/tmp/leaves.Rprof)
 x - replicate(5, system.time(do.call(punion, leaves)))
 Rprof(NULL)
 summaryRprof(/tmp/leaves.Rprof)
 $by.self
                     self.time self.pct total.time total.pct
 .Call                   1.24     69.7       1.24      69.7
 gc                      0.24     13.5       0.24      13.5
 FUN                     0.08      4.5       1.78     100.0
 [...SNIP...]

 Martin


 remko



 On Thu, Jun 3, 2010 at 10:46 PM, nikhil kaza nikhil.l...@gmail.com wrote:
 Reduce might work. Not sure about the speed advantages though. It does
 simplify code.

  Unionall - function(x) Reduce('union', x)
 leaveout - Unionall(leaves)


 On Tue, Jun 1, 2010 at 9:53 PM, Remko Duursma remkoduur...@gmail.com
 wrote:

 Dear R-helpers,

 thanks for yesterday's speeding-up tip. Here is my next query:

 I have lots of polygons (not necessarily convex ones, and they never
 have holes) given by x,y coordinates.

 I want to get the polygon that is the union of these polygons. This is
 my current method, but I am hoping there is a faster method (up to
 thousands of polygons, each with ca. 40 xy points).

 Example:

 library(gpclib)

 # A polygon
 leaf - structure(c(0, 1, 12.9, 16.5, 18.8, 17, 16.8, 15.5, 12.1, 8.2,
 6.3, 5, 2, 0, -1.5, -4.3, -6.6, -10.3, -14.8, -19.4, -22.2, -23.5,
 -22.2, -17.6, -7.8, 0, 0, -2.4, 2.8, 8.9, 19.9, 33.9, 34.8, 40.4,
 49.7, 69.2, 77.4, 83.4, 91.4, 99, 92.8, 87.3, 81.2, 71.1, 57.6,
 45.4, 39.2, 26, 15.6, 5.3, 0.6, 0), .Dim = c(26L, 2L), .Dimnames = list(
    NULL, c(X, Y)))

 # Lots of polygons:
 releaf -
 function(leaf)cbind(leaf[,1]+rnorm(1,0,50),leaf[,2]+rnorm(1,0,50))
 leaves - replicate(500, releaf(leaf), simplify=FALSE)

 # Make into gpc.poly class:
 leaves - lapply(leaves, as, gpc.poly)

 # Make union .
 system.time({
 leavesoutline - union(leaves[[1]], leaves[[2]])
 for(i in 3:length(leaves))leavesoutline - union(leavesoutline,
 leaves[[i]])
 })
 # about 1sec here.

 # Check it:
 plot(leavesoutline)



 thanks!

 Remko


 -
 Remko Duursma
 Research Lecturer

 Centre for Plants and the Environment
 University of Western Sydney
 Hawkesbury Campus
 Richmond NSW 2753

 Dept of Biological Science
 Macquarie University
 North Ryde NSW 2109
 Australia

 Mobile: +61 (0)422 096908
 www.remkoduursma.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.


 --
 Martin Morgan
 Computational Biology / Fred Hutchinson Cancer Research Center
 1100 Fairview Ave. N.
 PO Box 19024 Seattle, WA 98109

 Location: Arnold Building M1 B861
 Phone: (206) 667-2793


__
R-help@r-project.org mailing 

Re: [R] parttioning a matrix corresponding to different levels of y

2010-06-04 Thread sayan dasgupta
Suman take a look if this suffices your purpous

x - data.frame(y=as.factor(sample(0:2,1000,replace=TRUE)),x=runif(1000))
x1 - x[x$y==0,]
x2 - x[x$y==1,]
x3 - x[x$y==2,]

On Fri, Jun 4, 2010 at 10:29 AM, suman dhara suman.dhar...@gmail.comwrote:

 Sir,
 I have a problem regarding partitioning a matrix.I state my problem as
 follows:

 I have a y vector of length say 1000.Variable y has 4 levels say
 0,1,2.Corresponding to each y(response), I have a x-vector(explanatory) as
 a
 row of X matrix.Now, I want to partition the X matrix into 3 submatrices
 say
 x1,x2,x3  corresponding to each level of y.Is there any function to do this
 in R or how can I do this in R?

 For your convinience I attach a sample version of data.

Use dput()  and paste it in your mail


 Thanks,
 Suman Dhara

 __
 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] Boxplot: what is shown by default?

2010-06-04 Thread Thomas von Känel
hi,
i'm using /boxplot()/ to show some data:

x - c(0.99, 0.97, 0.91, 0.72, 1.00, 0.99, 1.02, 0.90, 0.91, 0.90, 1.02, 
0.90, 1.35, 1.01, 0.92)
boxplot(x)

is it correct when i say: /Boxes represent interquartile ranges (IQRs); 
bold horizontal lines, medians; whiskers, lowest and highest values 
still within 1.5 x IQR; open circles, outliers.?

/thanks in advance for any help!
cheers, tom
human genetics, bern/
/



[[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 implementation for Text analytics

2010-06-04 Thread Christofer Bogaso
Hi there, is there any R package which address the Text analytics topic?
It would also be great if someone point me about some good text books on
Text analytics and what statistical tools and techniques are generally
used on that field.

Thanks and regards,

[[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] R Newbie, please help!

2010-06-04 Thread Joshua Wiley
Hey Jeff,

I have a few ideas.  Each has some different requirements, and to help
you choose, I bench marked them.


###START###

##Basic data
 test - data.frame(totret=rnorm(10^7), id=rep(1:10^4, each=10^3), 
 time=rep(c(1, rep(0, 999)), 10^4))

##Option 1: probably the most general, but also the slowest by far.
##The idea is it does the calculation for each stock/ID, and then
concatenates [c()] an NA in front.

 system.time(test[,dailyreturns] - unlist(by(test[,totret], test[,id], 
 function(x) {c(NA, x[-1]/x[-length(x)])})), gcFirst=TRUE)
   user  system elapsed
  49.110.42   49.86

##Option 2: Assumes that you have the same number of measurements for
each stock/ID so you can just assign an NA every nth row.
##This is fairly fast

 system.time(test[-1,dailyreturns] - 
 test[-1,totret]/test[-nrow(test),totret], gcFirst=TRUE)
   user  system elapsed
   1.110.211.31
 system.time(test[seq(1, 10^7, by=10^3),dailyreturns] - NA, gcFirst=TRUE)
   user  system elapsed
   0.390.040.42

##Option 3: Assumes that you have some variable (time in my little
test data) that somehow indicates when each stock/ID has its first
measurement.  In the example, the first measurement gets a 1 and
subsequent ones a 0.  So we just assign NA in 'dailyreturns' everytime
the other time column has a 1.  Again, a big assumption, but fairly
quick.

 system.time(test[-1,dailyreturns] - 
 test[-1,totret]/test[-nrow(test),totret], gcFirst=TRUE)
   user  system elapsed
   1.060.171.25
 system.time(test[which(test[,time]==1),dailyreturns] - NA, gcFirst=TRUE)
   user  system elapsed
   0.460.090.55

###END###

I really feel like there should be a faster way that is also more
general, but it is late and I am not coming up with any better ideas
at the moment.  Perhaps somehow finding the first instance of a
stock/ID?  Anyway, this was simulated on 10 million rows, so maybe
by() works plenty fast for you.

Josh


On Thu, Jun 3, 2010 at 10:20 PM, Jeff08 jefferyd...@gmail.com wrote:

 Hey Josh,

 Thanks for the quick response!

 I guess I have to switch from the Java mindset to the matrix/vector mindset
 of R.

 Your code worked very well, but I just have one problem:

 Essentially I have a time series of stock A, followed by a time series of
 stock B, etc.
 So there are break points in the data (the points where it switches stocks
 have incorrect returns, and should be NA at t=0 for each stock)

 Is there an easy way to account for this in R? What I was thinking of is if
 there is a way to make a filter rule. Such as if the ID of the row matches
 Stock A, then perform this.

Hello Jeff,

 Try this:

 test - data.frame(totret=rnorm(10^7)) #create some sample data
 test[-1,dailyreturn] - test[-1,totret]/test[-nrow(test),totret]

 The general idea is to take the column totret excluding the first 1,
 dividided by totret exluding the last row.  This gives in effect t+1
 (since t is now shorter)/t

 I assigned the result to a new column dailyreturn.  For 10^7 rows,
 it tooks 1.92 seconds on my system.
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/R-Newbie-please-help-tp2242633p2242703.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.




-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.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 on ARFIMA modeling

2010-06-04 Thread ERIC AIDOO
Please I want to perform full data analysis using ARFIMA model but
I dont know the right package that can perform all the necessary
test on the time series data.

ERIC AIDOO

[[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] R Newbie, please help!

2010-06-04 Thread Joshua Wiley
I am not exactly sure how your filtering code is working, but take a look at

?na.omit

You will probably need a few additional steps if you want to remove
all rows related to a particular id.  Also look at ?subset which is a
good general way to subset your data.

Josh



On Thu, Jun 3, 2010 at 11:45 PM, Jeffery Ding jefferyd...@gmail.com wrote:
 Thanks, you have been tremendously helpful!
 I will be able to implement option 2, after I filter out stocks with
 incomplete data sets.

 So far, for my filtering code I have:

 ##Filtering

 x-length(unique(Returns$date_))
 y-unique(Returns$id)
 Returns.filter-Returns

 i-1

 while(i=length(y)) {
     a-sum(Returns$id==y[i])
     if(ax) {
         ##need code that will remove all rows with id a
     }
     i-i+1
     }



 On Fri, Jun 4, 2010 at 2:40 PM, Joshua Wiley jwiley.ps...@gmail.com wrote:

 Hey Jeff,

 I have a few ideas.  Each has some different requirements, and to help
 you choose, I bench marked them.


 ###START###

 ##Basic data
  test - data.frame(totret=rnorm(10^7), id=rep(1:10^4, each=10^3),
  time=rep(c(1, rep(0, 999)), 10^4))

 ##Option 1: probably the most general, but also the slowest by far.
 ##The idea is it does the calculation for each stock/ID, and then
 concatenates [c()] an NA in front.

  system.time(test[,dailyreturns] - unlist(by(test[,totret],
  test[,id], function(x) {c(NA, x[-1]/x[-length(x)])})), gcFirst=TRUE)
   user  system elapsed
  49.11    0.42   49.86

 ##Option 2: Assumes that you have the same number of measurements for
 each stock/ID so you can just assign an NA every nth row.
 ##This is fairly fast

  system.time(test[-1,dailyreturns] -
  test[-1,totret]/test[-nrow(test),totret], gcFirst=TRUE)
   user  system elapsed
   1.11    0.21    1.31
  system.time(test[seq(1, 10^7, by=10^3),dailyreturns] - NA,
  gcFirst=TRUE)
   user  system elapsed
   0.39    0.04    0.42

 ##Option 3: Assumes that you have some variable (time in my little
 test data) that somehow indicates when each stock/ID has its first
 measurement.  In the example, the first measurement gets a 1 and
 subsequent ones a 0.  So we just assign NA in 'dailyreturns' everytime
 the other time column has a 1.  Again, a big assumption, but fairly
 quick.

  system.time(test[-1,dailyreturns] -
  test[-1,totret]/test[-nrow(test),totret], gcFirst=TRUE)
   user  system elapsed
   1.06    0.17    1.25
  system.time(test[which(test[,time]==1),dailyreturns] - NA,
  gcFirst=TRUE)
   user  system elapsed
   0.46    0.09    0.55

 ###END###

 I really feel like there should be a faster way that is also more
 general, but it is late and I am not coming up with any better ideas
 at the moment.  Perhaps somehow finding the first instance of a
 stock/ID?  Anyway, this was simulated on 10 million rows, so maybe
 by() works plenty fast for you.

 Josh


 On Thu, Jun 3, 2010 at 10:20 PM, Jeff08 jefferyd...@gmail.com wrote:
 
  Hey Josh,
 
  Thanks for the quick response!
 
  I guess I have to switch from the Java mindset to the matrix/vector
  mindset
  of R.
 
  Your code worked very well, but I just have one problem:
 
  Essentially I have a time series of stock A, followed by a time series
  of
  stock B, etc.
  So there are break points in the data (the points where it switches
  stocks
  have incorrect returns, and should be NA at t=0 for each stock)
 
  Is there an easy way to account for this in R? What I was thinking of is
  if
  there is a way to make a filter rule. Such as if the ID of the row
  matches
  Stock A, then perform this.
 
 Hello Jeff,
 
  Try this:
 
  test - data.frame(totret=rnorm(10^7)) #create some sample data
  test[-1,dailyreturn] - test[-1,totret]/test[-nrow(test),totret]
 
  The general idea is to take the column totret excluding the first 1,
  dividided by totret exluding the last row.  This gives in effect t+1
  (since t is now shorter)/t
 
  I assigned the result to a new column dailyreturn.  For 10^7 rows,
  it tooks 1.92 seconds on my system.
  --
  View this message in context:
  http://r.789695.n4.nabble.com/R-Newbie-please-help-tp2242633p2242703.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.
 



 --
 Joshua Wiley
 Senior in Psychology
 University of California, Riverside
 http://www.joshuawiley.com/



 --
 Jeffery Ding
 Duke University, Class of 2012
 (224) 622-3398 | jd...@duke.edu




-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.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, 

Re: [R] import text file into R

2010-06-04 Thread Peter Ehlers

On 2010-06-03 22:51, Dhanasekaran wrote:

please look at the error..


LosA-read.table(E:\\Temporary

Tasks\\rub\\Los_R\\ca_los.txt,header=T,sep=\t)
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
:
   line 11022 did not have 87 elements


That error message seems pretty explicit to me: you have a problem with 
line 11022. Did you check it with a text editor?


It's always a good idea to run count.fields() on the file, as 
recommended on the help page for read.table.


If you're trying to import SAS data, you might want to check out the 
'foreign' package.


Note also that read.delim is convenient for tab-delimited files.

 -Peter Ehlers



ca_los.txt is my tab delimited large text file which contains about 16lakhs
observations.

thank you

On Fri, Jun 4, 2010 at 9:44 AM, Erik Iversoner...@ccbr.umn.edu  wrote:


Dhanasekaran wrote:


Sorry guys

It is a tab delimited text file which I just exported from SAS. I want to
import this in R. Pl let me know what is the delimiter I should use and R
syntax.

You still don't say the error you're getting when you try your read.table

command.





__
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] import text file into R

2010-06-04 Thread Glen Barnett
On Fri, Jun 4, 2010 at 2:51 PM, Dhanasekaran dhana...@gmail.com wrote:

 ca_los.txt is my tab delimited large text file which contains about 16lakhs
 observations.

Most readers of this list probably won't know that a 'lakh' is a
hundred thousand. 16lakhs means 1.6 million.

Glen

__
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] Shapes in barplots

2010-06-04 Thread khush ........
Hi,

I am making barplots . I am using the default shape of barplots with a pipe
but I wants to build bars in various 3d shapes. I have install rgl using
install.packages('rgl') for this purpose, but when I am doing library(rgl),
it shows

Error in library(rgl) : there is no package called 'rgl'

What are the other ways to build such plots of variuos shapes.

Is that *TeachingDemos *replace it..I am not sure how to use it for such
task.

Thanks in advance
Jeet

[[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] Handling of par() with variables

2010-06-04 Thread Steffen Uhlig
Hello!

In order to plot multiple graphs with the same set-up I use the
following code-structure:

###
# storing old parameter set
oldpar - par(no.readonly=T)

#copying old parameter set
newpar - par(no.readonly=T)

#adjusting parameters
newpar - par(mar=c(3.1,3.1,0.1,0.1),  # margin for figure area
  oma=c(0,0,0,0),  # margin for outer figure area
  cex.axis=0.9,  # axeneinteilung
  mgp=c(2,0.6,0),  # abstand der
achsenbeschriftung
  tck=0.02# major ticks innen
  )

...
...
postscript(...)
par(newpar)
...
dev.off()
###

Calling the variable newpar delivers the old paramter set only (from
code-line newpar - par(no.readonly=T)). If the code-segment newpar
- par(mar=... runs a second time, the correct paramter set is
stored, however, just the 5 parameters adjusted and not the full list.

My question is, why must the code segment newpar-par(mar...) run
twice? Is there a better way to handle the graphics output? I would be
grateful for a pointer on a FAQ-section or to an older discussion
thread in this group!

Thank you very much in advance!

Regards,
/steffen

__
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 CairoPNG

2010-06-04 Thread Thomas Steiner
Hi,
could it be that the text() fuction gives different output for normal
png() and CarioPNG()?
See the following example and the attached images: the font=2 and
font=3 seem to be exchanged!
Thanks for help,
Thomas

CairoPNG(Test-cairo.png,width=750,height=690)
#png(Test-normal.png,width=750,height=690)

plot(1,1,type=n,main=normal)
text(1,1,normal,adj=c(1,1))
text(1,1,bold,font=2,adj=c(-1,-1))
text(1,1,italic,font=3,adj=c(1,-1))
text(1,1,italicbold,font=4,adj=c(-1,1))

dev.off()
attachment: Test-cairo.pngattachment: Test-normal.png__
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] plot polar coordinates

2010-06-04 Thread Jim Lemon

On 06/04/2010 05:05 AM, Thomas Steiner wrote:

Thank you Greg,

I'll add 180 then.

Thanks for the hint with longer radial.lim arguments it works woderfull.


The lines function is plotting in Cartesian coordinates, not the polar 
coordinates.


Is there any (lines) function that plots polar coordinates to an existing plot?


Hi Thomas,
Greg has already given you most of the solutions. I was a bit surprised 
to find that if you include the negative values in the radial.lim 
argument, the polygon appears _and_ in the right place! I'll have to add 
this to the help page. Note that your labels may not be where you think 
they should be, as 0 degrees is east in your example. Maybe you want 
start=90?


I have thought about reprogramming the radial plot functions with an 
add argument, but haven't gotten around to it. I'll have a look and if 
I can do this without too much work, I'll let you know.


As far as 100 being prettier than 90, my experience is that I ain't 
gettin' any prettier as I get older.


Jim

__
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] StatET plot problem

2010-06-04 Thread Bunny, lautloscrew.com
Dear all, 

after trying several suggestions from the list for a nice R-Editor / IDE for 
MacOS X and really trying some of those that needed to be configured a little 
more (such as emacs, aquamacs and StatET / Eclipse), I prefer StatET at the 
moment. I found more experienced like John suggesting this combination 
(http://www.mail-archive.com/r-help@r-project.org/msg38883.html) on Mac OS X.

So far I am really happy with it except for the plotting. I just can´t get 
plots to go. everytime I plot(x) nothing happens. What´s striking is that the 
edit() works and opens up in X11. Is there some configuration option I just 
missed ? 

best regards

matt
__
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] import text file into R

2010-06-04 Thread Jim Lemon

On 06/03/2010 09:32 PM, dhanush wrote:


can anyone tell me how to import a text file in R? the text file I want to
import is a large file, about 800MB in size. Thanks in advance.

I tried using the following

data-read.table(file,header=T,sep=\t)



Hi dhanush,
If the problem is with read.table, maybe:

# whatlist is a list of data types defining what
# is in each line of data - see the help page
data-scan(file,skip=1,sep=\t,what=whatlist)

will get it in for you.

Jim

__
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: what is shown by default?

2010-06-04 Thread Peter Ehlers

On 2010-06-04 0:14, Thomas von Känel wrote:

hi,
i'm using /boxplot()/ to show some data:

x- c(0.99, 0.97, 0.91, 0.72, 1.00, 0.99, 1.02, 0.90, 0.91, 0.90, 1.02,
0.90, 1.35, 1.01, 0.92)
boxplot(x)

is it correct when i say: /Boxes represent interquartile ranges (IQRs);
bold horizontal lines, medians; whiskers, lowest and highest values
still within 1.5 x IQR; open circles, outliers.?



That's essentially correct, except that quartiles can be
defined in more than one way; see ?quantile and the
discussion leading to comments in
https://stat.ethz.ch/pipermail/r-help/2010-May/239074.html.

Note that the box limits are the 'hinges' given by
fivenum(x) and their difference need not equal IQR(x) which
uses quantile(..., type=7). [For your data above, they do
happen to coincide.]

 -Peter Ehlers


/thanks in advance for any help!
cheers, tom
human genetics, bern/
/



__
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] StatET plot problem

2010-06-04 Thread Philippe Grosjean

On 04/06/10 10:37, Bunny, lautloscrew.com wrote:

Dear all,

after trying several suggestions from the list for a nice R-Editor / IDE for 
MacOS X and really trying some of those that needed to be configured a little 
more (such as emacs, aquamacs and StatET / Eclipse), I prefer StatET at the 
moment. I found more experienced like John suggesting this combination 
(http://www.mail-archive.com/r-help@r-project.org/msg38883.html) on Mac OS X.

So far I am really happy with it except for the plotting. I just can´t get 
plots to go. everytime I plot(x) nothing happens. What´s striking is that the 
edit() works and opens up in X11. Is there some configuration option I just 
missed ?

best regards


You haven't try SciViews-K/Komodo, don't you? 
(http://www.sciviews.org/SciViews-K).

Best,

Philippe


matt
__
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] Comparing a 4-point and 5-point Likert scale

2010-06-04 Thread Jim Lemon

On 06/03/2010 11:11 PM, Simon Kiss wrote:

Help with survey data:
Hello R colleagues,
I hope this is an appropriate place to direct this question. It relates
specifically to the comparability of a 5-point likert to a 4-point
likert scale.

One question in my dataset asks How much should be done to reduce the
gap between rich and poor
Much more, somewhat more, about the same, somewhat less and much less.

The second questions ask:
People who can afford to, should be able to pay for their own health care
strongly agree, agree, disagree, strongly agree.

Now, assuming that I rescale them so that 1 equals the most egalitarian
position and the highest number (4 or 5) equals the least egalitarian
position, how can I make these two results comparable.

Two ways come to mind: one is to collapse both into a dichotomous
variable and do a logistic regression on both. The danger here is that I
have to decide what to do with the middle position in the first
question, assign it to the egalitarian or non-egalitarian category.
A second way would be to multiply the scores in the first question by 4
(to get results that are either 4, 8, 12, 16 or 20) and then multiply
the second question by five to get responses that are either 5, 10, 15
or 20. My idea is then to add the two, average them and use that value
as an index of economic egalitarianism?
Yes / no? Suggestions?
I am an R user and I hope that a purely statistical question is not
especially misplaced.


Hi Simon,
Strictly speaking, only the second question is a Likert scale, as that 
assumes a measure of agreement, not some other quantitative dimension. 
Assuming that the fourth option on Q2 is Strongly disagree, and you 
wish to argue that this and the first option on Q1 (Much more) both 
represent the maximally egalitarian responses, you could reverse Q2
and scale it to the same range (i.e. 1,2,3,4,to 5,3.67,2.33,1) so that 
it would have the same weight in an additive composite score. If I was 
reviewing a paper that suggested this, I would expect a pretty sound 
defense of the notion that income redistribution and public health care 
were strongly linked attitudes.


Jim

__
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] deduplication

2010-06-04 Thread Wu Gong

Please try this

## Import data
id1-c(4,17,9,1,1,1,3,3,6,15,1,1,1,1,3,3,3,3,4,4,4,5,5,12,9,9,10,10)
id2-c(8,18,10,3,6,7,6,7,7,16,4,5,12,18,4,5,12,18,5,12,18,12,18,18,15,16,15,16)
id-data.frame(id1 = id1, id2 = id2)

## Create same structure table
id - id0 - unique(id)
leng - nrow(id)

n - 0
repeat {
if (n == leng) {break}
n - 0
id - id[order(-id$id1, -id$id2),]
for (i in 1:leng) {
if (id$id1[i] == id$id2[i]) { 
n - n+1
next }
smal - min(id[i,])
larg - max(id[i,])
id$id2[which(id$id2 == larg)] - smal
id$id1[which(id$id1 == larg)] - smal
}}

## Create results
tab - table(as.matrix(id0),
as.matrix(id[order(as.numeric(rownames(id))),]))
res - list()
for (i in 1:ncol(tab)) {
res[[i]] - rownames(tab[(tab[,i] != 0),])}
res

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/deduplication-tp2241637p2242921.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] For Loop help needed

2010-06-04 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 03.06.2010 18:18:33:

 One option:
 
 t - data.frame(x1=c(1,1,0,0,0,1), x2=c(0,0,0,1,0,1), 
 Count=c(523,23,2,45,3,433))
 t.sum - function(df, x1, x2) sum(df[df$x1==x1  df$x2==x2,]$Count)
 t.sum(t, 1, 0)
 # [1] 546
 t.sum(t, 0, 0)
 # [1] 5

If this is what Khan wants so

aggregate(t$Count, list(interaction(t$x1, t$x2)), sum)
  Group.1   x
1 0.0   5
2 1.0 546
3 0.1  45
4 1.1 433

could be better option

Regards
Petr


 
 Hope this helps a little.
 
 Allan
 
 On 03/06/10 16:18, Geeti Khan wrote:
  Hi,
  I have a dataset with three column like this
  x1 x2 Count
  1  0  523
  1 0 23
  0 0 2
  0 1  45
  0 0  3
  1 1 433
 
  I need to create a loop so that when c(x1,x2)=c(1,1), I can add the 
 corresponding Counts.When c(x1,x2)=c(1,0), can add the corresponding 
counts 
 and so on. Can anyone help me
 
 
 
 
 [[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-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] moving average on irregular time series

2010-06-04 Thread Gustaf Rydevik
Dear William and Gabor,

Both solutions worked, and my problem is now solved.

Many thanks to both of you!

regards,
Gustaf



 On Thu, Jun 3, 2010 at 10:23 AM, Gustaf Rydevik
 gustaf.ryde...@gmail.com wrote:
 Hi all,


 I wonder if there is any way to calculate a moving average on an
 irregular time series, or use the rollapply function in zoo?
 I have a set of dates where I want to check if there has been an event
 14 days prior to each time point in order to mark these timepoints for
 removal, and can't figure out a good way to do it.

 Many thanks in advance!

 Gustaf


 Example data:

 exData-structure(list(Datebegin = structure(c(14476, 14569, 14576, 14621,
 14627, 14632, 14661, 14671, 14705, 14715, 14751, 14756, 14495,
 14518, 14523, 14526, 14528, 14529, 14545, 14548), class = Date),
    Event = c(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
    FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE,
    TRUE, FALSE, FALSE, FALSE)), .Names = c(Datebegin, Event
 ), row.names = c(NA, 20L), class = data.frame)

 ###In this example, row 18 is a date less than 14 days after an event
 and should be marked for removal.



 --
 Gustaf Rydevik, M.Sci.
 tel: +46(0)703 051 451
 address:Essingetorget 40,112 66 Stockholm, SE
 skype:gustaf_rydevik

 __
 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.





-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

__
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] Handling of par() with variables

2010-06-04 Thread Steffen Uhlig

Hello!

In order to plot multiple graphs with the same setup I use the
following code-structure:

###
# storing old parameter set
oldpar - par(no.readonly=T)

#copying old parameter set
newpar - par(no.readonly=T)

#adjusting parameters
newpar - par(mar=c(3.1,3.1,0.1,0.1),  # margin for figure area
 oma=c(0,0,0,0),  # margin for outer figure area
 cex.axis=0.9,  # font size axis
 mgp=c(2,0.6,0),  # distance of axis
 tck=0.02# major ticks inside
 )

...
...
postscript(...)
par(newpar)
...
dev.off()
###

Calling the variable newpar delivers the old paramter set only (from
code-line newpar - par(no.readonly=T)). If the code-segment newpar
- par(mar=... runs a second time, the correct paramter set is
stored, however, just the 5 parameters adjusted and not the full list.

My question is, why must the code segment newpar-par(mar...) run
twice? Is there a better way to handle the graphics output? I would be
grateful for a pointer on a FAQ-section or to an older discussion
thread in this group!

Thank you very much in advance!

Regards,
/steffen

--
Steffen Uhlig, PhD
Mechatronik und Sensortechnik
HTW des Saarlandes
Goebenstraße 40
66117 Saarbrücken

Tel.: +49 (0) 681 58 67 274

__
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] plot polar coordinates

2010-06-04 Thread Thomas Steiner
Thank you Jim,
I had a liitle off-list conversation with Greg and finally I got the solution.
All the code is now on
http://commons.wikimedia.org/wiki/File:Sonnenstand.png  I got the
workaround with my own (sun)lines function which does the shift from
cartesian coordiantes to polar coordinates. An example result is
attached.
The negative vales where just a stupid try from my side, it does of
course make no sense.
Best,
Thomas



2010/6/4 Jim Lemon j...@bitwrit.com.au:
 On 06/04/2010 05:05 AM, Thomas Steiner wrote:

 Thank you Greg,

 I'll add 180 then.

 Thanks for the hint with longer radial.lim arguments it works woderfull.

 The lines function is plotting in Cartesian coordinates, not the polar
 coordinates.

 Is there any (lines) function that plots polar coordinates to an existing
 plot?

 Hi Thomas,
 Greg has already given you most of the solutions. I was a bit surprised to
 find that if you include the negative values in the radial.lim argument, the
 polygon appears _and_ in the right place! I'll have to add this to the help
 page. Note that your labels may not be where you think they should be, as 0
 degrees is east in your example. Maybe you want start=90?

 I have thought about reprogramming the radial plot functions with an add
 argument, but haven't gotten around to it. I'll have a look and if I can do
 this without too much work, I'll let you know.

 As far as 100 being prettier than 90, my experience is that I ain't gettin'
 any prettier as I get older.

 Jim

attachment: sonnenstad-narvik.png__
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] ps-output and LaTeX/DVIPS/PS2PDF - Greek letters disappear

2010-06-04 Thread Steffen Uhlig

Hello!

My graphs are produced using the postscript-option in R (R version 
2.10.1 (2009-12-14)). When Greek letters are used on the axis, 
everything looks fine in the *.ps-file. If included in a LaTeX-file and 
(on Ubuntu 10.04, fresh install), the Greek letters appear in the DVI- 
and PS-output, however, if converted with ps2pdf they suddenly 
disappear. Could anyone suggest a solution?


Best regards,
/steffen

--
Steffen Uhlig, PhD
Mechatronik und Sensortechnik
HTW des Saarlandes
Goebenstraße 40
66117 Saarbrücken

Tel.: +49 (0) 681 58 67 274

__
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] For Loop help needed

2010-06-04 Thread Allan Engelhardt

On 04/06/10 10:32, Petr PIKAL wrote:

One option:

t- data.frame(x1=c(1,1,0,0,0,1), x2=c(0,0,0,1,0,1),
Count=c(523,23,2,45,3,433))
t.sum- function(df, x1, x2) sum(df[df$x1==x1  df$x2==x2,]$Count)
[...]

If this is what Khan wants so

aggregate(t$Count, list(interaction(t$x1, t$x2)), sum)
   Group.1   x
1 0.0   5
2 1.0 546
3 0.1  45
4 1.1 433

could be better option
   


Indeed it is better!  Or even shorter with the formula interface:

aggregate(Count ~ x1+x2, data=t, sum)
#   x1 x2 Count
# 1  0  0 5
# 2  1  0   546
# 3  0  145
# 4  1  1   433


Allan

__
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] ordinal variables

2010-06-04 Thread Joris Meys
Hi,

If you look around a bit, there is some great material on the web
about the powers and quirks of R. I've taught myself most of what I
know from R through reading a lot and trying it out on the console.
The help list is also a darn fine source of efficient code for a set
of general problems.

It won't help any more this year, but I'm working on a guide for R to
bundle valuable information I got from the help list and the internet.
It should be ready in a couple of months, and it will be available for
all to use. In any case, Owen's guide is of great value for an
introduction to the command line and basic statistics:
http://cran.r-project.org/doc/contrib/Owen-TheRGuide.pdf

Also the introduction to R is a must-read for all our students :
http://cran.r-project.org/doc/manuals/R-intro.pdf

Next to that, a couple of websites are great additional sources of code :
Quick-R, a guide for those who come over from SAS/SPSS/Stata. It
contains tons of examples for statistical analyses in about every
field. If you didn't know it yet, you'll love it for sure :
http://www.statmethods.net/

The R graph gallery, to show what exactly can be done with the
graphical power of R :
http://addictedtor.free.fr/graphiques/

The R Graphics gallery, doing the same :
http://research.stowers-institute.org/efg/R/

There's many more to be found, a whole community of users is
contributing to the information in various ways. We give the sources
mentioned here to our students, with the message that they should
never underestimate the power of Google.

Last but not least, there is a specific mailing list regarding
teaching statistics using R:
https://stat.ethz.ch/mailman/listinfo/r-sig-teaching

You might want to take a look at their archives as well.

Cheers
Joris

On Fri, Jun 4, 2010 at 6:39 AM, Iasonas Lamprianou lampria...@yahoo.com wrote:
 Thanks, I'll have a go and will let you know. I guess that the success has to 
 do with how efficiently I help them to demonstrate the efficiency of code 
 over menues. So part of the issue is how I teach them as well...


 Dr. Iasonas Lamprianou


 Assistant Professor (Educational Research and Evaluation)
 Department of Education Sciences
 European University-Cyprus
 P.O. Box 22006
 1516 Nicosia
 Cyprus
 Tel.: +357-22-713178
 Fax: +357-22-590539


 Honorary Research Fellow
 Department of Education
 The University of Manchester
 Oxford Road, Manchester M13 9PL, UK
 Tel. 0044  161 275 3485
 iasonas.lampria...@manchester.ac.uk


 --- On Thu, 3/6/10, S Ellison s.elli...@lgc.co.uk wrote:

 From: S Ellison s.elli...@lgc.co.uk
 Subject: Re: [R] ordinal variables
 To: Joris Meys jorism...@gmail.com, Iasonas Lamprianou 
 lampria...@yahoo.com
 Cc: r-help@r-project.org
 Date: Thursday, 3 June, 2010, 15:44
 If you set them a problem that has
 them doing the same sort of thing
 five times and compare the time it takes with code pasted
 from an editor
 (eg Tinn-R) and the time it takes via menius, you may have
 more luck
 convincing them.

 A command line sequence is harder than menus the first two
 times but
 easier for any n iterations thereafter.

 Steve ellison

  Iasonas Lamprianou lampria...@yahoo.com
 03/06/2010 14:51 
 Thank you Joris,
 I'll have a look into the commands you sent me. They look
 convincing. I
 hope my students will also see them in a positive way
 (although I can
 force them to pretend that they have a positive attitude)!

 Dr. Iasonas Lamprianou





 Assistant Professor (Educational Research and Evaluation)

 Department of Education Sciences

 European University-Cyprus

 P.O. Box 22006

 1516 Nicosia

 Cyprus

 Tel.: +357-22-713178

 Fax: +357-22-590539





 Honorary Research Fellow

 Department of Education

 The University of Manchester

 Oxford Road, Manchester M13 9PL, UK

 Tel. 0044  161 275 3485

 iasonas.lampria...@manchester.ac.uk


 --- On Thu, 3/6/10, Joris Meys jorism...@gmail.com
 wrote:

 From: Joris Meys jorism...@gmail.com
 Subject: Re: [R] ordinal variables
 To: Iasonas Lamprianou lampria...@yahoo.com
 Cc: r-help@r-project.org

 Date: Thursday, 3 June, 2010, 14:35

 see ?factor and ?as.factor. On ordered factors you can
 technically do a
 spearman without problem, apart from the fact that a
 spearman test by
 definition cannot give exact p-values with ties present.

 x - sample(c(a,b,c,d,e),100,replace=T)

 y - sample(c(a,b,c,d,e),100,replace=T)

 x.ordered -
 factor(x,levels=c(e,b,a,d,c),ordered=T)

 x.ordered
 y.ordered -
 factor(y,levels=c(e,b,a,d,c),ordered=T)
 y.ordered

 cor.test(x.ordered,y.ordered,method=spearman)

 require(pspearman)

 spearman.test(x.ordered,y.ordered)

 R commander has some menu options to deal with factors. R
 commander
 also provides a scripting window. Please do your students a
 favor, and
 show them how to use those commands.


 Cheers
 Joris


 On Thu, Jun 3, 2010 at 2:25 PM, Iasonas Lamprianou
 lampria...@yahoo.com
 wrote:

 Dear colleagues,



 I teach statistics using SPSS. I want to use R instead. I
 hit on one
 problem and I 

Re: [R] General-purpose GPU computing in statistics (using R)

2010-06-04 Thread Prof Brian Ripley

On Thu, 3 Jun 2010, Ravi Varadhan wrote:


Hi All,

I have been reading about general purpose GPU (graphical processing units)
computing for computational statistics.  I know very little about this, but
I read that GPUs currently cannot handle double-precision floating points


Not so for a while, and the latest ones are quite fast at it.


and also that they are not necessarily IEEE compliant.  However, I am not
sure what the practical impact of this limitation is likely to be on
computational statistics problems (e.g. optimization, multivariate analysis,
MCMC, etc.).

What are the main obstacles that are likely to prevent widespread use of
this technology in computational statistics?


Developing highly parallel algorithms that can exploit the 
architectures.  That's not just in statistics, see e.g.


http://www.microway.com/pdfs/TeslaC2050-Fermi-Performance.pdf

(A Tesla C2050 is the latest generation GPU -- shipping within the 
last month.)


Can algorithms be coded in R to take advantage of the GPU 
architecture to speed up computations?  I would appreciate hearing 
from R sages about their views on the usefulness of general purpose 
GPU (graphical processing units) computing for computational 
statistics.  I would also like to hear about views on the future of 
GPGPU - i.e. is it here to stay or is it just a gimmick that will 
quietly disappear into the oblivion.


They need a lot of programming work to use, and the R packages 
currently attempting to use them (cudaBayesreg and gputools) are very 
specialized.  It seems likely that they will remain a niche area, In 
much the same way that enhanced BLAS are -- there are problems for 
which the latter can make a big difference, but they are far from 
universally useful.


We've been here several times before: when I was on UK national 
supercomputing committees in the 1980s and 90s there were several 
similar contenders (SIMD arrays, Inmos Transputers ...) and all faded 
away.


That is not to say that general purpose parallelism is not going to be 
central, as we each get (several) machines with many CPU cores.  But 
that sort of parallelism is likely to be exploited in different ways 
from that of GPUs.






Thanks very much.



Best regards,

Ravi.


--

Ravi Varadhan, Ph.D.

Assistant Professor,

Center on Aging and Health,

Johns Hopkins University School of Medicine

(410)502-2619

rvarad...@jhmi.edu

http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml






[[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

__
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] Handling of par() with variables

2010-06-04 Thread Joris Meys
I think you misunderstand the working of par(). If you set new
parameters, R allows you to store the old parameters simultaneously.

Take a look at :

par(no.readonly=T)
oldpar - par(mar=c(1,1,1,1),tck=0.02)
par(no.readonly=T)
par(oldpar)
par(no.readonly=T)

So your line :
newpar - par(mar=c(3.1,3.1,0.1,0.1),  # margin for figure area
oma=c(0,0,0,0),  # margin for outer figure area
cex.axis=0.9,  # font size axis
mgp=c(2,0.6,0),  # distance of axis
tck=0.02# major ticks inside
)
actually stores the OLD parameters in newpar, and not the new ones. If
you want to set them using a variable, you'll need something like :
newmar - c(3.1,3.1,1.0,1.0) # store the mar values in a variable
oldpar - par(mar=newmar) # set the mar and store the old values
...
par(oldpar) # back to the old parameters

Cheers
Joris
On Fri, Jun 4, 2010 at 11:40 AM, Steffen Uhlig
steffen.uh...@htw-saarland.de wrote:
 Hello!

 In order to plot multiple graphs with the same setup I use the
 following code-structure:

 ###
 # storing old parameter set
 oldpar - par(no.readonly=T)t

 #copying old parameter set
 newpar - par(no.readonly=T)

 #adjusting parameters
 newpar - par(mar=c(3.1,3.1,0.1,0.1),  # margin for figure area
             oma=c(0,0,0,0),          # margin for outer figure area
             cex.axis=0.9,          # font size axis
             mgp=c(2,0.6,0),          # distance of axis
             tck=0.02                # major ticks inside
             )

 ...
 ...
 postscript(...)
 par(newpar)
 ...
 dev.off()
 ###

 Calling the variable newpar delivers the old paramter set only (from
 code-line newpar - par(no.readonly=T)). If the code-segment newpar
 - par(mar=... runs a second time, the correct paramter set is
 stored, however, just the 5 parameters adjusted and not the full list.

 My question is, why must the code segment newpar-par(mar...) run
 twice? Is there a better way to handle the graphics output? I would be
 grateful for a pointer on a FAQ-section or to an older discussion
 thread in this group!

 Thank you very much in advance!

 Regards,
 /steffen

 --
 Steffen Uhlig, PhD
 Mechatronik und Sensortechnik
 HTW des Saarlandes
 Goebenstraße 40
 66117 Saarbrücken

 Tel.: +49 (0) 681 58 67 274

 __
 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.




-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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] save in for loop

2010-06-04 Thread Joris Meys
On a side note:

On Thu, May 20, 2010 at 9:43 AM, Ivan Calandra
ivan.calan...@uni-hamburg.de wrote:
 Thanks to all of you for your answers!

 ...

 Tao, I don't understand why you have backslashes before file and after
 .rda. I guess it's something about regular expression, but I'm still
 very new to it.
 eval(parse(text=paste(save(file, i, , file=\file, i, .rda\),
 sep=)))

Very simple: You need to give a command as a string. In the save
command, you have to put quotation marks around the filename. Now
within the paste function, a simple quotation mark would make R
believe the string to paste ends there, and you don't want that. So
you escape the  by typing \, then R knows you want to add the symbol
 to the string instead of end it.  :

 paste(save(file, i, , file=\file, i, .rda\),sep=)
[1] save(file2, file=\file2.rda\)

 parse(text=paste(save(file, i, , file=\file, i, .rda\),sep=))

expression(save(file2, file=file2.rda))
attr(,srcfile)
text

 paste(save(file, i, , file=file, i, .rda),sep=)
Error: unexpected symbol in paste(save(file, i, , file=file

Hope it's a bit more clear now.
Cheers
Joris
-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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] ps-output and LaTeX/DVIPS/PS2PDF - Greek letters disappear

2010-06-04 Thread Joris Meys
That's a problem of LateX and Ubuntu, not R :

https://bugs.launchpad.net/ubuntu/+source/poppler/+bug/319495

You'll have more luck on an Ubuntu list or forum.

Cheers
Joris

On Fri, Jun 4, 2010 at 11:47 AM, Steffen Uhlig
steffen.uh...@htw-saarland.de wrote:
 Hello!

 My graphs are produced using the postscript-option in R (R version 2.10.1
 (2009-12-14)). When Greek letters are used on the axis, everything looks
 fine in the *.ps-file. If included in a LaTeX-file and (on Ubuntu 10.04,
 fresh install), the Greek letters appear in the DVI- and PS-output, however,
 if converted with ps2pdf they suddenly disappear. Could anyone suggest a
 solution?

 Best regards,
 /steffen

 --
 Steffen Uhlig, PhD
 Mechatronik und Sensortechnik
 HTW des Saarlandes
 Goebenstraße 40
 66117 Saarbrücken

 Tel.: +49 (0) 681 58 67 274

 __
 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.




-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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] moving average on irregular time series

2010-06-04 Thread Gabor Grothendieck
On Thu, Jun 3, 2010 at 8:04 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Replace the non-events with NA and then use na.locf from the zoo
 package to move the last event date up to give lastEvent.
 Then simply select those rows whose lastEvent date is at least 14 days
 ago or if the row itself is an Event:

 library(zoo) # na.locf

 lastEvent - with(exData, na.locf(ifelse(Event, Datebegin, NA), na.rm = 
 FALSE))
 exData[beg = lastEvent + 14 | exData$Event, ]

The last line should have been:

exData[exData$Datebegin = lastEvent + 14 | exData$Event, ]


    Datebegin Event
 1  2009-08-20  TRUE
 2  2009-11-21 FALSE
 3  2009-11-28 FALSE
 4  2010-01-12 FALSE
 5  2010-01-18 FALSE
 6  2010-01-23 FALSE
 7  2010-02-21 FALSE
 8  2010-03-03 FALSE
 9  2010-04-06 FALSE
 10 2010-04-16 FALSE
 11 2010-05-22  TRUE
 12 2010-05-27  TRUE
 13 2009-09-08  TRUE
 14 2009-10-01 FALSE
 15 2009-10-06 FALSE
 16 2009-10-09 FALSE
 17 2009-10-11  TRUE
 19 2009-10-28 FALSE
 20 2009-10-31 FALSE


 On Thu, Jun 3, 2010 at 10:23 AM, Gustaf Rydevik
 gustaf.ryde...@gmail.com wrote:
 Hi all,


 I wonder if there is any way to calculate a moving average on an
 irregular time series, or use the rollapply function in zoo?
 I have a set of dates where I want to check if there has been an event
 14 days prior to each time point in order to mark these timepoints for
 removal, and can't figure out a good way to do it.

 Many thanks in advance!

 Gustaf


 Example data:

 exData-structure(list(Datebegin = structure(c(14476, 14569, 14576, 14621,
 14627, 14632, 14661, 14671, 14705, 14715, 14751, 14756, 14495,
 14518, 14523, 14526, 14528, 14529, 14545, 14548), class = Date),
    Event = c(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
    FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE,
    TRUE, FALSE, FALSE, FALSE)), .Names = c(Datebegin, Event
 ), row.names = c(NA, 20L), class = data.frame)

 ###In this example, row 18 is a date less than 14 days after an event
 and should be marked for removal.



 --
 Gustaf Rydevik, M.Sci.
 tel: +46(0)703 051 451
 address:Essingetorget 40,112 66 Stockholm, SE
 skype:gustaf_rydevik

 __
 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] Tinn-R keyboard problem

2010-06-04 Thread dhidh23061972

I have the same problem. I also installed the older stable version (1.17.2.4,
compatible version with MDI), but with no success. The keyboard worked fine
before. I use Windows XP. Is there any solution?

Many thanks, Carsten
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Tinn-R-keyboard-problem-tp839036p2242964.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] R with Emacs

2010-06-04 Thread dhanush

I want to know how Emacs works with R. can anyone provide me a link or manual
to read? Thank you
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-with-Emacs-tp2243022p2243022.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] R with Emacs

2010-06-04 Thread Joris Meys
Emacs ESS :
http://ess.r-project.org/

Cheers
Joris

On Fri, Jun 4, 2010 at 12:55 PM, dhanush dhana...@gmail.com wrote:

 I want to know how Emacs works with R. can anyone provide me a link or manual
 to read? Thank you
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/R-with-Emacs-tp2243022p2243022.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.




-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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 with Emacs

2010-06-04 Thread Romain Francois


Le 04/06/10 12:55, dhanush a écrit :

I want to know how Emacs works with R. can anyone provide me a link or manual
to read? Thank you


http://lmgtfy.com/?q=R+emacs

The first link is what you want.

Romain

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/c6YnCi : graph gallery collage
|- http://bit.ly/bZ7ltC : inline 0.3.5
`- http://bit.ly/8YUsiC : highlight 0.2-0

__
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] Tinn-R keyboard problem

2010-06-04 Thread Joris Meys
Tinn-R works with SDI. Make sure you have both the settings in R and
the Rprofile.site correct. If the bug persists with the latest version
of Tinn-R, look for help on :

http://sourceforge.net/projects/tinn-r/support

Cheers
Joris

On Fri, Jun 4, 2010 at 11:56 AM, dhidh23061972 carsten.giess...@gmx.net wrote:

 I have the same problem. I also installed the older stable version (1.17.2.4,
 compatible version with MDI), but with no success. The keyboard worked fine
 before. I use Windows XP. Is there any solution?

 Many thanks, Carsten
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Tinn-R-keyboard-problem-tp839036p2242964.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.




-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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] ordinal variables

2010-06-04 Thread Iasonas Lamprianou
This is valuable material, thanks for all the help. I'll need many days to go 
through this information

jason

Dr. Iasonas Lamprianou


Assistant Professor (Educational Research and Evaluation)
Department of Education Sciences
European University-Cyprus
P.O. Box 22006
1516 Nicosia
Cyprus 
Tel.: +357-22-713178
Fax: +357-22-590539


Honorary Research Fellow
Department of Education
The University of Manchester
Oxford Road, Manchester M13 9PL, UK
Tel. 0044  161 275 3485
iasonas.lampria...@manchester.ac.uk


--- On Fri, 4/6/10, Joris Meys jorism...@gmail.com wrote:

 From: Joris Meys jorism...@gmail.com
 Subject: Re: [R] ordinal variables
 To: Iasonas Lamprianou lampria...@yahoo.com
 Cc: r-help@r-project.org
 Date: Friday, 4 June, 2010, 11:24
 Hi,
 
 If you look around a bit, there is some great material on
 the web
 about the powers and quirks of R. I've taught myself most
 of what I
 know from R through reading a lot and trying it out on the
 console.
 The help list is also a darn fine source of efficient code
 for a set
 of general problems.
 
 It won't help any more this year, but I'm working on a
 guide for R to
 bundle valuable information I got from the help list and
 the internet.
 It should be ready in a couple of months, and it will be
 available for
 all to use. In any case, Owen's guide is of great value for
 an
 introduction to the command line and basic statistics:
 http://cran.r-project.org/doc/contrib/Owen-TheRGuide.pdf
 
 Also the introduction to R is a must-read for all our
 students :
 http://cran.r-project.org/doc/manuals/R-intro.pdf
 
 Next to that, a couple of websites are great additional
 sources of code :
 Quick-R, a guide for those who come over from
 SAS/SPSS/Stata. It
 contains tons of examples for statistical analyses in about
 every
 field. If you didn't know it yet, you'll love it for sure
 :
 http://www.statmethods.net/
 
 The R graph gallery, to show what exactly can be done with
 the
 graphical power of R :
 http://addictedtor.free.fr/graphiques/
 
 The R Graphics gallery, doing the same :
 http://research.stowers-institute.org/efg/R/
 
 There's many more to be found, a whole community of users
 is
 contributing to the information in various ways. We give
 the sources
 mentioned here to our students, with the message that they
 should
 never underestimate the power of Google.
 
 Last but not least, there is a specific mailing list
 regarding
 teaching statistics using R:
 https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
 
 You might want to take a look at their archives as well.
 
 Cheers
 Joris
 
 On Fri, Jun 4, 2010 at 6:39 AM, Iasonas Lamprianou lampria...@yahoo.com
 wrote:
  Thanks, I'll have a go and will let you know. I guess
 that the success has to do with how efficiently I help them
 to demonstrate the efficiency of code over menues. So part
 of the issue is how I teach them as well...
 
 
  Dr. Iasonas Lamprianou
 
 
  Assistant Professor (Educational Research and
 Evaluation)
  Department of Education Sciences
  European University-Cyprus
  P.O. Box 22006
  1516 Nicosia
  Cyprus
  Tel.: +357-22-713178
  Fax: +357-22-590539
 
 
  Honorary Research Fellow
  Department of Education
  The University of Manchester
  Oxford Road, Manchester M13 9PL, UK
  Tel. 0044  161 275 3485
  iasonas.lampria...@manchester.ac.uk
 
 
  --- On Thu, 3/6/10, S Ellison s.elli...@lgc.co.uk
 wrote:
 
  From: S Ellison s.elli...@lgc.co.uk
  Subject: Re: [R] ordinal variables
  To: Joris Meys jorism...@gmail.com,
 Iasonas Lamprianou lampria...@yahoo.com
  Cc: r-help@r-project.org
  Date: Thursday, 3 June, 2010, 15:44
  If you set them a problem that has
  them doing the same sort of thing
  five times and compare the time it takes with code
 pasted
  from an editor
  (eg Tinn-R) and the time it takes via menius, you
 may have
  more luck
  convincing them.
 
  A command line sequence is harder than menus the
 first two
  times but
  easier for any n iterations thereafter.
 
  Steve ellison
 
   Iasonas Lamprianou lampria...@yahoo.com
  03/06/2010 14:51 
  Thank you Joris,
  I'll have a look into the commands you sent me.
 They look
  convincing. I
  hope my students will also see them in a positive
 way
  (although I can
  force them to pretend that they have a positive
 attitude)!
 
  Dr. Iasonas Lamprianou
 
 
 
 
 
  Assistant Professor (Educational Research and
 Evaluation)
 
  Department of Education Sciences
 
  European University-Cyprus
 
  P.O. Box 22006
 
  1516 Nicosia
 
  Cyprus
 
  Tel.: +357-22-713178
 
  Fax: +357-22-590539
 
 
 
 
 
  Honorary Research Fellow
 
  Department of Education
 
  The University of Manchester
 
  Oxford Road, Manchester M13 9PL, UK
 
  Tel. 0044  161 275 3485
 
  iasonas.lampria...@manchester.ac.uk
 
 
  --- On Thu, 3/6/10, Joris Meys jorism...@gmail.com
  wrote:
 
  From: Joris Meys jorism...@gmail.com
  Subject: Re: [R] ordinal variables
  To: Iasonas Lamprianou lampria...@yahoo.com
  Cc: r-help@r-project.org
 
  Date: Thursday, 3 June, 2010, 

Re: [R] string handling

2010-06-04 Thread Hadley Wickham
On Thu, Jun 3, 2010 at 4:06 PM, Wu Gong w...@mtmail.mtsu.edu wrote:

 Hope it helps.

 text - var1        var2
 9G/G09    abd89C/T90
 10A/T9    32C/C
 90G/G      A/A

 x - read.table(textConnection(text), header = T)

Or with the stringr package:

library(stringr)
str_match(x$var1, (.)/(.))

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
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] string handling

2010-06-04 Thread Gabor Grothendieck
This solution using strapply in gsubfn is along the same lines as the
stringr solution.  First we read in the data using as.is = TRUE so
that we get character rather than factor columns.  On the other hand,
if your data is already in columns with class factor then just replace
strappy(x, ...) with strapply(as.character(x), ...) below.   Then
lapply over the columns of DF using strapply on each one.See home
page at http://gsubfn.googlecode.com for more.

 Lines - var1var2
+ 9G/G09abd89C/T90
+ 10A/T932C/C
+ 90G/G  A/A

 library(gsubfn)
 DF - read.table(textConnection(Lines), header = TRUE, as.is = TRUE)
 lapply(DF, function(x) strapply(x, (.)/(.), c, simplify = rbind))
$var1
 [,1] [,2]
[1,] G  G
[2,] A  T
[3,] G  G

$var2
 [,1] [,2]
[1,] C  T
[2,] C  C
[3,] A  A


Also a slight simplification is possible using gsubfn's capability of
representing a one line function as a formula.  We just preface lapply
with fn$ and then formulas appearing in the arguments (subject to
certain rules) are interpreted as functions.  Here, the formula in the
second argument to lapply is interpreted as the anonymous function we
used above:

 fn$lapply(DF, x ~ strapply(x, (.)/(.), c, simplify = rbind))
$var1
 [,1] [,2]
[1,] G  G
[2,] A  T
[3,] G  G

$var2
 [,1] [,2]
[1,] C  T
[2,] C  C
[3,] A  A

On Thu, Jun 3, 2010 at 2:18 PM, karena dr.jz...@gmail.com wrote:

 I have a data.frame as the following:
 var1        var2
 9G/G09    abd89C/T90
 10A/T9    32C/C
 90G/G      A/A
 .             .
 .             .
 .             .
 10T/C      00G/G90

 What I want is to get the letters which are on the left and right of '/'.
 for example, for 9G/G09, I only want G, G, and for abd89C/T90, I
 only want C and T, how to get these?

 thank you,

 karena
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/string-handling-tp2242119p2242119.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] multinomial

2010-06-04 Thread azam jaafari
Hi

I carried out multinomial logistic reg. in R by package 'nnet'. 
response variable has 7 level and predictors (4 variable) are classifier and 
continuous. 
I want to present results as figur but I can't. also, I read R example but I 
have cell grid and I can't define data.frame.

please help me

thanks


  
[[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] setMethod does not work in Window 7??

2010-06-04 Thread Uwe Ligges
Wrong R version? Maybe loaded some other plot definition before your 
experiment? Works for me in R-2.11.1.


Uwe Ligges


Am 03.06.2010 23:05, schrieb Fang, Jianwen:

I am developing a S4 class but have had trouble to make setMethod work
in Window 7.  I tested an example found  in the setMethod manual:



require(graphics)


setMethod(plot, signature(x=track, y=missing),


+   function(x,  y, ...) plot(slot(x, x), slot(x, y), ...)

+ )



It gave me:



Error in setMethod(plot, signature(x = track, y = missing),
function(x,  :

   unused argument(s) (function(x, y, ...) plot(slot(x, x), slot(x,
y), ...))



It works perfectly fine in Linux.   Does anybody know why?



Thanks in advance!

JF






[[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-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] Reading newlines with read.table?

2010-06-04 Thread Allan Engelhardt
I have a text file that is UTF-16LE encoded with CRLF line endings and 
'@' as field separators that I want to read in R on a Linux system.  
Which would be fine as


read.table(foo.txt, file.encoding = UTF-16LE, sep = @, ...)

*except* that the data may contain the LF character which R treats as 
end-of-line and then barfs that there are too few elements on that line.


Any suggestions for how to process this one efficiently in R?  There is 
probably a solution using read.table(..., nrows = 1, ...) to get the 
header, split it on '@', build a list with that many character(0) 
elements, and then using scan(..., multi.line=TRUE, ...) . but that 
all sounds very complicated.


Allan.

__
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] package mgcv inconsistency in help files? cyclic P-spline cs not cyclic?

2010-06-04 Thread Joris Meys
Dear all,

I'm a bit stunned by the behaviour of a gam model using cyclic
P-spline smoothers.  I cannot provide the data, as I have about 61.000
observations from a time series.

I use the following model :
testgam - gam(NO~s(x)+s(y,bs=cs)+s(DD,bs=cs)+s(TT),data=Final)

The problem lies with the cyclic smoother I use for seasonal trends.
The variable Final$y is a numerical variable, going from 1 to 366,
representing the day of the year. I have hourly data from 2003 until
2009, so each day is represented 168 times in the dataset (apart from
366, that one only 48). DD is the wind direction, going from 1 to
3600, and is also modeled with the same cyclic smoother. Yet, if I
check the predictions, the smoother for y is far from cyclic.

I checked the help files ?smooth.terms, and found about 10 lines apart :

bs=cs specifies a shrinkage version of cr.

bs=cs gives a cyclic version of a P-spline.

When I use the (bs=cc) option, I get the results as I want them, so
I keep with the cyclic cubic splines for now. Yet, I find the
behaviour of bs=cs puzzling, and I'm wondering whether I missed
something, or if this really is an inconsistency in the package.

I currently run mgcv 1.6-1 on R 2.10.1

A small example showing what I experience. Mind you that here x is in
fact NOT cyclic, whereas in my data I'm sure it has to be :
y - rep(1:20,200)
x - 1:4000
DD - sample(1:360,4000,replace=T)
TT - sample(-10:10,4000,replace=T)
NO - TT^2 + (10-y+2)^2 + 10*sin(DD*2*pi/360) - 0.002*sqrt(x) +rnorm(4000,0,100)

model - gam(NO~s(x)+s(y,bs=cs)+s(DD,bs=cs)+s(TT))
plot(model)

model - gam(NO~s(x)+s(y,bs=cc)+s(DD,bs=cc)+s(TT))
plot(model)


Cheers
Joris

-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

__
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 need help about reverse axes

2010-06-04 Thread Uwe Ligges
scatterplot3d() currently does not supoort it, but you can hack an ugly 
workaround:


If you want to do it only once ot twice:

mirror your z data at mean(range of z axis) and add z.ticklabs manually 
(the reverse numbers)


Example:

x - 1:10
y - 1:10
z - 1:10
s3d - scatterplot3d(x, y, z)
env - environment(s3d[[1]])
zmin - get(z.min, env=env) * get(z.scal, env=env)
zmax - get(z.max, env=env) * get(z.scal, env=env)
zmean - mean(c(zmin, zmax))
znew - 2*zmean - z
scatterplot3d(x, y, znew, z.ticklabs=rev(get(z.prty, env=env)))

Best,
Uwe Ligges











Am 04.06.2010 02:48, schrieb Ali Alsamawi:


Hello

  im trying to plot 3d  with scatterplot packages , everything is work on my program 
below  but my problenm i want to set my pressure level or axis(z-axis) to reverse like 
from bottom to top, i used function rev but not work just for 2d plots the 
figure in attachment and the program shows below, can anyone help me to do this


Thanks
Ali




##load rgl package
library()
library(scatterplot3d)


## open binary file to read
dat- file(/srv/scratch/z3303149/back_Traj/parcel1_1,open=rb)
skip1st1 = seek(dat,where=4)
alldata = readBin(dat,numeric(),n=5040,size=4)
dim(alldata)- c(10,504)

totlen= 504
## replace zeros in lon,lat,pres,wv_cont with missing
for (i in 1:totlen) {
   if (alldata[2,i]==0) alldata[2,i] = NA
   if (alldata[3,i]==0) alldata[3,i] = NA
   if (alldata[4,i]==0) alldata[4,i] = NA
   if (alldata[10,i]==0) alldata[10,i] = NA
}

## total number of non-missing values
len = totlen - sum(is.na(alldata[2,]))



## set the dataset to use for colouring
coldat = alldata[10,1:len]

## creat colour from wv_cont - in hsv
hcol = cumsum(coldat)

hcol = hcol/max(hcol,na.rm=TRUE)
print(hcol)
col- hsv(h=hcol,s=1,v=1)






X- scatterplot3d(alldata[2,1:len],alldata[3,1:len],alldata[4,1:len],
xlab=lon,ylab=lat,zlab=pres,main=The Trajectory of the parcel1_1 
(%),zlim=rev(range(alldata[4,1:len])))

#to show the first point of the trajectory
X$points3d(alldata[2,1],alldata[3,1],alldata[4,1],col =col, type = p, pch = 
15)

X$points3d(alldata[2,1:len],alldata[3,1:len],alldata[4,1:len],col =col, type = 
p, pch = 1)


## create labelbar - need to create an image in order to do so
lbcol = hsv(h=seq(0,1,0.01),s=1,v=1)
tmp1=c(1:len)
tmp3=matrix(coldat,len,1)




par(oma=c( 0,0,0,0),font.axis=1,mar=(c(14.1,4.1,4.1,1.1)),cex=0.8)
image.plot(tmp1,1,tmp3,add=TRUE,legend.only=TRUE,col=lbcol,nlevel=10
,legend.shrink=0.8,legend.width=1)





#png()





Rplot001.png




__
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] package mgcv inconsistency in help files? cyclic P-spline cs not cyclic?

2010-06-04 Thread Gavin Simpson
On Fri, 2010-06-04 at 15:56 +0200, Joris Meys wrote:
 Dear all,
 
 I'm a bit stunned by the behaviour of a gam model using cyclic
 P-spline smoothers.  I cannot provide the data, as I have about 61.000
 observations from a time series.
snip /
 
 I checked the help files ?smooth.terms, and found about 10 lines apart :
 
 bs=cs specifies a shrinkage version of cr.
 
 bs=cs gives a cyclic version of a P-spline.

This is a typo in the help file ?smooth.terms. ?p.spline indicates that
bs = cp is what is needed for a cyclic P spline.

In ?smooth.terms

‘bs=cs’ gives a cyclic version of a P-spline.

should read

‘bs=cp’ gives a cyclic version of a P-spline.

in in the P Spline section.

By specifying bs = cs, you weren't getting a cyclic spline at all, it
is a cubic regression spline with shrinkage (so a smooth can potentially
be penalized out of the model entirely during the fitting).

If cc'd the author  maintainer of mgcv (Simon Wood) so that this
doesn't get overlooked amongst the other R-Help traffic.

HTH

G

 
 When I use the (bs=cc) option, I get the results as I want them, so
 I keep with the cyclic cubic splines for now. Yet, I find the
 behaviour of bs=cs puzzling, and I'm wondering whether I missed
 something, or if this really is an inconsistency in the package.
 
 I currently run mgcv 1.6-1 on R 2.10.1
 
 A small example showing what I experience. Mind you that here x is in
 fact NOT cyclic, whereas in my data I'm sure it has to be :
 y - rep(1:20,200)
 x - 1:4000
 DD - sample(1:360,4000,replace=T)
 TT - sample(-10:10,4000,replace=T)
 NO - TT^2 + (10-y+2)^2 + 10*sin(DD*2*pi/360) - 0.002*sqrt(x) 
 +rnorm(4000,0,100)
 
 model - gam(NO~s(x)+s(y,bs=cs)+s(DD,bs=cs)+s(TT))
 plot(model)
 
 model - gam(NO~s(x)+s(y,bs=cc)+s(DD,bs=cc)+s(TT))
 plot(model)
 
 
 Cheers
 Joris
 

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
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] using the design matrix to correctly configure contrasts

2010-06-04 Thread Karl Brand

Rich, Walmes,

Thank you for enriching my understanding of the concept of 
interaction: succinctly and clearly explained. I feel i can better 
phrase my question, the context being much clearer now.


In my case, i want to see the simple effects of changing levels of time, 
whilst holding Photperiod and Tissue constant. And i wnat to do this for 
each of the (total) 6 levels of Photoperiod and Tissue.


My poor working knowledge of R leaves me stuck, for now, with the 
default treatment constrasts i get when using the function model.matrix. 
In fact thats been fine, once i decoded the interpretation of the 
colnames of the model.matrix using available examples, at least for 
analyses no more complex than 2-way interactions.


Now im faced with 3 factors, and a model.matrix where i am unble to see 
the constrasts im interested in explictly stated. Does this mean they 
are not possible, ie., i lack enough observations for the contrasts i 
want? If so then i'm still missing some basic concepts of ANOVA.


#I have three photoperiod treatments:

Pperiod - factor(targets$Pperiod, levels = c(E, L, S))

#Two different tissues were sampled from each* subject:

Tissue - factor(targets$Tissue, levels = c(R, C))

#*Such samples are said to be 'paired', no? Not sure how to deal with
#this, how necessary dealing with it is, or how possible...

#And where 16 unique subjects were sampled (for tissues R asnd C
# at 16 different times giving the #third factor:

Time - factor(targets$Time,
   levels = c(1, 2, 3, 4, 5, 6, 7, 8,
  9,10,11,12,13,14,15, 16))

My primary question is- what changes occur across all times for each 
p.period and tissue combination., ie., ER, LR, SR, EC, LC  SC?


Contrast wise, this appears straight forward to me for ER, LR, SR 
 EC which are explicit in the model.matrix i get from R (shown again 
below). That is, *assuming* my interpretation of the contrast is correct 
which is what my original post focused on.


But, its just not obvious to me how LC and SC (for all times) 
contrasts can be specified.


This is my practical problem i'm yet to overcome. And using the package 
contrast hasn't helped me overcome this so far (thank you no less Walmes).


Further thoughts and advice gratefully received,

Karl

 colnames(design)
 [1] (Intercept)  Time2
 [3] Time3Time4
 [5] Time5Time6
 [7] Time7Time8
 [9] Time9Time10
[11] Time11   Time12
[13] Time13   Time14
[15] Time15   Time16
[17] TissueC  PperiodL
[19] PperiodS Time2:TissueC
[21] Time3:TissueCTime4:TissueC
[23] Time5:TissueCTime6:TissueC
[25] Time7:TissueCTime8:TissueC
[27] Time9:TissueCTime10:TissueC
[29] Time11:TissueC   Time12:TissueC
[31] Time13:TissueC   Time14:TissueC
[33] Time15:TissueC   Time16:TissueC
[35] Time2:PperiodL   Time3:PperiodL
[37] Time4:PperiodL   Time5:PperiodL
[39] Time6:PperiodL   Time7:PperiodL
[41] Time8:PperiodL   Time9:PperiodL
[43] Time10:PperiodL  Time11:PperiodL
[45] Time12:PperiodL  Time13:PperiodL
[47] Time14:PperiodL  Time15:PperiodL
[49] Time16:PperiodL  Time2:PperiodS
[51] Time3:PperiodS   Time4:PperiodS
[53] Time5:PperiodS   Time6:PperiodS
[55] Time7:PperiodS   Time8:PperiodS
[57] Time9:PperiodS   Time10:PperiodS
[59] Time11:PperiodS  Time12:PperiodS
[61] Time13:PperiodS  Time14:PperiodS
[63] Time15:PperiodS  Time16:PperiodS
[65] TissueC:PperiodL TissueC:PperiodS




On 6/2/2010 8:26 PM, RICHARD M. HEIBERGER wrote:

Karl,

The definition and interpretation of contrasts is part of any
intermediate design of
experiments text.
Contrasts for interactions say that the effect of moving
from level 1 of A to level 2 of A depends on the level of B.
I will use notation YAB to indicate the levels of A and B.
For example, if
(Y11 - Y21) differs from (Y12 - Y22)
we say that A and B have an interaction.  When A and B interact, then
the interpretation of main effects is ambiguous at best.  Instead,
we use the concept of simple effects, which, for example, are the
effects of changing levels of A while holding the levels of B
constant.
Interpreting the interactions themselves depends on knowing something
about the structure of the design, for example whether the effects (A
and B, here) are treatments, blocks, nested effects, or repeated
measures.
Simple effects are usually interpretable.  Interactions are tougher.
Rich
https://mail.google.com/a/temple.edu/?AuthEventSource=SSO#inbox


--
Karl Brand k.br...@erasmusmc.nl
Department of Genetics
Erasmus MC
Dr Molewaterplein 50
3015 GE Rotterdam
P +31 (0)10 704 3409 | F +31 (0)10 704 4743 | M +31 (0)642 777 268

__
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] Build Design Matrix with avoiding loops

2010-06-04 Thread Gildas Mazo
Dear R users,

I'd like to build a simple design matrix in a efficient way. I naively
wrote the code below.


n = 15
k = 3
nbPerGrp = c(5,5,5)
xT - list()
   
for (i in 1:k){
  xT[[i]] - rep(0, k)
  xT[[i]][i] - 1
}

X - matrix(nrow = n, ncol = k) #design matrix

for (i in 1:nbPerGrp[1]){
  X[i,] - xT[[1]]
}
   
for (i in 1:k-1){
  for (j in nbPerGrp[i]+1:nbPerGrp[i+1]){
X[j,] - xT[[i]]
  }}

for (i in 1:nbPerGrp[k]){
  X[n - nbPerGrp[k] + i, ] - xT[[k]]
}

X # That's I wanna get.


But as soon as n, k increase it takes too much time because of the loops.
Then my question is how can I get such a design matrix X without too
much loops ? Which function I should look at ?

Thanks in advance for responding me,


Gildas

__
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] Build Design Matrix with avoiding loops

2010-06-04 Thread Martyn Byng
Hi,

Something like

x = as.factor(rep(1:k,rep(n/k,k))
X = model.matrix(~x-1)

Might be what you are looking for

Martyn

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Gildas Mazo
Sent: 04 June 2010 16:19
To: r-help@r-project.org
Subject: [R] Build Design Matrix with avoiding loops

Dear R users,

I'd like to build a simple design matrix in a efficient way. I naively
wrote the code below.


n = 15
k = 3
nbPerGrp = c(5,5,5)
xT - list()
   
for (i in 1:k){
  xT[[i]] - rep(0, k)
  xT[[i]][i] - 1
}

X - matrix(nrow = n, ncol = k) #design matrix

for (i in 1:nbPerGrp[1]){
  X[i,] - xT[[1]]
}
   
for (i in 1:k-1){
  for (j in nbPerGrp[i]+1:nbPerGrp[i+1]){
X[j,] - xT[[i]]
  }}

for (i in 1:nbPerGrp[k]){
  X[n - nbPerGrp[k] + i, ] - xT[[k]]
}

X # That's I wanna get.


But as soon as n, k increase it takes too much time because of the
loops.
Then my question is how can I get such a design matrix X without too
much loops ? Which function I should look at ?

Thanks in advance for responding me,


Gildas

__
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 e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}

__
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 plotting on linux, regardless of architecture of local machine

2010-06-04 Thread vaneet

Hello,

I just installed R 2.11.0 on a 64 bit Linux machine:

Red Hat Enterprise Linux Server release 5.5 (Tikanga)

I am still in the learning process in terms of handling Unix and have used R
on both windows and Unix before.  I am wondering when running R in this
linux machine is there a way to be able to see plots pop up right on the
screen after using the plot() function instead of saving it directly to a
picture to view it later.  I am connecting to the linux machine remotely
through my Windows machine through Putty, I also have Cygwin installed as
well.  I realize this question may have been examined before in this forum
and others and it seems a very common solution proposed depends on what
machine you're accessing linux from remotely and if it's Windows you can
install a X windows system to manage this which I know can be done through
Cygwin.  

However I anticipate R on this linux machine to be used by several different
users and it seems like it would be too difficult to anticipate what the
architecture of all their local machines are as well as expect them to each
install their own X windows manager as this is never present by default.  So
what I am wondering is there an easy way to install a package or configure
something on the Linux machine so that when any user logs in and starts up R
they can execute the plot() function and a plot window will pop up without
having to execute any additional commands preferably?  Also if there is a
way I would be curious to know how to save the plots through that method as
well unless it is still thru the usual functions (png, jpeg...)

Appreciate the help!

-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-plotting-on-linux-regardless-of-architecture-of-local-machine-tp2243391p2243391.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] Build Design Matrix with avoiding loops

2010-06-04 Thread Erik Iverson

help.search(design matrix) will lead you to ?model.matrix ...

Gildas Mazo wrote:

Dear R users,

I'd like to build a simple design matrix in a efficient way. I naively
wrote the code below.


n = 15
k = 3
nbPerGrp = c(5,5,5)
xT - list()
   
for (i in 1:k){

  xT[[i]] - rep(0, k)
  xT[[i]][i] - 1
}

X - matrix(nrow = n, ncol = k) #design matrix

for (i in 1:nbPerGrp[1]){
  X[i,] - xT[[1]]
}
   
for (i in 1:k-1){

  for (j in nbPerGrp[i]+1:nbPerGrp[i+1]){
X[j,] - xT[[i]]
  }}

for (i in 1:nbPerGrp[k]){
  X[n - nbPerGrp[k] + i, ] - xT[[k]]
}

X # That's I wanna get.


But as soon as n, k increase it takes too much time because of the loops.
Then my question is how can I get such a design matrix X without too
much loops ? Which function I should look at ?

Thanks in advance for responding me,


Gildas

__
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] reformat time from hhmm

2010-06-04 Thread Peter Moore
Thanks much for the advice.  These solutions have worked great!
-Pete

On Thu, Jun 3, 2010 at 8:10 PM, William Dunlap wdun...@tibco.com wrote:

  -Original Message-
  From: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Moore
  Sent: Thursday, June 03, 2010 2:22 PM
  To: r-help@r-project.org
  Subject: [R] reformat time from hhmm
 
  Hi,
  I'm newish to R, a recent convert from Matlab... So far I'm
  impressed, and
  determined to solve the following problem, which seems like
  it should be
  easy:
  I have a long (millions of points) data series recorded with
  a datalogger
  that produced a timestamp in 4 columns: Year, Day of Year,
  Time in (H)HMM
  and Seconds.  I would like to have R interpret these columns as a time
  object and have made some progress (e.g., using paste() to
  create a single
  column and then strptime() to interpret -- is that too
  roundabout??), but
  one thing is throwing me off and I can't seem to conquer it.  The
  hour-minute column in the raw data has no colon, so noon
  looks like 1200.
  Morning times have only 3 characters and afternoon times have
  4.  I've been
  playing around with a fake set of times:
 times - c(110, 230, 459, 1001, 1238, 1922)
 
  When I use
 strptime(data, %k%M

 You must have done this with 'times', not 'data'.
 strptime's first argument should be character data,
 not numeric and the default conversion of numeric
 to character changes 110-110, not 0110.  I like
 to use sprintf() (with its C syntax) to control the
 conversion:

  strptime(sprintf(%04d, times), %k%M)
 [1] 2010-06-03 01:10:00 2010-06-03 02:30:00 2010-06-03 04:59:00
 2010-06-03 10:01:00 2010-06-03 12:38:00
 [6] 2010-06-03 19:22:00

 You could put the year-month-day part into the sprintf's
 format argument as well if you don't want it to use today's
 date for that.

 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com


  the last three are interpreted fine but the first three are messed up
  because, for some reason, (even though I use %k for hour
  format?) the first
  two characters are assumed to be hour and the remaining one
  is minutes.  For
  times[3] I get NA because R doesn't know what to do with 45 hours...
 [1] 2010-06-03 11:00:00 2010-06-03 23:00:00 NA
 [4] 2010-06-03 10:01:00 2010-06-03 12:38:00
  2010-06-03 19:22:00
 
  Fair enough, so I tried a different angle, using an if...else
  statement:
 hours - if(nchar(times)3) strtrim(times,2) else strtrim(times,1)
 
  This worked great when times was only a vector of length=1,
  but when I try
  to apply it to something larger, I get the following warning:
 Warning message:
   In  if(nchar(times)3) strtrim(times,2) else strtrim(times,1)  :
   the condition has length  1 and only the first element
  will be used
  and the output hours are only the first character.  Not
  entirely sure if I
  understand this.
 
  Any advice on how to do this?  Are there packages or commands
  that I'm not
  aware of that know how to deal with (h)hmm times?
 
  Thanks much,
  -Pete
  -
  platform   i486-pc-linux-gnu
  arch   i486
  os linux-gnu
  system i486, linux-gnu
  status
  major  2
  minor  10.1
  year   2009
  month  12
  day14
  svn rev50720
  language   R
  version.string R version 2.10.1 (2009-12-14)
 
  --
  Pete Moore
  Postdoctoral Research Associate
  Dept. Geological  Atmospheric Sciences
  Iowa State University
 
[[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.
 




-- 
Peter L. Moore
Postdoctoral Research Associate
Dept. Geological  Atmospheric Sciences
Iowa State University
Ames, IA
515-294-7201

[[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] using string as variable name in model

2010-06-04 Thread Thomas Lumley



I think you're looking for the update() function.

   -thomas

On Thu, 3 Jun 2010, Roni Kobrosly wrote:


Hi,

I made a small table of strings that will serve as variable names for lm models 
I will run. The table looks like this:


varnames

  numname
11  zCANTAB_log_IED_totaltrials
22   zCANTAB_log_IED_preED
33zCANTAB_logPALerrors
44   zCANTAB_PALstages
55  zCANTAB_logRTI
66   zCANTAB_RVP_Totalmisses
77  zCANTAB_log_RVP_falsealarm
88   zCANTAB_DMS_12000
99 zCANTAB_PRM_Percent
10  10 zCANTAB_SRM_Percent
11  11 zCANTAB_sqrt_SWM_within
12  12  zCANTAB_sqrt_SWM_Total
13  13  zSS_WJ_PC
14  14 zSS_WJ_CALC
15  15   zSS_WJ_LW
16  16   zSS_WJ_AP
17  17   zSS_WJ_MF


What I'm trying to do is


varnames[1,2] - outcome

lm(outcome ~ income + covariate1 + coviarate2, data=my.data) - model

I get the following error message:
Error in model.frame.default(formula = outcome ~ Hollings_Enroll + Child_sex + 
 :
 variable lengths differ (found for 'Hollings_Enroll')

But when I run the model:
lm(zCANTAB_log_IED_totaltrials ~ income + covariate1 + coviarate2, data=my.data) 
- model

it works fine. Eventually, once I resolve this, I'd like to make a custom R 
function to automatically generate 17 regression models with these 17 outcome 
variable strings. Do you have any ideas how to resolve this error?

Thanks!
-Roni

__
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.



Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

__
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 Newbie, please help!

2010-06-04 Thread Dennis Murphy
Hi:

The key phrase in your mail was 'data.table'. Given the size of the object,
it is very likely to be a data.table, which (oddly enough) comes from
package
data.table. It is designed to quickly process information in very large
datasets. 3M rows is an 'average' sized data.table :)

Your request isn't very sophisticated - it appears this function should
work groupwise (group = ID):

dret - function(x) c(100.00, 100 * x[-1]/x[-length(x)])

This function can be processed in data.table or ddply (package plyr)
groupwise without much difficulty. I'm going to assume that the data are
ordered in time for simplicity. I'm also using 100 for the first entry in
the
function - if you want, you can change the initial 100.00 to NA.

Let's generate a little fake data:
id - as.character(rep(c(427225, 290157, 394025, 382940), each = 1000))
times - rep(seq(as.Date('2001-11-13'), by = 'days', length = 1000), 4)
totret - c(rnorm(1000, 20, 0.1), rnorm(1000, 25, 0.1), rnorm(1000, 30,
0.1),
 rnorm(1000, 35, 0.1))

# data frame:
DF - data.frame(id = id, times = times, totret = totret)

# data table:
library(data.table)
DR - data.table(DF)

# data.table sets up id as the table's primary key - note that the storage
mode
# of the key has to be integer.
tables()   # see what we've got

# set id as the table key, do the calculation by group and tack the result
onto DR
system.time({ setkey(DR, id); DR2 - DR[, dret(totret), by = id];
  DR$return - DR2$V1 })
   user  system elapsed
  0   0   0

library(plyr)
system.time(df2 - ddply(DF, .(id), transform, return = dret(totret)))
   user  system elapsed
   0.030.000.05

The difference between the two is this. The data.table calculation returns a
data.table DR2 with the key and the returns, after which we add the column
of returns to the original data table DR. In contrast, the ddply calculation
tacks
on the column of returns to the original data frame as a result of
transform.
Notice that in the data.table code, we set the table key (which is often the
most time consuming task, since it orders the data by the values in its
key),
did the calculation and tacked the result onto the original table almost
instantaneously.

According to the data.table package author, the time savings in using
data.table scales upward as the size of the table increases - in other
words,
the bigger the table, the faster data.table will be relative to other
processing
methods currently available in R. You can see that there is a noticeable
time
difference at n = 4000, so the difference at n = 3M will be more dramatic.
Development work in plyr is showing that the gap between it and data.table
is narrowing, but both packages are in active development, so R users can
look forward to two very powerful packages for summarizing, transforming
and condensing data.

I would suggest that you read the vignette and FAQ from data.table
(available
from the on-line data.table help page) and the documentation of plyr
at its author's web site:
http://had.co.nz/plyr/
There is a tutorial with slides and a full-scale document.

HTH,
Dennis


On Thu, Jun 3, 2010 at 8:04 PM, Jeff08 jefferyd...@gmail.com wrote:


 Hello Everyone,

 I just started a new job  it requires heavy use of R to analyze datasets.

 I have a data.table that looks like this. It is sorted by ID  Date, there
 are about 150 different IDs  the dataset spans 3 million rows. The main
 columns of concern are ID, date, and totret. What I need to do is to derive
 daily returns for each ID from totret, which is simply totret at time t+1
 divided by totret at time t.

  X   id ticker  date_ adjClosetotret RankStk
 427225   427225 00174410AHS 2001-11-1321.66 100.01235
 441910   441910 00174410AHS 2001-11-1421.60  99.723001235
 458458   458458 00174410AHS 2001-11-1521.65  99.953801235
 284003   284003 00174410AHS 2001-11-1621.59  99.676801235

 Two problems for me:

 1)I can't just apply it to the entire column since there will be problems
 at
 the boundary points where the ID changes from 1 to another. I need to find
 out how to specify a restriction on the name of the ID

 2) From Java, instinctively I would use a loop to calculate daily returns,
 but I found out that R is very slow with loops, so I need to find an
 efficient way to calculate  daily returns with such a huge dataset.

 Thanks a lot!


 --
 View this message in context:
 http://r.789695.n4.nabble.com/R-Newbie-please-help-tp2242633p2242633.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.


[[alternative HTML version deleted]]

__

Re: [R] R plotting on linux, regardless of architecture of local machine

2010-06-04 Thread Marius 't Hart

Hi,

If one wants to see an X GUI from a remote application, there's no other 
way than to run an X server locally (the easiest way to do that on 
Windows is with Xming IMHO).


So if you don't want an X server locally, you should not use an X GUI. R 
can of course also be installed on Windows, including Windows servers, 
which may be accessible through Remote Desktop on your network (even 
from Linux machines).


You could also try using Rweb (http://www.math.montana.edu/Rweb/) though 
that will require running R on a web server of course. And I guess you'd 
get some sort of bitmap images, maybe svg.


In my opinion a local X server is the easiest solution, but there are 
other options.


Good luck,

Marius.

On 06/04/2010 05:31 PM, vaneet wrote:

Hello,

I just installed R 2.11.0 on a 64 bit Linux machine:

Red Hat Enterprise Linux Server release 5.5 (Tikanga)

I am still in the learning process in terms of handling Unix and have used R
on both windows and Unix before.  I am wondering when running R in this
linux machine is there a way to be able to see plots pop up right on the
screen after using the plot() function instead of saving it directly to a
picture to view it later.  I am connecting to the linux machine remotely
through my Windows machine through Putty, I also have Cygwin installed as
well.  I realize this question may have been examined before in this forum
and others and it seems a very common solution proposed depends on what
machine you're accessing linux from remotely and if it's Windows you can
install a X windows system to manage this which I know can be done through
Cygwin.

However I anticipate R on this linux machine to be used by several different
users and it seems like it would be too difficult to anticipate what the
architecture of all their local machines are as well as expect them to each
install their own X windows manager as this is never present by default.  So
what I am wondering is there an easy way to install a package or configure
something on the Linux machine so that when any user logs in and starts up R
they can execute the plot() function and a plot window will pop up without
having to execute any additional commands preferably?  Also if there is a
way I would be curious to know how to save the plots through that method as
well unless it is still thru the usual functions (png, jpeg...)

Appreciate the help!




__
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] Reading newlines with read.table?

2010-06-04 Thread Allan Engelhardt
I ended up pre-processing the files outside of R using a script along 
the lines of


#!/bin/bash
for f in *_table_extract_*.txt; do
echo -n Processing $f...
o=${f}.xz
iconv -f UTF-16LE -t UTF-8 $f | \
tail -c +4 | \
perl -l012 -015 -pe 's/\n//g' | \
perl -ne 'print if (!m{\A \( \d+ \s row\(s\) \s affected \) \s* 
\z}ixms  !m{\A \s* \z}xms)' | \

xz -7  $o
echo done.
done

Ugly, but it worked for me.  You can change the first perl regular 
expression to do different things with line terminating \n versus 
in-field \n characters but I just dropped them all.  The tail command 
drops the byte-order-mark (which we do not need for utf-8) and the 
second perl command drops blanks and a stupid SQL tool output.


Thanks to Prof. Brian Ripley who, essentially, pointed out that with 
embedded linefeed characters my file was a binary file and not really a 
text file.  Her Majesty's government respectfully begs to disagree [1] 
but that's the R definition so we'll use it on this list.


Allan

[1] Original data sets described at 
http://www.hm-treasury.gov.uk/psr_coins_data.htm and downloaded from 
http://data.gov.uk/dataset/coins (hint: you'll need p7zip to unpack them 
on a Linux box).



On 04/06/10 14:49, Allan Engelhardt wrote:
I have a text file that is UTF-16LE encoded with CRLF line endings and 
'@' as field separators that I want to read in R on a Linux system.  
Which would be fine as


read.table(foo.txt, file.encoding = UTF-16LE, sep = @, ...)

*except* that the data may contain the LF character which R treats as 
end-of-line and then barfs that there are too few elements on that line.


Any suggestions for how to process this one efficiently in R?  [...]


__
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] horizontal and vertical line with arrow in a plot

2010-06-04 Thread John Kane
# A very quick example of how to draw an arrow on a graph.
plot(1:10)
text(2,5, Point 5 , cex=.8)
arrows(3,5, 4.5, 5)


--- On Thu, 6/3/10, Roslina Zakaria zrosl...@yahoo.com wrote:

 From: Roslina Zakaria zrosl...@yahoo.com
 Subject: [R] horizontal and vertical line with arrow in a plot
 To: r-help@r-project.org
 Received: Thursday, June 3, 2010, 11:34 PM
 Hi r-users,
 
 I would like to add a plot of vertical line segment with
 arrow from (77,.6) to (77,0) and also a horizontal  line
 segment with arrow from (0,0.6) to (77,.6) .  So far this
 is what I have:
 
 plot(sq, cdf, type=l, lwd=4,col=blue,xaxs=i,yaxs=i,
 xlab= Rainfall (mm), ylab= Random no.,
 main=Random number  and rainfall totals (mm))
 abline(v=77,h=0.6,col=2,lwd=2,lty=3)
 text(120,0.63, r = 0.6)
 text(120,0.05, x = 70)
 
 I also tried to use the 'diagram' and 'shape' package but
 not really sure how to use them.
 
 Thank you for all the help given.
 
 
       
     [[alternative HTML version deleted]]
 
 
 -Inline Attachment Follows-
 
 __
 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] Wrong symbol rendering in plots (Ubuntu)

2010-06-04 Thread Eduardo J. Chica
Hi I am having problems with the rendering of scientific symbols (mu and 
degree) in my plots. Whenever I use these symbols they are rendered 
changed (mu is changed to the proportionality symbol and degree is 
changed to something resembling a gamma) in the X-device. If I make a 
pdf of the plot and open the file in Evince or Okular symbols are also 
rendered wrong, however if I open the file with Xpdf or Acroread they 
are rendered correctly.


I did not have this problem before, it arose after I upgraded both R and 
my system (Ubuntu karmic koala to lucid lynx), so I can not tell for 
sure if the problem is R-related or Ubuntu related (I have posted in a 
Ubuntu forum also http://ubuntuforums.org/showthread.php?t=1325289).


Please let me know if you have any idea of how to fix this, or if you 
can confirm this is not an R-related issue.


Thank you very much in advance,

Eduardo J. Chica
Graduate student
UF/IFAS-CREC

__
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 with iteration using while loop

2010-06-04 Thread Subodh Acharya
Hello everyone,

I am trying to use while loop to iterate a function until convergence. But I
am having problem when I try to use a fixed number of iterations.
Say I want to use maximum iteration of 150. If the value don't converge
within maximum iteration, show warning of no convergence.

Currently I don't have non- convergence problem so I think my code works
fine. But in future I may encounter such problem that are likely to not
converge easily.

Below is my function that is working when I don't provide maximum iteration.

iter- function (Fpi, Time, tolerance){
S = 22.4
Ts = 0.499
Ti = 0.25
K = 0.044
r- 1.5
M = Ts- Ti
Ks = 0.044
 Fpt = K*Time + M*S*log(1+ Fpi/(M*S))
   while((Fpt-Fpi)  tolerance) {
 Fpi = Fpt
 Fpt = K*Time + M*S*log(1+ Fpi/(M*S))
 Fp0 = Fpt
}
 return(Fpt)
}
x- iter(Fpi = 0.224, Time = 0.2, tolerance = 0.01)

But I want do something like this ( conceptually)
for( i in 2:itermax) {
  Fpt[i] = K*Time + M*S*log(1+ Fpi/(M*S))
if((Fpt[i]- Fpt[i-1])= tolerance) break
print(Fpt[i]
}
something like this.

any kind of help is highly appreciated.
thank you





-- 
Acharya, Subodh

[[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] Shapes in barplots

2010-06-04 Thread Greg Snow
The TeachingDemos package does not in any way replace the rgl package.  They 
serve very different purposes (the TeachingDemos package does use rgl for a 
couple of functions).

I would be very surprised if there was anything in the TeachingDemos package 
that would be of help in creating barplots with 3d effects.  3d effects distort 
the information in graphs without adding anything to their interpretation.  

If you want to display information, then use the appropriate graph without the 
extra chartjunk.  If you want something to catch the reader's attention, use a 
picture of a kitten.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of khush 
 Sent: Friday, June 04, 2010 1:45 AM
 To: r-help@r-project.org
 Subject: [R] Shapes in barplots
 
 Hi,
 
 I am making barplots . I am using the default shape of barplots with a
 pipe
 but I wants to build bars in various 3d shapes. I have install rgl
 using
 install.packages('rgl') for this purpose, but when I am doing
 library(rgl),
 it shows
 
 Error in library(rgl) : there is no package called 'rgl'
 
 What are the other ways to build such plots of variuos shapes.
 
 Is that *TeachingDemos *replace it..I am not sure how to use it for
 such
 task.
 
 Thanks in advance
 Jeet
 
   [[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-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 do I 'merge' a altered subset of a data.frame back into the same data.frame

2010-06-04 Thread dominik beck
Hi

Step 1: I create a data.frame called iolm.
Step 2: I create a conditional subset i_wtr.
Step 3: In this subset I add 0.3 to all values in the IOLM_AST column.
Step 4: Now I am looking for the best way to Œmerge¹ the altered subset back
into the original iolm data.frame

## STEP 1
iolm
 ID IOLM_AST IOLM_AXIS
1 1 1.15165.33
2 2 1.20 79.00
3 3 0.40 51.66
4 4 0.50 57.00
5 5 1.77  7.70
6 6 0.28 99.70
7 7 0.48160.00
8 8 0.74 84.00
9 9 1.63 87.00
10   10 0.43150.70


## STEP 2

 i_wtr-subset(iolm,IOLM_AXIS  60  IOLM_AXIS  120)
 i_wtr
 ID IOLM_AST IOLM_AXIS
2 2 1.20  79.0
6 6 0.28  99.7
8 8 0.74  84.0
9 9 1.63  87.0
16   16 0.93  94.0
20   20 1.37  91.0
21   21 1.19  63.0
...

## STEP 3

i_wtr$IOLM_AST - i_wtr$IOLM_AST + 0.3
 i_wtr
 ID IOLM_AST IOLM_AXIS
2 2 1.50  79.0
6 6 0.58  99.7
8 8 1.04  84.0
9 9 1.93  87.0
16   16 1.23  94.0
20   20 1.67  91.0
21   21 1.49  63.0
...

## STEP 4 ­ result (not what I wish to get)

newiolm-merge(i_wtr, iolm, by.x=ID, by.y=ID, all = T)
 newiolm
 ID IOLM_AST.x IOLM_AXIS.x IOLM_AST.y IOLM_AXIS.y
1 1 NA  NA   1.15  165.33
2 2   1.5079.0   1.20   79.00
3 3 NA  NA   0.40   51.66
4 4 NA  NA   0.50   57.00
5 5 NA  NA   1.777.70
6 6   0.5899.7   0.28   99.70
7 7 NA  NA   0.48  160.00
8 8   1.0484.0   0.74   84.00
9 9   1.9387.0   1.63   87.00
10   10 NA  NA   0.43  150.70
...


## The result I am looking to get:

 ID   IOLM_AST   IOLM_AXIS
1 1   1.15  165.33
2 2   1.50   79.00
3 3   0.40   51.66
4 4   0.50   57.00
5 5   1.77   7.70
6 6   0.58   99.70
7 7   0.48   160.00
8 8   1.04   84.00
9 9   1.93   87.00
10   10   0.43   150.70
...

What is the correct way to do this?
Thanks a lot for your help.
Dominik

[[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-Package FDTH

2010-06-04 Thread Enio Jelihovschi
We whish to announce the new package
FDTH  -  Frequency Distribution Table and Associated Histogram

The package contains a high level main function which easily allows the user
  to make a frequency distribution table and its associated histogram. The
  results of the table can be formatted in many ways which may be suited to
  publication in many different ways as for example papers or books. The
plot
  of the method is the histogram and poligons which can be dealt with the
easiness and
  flexibility of a high level function.

José Claudio Faria Enio
Jelihovschi

Professor titular   Professor Adjunto
DCET - Estatística  DCET - Estatística
UESC   UESC

[[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] Help with iteration using while loop

2010-06-04 Thread Steve Lianoglou
Code inline:

On Fri, Jun 4, 2010 at 1:30 PM, Subodh Acharya shoeb...@gmail.com wrote:
 Hello everyone,

 I am trying to use while loop to iterate a function until convergence. But I
 am having problem when I try to use a fixed number of iterations.
 Say I want to use maximum iteration of 150. If the value don't converge
 within maximum iteration, show warning of no convergence.

 Currently I don't have non- convergence problem so I think my code works
 fine. But in future I may encounter such problem that are likely to not
 converge easily.

 Below is my function that is working when I don't provide maximum iteration.

 iter- function (Fpi, Time, tolerance){
 S = 22.4
 Ts = 0.499
 Ti = 0.25
 K = 0.044
 r- 1.5
 M = Ts- Ti
 Ks = 0.044
     Fpt = K*Time + M*S*log(1+ Fpi/(M*S))
       while((Fpt-Fpi)  tolerance) {
         Fpi = Fpt
             Fpt = K*Time + M*S*log(1+ Fpi/(M*S))
     Fp0 = Fpt
    }
  return(Fpt)
 }
 x- iter(Fpi = 0.224, Time = 0.2, tolerance = 0.01)

Add a counter variable and a second check in your `while` criteria:

...
...
iter - 0
while (((Fpt - Fpi)  tolerance)  (iter  itermax)) {
  Fpi = Fpt
  Fpt = K*Time + M*S*log(1+ Fpi/(M*S))
  Fp0 = Fpt
  iter - iter + 1
}

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
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 do I 'merge' a altered subset of a data.frame back into the same data.frame

2010-06-04 Thread Marc Schwartz
On Jun 4, 2010, at 1:09 PM, dominik beck wrote:

 Hi
 
 Step 1: I create a data.frame called iolm.
 Step 2: I create a conditional subset i_wtr.
 Step 3: In this subset I add 0.3 to all values in the IOLM_AST column.
 Step 4: Now I am looking for the best way to ‘merge’ the altered subset back
 into the original iolm data.frame
 
 ## STEP 1
 iolm
 ID IOLM_AST IOLM_AXIS
 1 1 1.15165.33
 2 2 1.20 79.00
 3 3 0.40 51.66
 4 4 0.50 57.00
 5 5 1.77  7.70
 6 6 0.28 99.70
 7 7 0.48160.00
 8 8 0.74 84.00
 9 9 1.63 87.00
 10   10 0.43150.70
 
 
 ## STEP 2
 
 i_wtr-subset(iolm,IOLM_AXIS  60  IOLM_AXIS  120)
 i_wtr
 ID IOLM_AST IOLM_AXIS
 2 2 1.20  79.0
 6 6 0.28  99.7
 8 8 0.74  84.0
 9 9 1.63  87.0
 16   16 0.93  94.0
 20   20 1.37  91.0
 21   21 1.19  63.0
 ...
 
 ## STEP 3
 
 i_wtr$IOLM_AST - i_wtr$IOLM_AST + 0.3
 i_wtr
 ID IOLM_AST IOLM_AXIS
 2 2 1.50  79.0
 6 6 0.58  99.7
 8 8 1.04  84.0
 9 9 1.93  87.0
 16   16 1.23  94.0
 20   20 1.67  91.0
 21   21 1.49  63.0
 ...
 
 ## STEP 4 – result (not what I wish to get)
 
 newiolm-merge(i_wtr, iolm, by.x=ID, by.y=ID, all = T)
 newiolm
 ID IOLM_AST.x IOLM_AXIS.x IOLM_AST.y IOLM_AXIS.y
 1 1 NA  NA   1.15  165.33
 2 2   1.5079.0   1.20   79.00
 3 3 NA  NA   0.40   51.66
 4 4 NA  NA   0.50   57.00
 5 5 NA  NA   1.777.70
 6 6   0.5899.7   0.28   99.70
 7 7 NA  NA   0.48  160.00
 8 8   1.0484.0   0.74   84.00
 9 9   1.9387.0   1.63   87.00
 10   10 NA  NA   0.43  150.70
 ...
 
 
 ## The result I am looking to get:
 
 ID   IOLM_AST   IOLM_AXIS
 1 1   1.15  165.33
 2 2   1.50   79.00
 3 3   0.40   51.66
 4 4   0.50   57.00
 5 5   1.77   7.70
 6 6   0.58   99.70
 7 7   0.48   160.00
 8 8   1.04   84.00
 9 9   1.93   87.00
 10   10   0.43   150.70
 ...
 
 What is the correct way to do this?
 Thanks a lot for your help.
 Dominik


Just replace the values that meet the condition with the new values, leaving 
the others alone:

 iolm
   ID IOLM_AST IOLM_AXIS
1   1 1.15165.33
2   2 1.20 79.00
3   3 0.40 51.66
4   4 0.50 57.00
5   5 1.77  7.70
6   6 0.28 99.70
7   7 0.48160.00
8   8 0.74 84.00
9   9 1.63 87.00
10 10 0.43150.70


# See ?ifelse and ?with

 with(iolm, ifelse(IOLM_AXIS  60  IOLM_AXIS  120, 
IOLM_AST + 0.3, 
IOLM_AST))
 [1] 1.15 1.50 0.40 0.50 1.77 0.58 0.48 1.04 1.93 0.43


# Replace the original column with the above result

iolm$IOLM_AST - with(iolm, ifelse(IOLM_AXIS  60  IOLM_AXIS  120, 
   IOLM_AST + 0.3, 
   IOLM_AST))

 iolm
   ID IOLM_AST IOLM_AXIS
1   1 1.15165.33
2   2 1.50 79.00
3   3 0.40 51.66
4   4 0.50 57.00
5   5 1.77  7.70
6   6 0.58 99.70
7   7 0.48160.00
8   8 1.04 84.00
9   9 1.93 87.00
10 10 0.43150.70


HTH,

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] split a row into multiple columns

2010-06-04 Thread Kevin Burnham
Thanks, that worked great, but I am having trouble generalizing it to my
entire data set for some reason.

I have 318 rows like this:

Main Group\t1000\tMP Test\tMP Test, 1\tAudio (1, f1-qaddara.aiff)\tl
(target is right word)\tl\tPressed\tl (target is right
word)\tC\t3111\t\t\t\t\t

and the command:
mydata - matrix(strsplit(x, '\t')[[1]], nrow=1)

gives me a matrix with only the 1st row of the data.  I have tried playing
around with it, but so far the best I can do is get 318 copies of row 1.

How can I get a matrix with all 318 rows and 15 columns split by the '\t'?

Thanks again.

kevin


On Thu, Jun 3, 2010 at 2:39 PM, jim holtman jholt...@gmail.com wrote:

 If you want a matrix, then just create one from the data you have:

 mydata - matrix(strsplit(x, '\t')[[1]], nrow=1)

 On Thu, Jun 3, 2010 at 1:30 PM, Kevin Burnham kburn...@gmail.com wrote:
  Would somebody please help me break this row:
 
  Main Group\t1000\tMP Test\tMP Test, 1\tAudio (1, f1-qaddara.aiff)\tl
  (target is right word)\tl\tPressed\tl (target is right
  word)\tC\t3111\t\t\t\t\t
 
  into multiple columns along the \t separator?
 
  When I try the strsplit (x,\t) command I get:
 
  [[1]]
   [1] Main Group 1000   MP
  TestMP Test, 1 Audio (1,
  f1-qaddara.aiff)
   [6] l (target is right word)   l
  Pressedl (target is right word)
  C
  [11] 3111   

 
  Which which is closer to what I need, but still not in columns.
 
  Thanks,
  Kevin
 
 [[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.
 



 --
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem that you are trying to solve?


[[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] R with Emacs

2010-06-04 Thread Richard M. Heiberger
ess.r-project.org
__
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] string handling

2010-06-04 Thread karena

Thank you guys very much, these help!!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/string-handling-tp2242119p2243388.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] R plotting on linux, regardless of architecture of local machine

2010-06-04 Thread vaneet

I can try having an X server locally, but what are the other options?  Isn't
there anything that can be installed on Linux to be able to display graph
windows in R without too much trouble?  As I said I was looking for a
solution to benefit many users not just me as I can't assume or expect
everyone logging in to the linux machine to have a local X server running.

Thanks
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-plotting-on-linux-regardless-of-architecture-of-local-machine-tp2243391p2243650.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] using string as variable name in model

2010-06-04 Thread Roni Kobrosly
update() works!
Thank you thomas


On Jun 4, 2010, at 11:47 AM, Thomas Lumley wrote:

 
 
 I think you're looking for the update() function.
 
   -thomas
 
 On Thu, 3 Jun 2010, Roni Kobrosly wrote:
 
 Hi,
 
 I made a small table of strings that will serve as variable names for lm 
 models I will run. The table looks like this:
 
 varnames
  numname
 11  zCANTAB_log_IED_totaltrials
 22   zCANTAB_log_IED_preED
 33zCANTAB_logPALerrors
 44   zCANTAB_PALstages
 55  zCANTAB_logRTI
 66   zCANTAB_RVP_Totalmisses
 77  zCANTAB_log_RVP_falsealarm
 88   zCANTAB_DMS_12000
 99 zCANTAB_PRM_Percent
 10  10 zCANTAB_SRM_Percent
 11  11 zCANTAB_sqrt_SWM_within
 12  12  zCANTAB_sqrt_SWM_Total
 13  13  zSS_WJ_PC
 14  14 zSS_WJ_CALC
 15  15   zSS_WJ_LW
 16  16   zSS_WJ_AP
 17  17   zSS_WJ_MF
 
 
 What I'm trying to do is
 
 
 varnames[1,2] - outcome
 
 lm(outcome ~ income + covariate1 + coviarate2, data=my.data) - model
 
 I get the following error message:
 Error in model.frame.default(formula = outcome ~ Hollings_Enroll + 
 Child_sex +  :
 variable lengths differ (found for 'Hollings_Enroll')
 
 But when I run the model:
 lm(zCANTAB_log_IED_totaltrials ~ income + covariate1 + coviarate2, 
 data=my.data) - model
 
 it works fine. Eventually, once I resolve this, I'd like to make a custom R 
 function to automatically generate 17 regression models with these 17 
 outcome variable strings. Do you have any ideas how to resolve this error?
 
 Thanks!
 -Roni
 
 __
 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.
 
 
 Thomas Lumley Assoc. Professor, Biostatistics
 tlum...@u.washington.edu  University of Washington, Seattle
 

__
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] Convolution vector to be derived

2010-06-04 Thread Moohwan Kim
I want to generate the following outcome using convolution of two sequences.

x - c(1,2,3,4,5)
y - c(6,7,8,9)

The resulting convolution vector is
6
19
40
70
100
94
76
45
When using convolve(), it is hard to produce the result above.
Would you help me out to get that?

Best regards
Moohwan Kim

__
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] Convolution vector to be derived

2010-06-04 Thread Moohwan Kim
Dear R-help,

I want to generate the following outcome using the convolution of two sequences.

x - c(1,2,3,4,5)
y - c(6,7,8,9)

The resulting convolution vector is
6
19
40
70
100
94
76
45
When using convolve(), it is hard to produce the result above.
Would you help me out to get that?

Best regards
Moohwan Kim

__
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] string handling

2010-06-04 Thread Gabor Grothendieck
Here is a slightly simpler variant of the strapply solution:

 lapply(DF, strapply, (.)/(.), c, simplify = rbind)
$var1
 [,1] [,2]
[1,] G  G
[2,] A  T
[3,] G  G

$var2
 [,1] [,2]
[1,] C  T
[2,] C  C
[3,] A  A


On Fri, Jun 4, 2010 at 8:08 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 This solution using strapply in gsubfn is along the same lines as the
 stringr solution.  First we read in the data using as.is = TRUE so
 that we get character rather than factor columns.  On the other hand,
 if your data is already in columns with class factor then just replace
 strappy(x, ...) with strapply(as.character(x), ...) below.   Then
 lapply over the columns of DF using strapply on each one.    See home
 page at http://gsubfn.googlecode.com for more.

 Lines - var1        var2
 + 9G/G09    abd89C/T90
 + 10A/T9    32C/C
 + 90G/G      A/A

 library(gsubfn)
 DF - read.table(textConnection(Lines), header = TRUE, as.is = TRUE)
 lapply(DF, function(x) strapply(x, (.)/(.), c, simplify = rbind))
 $var1
     [,1] [,2]
 [1,] G  G
 [2,] A  T
 [3,] G  G

 $var2
     [,1] [,2]
 [1,] C  T
 [2,] C  C
 [3,] A  A


 Also a slight simplification is possible using gsubfn's capability of
 representing a one line function as a formula.  We just preface lapply
 with fn$ and then formulas appearing in the arguments (subject to
 certain rules) are interpreted as functions.  Here, the formula in the
 second argument to lapply is interpreted as the anonymous function we
 used above:

 fn$lapply(DF, x ~ strapply(x, (.)/(.), c, simplify = rbind))
 $var1
     [,1] [,2]
 [1,] G  G
 [2,] A  T
 [3,] G  G

 $var2
     [,1] [,2]
 [1,] C  T
 [2,] C  C
 [3,] A  A

 On Thu, Jun 3, 2010 at 2:18 PM, karena dr.jz...@gmail.com wrote:

 I have a data.frame as the following:
 var1        var2
 9G/G09    abd89C/T90
 10A/T9    32C/C
 90G/G      A/A
 .             .
 .             .
 .             .
 10T/C      00G/G90

 What I want is to get the letters which are on the left and right of '/'.
 for example, for 9G/G09, I only want G, G, and for abd89C/T90, I
 only want C and T, how to get these?

 thank you,

 karena
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/string-handling-tp2242119p2242119.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] Creating a maxtrix from conditional prints

2010-06-04 Thread EM
Hi guys :)

I'm dealing with this problem, perhaps conceptually not that complex, but
still - I'm stuck.

Two columns, values 1x10, only integers. I want to check when the first
column's index is identical to the second's (and vice versa). If that's
true, I want to add a further column with value 1 (if true) or NA (if
false).
Thus, I obtain 100 matrices (for each columns I will have 1-1, 1-2, 1-3
etc). Now, I want R to  consider only those matrices whose new column has
value = 1  whose total number of rows is equal to 2. I can get R to print
this result inside the for cycle, yet I can't manage to build a single
matrix, to store all the results altoghether - which is what I really want.


Code example:

for (x in 1:10) {
for (y in 1:10) {
qui - ifelse((mac[,1] == x)  (mac[,5] == y) |  (mac[,1] == y)  (mac[,5]
== x), 1, NA)
quo - cbind(mac,qui)
qua - subset(quo, qui ==1)
if(nrow(qua) == 2)
print(qua)
}}

result (wrong, now):

 ricevente genere_r abo_r classieta_r donatore genere_d abo_d
classieta_deta_d mismatch pra comp   mum qui
[1,] 80 1   391 1
4 56.174372   11 -6.645437   1
[2,] 91 1   280 1
3 48.775792   11 -5.905579   1
 ricevente genere_r abo_r classieta_r donatore genere_d abo_d
classieta_deta_d mismatch pra comp   mum qui
[1,] 80 1   3   100 0
3 48.775792   11 -5.905579   1
[2,]100 2   580 1
3 48.775791   11 -5.391579   1
 ricevente genere_r abo_r classieta_r donatore genere_d abo_d
classieta_deta_d mismatch pra comp   mum qui
[1,] 80 1   391 1
4 56.174372   11 -6.645437   1
[2,] 91 1   280 1
3 48.775792   11 -5.905579   1
 ricevente genere_r abo_r classieta_r donatore genere_d abo_d
classieta_deta_d mismatch pra comp   mum qui
[1,] 91 1   2   100 0
3 48.775790   11 -4.877579   1
[2,]100 2   591 1
4 56.174370   11 -5.617437   1

what I'd like to get:

 ricevente genere_r abo_r classieta_r donatore genere_d abo_d
classieta_deta_d mismatch pra comp   mum qui
[1,] 80 1   391 1
4 56.174372   11 -6.645437   1
[2,] 91 1   280 1
3 48.775792   11 -5.905579   1
[3,] 80 1   3   100 0
3 48.775792   11 -5.905579   1
[4,]100 2   580 1
3 48.775791   11 -5.391579   1
[5,] 80 1   391 1
4 56.174372   11 -6.645437   1
[6,] 91 1   280 1
3 48.775792   11 -5.905579   1
[7,] 91 1   2   100 0
3 48.775790   11 -4.877579   1
[8,]100 2   591 1
4 56.174370   11 -5.617437   1

(don't mind the values  names, this is just a small part of a longer
algorithm)

Thanks for your help, in advance :)

[[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] split a row into multiple columns

2010-06-04 Thread Dennis Murphy
Hi:

Maybe something like this?

txt - Main Group\t1000\tMP Test\tMP Test, 1\tAudio (1, f1-qaddara.aiff)\tl
 (target is right word)\tl\tPressed\tl (target is right
 word)\tC\t3111\t\t\t\t\t
txtdf - as.data.frame(rbind(txt, txt, txt, txt, txt))  # create toy data
frame
res - t(as.matrix(apply(txtdf, 1, function(x) strsplit(x, '\t')[[1]])))

 res
[,1] [,2]   [,3]  [,4] [,5]
txt Main Group 1000 MP Test MP Test, 1 Audio (1, f1-qaddara.aiff)
txt Main Group 1000 MP Test MP Test, 1 Audio (1, f1-qaddara.aiff)
txt Main Group 1000 MP Test MP Test, 1 Audio (1, f1-qaddara.aiff)
txt Main Group 1000 MP Test MP Test, 1 Audio (1, f1-qaddara.aiff)
txt Main Group 1000 MP Test MP Test, 1 Audio (1, f1-qaddara.aiff)
[,6][,7] [,8]  [,9]
txt l\n(target is right word) l  Pressed l (target is right\nword)
txt l\n(target is right word) l  Pressed l (target is right\nword)
txt l\n(target is right word) l  Pressed l (target is right\nword)
txt l\n(target is right word) l  Pressed l (target is right\nword)
txt l\n(target is right word) l  Pressed l (target is right\nword)
[,10] [,11]  [,12] [,13] [,14] [,15]
txt C   3111 
txt C   3111 
txt C   3111 
txt C   3111 
txt C   3111 

The rownames are an artifice of having copied txt five times to create the
df.

HTH,
Dennis


On Fri, Jun 4, 2010 at 11:42 AM, Kevin Burnham kburn...@gmail.com wrote:

 Thanks, that worked great, but I am having trouble generalizing it to my
 entire data set for some reason.

 I have 318 rows like this:

 Main Group\t1000\tMP Test\tMP Test, 1\tAudio (1, f1-qaddara.aiff)\tl
 (target is right word)\tl\tPressed\tl (target is right
 word)\tC\t3111\t\t\t\t\t

 and the command:
 mydata - matrix(strsplit(x, '\t')[[1]], nrow=1)

 gives me a matrix with only the 1st row of the data.  I have tried playing
 around with it, but so far the best I can do is get 318 copies of row 1.

 How can I get a matrix with all 318 rows and 15 columns split by the '\t'?

 Thanks again.

 kevin


 On Thu, Jun 3, 2010 at 2:39 PM, jim holtman jholt...@gmail.com wrote:

  If you want a matrix, then just create one from the data you have:
 
  mydata - matrix(strsplit(x, '\t')[[1]], nrow=1)
 
  On Thu, Jun 3, 2010 at 1:30 PM, Kevin Burnham kburn...@gmail.com
 wrote:
   Would somebody please help me break this row:
  
   Main Group\t1000\tMP Test\tMP Test, 1\tAudio (1, f1-qaddara.aiff)\tl
   (target is right word)\tl\tPressed\tl (target is right
   word)\tC\t3111\t\t\t\t\t
  
   into multiple columns along the \t separator?
  
   When I try the strsplit (x,\t) command I get:
  
   [[1]]
[1] Main Group 1000   MP
   TestMP Test, 1 Audio (1,
   f1-qaddara.aiff)
[6] l (target is right word)   l
   Pressedl (target is right word)
   C
   [11] 3111   
 
  
   Which which is closer to what I need, but still not in columns.
  
   Thanks,
   Kevin
  
  [[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.
  
 
 
 
  --
  Jim Holtman
  Cincinnati, OH
  +1 513 646 9390
 
  What is the problem that you are trying to solve?
 

[[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.


[[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] sem R: singular and Could not compute QR decomposition of Hessian

2010-06-04 Thread sanchez ana
Can somebody help me with the following issue (SEM in R), please:
 
When I run the model (includes second order models) in R, it gives me the 
following:
 
1)   In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names 
= vars,  :
  Could not compute QR decomposition of Hessian.
Optimization probably did not converge.
 
2)   I have aliased parameters and NaNS
 
or sometimes when I run it again I have the following message:
 
1)   Error in solve.default(C) : 
  The system is computationally singular: condition number = 4.28182e-19 (it 
says so in Spanish)
 
Since the items are measured in likert scales I was using polychoric 
correlations, however, I saw that it can cause troubles, so I decided not to 
use it anymore. I also check the following:
 
1) Variables with variance 0 (I do not have)
2) Linear combinations of variables (I do not have high correlations)
3) I already used initial values for the aliased parameters
4) I do not have missing data
5) The eigenvalues of the S matrix are all positive (no zeros)
6) I calculate the determinant of the correlation matrix, adding one variable 
at a time, in order to look for multivariate dependencies, but the determinants 
are not cero, the lowest one is:0.0004054475
 
 
Since the model has constructs that are measured with only one item, I decided 
to connect directly the variable (item) to the other constructs.

Thanks

Ana


  
[[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] R plotting on linux, regardless of architecture of local machine

2010-06-04 Thread Marc Schwartz
On Jun 4, 2010, at 1:53 PM, vaneet wrote:

 
 I can try having an X server locally, but what are the other options?  Isn't
 there anything that can be installed on Linux to be able to display graph
 windows in R without too much trouble?  As I said I was looking for a
 solution to benefit many users not just me as I can't assume or expect
 everyone logging in to the linux machine to have a local X server running.
 
 Thanks


I think that the goal is noble, but you are asking Windows to emulate 
functionality specific to Linux/Unix. 

Kind of like asking BP to stop an oil leak...  

Windows does not natively support X11, which is the default graphic device on 
Linux. Even on OSX (which is a BSD Unix derivative), X11 is not installed by 
default, though it is on the OSX installation DVD.

You are going to have to install something on the client machines. At minimum 
on Windows, you would have to install an SSH client, like PuTTY or similar, to 
connect to the RHEL server to run R at the CLI. So while somebody is doing 
that, they can take one more step and add in Xming or perhaps Cygwin/X. 

It is either going to be a combination of an SSH client and an X server, or R 
for Windows itself, if you want local display graphics.

I am not cognizant of other options, but will defer to others with more recent 
Windows experience.

HTH,

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] Convolution vector to be derived

2010-06-04 Thread Allan Engelhardt

On the contrary: it is trivial to produce the result.

x - c(1,2,3,4,5)
y - c(6,7,8,9)
convolve(x, rev(y), type=open)
# [1]   6  19  40  70 100  94  76  45

Try help(convolve).

Allan


On 04/06/10 19:21, Moohwan Kim wrote:

Dear R-help,

I want to generate the following outcome using the convolution of two sequences.

x- c(1,2,3,4,5)
y- c(6,7,8,9)

The resulting convolution vector is
6
19
40
70
100
94
76
45
When using convolve(), it is hard to produce the result above.
Would you help me out to get that?




__
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 plotting on linux, regardless of architecture of local machine

2010-06-04 Thread vaneet

So just so I understand properly,  if there are multiple users connecting to
this remote linux machine in which I installed R and lets just say they all
have Windows machines.  To view plots they would all need to have an SSH
client and an X server installed on their local machine to do this?  You
said that X11 is the default graphic device on Linux, isn't there some way
of using X11 in R to show the plot while logged in to the remote linux
machine?

Thanks


-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-plotting-on-linux-regardless-of-architecture-of-local-machine-tp2243391p2243732.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] R plotting on linux, regardless of architecture of local machine

2010-06-04 Thread Erik Iverson



vaneet wrote:

So just so I understand properly,  if there are multiple users connecting to
this remote linux machine in which I installed R and lets just say they all
have Windows machines.  To view plots they would all need to have an SSH
client and an X server installed on their local machine to do this?  


Yes, with X11-forwarding enabled when the SSH connection is established. 
 Usually this would not be the default.




You said that X11 is the default graphic device on Linux, isn't there some way
of using X11 in R to show the plot while logged in to the remote linux
machine?


Yes, by running an X11 server on the Windows machine, as others have 
suggested.


In some situations, I have just left open a GUI SFTP client to some 
directory where my R plots get generated.  After my script is done, I 
then simply double-click the graphics file to open it.


Perhaps there is some image or PDF viewer out there that can load a 
remote file, and then 'watch' it so that when it changes, it reloads 
automatically.   I suppose that's another option.  I know programs exist 
that can do this when the file is local.


Perhaps Dropbox could be used as a solution.

Running the X server is going to be the easiest in my opinion, though.

__
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] Wrong symbol rendering in plots (Ubuntu)

2010-06-04 Thread Ben Bolker
Eduardo J. Chica ejchica at gmail.com writes:
 Hi I am having problems with the rendering of scientific symbols (mu and 
 degree) in my plots. Whenever I use these symbols they are rendered 
 changed (mu is changed to the proportionality symbol and degree is 
 changed to something resembling a gamma) in the X-device. If I make a 
 pdf of the plot and open the file in Evince or Okular symbols are also 
 rendered wrong, however if I open the file with Xpdf or Acroread they 
 are rendered correctly.
 
 I did not have this problem before, it arose after I upgraded both R and 
 my system (Ubuntu karmic koala to lucid lynx), so I can not tell for 
 sure if the problem is R-related or Ubuntu related (I have posted in a 
 Ubuntu forum also http://ubuntuforums.org/showthread.php?t=1325289).

  Could you please post a reproducible example?  It would be
good to see exactly what you are doing, and it will save time
for anyone who wants to try your example on their machine to
try to narrow down the problem.

   Ben Bolker

__
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 plotting on linux, regardless of architecture of local

2010-06-04 Thread Ted Harding
On 04-Jun-10 20:26:50, vaneet wrote:
 So just so I understand properly,  if there are multiple users
 connecting to this remote linux machine in which I installed R
 and lets just say they all have Windows machines. To view plots
 they would all need to have an SSH client and an X server installed
 on their local machine to do this?

Yes.

 You said that X11 is the default graphic device on Linux, isn't
 there some way of using X11 in R to show the plot while logged in
 to the remote linux machine?
 
 Thanks

It is important to understand one thing about the X11 system.
Namely, that the notions of X-server and X-client are the oposite
way round from what a user might naively expect.

When you are sitting at one machine, remotely logged in to another
machine which is running some program which you have requested,
you are likely to think that your machine is the client, requesting
service from the remote machine. So you request an action from the
remote machine, and the remote machine serves you with the result.

However, an X-capable program (say R), running on the remote machine,
will need to enable you to see (e.g.) graphics results computed by
thbe remote machine. This it will do by sending requests to your local
machine to make marks on the local screen. So your local machine must
be running a program which can accept these requests and make the
marks on the screen. Thus the local machine is now the *server*,
responding to requests from the remote machine (the *client*).

Thus an X system must be installed on your local machine so that it
can respond to the requests from the remote machine. I.e. your local
machine must be capable of acting as an X-server.

Therefore you must install X on your local machine.

Hoping this helps!
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 04-Jun-10   Time: 21:45:46
-- XFMail --

__
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 plotting on linux, regardless of architecture of local

2010-06-04 Thread vaneet

Thanks for explaining it in detail, that really helps.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-plotting-on-linux-regardless-of-architecture-of-local-machine-tp2243391p2243757.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] subsetting a dataframe

2010-06-04 Thread yjmha69
Hi there, 
 a-data.frame(c(1,2,2,5,9,9),c(A,B,C,D,E,F)) 
 names(a)-c(x1,x2) 
 max(table(a$x1)) 
[1] 2 
 
The above shows the max count for x1 is 2, which is correct. But we can't tell 
there are 2 groups that meet this criteria: 2,2 and 9,9. 
I then want to extract the records that has the hightest count 
 a[max(table(a$x1)),] 
  x1 x2 
2  2  B 
This is not working, since it is equvalent to a[2,] 
What I want is 
   x1 x2 
2 2   B 
3 2   C 
5 9   E 
5 9   F 

I think this should be very easy, but I'm a beginner :-) 

Thanks 

YJM 





__
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] tapply help

2010-06-04 Thread Mark Ebbert
Dear R gurus,

I am trying perform what I believe will be a pretty simple task, but I'm 
struggling to figure out how to do it. I have two vectors of the same length, 
the first is numeric and the second is factor. I understand that tapply is 
perfect for applying a function to the numeric vector by subsets of the factors 
in the second vector. My issue is trying to make use of two other vectors 
within the custom function I've written for tapply. The two other vectors are a 
high and low value for each subset I am breaking my data into, and I want to 
calculate the percentage of data points that fall into each respective range. I 
will attempt to provide a coherent example:

# create range for each possible class
lows-c(1,2,3,4,5)
highs-c(5,6,7,8,9)

# data values
vals-sample(1:10,100,replace=T)

#classes
classes-sample(letters[1:5],100,replace=T)

# Try to calculate percentage of values that fall
# into the respective range for the given class.
percentages-tapply(vals,classes,
function(i){
length(i[i=lows[index]  i=highs[index]])/length(i)  # I 
don't know how to actually keep an index count in tapply, but I'm guessing 
there's a better way.
})

I really appreciate any help.

ME
__
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] fixed intercept

2010-06-04 Thread array chip
Hi, is it possible to specify a constant intercept (based on prior knowledge) 
in linear regression using lm()?

Thanks

John

__
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] Your message to R-help awaits moderator approval

2010-06-04 Thread yjmha69
What filter rule is violated?
So frustrated, why can't I post question!



- Original Message 
From: r-help-boun...@r-project.org r-help-boun...@r-project.org
To: yjmh...@yahoo.com
Sent: Fri, June 4, 2010 12:28:37 PM
Subject: Your message to R-help awaits moderator approval

Your mail to 'R-help' with the subject

    subsetting a dataframe

Is being held until the list moderator can review it for approval.

The reason it is being held:

    The message headers matched a filter rule

Either the message will get posted to the list, or you will receive
notification of the moderator's decision.  If you would like to cancel
this posting, please visit the following URL:

    
https://stat.ethz.ch/mailman/confirm/r-help/151139c40b029d260fb9bde07e60a96a68dc572d




__
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 with iteration using while loop

2010-06-04 Thread Steve Lianoglou
Hi Subodh,

Minor note: please keep replies on list so everyone benefits from
answers/questions.

Now:


On Fri, Jun 4, 2010 at 2:49 PM, Subodh Acharya shoeb...@gmail.com wrote:
 Thanks a lot Steve,
 It worked. I appreciate. But I have another question, may be thats trivial.
 Say, it doesn't converge at itermax. I need to display error message saying
 values don't converge at at itermax. Is there another statement that
 accompanies while for this?

Perhaps you can use warning(...). You can check whether (or not)
your  Fpt - Fpi is  tolerance after you loop. If it is, you know your
loop terminated because you hit itermax, and not because your algo
converged:
...
...
iter - 0
while (((Fpt - Fpi)  tolerance)  (iter  itermax)) {
  Fpi = Fpt
  Fpt = K*Time + M*S*log(1+ Fpi/(M*S))
  Fp0 = Fpt
  iter - iter + 1
}

if (Fpt - Fpi  tolerance) {
  warning(Algorithm reached itermax and did not converge)
}

...

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
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] Wrong symbol rendering in plots (Ubuntu)

2010-06-04 Thread Peter Langfelder
On Fri, Jun 4, 2010 at 1:44 PM, Ben Bolker bol...@ufl.edu wrote:
 Eduardo J. Chica ejchica at gmail.com writes:
 Hi I am having problems with the rendering of scientific symbols (mu and
 degree) in my plots. Whenever I use these symbols they are rendered
 changed (mu is changed to the proportionality symbol and degree is
 changed to something resembling a gamma) in the X-device. If I make a
 pdf of the plot and open the file in Evince or Okular symbols are also
 rendered wrong, however if I open the file with Xpdf or Acroread they
 are rendered correctly.

 I did not have this problem before, it arose after I upgraded both R and
 my system (Ubuntu karmic koala to lucid lynx), so I can not tell for
 sure if the problem is R-related or Ubuntu related (I have posted in a
 Ubuntu forum also http://ubuntuforums.org/showthread.php?t=1325289).

  Could you please post a reproducible example?  It would be
 good to see exactly what you are doing, and it will save time
 for anyone who wants to try your example on their machine to
 try to narrow down the problem.

   Ben Bolker

I have noticed something similar. Even a regular plot, say

plot(c(1:10))

when put into a pdf file via pdf() device, will display incorrect
symbols in linux pdf viewers (evince, okular). The circles (o) become
q, literally the letter q, and lose colors. In Acroread I see the
plots as they should be. This started happening around R-2.9 or so. Am
also not sure whether it's the R pdf or pdfCairo, or whether it's a
bug in the evince/okular backend.

Peter

__
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] Wrong symbol rendering in plots (Ubuntu)

2010-06-04 Thread Erik Iverson




plot(c(1:10))

when put into a pdf file via pdf() device, will display incorrect
symbols in linux pdf viewers (evince, okular). The circles (o) become
q, literally the letter q, and lose colors. 


This issue is already in the Notes section of ?pdf.  It remains to be 
seen if the OP's problem was this exact one, since they didn't specify 
an example.


From ?pdf,

 On some systems the default plotting character ‘pch = 1’ is
 displayed in some PDF viewers incorrectly as a ‘q’ character.
 (These seem to be viewers based on the ‘poppler’ PDF rendering
 library). This may be due to incorrect or incomplete mapping of
 font names to those used by the system.  Adding the following
 lines to ‘~/.fonts.conf’ or ‘/etc/fonts/local.conf’ may circumvent
 this problem.



 alias binding=same
familyZapfDingbats/family
acceptfamilyDingbats/family/accept
 /alias

__
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] Wrong symbol rendering in plots (Ubuntu)

2010-06-04 Thread Peter Langfelder

 This issue is already in the Notes section of ?pdf.  It remains to be seen
 if the OP's problem was this exact one, since they didn't specify an
 example.

aahhh, thank you for pointing this out. I never noticed this note.

Peter

__
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] subsetting a dataframe

2010-06-04 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of yjmha69
 Sent: Friday, June 04, 2010 12:28 PM
 To: R-help@r-project.org
 Subject: [R] subsetting a dataframe
 
 Hi there, 
  a-data.frame(c(1,2,2,5,9,9),c(A,B,C,D,E,F)) 
  names(a)-c(x1,x2) 
  max(table(a$x1)) 
 [1] 2 
  
 The above shows the max count for x1 is 2, which is correct. 
 But we can't tell 
 there are 2 groups that meet this criteria: 2,2 and 9,9. 
 I then want to extract the records that has the hightest count 
  a[max(table(a$x1)),] 
   x1 x2 
 2  2  B 
 This is not working, since it is equvalent to a[2,] 
 What I want is 
    x1 x2 
 2 2   B 
 3 2   C 
 5 9   E 
 5 9   F 
 
 I think this should be very easy, but I'm a beginner :-) 

One way is to use merge to combine your table with
the original data.frame:
   tmp - merge(a, as.data.frame(table(a$x1)), by.x=x1, by.y=Var1)
   tmp[tmp$Freq==max(tmp$Freq), ,drop=FALSE]
Another way is to use ave:
   tmp - with(a, ave(x1, x1, FUN=length))
   a[tmp==max(tmp), , drop=FALSE]
Another way is
   a[as.character(a$x1) %in% names(tmp[tmp==max(tmp)]), , drop=FALSE]
(This last one might have problems when some values in a$x1
are different but so close that as.character() makes the same
string out of them.)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 


 
 Thanks 
 
 YJM 
 
 
 
 
 
 __
 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] Your message to R-help awaits moderator approval

2010-06-04 Thread Gabor Grothendieck
This has happened to me too.  The last time it occurred I was replying
to another post and on my second attempt I deleted the replied-to
portion and reposted just my portion and it worked.

On Fri, Jun 4, 2010 at 4:35 PM, yjmha69 yjmh...@yahoo.com wrote:
 What filter rule is violated?
 So frustrated, why can't I post question!



 - Original Message 
 From: r-help-boun...@r-project.org r-help-boun...@r-project.org
 To: yjmh...@yahoo.com
 Sent: Fri, June 4, 2010 12:28:37 PM
 Subject: Your message to R-help awaits moderator approval

 Your mail to 'R-help' with the subject

     subsetting a dataframe

 Is being held until the list moderator can review it for approval.

 The reason it is being held:

     The message headers matched a filter rule

 Either the message will get posted to the list, or you will receive
 notification of the moderator's decision.  If you would like to cancel
 this posting, please visit the following URL:

     
 https://stat.ethz.ch/mailman/confirm/r-help/151139c40b029d260fb9bde07e60a96a68dc572d




 __
 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] R plotting on linux, regardless of architecture of local machine

2010-06-04 Thread Marc Schwartz
On Jun 4, 2010, at 3:26 PM, vaneet wrote:

 
 So just so I understand properly,  if there are multiple users connecting to
 this remote linux machine in which I installed R and lets just say they all
 have Windows machines.  To view plots they would all need to have an SSH
 client and an X server installed on their local machine to do this?  You
 said that X11 is the default graphic device on Linux, isn't there some way
 of using X11 in R to show the plot while logged in to the remote linux
 machine?
 
 Thanks


There are two separate functions required:

1. SSH Client - This provides the ability to login securely to the RHEL server 
from a remote client system. That could be another Linux/Unix machine, a 
Windows machine or an OSX machine (could even be a smartphone). This, in 
isolation, strictly provides a text based, point-to-point encrypted 
communication mechanism for the two machines to interact, over some network 
connection (could be the internet). 

It provides the functional equivalent of you sitting at the server itself and 
logging in locally using text mode only. Since it is a remote connection, SSH 
encrypts the connection to provide for the security of the data going back and 
forth over the network connection.

On a PC, think of the old DOS command line interface before Windows came along.

With respect to R, you need the SSH client to connect to the RHEL server to be 
able to run R. R is not running (executing) on your Windows machine. R is 
actually running on the RHEL server and the SSH connection is providing the 
means to transmit your keystrokes to the server and to provide the text mode 
screen output back to you. So the SSH network connection is essentially 
providing really long cables between your keyboard, your display and the server.


2. X11 - Linux uses X11 to provide the basic substrate for creating the GUI or 
windowing functionality on the display. This provides the basic means of 
graphical interaction with the computer as we generally know it today. When R 
generates plots in response to your commands, the RHEL server needs to send the 
results (signal) back to you and your computer needs the ability to interpret 
those signals and display them on your machine.  It is the X11 server (eg. 
Xming) running on your computer, that interprets those signals and enables the 
plot to be displayed on your machine. Without the X11 server running on your 
machine, all you have is a text based interaction with the RHEL server, because 
Windows would not know what to do with the signals coming from the RHEL server. 

If you are familiar with the difference between NTSC (aka Never The Same Color) 
and PAL, this would be something of a parallel. They are both TV display signal 
standards, but are not compatible.


Now, in reality, there is another component here, called X11 port forwarding. 
Think call forwarding. We have to have some way for the RHEL server to know to 
send (forward) the signals for the plot, over the SSH connection, to your 
machine, rather than sending them to the display that is physically connected 
to the RHEL server. Otherwise, you won't see the plot on your end.

In order to accomplish this, the RHEL server has to be configured to support 
this functionality (your SysAdmin will know how to do this) AND the SSH client 
needs to be configured to support the connection as well. In PuTTY for example, 
there is a setting in the application that enables this. But remember, this has 
to be supported on both ends, so you need to check with your SysAdmin. 
Sometimes, because of security concerns, X11 port forwarding will be disabled 
on the RHEL server side of things.

I see that Ted has also provided an excellent reply, so hopefully this might 
supplement his in some fashion.

HTH,

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.


[R] plotting a dataset with median 0

2010-06-04 Thread Georg Ehret
Dear R community,

[[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] plotting a dataset with median 0

2010-06-04 Thread Georg Ehret
Dear R community,
  I am working on a dataset that has median 0 (due to many 0 entries)
for my principal variable of interest (40 entries in total). I would like to
plot a graph of this variable to show it visually, but have a hard time:
boxplots are not informative (because median 0). Conventional scatterplots
are neither. Is there a good way to do this (e.g. plotting the 0 values
with a jitter or something else...)?

Thanking you all and best regards, Georg.
*
Georg Ehret
Johns Hopkins
Baltimore

[[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] What is the largest in memory data object you've worked with in R?

2010-06-04 Thread Nathan Stephens
For me, I've found that I can easily work with 1 GB datasets.  This includes
linear models and aggregations.  Working with 5 GB becomes cumbersome.
Anything over that, and R croaks.  I'm using a dual quad core Dell with 48
GB of RAM.

I'm wondering if there is anyone out there running jobs in the 100 GB
range.  If so, what does your hardware look like?

--Nathan

[[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] Ignoring missing elements in data.frame()

2010-06-04 Thread Scott Chamberlain
Hello, I am trying to make a data frame from many elements after
running a function which creates many elements, some of which may not
end up being real elements due to errors or missing data. For example,
I have the following three elements p1s, p2s, and p3s. p9s did not
generate the same data as there was an error in the function for some
reason. I currently have to delete p9s from the data.frame() command
to get the data.frame to work.  How can I make a data frame by somehow
ignoring elements (e.g., p9s) that do not exist, without having to
delete each missing element from data.frame()? The below is an example
of the code.

 p1s
 statistic parameter p.value
[1,] 3.606518  153   0.0004195377
 p2s
 statistic parameter p.value
[1,] -3.412436 8 0.009190015
 p3s
 statistic parameter p.value
[1,] 1.543685  599   0.1231928

 t(data.frame(t(p1s),t(p2s),t(p3s),t(p9s)))
Error in t(p9s) : object 'p9s' not found


Thanks, Scott Chamberlain
Rice University
Houston, TX

__
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] 380x380 dataframe to list

2010-06-04 Thread Nick Matzke

Hi,

This can't be hard, but I can't find the solution.  I have a 
380x380 data frame of numbers.  I would like to turn it into 
a single column so I can do e.g. hist and mean on it without 
writing my own function.  There must be a simple function 
for this, but I'm stumped -- reshape, dim, etc. don't seem 
to do it...


Help appreciated!
Thanks!!
Nick

--

Nicholas J. Matzke
Ph.D. Candidate, Graduate Student Researcher
Huelsenbeck Lab
Center for Theoretical Evolutionary Genomics
4151 VLSB (Valley Life Sciences Building)
Department of Integrative Biology
University of California, Berkeley

Graduate Student Instructor, IB200A
Principles of Phylogenetics: Systematics
http://ib.berkeley.edu/courses/ib200a/index.shtml

Lab websites:
http://ib.berkeley.edu/people/lab_detail.php?lab=54
http://fisher.berkeley.edu/cteg/hlab.html
Dept. personal page: 
http://ib.berkeley.edu/people/students/person_detail.php?person=370
Lab personal page: 
http://fisher.berkeley.edu/cteg/members/matzke.html

Lab phone: 510-643-6299
Dept. fax: 510-643-6264
Cell phone: 510-301-0179
Email: mat...@berkeley.edu

Mailing address:
Department of Integrative Biology
3060 VLSB #3140
Berkeley, CA 94720-3140

-
[W]hen people thought the earth was flat, they were wrong. 
When people thought the earth was spherical, they were 
wrong. But if you think that thinking the earth is spherical 
is just as wrong as thinking the earth is flat, then your 
view is wronger than both of them put together.


Isaac Asimov (1989). The Relativity of Wrong. The 
Skeptical Inquirer, 14(1), 35-44. Fall 1989.

http://chem.tufts.edu/AnswersInScience/RelativityofWrong.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.


Re: [R] 380x380 dataframe to list

2010-06-04 Thread Jorge Ivan Velez
Hi Nick,

Try unlist(yourdataframe).

HTH,
Jorge

On Fri, Jun 4, 2010 at 8:47 PM, Nick Matzke  wrote:

 Hi,

 This can't be hard, but I can't find the solution.  I have a 380x380 data
 frame of numbers.  I would like to turn it into a single column so I can do
 e.g. hist and mean on it without writing my own function.  There must be a
 simple function for this, but I'm stumped -- reshape, dim, etc. don't seem
 to do it...

 Help appreciated!
 Thanks!!
 Nick

 --
 
 Nicholas J. Matzke
 Ph.D. Candidate, Graduate Student Researcher
 Huelsenbeck Lab
 Center for Theoretical Evolutionary Genomics
 4151 VLSB (Valley Life Sciences Building)
 Department of Integrative Biology
 University of California, Berkeley

 Graduate Student Instructor, IB200A
 Principles of Phylogenetics: Systematics
 http://ib.berkeley.edu/courses/ib200a/index.shtml

 Lab websites:
 http://ib.berkeley.edu/people/lab_detail.php?lab=54
 http://fisher.berkeley.edu/cteg/hlab.html
 Dept. personal page:
 http://ib.berkeley.edu/people/students/person_detail.php?person=370
 Lab personal page: http://fisher.berkeley.edu/cteg/members/matzke.html
 Lab phone: 510-643-6299
 Dept. fax: 510-643-6264
 Cell phone: 510-301-0179
 Email: mat...@berkeley.edu

 Mailing address:
 Department of Integrative Biology
 3060 VLSB #3140
 Berkeley, CA 94720-3140

 -
 [W]hen people thought the earth was flat, they were wrong. When people
 thought the earth was spherical, they were wrong. But if you think that
 thinking the earth is spherical is just as wrong as thinking the earth is
 flat, then your view is wronger than both of them put together.

 Isaac Asimov (1989). The Relativity of Wrong. The Skeptical Inquirer,
 14(1), 35-44. Fall 1989.
 http://chem.tufts.edu/AnswersInScience/RelativityofWrong.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.


[[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] Help with iteration using while loop

2010-06-04 Thread Subodh Acharya
Hi Steve,
Actually I figured that out  after I emailed you but I forgot to email
you before I left office.
Anyway thanks a lot.And thanks for the note. I'll do that from now on.

Subodh
On Fri, Jun 4, 2010 at 4:54 PM, Steve Lianoglou 
mailinglist.honey...@gmail.com wrote:

 Hi Subodh,

 Minor note: please keep replies on list so everyone benefits from
 answers/questions.

 Now:


 On Fri, Jun 4, 2010 at 2:49 PM, Subodh Acharya shoeb...@gmail.com wrote:
  Thanks a lot Steve,
  It worked. I appreciate. But I have another question, may be thats
 trivial.
  Say, it doesn't converge at itermax. I need to display error message
 saying
  values don't converge at at itermax. Is there another statement that
  accompanies while for this?

 Perhaps you can use warning(...). You can check whether (or not)
 your  Fpt - Fpi is  tolerance after you loop. If it is, you know your
 loop terminated because you hit itermax, and not because your algo
 converged:
 ...
 ...
 iter - 0
 while (((Fpt - Fpi)  tolerance)  (iter  itermax)) {
   Fpi = Fpt
   Fpt = K*Time + M*S*log(1+ Fpi/(M*S))
   Fp0 = Fpt
   iter - iter + 1
 }

 if (Fpt - Fpi  tolerance) {
  warning(Algorithm reached itermax and did not converge)
 }

 ...

 --
 Steve Lianoglou
 Graduate Student: Computational Systems Biology
  | Memorial Sloan-Kettering Cancer Center
  | Weill Medical College of Cornell University
 Contact Info: http://cbio.mskcc.org/~lianos/contact




-- 
Acharya, Subodh

[[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] 380x380 dataframe to list

2010-06-04 Thread Peter Langfelder
c(as.matrix(data)) will not do it?

Peter

On Fri, Jun 4, 2010 at 5:47 PM, Nick Matzke mat...@berkeley.edu wrote:
 Hi,

 This can't be hard, but I can't find the solution.  I have a 380x380 data
 frame of numbers.  I would like to turn it into a single column so I can do
 e.g. hist and mean on it without writing my own function.  There must be a
 simple function for this, but I'm stumped -- reshape, dim, etc. don't seem
 to do it...

 Help appreciated!
 Thanks!!
 Nick

 --
 
 Nicholas J. Matzke
 Ph.D. Candidate, Graduate Student Researcher
 Huelsenbeck Lab
 Center for Theoretical Evolutionary Genomics
 4151 VLSB (Valley Life Sciences Building)
 Department of Integrative Biology
 University of California, Berkeley

 Graduate Student Instructor, IB200A
 Principles of Phylogenetics: Systematics
 http://ib.berkeley.edu/courses/ib200a/index.shtml

 Lab websites:
 http://ib.berkeley.edu/people/lab_detail.php?lab=54
 http://fisher.berkeley.edu/cteg/hlab.html
 Dept. personal page:
 http://ib.berkeley.edu/people/students/person_detail.php?person=370
 Lab personal page: http://fisher.berkeley.edu/cteg/members/matzke.html
 Lab phone: 510-643-6299
 Dept. fax: 510-643-6264
 Cell phone: 510-301-0179
 Email: mat...@berkeley.edu

 Mailing address:
 Department of Integrative Biology
 3060 VLSB #3140
 Berkeley, CA 94720-3140

 -
 [W]hen people thought the earth was flat, they were wrong. When people
 thought the earth was spherical, they were wrong. But if you think that
 thinking the earth is spherical is just as wrong as thinking the earth is
 flat, then your view is wronger than both of them put together.

 Isaac Asimov (1989). The Relativity of Wrong. The Skeptical Inquirer,
 14(1), 35-44. Fall 1989.
 http://chem.tufts.edu/AnswersInScience/RelativityofWrong.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.


__
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.


  1   2   >