Re: [R] get index of current element in vector

2012-06-05 Thread Erdal Karaca
Thanks all, that worked!

Yes, it should be
for (i in 1:length(a)) a[i]- scalar * a[i] * i

And now is...

a - a * scalar * seq_along(a)

That is almost as cool as the PERL programming language :-)

2012/6/4 Rui Barradas ruipbarra...@sapo.pt

 Hello,

 Just learning the alphabet? If yes, there's a difference between 'v' and
 'a'.

 Now more seriously. Your description and your loop don't do the same.

 Description:
 vm - scalar * v * seq_along(v)

 Loop:
 a - scalar * a

 Also, seq_along is the way to do it, it works even if length(a) == 0.

 Hope this helps,

 Rui Barradas

 Em 04-06-2012 21:25, Erdal Karaca escreveu:

 (Just learning R)

 I have this vector:

 v- c(1:10)

 Now, I want to multiply each element of that vector with a scalar value
 multiplied with its index:

 vm- v * scalar * indexOfCurrentElementOf_v

 Is that possible without using a loop?

 In a loop I would do this:

 for (i in 1:length(a)) a[i]- scalar * a[i]

[[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] R Error : Error in vector(list, gamma(n + 1)) : vector size specified is too large

2012-06-05 Thread ritwik_r
Dear R-listers,

I am giving part of my R code :

###

n=15
m=1


library(partitions)
library(gregmisc)
library(combinat)

x = t(restrictedparts(n-m,m))
l = length(x[,1])

for(u in 1:l){

  A= unique(matrix( unlist(permn(x[u,])), ncol=m, byrow=TRUE ))

}

###

when I put m=1 error shows : Error in vector(list, gamma(n + 1)) :
vector size specified is too large .  But it works fine with other values
of m ( n).  Any suggestion will be highly accepted.

Ritwik Bhattacharya
SRF, Indian Statistical Institute Kolkata

This mail is scanned by Ironport

__
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] probit analysis

2012-06-05 Thread arun
Hi Trinh,

Please check ?dose.p() from library MASS.

Since you wanted the rate, the code was a bit modified from the example.  

 datPr
   X Event Trial
1 1210.0 8 8
2  121.0 6 8
3   60.5 6 8
 fm-glm(Event/Trial~X,data=datPr,family=quasibinomial(link=probit))
 XD50-dose.p(fm,cf=1:2,p=0.5)
  Dose   SE
p = 0.5: -203.7126 105.3647

 XD50_CI-XD50+c(1,-1.96,1.96)*attr(XD50,SE)
 names(XD50_CI)-c(XD50,lower,upper)
 XD50_CI
   XD50   lower   upper 
 -98.347938 -410.227309    2.802128 

I am not very confident about the results though.
 

 A.K.
 

From: phale_chuong gionho phale_chuonggio...@yahoo.com
To: r-help@r-project.org r-help@r-project.org
Cc: 
Sent: Monday, June 4, 2012 10:52 AM
Subject: [R] probit analysis

 Hello!
 I have a very simple set of data and I would like to analyze
 them with probit analysis.
 The data are: X    Event    Trial
 1210  8        8
 121  6        8
 60.5  6        8
 I want to estimate the value of X that will give a 95% hit
 rate (Event/Trial) and the corresponding 95% CI.
 you can help me? Thanks!!
 Trinh 

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


Re: [R] Read txt File contains character 

2012-06-05 Thread climmi
Thank you !  Rui Barradas .

Yes, the arrow character  can not be recoginised by R. 
the character will be treat as a stop command...
So I replace all the character  with space, then it works..
Just want to know is there any way for R to handle it.

Not sure does eveybody able to view the character, it's looks like this. 
http://r.789695.n4.nabble.com/file/n4632369/arrow.png 

--
View this message in context: 
http://r.789695.n4.nabble.com/Read-txt-File-contains-character-tp4632286p4632369.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] Merror

2012-06-05 Thread tkcasso
I have been try to work with Merror n I keep getting this message:

Error in solve.default(H) : 
  system is computationally singular: reciprocal condition number = 0

can some one please tell me what it mean and how to solve this.

--
View this message in context: 
http://r.789695.n4.nabble.com/Merror-tp4632371.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] Read txt File contains character 

2012-06-05 Thread peter dalgaard

On Jun 5, 2012, at 08:42 , climmi wrote:

 Thank you !  Rui Barradas .
 
 Yes, the arrow character  can not be recoginised by R. 
 the character will be treat as a stop command...
 So I replace all the character  with space, then it works..
 Just want to know is there any way for R to handle it.

To paraphrase Brian, you're likely the victim of your unstated operating 
system...

Hex 1a is ctr-Z, alias the end-of-file marker, which dates back from CP/M times 
and was never excised from the various Microsoft OS. R can't handle it because 
the OS is telling it that the file has ended. 

Opening the file in binary mode (?file) might help, but as I'm not on Windows, 
I can't easily check for you.

 
 Not sure does eveybody able to view the character, it's looks like this. 
 http://r.789695.n4.nabble.com/file/n4632369/arrow.png 

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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] approximating matrix columns

2012-06-05 Thread eliza botto



Dear Gunter Berton and all,
As
you can see, my data has three lists each containing 366 entries. I converted
them into the matrix. I now want to approx./interpolate 366 entries over 365
intervals, Which means I want to have a matrix with 365 entries. 

I
used 

 

approx(matrix, method=”linear”,
n=365)

 

but
it only converted the first column of my data, and left the rest untouched.

 

 

list(c(0.86, 0.86, 0.86, 0.86, 0.86,
1.08, 1.08, 1.08, 1.08,

 1.08, 1.08, 1.4, 1.4, 23, 11.18, 38.83, 23,
3.45, 3.45, 3.45,

 3.45, 3.45, 3.45, 3.45, 3.45, 3.02, 2.58,
2.58, 2.15, 2.15, 2.15,

 2.15, 2.15, 2.15, 2.15, 2.15, 3.02, 1.72,
1.72, 1.72, 1.72, 1.72,

 1.72, 1.72, 1.72, 1.6, 1.6, 1.6, 1.6, 1.6,
1.6, 1.6, 1.6, 1.6,

 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6,
1.6, 1.6, 1.6, 1.6,

 1.6, 1.6, 1.6, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4,
2.4, 2.8, 2.8, 2.8,

 4.1, 4.1, 13.55, 9.34, 8.32, 7.31, 4.5, 4.1,
14.63, 24.88, 39.99,

 23.69, 14.63, 7.31, 4.5, 7.31, 16.82, 21.35,
24.88, 20.2, 24.88,

 26.07, 30.98, 49.58, 51.01, 26.07, 24.88,
30.98, 34.77, 58.26,

 30.98, 23.69, 26.07, 19.06, 16.82, 20.2,
16.82, 23.69, 14.63,

 16.82, 11.42, 11.42, 11.42, 11.42, 10.38,
10.38, 8.32, 7.31,

 6.31, 16.82, 6.31, 6.31, 6.31, 4.9, 4.9, 4.5,
4.5, 4.5, 4.5,

 4.5, 4.1, 4.1, 2.8, 2.4, 2.4, 26.07, 45.4,
16.82, 7.31, 4.5,

 3.2, 3.2, 2.8, 2.8, 2.4, 2.4, 2.8, 3.2, 3.2,
4.9, 4.9, 36.05,

 65.8, 76.86, 53.87, 26.07, 20.2, 21.36, 14.63,
10.38, 10.38,

 7.31, 7.31, 51.01, 16.82, 14.63, 12.48, 14.63,
10.38, 11.42,

 52.44, 64.27, 36.05, 26.07, 21.36, 21.36,
23.69, 47.79, 52.44,

 167.9, 97.12, 76.86, 144.71, 90.18, 34.77,
30.98, 28.5, 26.07,

 26.07, 14.63, 14.63, 6.31, 6.31, 6.31, 4.5,
4.1, 3.2, 6.31, 6.31,

 16.82, 4.5, 3.2, 3.2, 3.2, 3.2, 4.5, 8.32,
10.38, 10.38, 8.32,

 11.42, 10.38, 7.31, 6.31, 6.31, 6.31, 6.31,
6.31, 6.31, 6.31,

 8.32, 6.31, 6.31, 20.2, 14.63, 7.31, 4.9,
34.77, 26.07, 14.63,

 10.38, 6.31, 4.9, 7.31, 4.9, 4.5, 4.5, 4.5,
21.36, 12.48, 7.31,

 4.5, 4.5, 6.31, 4.9, 4.9, 6.31, 8.32, 7.31,
6.31, 6.31, 14.63,

 11.42, 6.31, 6.31, 4.9, 6.31, 14.63, 7.31,
12.48, 6.31, 6.31,

 24.88, 15.72, 33.49, 111.57, 44.03, 39.99,
44.03, 24.88, 12.48,

 39.99, 11.42, 7.31, 4.9, 4.5, 4.1, 4.5, 4.1,
4.1, 3.2, 3.2, 3.2,

 3.2, 3.2, 2.8, 2.8, 3.2, 3.2, 3.2, 3.2, 3.2,
3.2, 3.2, 2.8, 2.8,

 3.2, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8,
2.8, 2.8, 2.8, 2.8,

 4.1, 4.1, 2.4, 3.2, 10.38, 8.32, 4.5, 3.2,
3.2, 2.8, 3.2, 3.2,

 3.2, 2.4, 2.4, 2.4, 15.72, 23.69, 12.48,
14.63, 4.5, 4.1, 4.5,

 4.1, 4.1, 4.1, 3.2, 2.8, 2.8, 3.2, 2.8, 2.4,
4.5, 4.5, 12.48,

 68.9, 30.98, 39.99, 29.73, 95.37, 44.03,
26.07, 41.33, 49.58,

 23.69, 28.5), c(16.82, 14.63, 6.31, 6.31, 4.5, 4.5, 4.1, 4.1,

 4.1, 3.2, 3.2, 4.1, 3.2, 3.2, 4.1, 4.5, 4.1,
4.1, 167.9, 75.24,

 44.03, 23.69, 19.06, 15.72, 11.42, 8.32, 6.31,
4.9, 6.31, 4.9,

 4.9, 4.1, 4.1, 3.2, 4.1, 4.1, 4.1, 90.18,
102.45, 39.99, 29.73,

 8.32, 21.36, 21.36, 21.36, 12.48, 11.42,
12.48, 11.42, 12.48,

 14.63, 14.63, 15.72, 23.69, 28.5, 29.73,
33.49, 29.73, 23.69,

 21.36, 6.31, 16.82, 15.72, 15.72, 15.72,
15.72, 16.82, 20.2,

 20.2, 21.36, 21.36, 26.07, 28.5, 29.73, 33.49,
29.73, 33.49,

 34.77, 26.07, 26.07, 23.69, 23.69, 26.07,
21.36, 23.69, 23.69,

 23.69, 24.88, 21.36, 20.2, 16.82, 19.06, 20.2,
21.36, 20.2, 20.2,

 24.88, 23.69, 26.07, 29.73, 23.69, 24.88,
29.73, 36.05, 33.49,

 34.77, 28.5, 28.5, 26.07, 153, 70.47, 58.26,
81.77, 36.05, 39.99,

 30.98, 33.49, 28.5, 28.5, 33.49, 29.73, 28.5,
24.88, 30.98, 38.67,

 30.98, 50.01, 65.8, 51.01, 38.67, 34.77,
29.73, 29.73, 33.49,

 30.98, 30.98, 30.98, 33.49, 34.77, 33.49,
30.98, 88.48, 14.63,

 8.32, 19.06, 14.63, 104.25, 44.03, 33.49,
21.36, 20.2, 15.72,

 15.72, 11.42, 7.31, 6.31, 4.9, 4.5, 4.5, 4.5,
3.2, 8.32, 8.32,

 14.63, 97.12, 310.8, 88.48, 36.05, 24.88,
19.06, 14.63, 12.48,

 8.32, 23.69, 11.42, 19.06, 90.18, 90.18,
33.49, 16.82, 70.47,

 38.67, 29.73, 34.77, 33.49, 68.9, 102.45,
176.7, 78.48, 45.4,

 106.06, 83.43, 45.4, 68.9, 39.99, 28.5, 23.69,
20.2, 36.05, 38.67,

 30.98, 26.07, 20.2, 47.79, 52.44, 28.5, 23.69,
20.2, 14.63, 14.63,

 14.63, 12.48, 21.36, 24.88, 47.79, 38.67,
34.77, 21.36, 16.82,

 8.32, 153, 47.79, 53.87, 29.73, 23.69, 15.72,
19.06, 97.12, 33.49,

 15.72, 10.38, 6.31, 4.5, 11.42, 6.31, 6.31,
6.31, 4.5, 19.06,

 14.63, 4.9, 4.9, 28.5, 70.47, 15.72, 4.9, 4.1,
41.33, 241, 85.1,

 38.67, 28.5, 20.2, 15.72, 12.48, 12.48, 20.2,
14.63, 12.48, 10.38,

 7.31, 7.31, 15.72, 33.49, 20.2, 15.72, 12.48,
8.32, 7.31, 6.31,

 4.9, 4.5, 4.1, 4.9, 4.5, 4.9, 20.2, 11.42,
6.31, 4.9, 4.9, 4.9,

 4.5, 4.5, 4.5, 4.1, 4.1, 4.1, 4.1, 4.1, 4.1,
4.1, 4.1, 4.1, 6.31,

 6.31, 4.5, 4.9, 4.9, 4.5, 4.5, 4.5, 4.9, 4.5,
15.72, 24.88, 4.1,

 58.26, 23.69, 26.07, 28.5, 174.5, 58.26,
49.58, 23.69, 23.69,

 23.69, 28.5, 

[R] Converiting longitude/latitude to utm

2012-06-05 Thread Boris Beranger
Dear all,

I have been trying to convert coordinates from longitude/latitude to utm
but I got an error. As soon as the longitude coordinate is greater than 90,
I get the folloowing error message:  error in pj_transform: latitude or
longitude exceeded limits

Here is what I did:

 SP-SpatialPoints(cbind(126.59,-14.30),proj4string=CRS(+proj=longlat))
coordinatesUTM-spTransform(SP,CRS(+proj=utm))

Error in spTransform(SP, CRS(+proj=utm)) :
  error in pj_transform: latitude or longitude exceeded limits

Can someone explain me what I did wrong? I am using coordinates of
Australia so the range of my longitudes is around [110,150] and the one of
my latitudes [-10,-45].

Thanks in advance,

Cheers,
Boris

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

2012-06-05 Thread Özgür Asar
I believe that dozens of people asked this question before you.

If you search this error in google, you can find your answer!

Ozgur

--
View this message in context: 
http://r.789695.n4.nabble.com/Merror-tp4632371p4632378.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] Need package which can parse linux configuration file '.conf'

2012-06-05 Thread Prakash Thomas
Hi,
   Please let me whether there is a package which can parse linux
configuration file '.conf. If there is no specific package can any of the
generic package handle this?
Thanks  Regards,
Thomas

[[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] Converiting longitude/latitude to utm

2012-06-05 Thread Michael Sumner
UTM needs a +zone and +south marker for the southern hemisphere, so
your PROJ.4 specification is incomplete, probably assuming +zone=1
which is completely wrong for longitude=126.

http://en.wikipedia.org/wiki/File:Utm-zones.jpg

Longitude 126.59 suggests zone 51 or 52, but it really depends on your
local usage and could be for the northern or southern hemisphere, and
the appropriate datum to be used. You should find out these details to
ensure you are targetting the right projection. It won't matter for
this simple example, but it might when you start sharing the data with
others. This is also important for the datum used for the
longitude/latitude values, you really should find out whether WGS84 is
a sensible assumption (probably ok for GDA94, but not older Australian
datums for example). These details really matter and you will save
pain if you ensure that you know them. (There are Australian datums
that a default GDAL build cannot transform between by name and
requires explicit parameters, as an example).

You could try the R-Sig-Geo mailing list as a better group for this
topic, and please declare your use of contributed packages, here sp
and rgdal. Here's an example that can work:

library(sp)
library(rgdal)

SP - SpatialPoints(cbind(126.59,-14.30), proj4string =
CRS(+proj=longlat +datum=WGS84))

coordinatesUTM - spTransform(SP, CRS(+proj=utm +south +zone=52 +datum=WGS84))

coordinatesUTM
SpatialPoints:
 coords.x1 coords.x2
[1,]  240015.6   8417744
Coordinate Reference System (CRS) arguments: +proj=utm +south +zone=52
+datum=WGS84 +ellps=WGS84 +towgs84=0,0,0

Also note that the rgdal function project() can be used to do simpler
transformations on matrices, though it cannot do datum conversions
(not relevant here but worth knowing).

Cheers, Mike.



On Tue, Jun 5, 2012 at 6:28 PM, Boris Beranger borisberan...@gmail.com wrote:
 Dear all,

 I have been trying to convert coordinates from longitude/latitude to utm
 but I got an error. As soon as the longitude coordinate is greater than 90,
 I get the folloowing error message:  error in pj_transform: latitude or
 longitude exceeded limits

 Here is what I did:

  SP-SpatialPoints(cbind(126.59,-14.30),proj4string=CRS(+proj=longlat))
 coordinatesUTM-spTransform(SP,CRS(+proj=utm))

 Error in spTransform(SP, CRS(+proj=utm)) :
  error in pj_transform: latitude or longitude exceeded limits

 Can someone explain me what I did wrong? I am using coordinates of
 Australia so the range of my longitudes is around [110,150] and the one of
 my latitudes [-10,-45].

 Thanks in advance,

 Cheers,
 Boris

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



-- 
Michael Sumner
Hobart, Australia
e-mail: mdsum...@gmail.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] mgcv (bam) very large standard error difference between versions 1.7-11 and 1.7-17, bug?

2012-06-05 Thread Martijn Wieling
Dear useRs, Simon,

@Simon: I'll send the data offline.
The command summary(...,freq=F) yields the same result as before. Why
did the default change from freq=F in version 1.7-13 to freq=T in
version 1.7-17? Especially since the original default appeared to be
better.

I noticed that some of my commands were slightly off in the R-example
of my previous e-mail (cut-paste errors...). They should be:

modelLMER - lmer(RefPMIdistMeanLog.c ~ SpYearBirth.z*IsAragon +
SpIsMale + (1|Key), data=wrddst)
print(modelLMER,cor=F)

# using version 1.7-13, default = REML
modelBAMold - bam(RefPMIdistMeanLog.c ~ SpYearBirth.z*IsAragon +
SpIsMale + s(Key,bs=re), data=wrddst)
summary(modelBAMold)

# using version 1.7-17, explicitly stating method=REML
modelBAMnew - bam(RefPMIdistMeanLog.c ~ SpYearBirth.z*IsAragon +
SpIsMale + s(Key,bs=re), data=wrddst, method=REML)
summary(modelBAMnew)
summary(modelBAMnew,freq=F) # same results as modelBAMold

# using version 1.7-17, default: fREML - contains a bug
modelBAMfREML - bam(RefPMIdistMeanLog.c ~ SpYearBirth.z*IsAragon +
SpIsMale + s(Key,bs=re), data=wrddst)
summary(modelBAMfREML)

With kind regards,
Martijn Wieling

--
***
Martijn Wieling
http://www.martijnwieling.nl
wiel...@gmail.com
+31(0)614108622
***
University of Groningen
http://www.rug.nl/staff/m.b.wieling
***


On Sun, Jun 3, 2012 at 7:45 PM, Martijn Wieling wiel...@gmail.com wrote:
 Dear useRs,

 I've ran some additional analyses (see below), which strongly suggest
 the standard errors of the bam (and gam) function are much too low in
 mgcv version 1.7-17, at least when including an s(X,bs=re) term.
 Until this issue has been clarified, it's perhaps best to use an older
 version of mgcv (unfortunately, however, in earlier versions the
 p-value calculation of s(X,bs=re) is not correct). All analyses were
 conducted in R 2.15.0.

 My approach was the following: I created a mixed-effects regression
 model with a single random intercept and only linear predictors. In my
 view, the results using lmer (lme4) should be comparable to those of
 bam and gam (mgcv). This was the case when using an older version of
 mgcv (version 1.7-13), but this is not the case anymore in version
 1.7-17. In version 1.7-17, the standard errors and p-values are much
 lower and very similar to those of a linear model (which does not take
 the random-effects structure into account). The R-code and results are
 shown below. (The results using gam are not shown, but show the same
 pattern.)

 Furthermore, note that the differences in standard errors become less
 severe (but still noticeable) when less data is involved (e.g., using
 only 500 rows as opposed to 100.000). Finally, when not including an
 s(X,bs=re) term, but another non-random-effect smooth, the standard
 errors do not appear to be structurally lower (only for some
 variables, but not by a great deal - see also below).

 With kind regards,
 Martijn Wieling
 University of Groningen

  lme4 model (most recent version of lme4)
 modelLMER - lmer(RefPMIdistMeanLog.c ~ SpYearBirth.z*IsAragon +
 SpIsMale + (1|Key), data=wrddst)
 #                        Estimate Std. Error t value
 #SpYearBirth.z          -0.012084   0.004577  -2.640
 #IsAragon                0.138959   0.010040  13.840
 #SpIsMale               -0.003087   0.008290  -0.372
 #SpYearBirth.z:IsAragon  0.015429   0.010159   1.519


  mgcv 1.7-13, default (method = REML) - almost identical to modelLMER
 modelBAMold - bam(RefPMIdistMeanLog.c ~ SpYearBirth.z*IsAragon +
 SpIsMale + s(Key,bs=re), data=wrddst)
 #                        Estimate Std. Error t value Pr(|t|)
 #SpYearBirth.z          -0.012084   0.004578  -2.640  0.00829 **
 #IsAragon                0.138959   0.010042  13.838   2e-16 ***
 #SpIsMale               -0.003087   0.008292  -0.372  0.70968
 #SpYearBirth.z:IsAragon  0.015429   0.010160   1.519  0.12886


  mgcv 1.7-17, method = REML - standard errors greatly reduced
 # (comparable to standard errors of LM without random intercept)
 modelBAMnew - bam(RefPMIdistMeanLog.c ~ SpYearBirth.z*IsAragon +
 SpIsMale + s(Key,bs=re), data=wrddst); print(testje,cor=F)
 #                        Estimate Std. Error t value Pr(|t|)
 #SpYearBirth.z          -0.012084   0.001159 -10.428   2e-16 ***
 #IsAragon                0.138959   0.002551  54.472   2e-16 ***
 #SpIsMale               -0.003087   0.002098  -1.471    0.141
 #SpYearBirth.z:IsAragon  0.015429   0.002587   5.965 2.45e-09 ***

  lm results, standard errors comparable to mgcv 1.7-17
 modelLM - lm(RefPMIdistMeanLog.c ~ SpYearBirth.z*IsAragon + SpIsMale,
 data=wrddst)
 #                        Estimate Std. Error t value Pr(|t|)
 #(Intercept)            -0.025779   0.001653 -15.595   2e-16 ***
 #SpYearBirth.z          -0.011906   0.001182 -10.070   2e-16 ***
 #IsAragon                0.139323   0.002603  53.531   2e-16 ***
 #SpIsMale          

Re: [R] How to calculate chi sqaure value from statistical value and degrees of freedom?

2012-06-05 Thread Özgür Asar
Hi,

Try

pchisq(q,df)

available at help(Chisquare)

Ozgur

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-calculate-chi-sqaure-value-from-statistical-value-and-degrees-of-freedom-tp4632385p4632386.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] Math labels in .eps files

2012-06-05 Thread Prof Brian Ripley

On 04/06/2012 17:25, Fredrik Karlsson wrote:

Dear list,

I have non-ascii labels that I want to include somethow in a .eps file for
inclusion into a LateX document. Is this possible?

What I see is that the (attached)  png file looks ok but the .eps renders
all non-ascii labels at the bottom as [..].


I've searched around enough to learn that including math labels in a .eps
is a problem. Hower, is there a solution too somewhere?


I don't think it is a problem: see ?plotmath.  But the problem here is 
that you seem to want glyphs not in the plotmath set.


You have neither told us your platform nor the R code you used (as 
requested in the posting guide), so we cannot reproduce this.  But see 
?postscript and its section 'Encodings'.  You need to specify a 
PostScript encoding which contains your glyphs ... if there is one. 
Note too


See Also:

 ‘cairo_ps’ for another device that can produce PostScript.

--
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] how to ignore NA with NA or NULL

2012-06-05 Thread jeff6868
Thanks again but my errors are still here. Is it maybe coming from the next
fonction (I combinate these 2 functions but I thought it was coming from the
first one):

process.all - function(df.list, mat){

f - function(station)
 na.fill(df.list[[ station ]], df.list[[ max.cor[station] ]])
 
g - function(station){
x - df.list[[station]]
if(any(is.na(x[1:8700,1]))){
mat[row(mat) == col(mat)] - -Inf
nas - which(is.na(x[1:8700,1]))
ord - order(mat[station, ], decreasing = TRUE)[-c(1,
ncol(mat))]
for(y in ord){   
if(all(!is.na(df.list[[y]][1:8700,1][nas]))){
xx - df.list[[y]][1:8700,1]
new - data.frame(xx=xx)
x[1:8700,1][nas] - predict(lm(x[1:8700,1]~xx,
na.action=na.exclude), new)[nas]
break
}
}
}
x
} 

n - length(df.list)
nms - names(df.list)
max.cor - sapply(seq.int(n), get.max.cor, corhiver2008capt1)
df.list - lapply(seq.int(n), f)
df.list - lapply(seq.int(n), g)
names(df.list) - nms
df.list
}

refill - process.all(lst, corhiver2008capt1)
refill - as.data.frame(refill)

The error is when refill is created. It applies process.all in which
na.fill is also used. Do you see perhaps any error or missing code which
could create this NA problem when I introduce only NAs files?

--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-ignore-NA-with-NA-or-NULL-tp4632287p4632388.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] par and complex graph

2012-06-05 Thread Francesco Nutini

Dear R-Users, I'd like to have some tips about printing graph. 
I use the command par to print more graphs in one window:par(mfrow=c(6,1)); 
par(oma=c(2.5, 2.5, 2.5, 2.5));  par(mar=c(0.5,4, 0.5, 0.5))

But this command doesn't run with complex graphic command (i.e. xyplot, 
ternaryplot).How can I print more than one graph per page, when I work with 
this elaborated graph?Many thanks!Francesco

  
[[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] Read txt File contains character 

2012-06-05 Thread Rui Barradas

Hello,

Yes, there are ways for R to handle it. You could use readChar/writeChar 
after openning the file in binary mode.

Something like,

len - file.info(test.txt)$size
#len
fc - file(test.txt, open=rb)
s - readChar(fc, nchars=len, useBytes = TRUE)
close(fc)
#grep(\032, s)
s - gsub(\032,  , s)

test.txt is the file I created with the ctrl-z.
Then open=wb/writeChar with useBytes set to TRUE.

Rui Barradas

Em 05-06-2012 07:42, climmi escreveu:

Thank you !  Rui Barradas .

Yes, the arrow character  can not be recoginised by R.
the character will be treat as a stop command...
So I replace all the character  with space, then it works..
Just want to know is there any way for R to handle it.

Not sure does eveybody able to view the character, it's looks like this.
http://r.789695.n4.nabble.com/file/n4632369/arrow.png

--
View this message in context: 
http://r.789695.n4.nabble.com/Read-txt-File-contains-character-tp4632286p4632369.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.


Re: [R] approximating matrix columns

2012-06-05 Thread Rui Barradas

Hello,

Try

apply(mat, 2, approx, method=”linear”, n=365)

This reads apply to each column (dimension = 2) of mat the function 
approx with extra args method and n.


Three notes.
1. Your data does NOT have three list, it IS one list with three vectors.
2. 'matrix' is a function so choose something else as a name. Above I've 
chosen 'mat'.
3. Bert is obviously right. You are wrong in not following simple 
posting instructions. And in not even bothering to quote his post.


Rui Barradas

Em 05-06-2012 09:27, eliza botto escreveu:



Dear Gunter Berton and all,
As
you can see, my data has three lists each containing 366 entries. I converted
them into the matrix. I now want to approx./interpolate 366 entries over 365
intervals, Which means I want to have a matrix with 365 entries.

I
used



approx(matrix, method=”linear”,
n=365)



but
it only converted the first column of my data, and left the rest untouched.





list(c(0.86, 0.86, 0.86, 0.86, 0.86,
1.08, 1.08, 1.08, 1.08,

  1.08, 1.08, 1.4, 1.4, 23, 11.18, 38.83, 23,
3.45, 3.45, 3.45,

  3.45, 3.45, 3.45, 3.45, 3.45, 3.02, 2.58,
2.58, 2.15, 2.15, 2.15,

  2.15, 2.15, 2.15, 2.15, 2.15, 3.02, 1.72,
1.72, 1.72, 1.72, 1.72,

  1.72, 1.72, 1.72, 1.6, 1.6, 1.6, 1.6, 1.6,
1.6, 1.6, 1.6, 1.6,

  1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6,
1.6, 1.6, 1.6, 1.6,

  1.6, 1.6, 1.6, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4,
2.4, 2.8, 2.8, 2.8,

  4.1, 4.1, 13.55, 9.34, 8.32, 7.31, 4.5, 4.1,
14.63, 24.88, 39.99,

  23.69, 14.63, 7.31, 4.5, 7.31, 16.82, 21.35,
24.88, 20.2, 24.88,

  26.07, 30.98, 49.58, 51.01, 26.07, 24.88,
30.98, 34.77, 58.26,

  30.98, 23.69, 26.07, 19.06, 16.82, 20.2,
16.82, 23.69, 14.63,

  16.82, 11.42, 11.42, 11.42, 11.42, 10.38,
10.38, 8.32, 7.31,

  6.31, 16.82, 6.31, 6.31, 6.31, 4.9, 4.9, 4.5,
4.5, 4.5, 4.5,

  4.5, 4.1, 4.1, 2.8, 2.4, 2.4, 26.07, 45.4,
16.82, 7.31, 4.5,

  3.2, 3.2, 2.8, 2.8, 2.4, 2.4, 2.8, 3.2, 3.2,
4.9, 4.9, 36.05,

  65.8, 76.86, 53.87, 26.07, 20.2, 21.36, 14.63,
10.38, 10.38,

  7.31, 7.31, 51.01, 16.82, 14.63, 12.48, 14.63,
10.38, 11.42,

  52.44, 64.27, 36.05, 26.07, 21.36, 21.36,
23.69, 47.79, 52.44,

  167.9, 97.12, 76.86, 144.71, 90.18, 34.77,
30.98, 28.5, 26.07,

  26.07, 14.63, 14.63, 6.31, 6.31, 6.31, 4.5,
4.1, 3.2, 6.31, 6.31,

  16.82, 4.5, 3.2, 3.2, 3.2, 3.2, 4.5, 8.32,
10.38, 10.38, 8.32,

  11.42, 10.38, 7.31, 6.31, 6.31, 6.31, 6.31,
6.31, 6.31, 6.31,

  8.32, 6.31, 6.31, 20.2, 14.63, 7.31, 4.9,
34.77, 26.07, 14.63,

  10.38, 6.31, 4.9, 7.31, 4.9, 4.5, 4.5, 4.5,
21.36, 12.48, 7.31,

  4.5, 4.5, 6.31, 4.9, 4.9, 6.31, 8.32, 7.31,
6.31, 6.31, 14.63,

  11.42, 6.31, 6.31, 4.9, 6.31, 14.63, 7.31,
12.48, 6.31, 6.31,

  24.88, 15.72, 33.49, 111.57, 44.03, 39.99,
44.03, 24.88, 12.48,

  39.99, 11.42, 7.31, 4.9, 4.5, 4.1, 4.5, 4.1,
4.1, 3.2, 3.2, 3.2,

  3.2, 3.2, 2.8, 2.8, 3.2, 3.2, 3.2, 3.2, 3.2,
3.2, 3.2, 2.8, 2.8,

  3.2, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8,
2.8, 2.8, 2.8, 2.8,

  4.1, 4.1, 2.4, 3.2, 10.38, 8.32, 4.5, 3.2,
3.2, 2.8, 3.2, 3.2,

  3.2, 2.4, 2.4, 2.4, 15.72, 23.69, 12.48,
14.63, 4.5, 4.1, 4.5,

  4.1, 4.1, 4.1, 3.2, 2.8, 2.8, 3.2, 2.8, 2.4,
4.5, 4.5, 12.48,

  68.9, 30.98, 39.99, 29.73, 95.37, 44.03,
26.07, 41.33, 49.58,

  23.69, 28.5), c(16.82, 14.63, 6.31, 6.31, 4.5, 4.5, 4.1, 4.1,

  4.1, 3.2, 3.2, 4.1, 3.2, 3.2, 4.1, 4.5, 4.1,
4.1, 167.9, 75.24,

  44.03, 23.69, 19.06, 15.72, 11.42, 8.32, 6.31,
4.9, 6.31, 4.9,

  4.9, 4.1, 4.1, 3.2, 4.1, 4.1, 4.1, 90.18,
102.45, 39.99, 29.73,

  8.32, 21.36, 21.36, 21.36, 12.48, 11.42,
12.48, 11.42, 12.48,

  14.63, 14.63, 15.72, 23.69, 28.5, 29.73,
33.49, 29.73, 23.69,

  21.36, 6.31, 16.82, 15.72, 15.72, 15.72,
15.72, 16.82, 20.2,

  20.2, 21.36, 21.36, 26.07, 28.5, 29.73, 33.49,
29.73, 33.49,

  34.77, 26.07, 26.07, 23.69, 23.69, 26.07,
21.36, 23.69, 23.69,

  23.69, 24.88, 21.36, 20.2, 16.82, 19.06, 20.2,
21.36, 20.2, 20.2,

  24.88, 23.69, 26.07, 29.73, 23.69, 24.88,
29.73, 36.05, 33.49,

  34.77, 28.5, 28.5, 26.07, 153, 70.47, 58.26,
81.77, 36.05, 39.99,

  30.98, 33.49, 28.5, 28.5, 33.49, 29.73, 28.5,
24.88, 30.98, 38.67,

  30.98, 50.01, 65.8, 51.01, 38.67, 34.77,
29.73, 29.73, 33.49,

  30.98, 30.98, 30.98, 33.49, 34.77, 33.49,
30.98, 88.48, 14.63,

  8.32, 19.06, 14.63, 104.25, 44.03, 33.49,
21.36, 20.2, 15.72,

  15.72, 11.42, 7.31, 6.31, 4.9, 4.5, 4.5, 4.5,
3.2, 8.32, 8.32,

  14.63, 97.12, 310.8, 88.48, 36.05, 24.88,
19.06, 14.63, 12.48,

  8.32, 23.69, 11.42, 19.06, 90.18, 90.18,
33.49, 16.82, 70.47,

  38.67, 29.73, 34.77, 33.49, 68.9, 102.45,
176.7, 78.48, 45.4,

  106.06, 83.43, 45.4, 68.9, 39.99, 28.5, 23.69,
20.2, 36.05, 38.67,

  30.98, 26.07, 20.2, 47.79, 52.44, 28.5, 23.69,
20.2, 14.63, 14.63,

  14.63, 12.48, 21.36, 24.88, 47.79, 38.67,
34.77, 21.36, 16.82,

  8.32, 153, 47.79, 53.87, 29.73, 23.69, 15.72,
19.06, 97.12, 

[R] N Gram in textcat

2012-06-05 Thread ashishkalra
Hi, 
I want to use N gram approach for assessing words association and their
placing in a sentence. I have tried textcat package and the syntaxes but it
deals with language classificaiton rather than a user defined
classification. Can someone help me with this?
Basically, I have these two objectives to solve:
1. To specify N in n-gram based on the training data.(Any clue on how to
train my data in textcat???)
2.  To test it on my testing data.

Thanks
Ashish

--
View this message in context: 
http://r.789695.n4.nabble.com/N-Gram-in-textcat-tp4632374.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] Chi square value of anova(binomialglmnull, binomglmmod, test=Chisq)

2012-06-05 Thread lincoln
Thank you for your commentaries and suggestions.

Site 0 and site 1 are interpretable like events. 
In fact these data come from a simultaneous observations of individuals in
two different sites (so they are independent observations: while one
individual is observed in one site it can't be in another). 

Each individual is assigned to age 0 (first year of age), or 1 (all the
rest); even though it may seem a very strong (brutal?) pooling, from a
biological point of view it makes sense given these two classes of
individuals are quite homogeneous in their dispersal behavior within each
age class (0 or 1). The goal of this analysis is just to characterize their
dispersal behavior (which individuals stay home at site 0 and which ones
disperse to site 1?

About the birth issue, here I am more in doubt. Birth relates to the
month of birth (5= May, 6= June, 7= July). It seems to me too it is a quite
severe pooling (one individual born 1st June is 5 as one individual born
30th June but one individual born 30th May or 1st July is 4 or 6 - it
doesn't make much sense). Anyway I didn't find a way to better measure this
variable as there is no a real starting and ending point, more or less
individuals may born since 1st May up to 31th July (I mean in my data set
there are no individuals born before and after these dates).

Any hint?


--
View this message in context: 
http://r.789695.n4.nabble.com/Chi-square-value-of-anova-binomialglmnull-binomglmmod-test-Chisq-tp4632293p4632380.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] Summarizing a matrix

2012-06-05 Thread Özgür Asar
Hi,

x-matrix(0,80,ncol=1)

will create x matrix with all elements 0 (to be filled by the sums that you
need)

sum(y[y[,4]==1,5]) 

will calculate the sum of 5th column of y with 4th column=1

Similarly, 

sum(y[y[,4]==80,5])

 will calculate the sum of 5th column of y with 4th column=80.

You can adapt this to your case, with simple loops, etc.

Hope this helps.
Ozgur

--
View this message in context: 
http://r.789695.n4.nabble.com/Summarizing-a-matrix-tp4632319p4632381.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] How to calculate chi sqaure value from statistical value and degrees of freedom?

2012-06-05 Thread Manish Gupta
Hi,

How to calculate chi sqaure p value for given statistical value and degrees
of freedom.

Input : 
x = statistical value
d = degrees of freedom
output: 
p value = ? 

Regards

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-calculate-chi-sqaure-value-from-statistical-value-and-degrees-of-freedom-tp4632385.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] approximating matrix columns

2012-06-05 Thread eliza botto

Dear Rui,
i am greatful for everything you did. bret advised me to use dput(), which i 
did. yes! i forgot to complement him. i literally feel sorry for that. i hope 
you wont mind and continue extending your help.
regards and love for every one
eliza botto
waters inn

 Date: Tue, 5 Jun 2012 12:46:25 +0100
 From: ruipbarra...@sapo.pt
 To: eliza_bo...@hotmail.com
 CC: r-help@r-project.org
 Subject: Re: approximating matrix columns
 
 Hello,
 
 Try
 
 apply(mat, 2, approx, method=”linear”, n=365)
 
 This reads apply to each column (dimension = 2) of mat the function 
 approx with extra args method and n.
 
 Three notes.
 1. Your data does NOT have three list, it IS one list with three vectors.
 2. 'matrix' is a function so choose something else as a name. Above I've 
 chosen 'mat'.
 3. Bert is obviously right. You are wrong in not following simple 
 posting instructions. And in not even bothering to quote his post.
 
 Rui Barradas
 
 Em 05-06-2012 09:27, eliza botto escreveu:
 
 
  Dear Gunter Berton and all,
  As
  you can see, my data has three lists each containing 366 entries. I 
  converted
  them into the matrix. I now want to approx./interpolate 366 entries over 365
  intervals, Which means I want to have a matrix with 365 entries.
 
  I
  used
 
 
 
  approx(matrix, method=”linear”,
  n=365)
 
 
 
  but
  it only converted the first column of my data, and left the rest untouched.
 
 
 
 
 
  list(c(0.86, 0.86, 0.86, 0.86, 0.86,
  1.08, 1.08, 1.08, 1.08,
 
1.08, 1.08, 1.4, 1.4, 23, 11.18, 38.83, 23,
  3.45, 3.45, 3.45,
 
3.45, 3.45, 3.45, 3.45, 3.45, 3.02, 2.58,
  2.58, 2.15, 2.15, 2.15,
 
2.15, 2.15, 2.15, 2.15, 2.15, 3.02, 1.72,
  1.72, 1.72, 1.72, 1.72,
 
1.72, 1.72, 1.72, 1.6, 1.6, 1.6, 1.6, 1.6,
  1.6, 1.6, 1.6, 1.6,
 
1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6,
  1.6, 1.6, 1.6, 1.6,
 
1.6, 1.6, 1.6, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4,
  2.4, 2.8, 2.8, 2.8,
 
4.1, 4.1, 13.55, 9.34, 8.32, 7.31, 4.5, 4.1,
  14.63, 24.88, 39.99,
 
23.69, 14.63, 7.31, 4.5, 7.31, 16.82, 21.35,
  24.88, 20.2, 24.88,
 
26.07, 30.98, 49.58, 51.01, 26.07, 24.88,
  30.98, 34.77, 58.26,
 
30.98, 23.69, 26.07, 19.06, 16.82, 20.2,
  16.82, 23.69, 14.63,
 
16.82, 11.42, 11.42, 11.42, 11.42, 10.38,
  10.38, 8.32, 7.31,
 
6.31, 16.82, 6.31, 6.31, 6.31, 4.9, 4.9, 4.5,
  4.5, 4.5, 4.5,
 
4.5, 4.1, 4.1, 2.8, 2.4, 2.4, 26.07, 45.4,
  16.82, 7.31, 4.5,
 
3.2, 3.2, 2.8, 2.8, 2.4, 2.4, 2.8, 3.2, 3.2,
  4.9, 4.9, 36.05,
 
65.8, 76.86, 53.87, 26.07, 20.2, 21.36, 14.63,
  10.38, 10.38,
 
7.31, 7.31, 51.01, 16.82, 14.63, 12.48, 14.63,
  10.38, 11.42,
 
52.44, 64.27, 36.05, 26.07, 21.36, 21.36,
  23.69, 47.79, 52.44,
 
167.9, 97.12, 76.86, 144.71, 90.18, 34.77,
  30.98, 28.5, 26.07,
 
26.07, 14.63, 14.63, 6.31, 6.31, 6.31, 4.5,
  4.1, 3.2, 6.31, 6.31,
 
16.82, 4.5, 3.2, 3.2, 3.2, 3.2, 4.5, 8.32,
  10.38, 10.38, 8.32,
 
11.42, 10.38, 7.31, 6.31, 6.31, 6.31, 6.31,
  6.31, 6.31, 6.31,
 
8.32, 6.31, 6.31, 20.2, 14.63, 7.31, 4.9,
  34.77, 26.07, 14.63,
 
10.38, 6.31, 4.9, 7.31, 4.9, 4.5, 4.5, 4.5,
  21.36, 12.48, 7.31,
 
4.5, 4.5, 6.31, 4.9, 4.9, 6.31, 8.32, 7.31,
  6.31, 6.31, 14.63,
 
11.42, 6.31, 6.31, 4.9, 6.31, 14.63, 7.31,
  12.48, 6.31, 6.31,
 
24.88, 15.72, 33.49, 111.57, 44.03, 39.99,
  44.03, 24.88, 12.48,
 
39.99, 11.42, 7.31, 4.9, 4.5, 4.1, 4.5, 4.1,
  4.1, 3.2, 3.2, 3.2,
 
3.2, 3.2, 2.8, 2.8, 3.2, 3.2, 3.2, 3.2, 3.2,
  3.2, 3.2, 2.8, 2.8,
 
3.2, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8,
  2.8, 2.8, 2.8, 2.8,
 
4.1, 4.1, 2.4, 3.2, 10.38, 8.32, 4.5, 3.2,
  3.2, 2.8, 3.2, 3.2,
 
3.2, 2.4, 2.4, 2.4, 15.72, 23.69, 12.48,
  14.63, 4.5, 4.1, 4.5,
 
4.1, 4.1, 4.1, 3.2, 2.8, 2.8, 3.2, 2.8, 2.4,
  4.5, 4.5, 12.48,
 
68.9, 30.98, 39.99, 29.73, 95.37, 44.03,
  26.07, 41.33, 49.58,
 
23.69, 28.5), c(16.82, 14.63, 6.31, 6.31, 4.5, 4.5, 4.1, 4.1,
 
4.1, 3.2, 3.2, 4.1, 3.2, 3.2, 4.1, 4.5, 4.1,
  4.1, 167.9, 75.24,
 
44.03, 23.69, 19.06, 15.72, 11.42, 8.32, 6.31,
  4.9, 6.31, 4.9,
 
4.9, 4.1, 4.1, 3.2, 4.1, 4.1, 4.1, 90.18,
  102.45, 39.99, 29.73,
 
8.32, 21.36, 21.36, 21.36, 12.48, 11.42,
  12.48, 11.42, 12.48,
 
14.63, 14.63, 15.72, 23.69, 28.5, 29.73,
  33.49, 29.73, 23.69,
 
21.36, 6.31, 16.82, 15.72, 15.72, 15.72,
  15.72, 16.82, 20.2,
 
20.2, 21.36, 21.36, 26.07, 28.5, 29.73, 33.49,
  29.73, 33.49,
 
34.77, 26.07, 26.07, 23.69, 23.69, 26.07,
  21.36, 23.69, 23.69,
 
23.69, 24.88, 21.36, 20.2, 16.82, 19.06, 20.2,
  21.36, 20.2, 20.2,
 
24.88, 23.69, 26.07, 29.73, 23.69, 24.88,
  29.73, 36.05, 33.49,
 
34.77, 28.5, 28.5, 26.07, 153, 70.47, 58.26,
  81.77, 36.05, 39.99,
 
30.98, 33.49, 28.5, 28.5, 33.49, 29.73, 28.5,
  24.88, 30.98, 38.67,
 
30.98, 50.01, 65.8, 51.01, 38.67, 34.77,
 

Re: [R] get index of current element in vector

2012-06-05 Thread Uwe Ligges



On 05.06.2012 00:36, Erdal Karaca wrote:

Thanks all, that worked!

Yes, it should be
for (i in 1:length(a)) a[i]- scalar * a[i] * i

And now is...

a- a * scalar * seq_along(a)

That is almost as cool as the PERL programming language :-)



Almost?

Uwe Ligges




2012/6/4 Rui Barradasruipbarra...@sapo.pt


Hello,

Just learning the alphabet? If yes, there's a difference between 'v' and
'a'.

Now more seriously. Your description and your loop don't do the same.

Description:
vm- scalar * v * seq_along(v)

Loop:
a- scalar * a

Also, seq_along is the way to do it, it works even if length(a) == 0.

Hope this helps,

Rui Barradas

Em 04-06-2012 21:25, Erdal Karaca escreveu:


(Just learning R)

I have this vector:

v- c(1:10)

Now, I want to multiply each element of that vector with a scalar value
multiplied with its index:

vm- v * scalar * indexOfCurrentElementOf_v

Is that possible without using a loop?

In a loop I would do this:

for (i in 1:length(a)) a[i]- scalar * a[i]

[[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-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] get index of current element in vector

2012-06-05 Thread jim holtman
Do we need an Obfuscated R contest?

On Tue, Jun 5, 2012 at 8:17 AM, Uwe Ligges
lig...@statistik.tu-dortmund.de wrote:


 On 05.06.2012 00:36, Erdal Karaca wrote:

 Thanks all, that worked!

 Yes, it should be
 for (i in 1:length(a)) a[i]- scalar * a[i] * i

 And now is...

 a- a * scalar * seq_along(a)

 That is almost as cool as the PERL programming language :-)



 Almost?

 Uwe Ligges




 2012/6/4 Rui Barradasruipbarra...@sapo.pt

 Hello,

 Just learning the alphabet? If yes, there's a difference between 'v' and
 'a'.

 Now more seriously. Your description and your loop don't do the same.

 Description:
 vm- scalar * v * seq_along(v)

 Loop:
 a- scalar * a

 Also, seq_along is the way to do it, it works even if length(a) == 0.

 Hope this helps,

 Rui Barradas

 Em 04-06-2012 21:25, Erdal Karaca escreveu:

 (Just learning R)

 I have this vector:

 v- c(1:10)

 Now, I want to multiply each element of that vector with a scalar value
 multiplied with its index:

 vm- v * scalar * indexOfCurrentElementOf_v

 Is that possible without using a loop?

 In a loop I would do this:

 for (i in 1:length(a)) a[i]- scalar * a[i]

        [[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-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
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

__
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] get index of current element in vector

2012-06-05 Thread Uwe Ligges



On 05.06.2012 14:46, jim holtman wrote:

Do we need an Obfuscated R contest?



I already know potential winners

Uwe







On Tue, Jun 5, 2012 at 8:17 AM, Uwe Ligges
lig...@statistik.tu-dortmund.de  wrote:



On 05.06.2012 00:36, Erdal Karaca wrote:


Thanks all, that worked!

Yes, it should be
for (i in 1:length(a)) a[i]- scalar * a[i] * i

And now is...

a- a * scalar * seq_along(a)

That is almost as cool as the PERL programming language :-)




Almost?

Uwe Ligges





2012/6/4 Rui Barradasruipbarra...@sapo.pt


Hello,

Just learning the alphabet? If yes, there's a difference between 'v' and
'a'.

Now more seriously. Your description and your loop don't do the same.

Description:
vm- scalar * v * seq_along(v)

Loop:
a- scalar * a

Also, seq_along is the way to do it, it works even if length(a) == 0.

Hope this helps,

Rui Barradas

Em 04-06-2012 21:25, Erdal Karaca escreveu:


(Just learning R)

I have this vector:

v- c(1:10)

Now, I want to multiply each element of that vector with a scalar value
multiplied with its index:

vm- v * scalar * indexOfCurrentElementOf_v

Is that possible without using a loop?

In a loop I would do this:

for (i in 1:length(a)) a[i]- scalar * a[i]

[[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-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 with the predict function

2012-06-05 Thread Joachim Audenaert
Hi all,

I would like to predict some values for an nls regression function 
(functional response model Rogers type II). This is an asymptotic function 
of which I would like to predict the asymptotic value
I estimated the paramters with nls, but can't seem to get predictions for 
values of m choice..
This is my script:

RogersII_N - 
nls(FR~N0-lambertW(attackR3_N*Th3_N*N0*exp(-attackR3_N*(24-Th3_N*N0)))/(attackR3_N*Th3_N),start=list(attackR3_N=0.04,Th3_N=1.46),control=list(maxiter=1))
lista - c(1,2,100,1000)
predict(RogersII_N,newdata=lista)

I created a list (lista) with some values of which I would like the 
predict function to give me function values

What am I doing wrong?

Kind regards,
Met vriendelijke groeten,
Joachim

Don't waste paper! Think about the environment before printing this e-mail

__

Joachim Audenaert
Adviesdienst Gewasbescherming
Proefcentrum voor Sierteelt
Schaessestraat 18
B-9070 Destelbergen
Belgium
Tel. +32 9 353 94 71
Fax +32 9 353 94 95
E-mail: joachim.audena...@pcsierteelt.be
www.pcsierteelt.be
__
[[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] how to calculating the p vaules of Canonical correlation analysis in vegan package

2012-06-05 Thread Xinhui Wang
Dear R users,
currently, i am working on the canonical correlation analysis (R package
vegan or CCA). I have a trouble to calculate the pvalue of the association
between each dependent variable and each independent variable, also i want
to calculate the pvalue of the association between a dependent variable
with the whole set of the independent variable. I tried it, unfortunately,
no results could be achieved. it will be greatly appreciated if any one
could help us.
With best regards,
Alex

[[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] Chi square value of anova(binomialglmnull, binomglmmod, test=Chisq)

2012-06-05 Thread David Winsemius


On Jun 5, 2012, at 4:52 AM, lincoln wrote:


Thank you for your commentaries and suggestions.

Site 0 and site 1 are interpretable like events.
In fact these data come from a simultaneous observations of  
individuals in

two different sites (so they are independent observations: while one
individual is observed in one site it can't be in another).

Each individual is assigned to age 0 (first year of age), or  
1 (all the

rest); even though it may seem a very strong (brutal?) pooling, from a
biological point of view it makes sense given these two classes of
individuals are quite homogeneous in their dispersal behavior within  
each
age class (0 or 1). The goal of this analysis is just to  
characterize their
dispersal behavior (which individuals stay home at site 0 and which  
ones

disperse to site 1?


This is making me think you really have multiple observation on the  
same individuals (and that persons make transitions from one state to  
another as a result of the passage of time. That needs a more complex  
analysis than simple logistic regression. You might consider posting  
a more complete description of the study on the SIG Mixed Effects  
mailing list.


--
David.



About the birth issue, here I am more in doubt. Birth relates to  
the
month of birth (5= May, 6= June, 7= July). It seems to me too it is  
a quite
severe pooling (one individual born 1st June is 5 as one individual  
born

30th June but one individual born 30th May or 1st July is 4 or 6 - it
doesn't make much sense). Anyway I didn't find a way to better  
measure this

variable as there is no a real starting and ending point, more or less
individuals may born since 1st May up to 31th July (I mean in my  
data set

there are no individuals born before and after these dates).

Any hint?


--
View this message in context: 
http://r.789695.n4.nabble.com/Chi-square-value-of-anova-binomialglmnull-binomglmmod-test-Chisq-tp4632293p4632380.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.


David Winsemius, MD
West Hartford, CT

__
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] Converiting longitude/latitude to utm

2012-06-05 Thread David L Carlson
You might try R-Sig-Geo for the reasons, but you need to include the UTM
zone to convert:

SP-SpatialPoints(cbind(126.59,-14.30),proj4string=CRS(+proj=longlat))
SP

SpatialPoints:
 coords.x1 coords.x2
[1,]126.59 -14.3
Coordinate Reference System (CRS) arguments: +proj=longlat +ellps=WGS84

coordinatesUTM-spTransform(SP,CRS(+proj=utm +zone=52))
coordinatesUTM

SpatialPoints:
 coords.x1 coords.x2
[1,]  240015.6  -1582256
Coordinate Reference System (CRS) arguments: +proj=utm +zone=52
+ellps=WGS84

--
David L Carlson
Associate Professor of Anthropology
Texas AM University
College Station, TX 77843-4352



 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Boris Beranger
 Sent: Tuesday, June 05, 2012 3:29 AM
 To: R-help@r-project.org
 Subject: [R] Converiting longitude/latitude to utm
 
 Dear all,
 
 I have been trying to convert coordinates from longitude/latitude to
 utm
 but I got an error. As soon as the longitude coordinate is greater than
 90,
 I get the folloowing error message:  error in pj_transform: latitude
 or
 longitude exceeded limits
 
 Here is what I did:
 
  SP-SpatialPoints(cbind(126.59,-
 14.30),proj4string=CRS(+proj=longlat))
 coordinatesUTM-spTransform(SP,CRS(+proj=utm))
 
 Error in spTransform(SP, CRS(+proj=utm)) :
   error in pj_transform: latitude or longitude exceeded limits
 
 Can someone explain me what I did wrong? I am using coordinates of
 Australia so the range of my longitudes is around [110,150] and the one
 of
 my latitudes [-10,-45].
 
 Thanks in advance,
 
 Cheers,
 Boris
 
   [[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.


Re: [R] - help with the predict function

2012-06-05 Thread Ben Bolker
Joachim Audenaert Joachim.Audenaert at pcsierteelt.be writes:

 
 Hi all,
 
 I would like to predict some values for an nls regression function 
 (functional response model Rogers type II). This is an asymptotic function 
 of which I would like to predict the asymptotic value
 I estimated the paramters with nls, but can't seem to get predictions for 
 values of m choice..
 This is my script:
 
 RogersII_N - 
 nls(FR~N0-lambertW(attackR3_N*Th3_N*N0*
 exp(-attackR3_N*(24-Th3_N*N0)))/(attackR3_N*Th3_N),
 start=list(attackR3_N=0.04,Th3_N=1.46),control=list(maxiter=1))
 lista - c(1,2,100,1000)
 predict(RogersII_N,newdata=lista)
 
 I created a list (lista) with some values of which I would like the 
 predict function to give me function values
 
 What am I doing wrong?
 

  If you want to use the predict() function, it is best
(necessary?) to use the form of nls() where you pass data
explicitly within a data frame, as the data= argument, instead
of using variables in the global workspace.  Also: for this
model, the asymptotic value is (time/(handling time)) = 24/Th3_N ...
so you don't really need predict() (although it is still useful)

library(emdbook)
rogers.pred - function(N0,a,h,T) {
N0 - lambertW(a*h*N0*exp(-a*(T-h*N0)))/(a*h)
}

params0 - list(attackR3_N=0.05,Th3_N=1.5)
params1 - list(attackR3_N=0.04,Th3_N=1.46)

dat - expand.grid(N0=1:20,rep=1:10)
dat$FR0 - with(c(dat,params0),
rogers.pred(N0,a=attackR3_N,h=Th3_N,T=24))
par(las=1,bty=l)
with(dat,plot(N0,FR0,ylim=c(0,12)))
set.seed(101)
dat$FR - rnorm(nrow(dat),dat$FR0,sd=1)
with(dat,points(N0,FR,col=rgb(1,0,0,alpha=0.5)))
RogersII_N - nls(FR~rogers.pred(N0,attackR3_N,Th3_N,T=24),
  start=params1,data=dat,control=list(maxiter=1))
lista - c(1,2,100,1000,1)
predict(RogersII_N,newdata=data.frame(N0=lista))
N0vec - 1:20
lines(N0vec,predict(RogersII_N,newdata=data.frame(N0=N0vec)),
  col=4)
with(as.list(coef(RogersII_N)),24/Th3_N)

__
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] ggplot2, grid graphics, x11(), windows(), and device fonts

2012-06-05 Thread Robert Baer
I am trying to use ggplot() to produce a graph and am getting warnings that 
I don't understand.  This is happening from within RStudio, but also happens 
if I start Windows R GUI.   Can anyone help me understand the warning and 
how to make sure the right fonts are designated?  The relevant code fragment 
is:


x11(width=7, height = 7)
library(ggplot2)
# Now some Distance ~ Time plots
p2 - ggplot(lu.mig, aes(x=Time, y=Net.Distance, colour = PlateRow)) +
 geom_point(size= 3) +
 geom_line(size=1) +
 facet_grid(Substrate ~ Expression) +
 xlab(Time After Scratch (h)) +
 ylab(Net half-distance (um)) +
 opts(title='Repaired Raw 1205Lu Scratch Time Course') +
 theme_bw(base_size = 18, base_family = )
print(p2)

The warnings are:
There were 22 warnings (use warnings() to see them)


warnings()

Warning messages:
1: Removed 1 rows containing missing values (geom_point).
2: Removed 1 rows containing missing values (geom_path).
3: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
 Font family not found in Windows font database
4: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
 Font family not found in Windows font database
...  snip ...   # repeat same warning
22: In grid.Call.graphics(L_text, as.graphicsAnnot(x$label),  ... :
 Font family not found in Windows font database

If I comment out,
   x11(width=7, height = 7)
so that the plot is drawn to the RStudio graphics device (or the default 
device in R GUI), I only get the expected first two warnings.  As I have 
traced through the documentation I've seen reference to an 'Rdevga’ that may 
be a culprit, but I can't quite understand how I set this up properly.  Any 
debugging pointers?


It also seems that if I replace x11() with windows(), the warnings 
disappear.  Somewhere (wrongly, I guess) I had gotten the impression that 
x11() on the windows platform behaved just like windows().  For now, I've 
just reverted to using windows(), but I'd like to understand this better, 
particularly how to be certain ggplot() (or grid()) will be able to find a 
default font.  Of course, despite the warnings the graph draws fine so it 
could be something to evaluation in ggplot.


Thanks,
Rob


R.Version()

$platform
[1] i386-pc-mingw32

$arch
[1] i386

$os
[1] mingw32

$system
[1] i386, mingw32

$status
[1] 

$major
[1] 2

$minor
[1] 15.0

$year
[1] 2012

$month
[1] 03

$day
[1] 30

$`svn rev`
[1] 58871

$language
[1] R

$version.string
[1] R version 2.15.0 (2012-03-30)

$nickname
[1] 


C:\Users\rbaerpath
PATH=C:\Perl\site\bin;C:\Perl\bin;C:\Program Files\GTK\bin;C:\Program 
Files\ImageMagick-6.7.6-Q16;C:\Program Files\Mende
ley Desktop\wordPlugin;C:\Program Files\Common Files\Microsoft 
Shared\Windows Live;c:\Rtools\bin;c:\Rtools\perl\bin;c:\R

tools\MinGW\bin;c:\Rtools\MinGW64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\Window
sPowerShell\v1.0\;C:\Program Files\Microsoft Application Virtualization 
Client;C:\Program Files\WIDCOMM\Bluetooth Softwa
re\;C:\Program Files\Windows Live\Shared;C:\Program Files\MiKTeX 
2.9\miktex\bin\;C:\Program Files\QuickTime\QTSystem\;C:

\GTK\bin;


--
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A. T. Still University of Health Sciences
800 W. Jefferson St.
Kirksville, MO 63501
660-626-2322
FAX 660-626-2965 


__
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 to ignore NA with NA or NULL

2012-06-05 Thread Rui Barradas

Hello,

I believe the error is in function 'g'. If I'm right, follow these steps

1. Just before the first if include
flag - TRUE
2. Just before for(y in ord) include
flag - FALSE
3. Just before break include
flag - TRUE
3. Change the return value form simply x to
if(flag) x else NA


The code loops through the ordered matrix until it finds no NAs in the 
respective df.list element. Nothing guarantees that there are such list 
elements. The changes above check it by setting a flag.


Rui Barradas

Em 05-06-2012 10:54, jeff6868 escreveu:

Thanks again but my errors are still here. Is it maybe coming from the next
fonction (I combinate these 2 functions but I thought it was coming from the
first one):

process.all- function(df.list, mat){

 f- function(station)
  na.fill(df.list[[ station ]], df.list[[ max.cor[station] ]])

 g- function(station){
 x- df.list[[station]]
 if(any(is.na(x[1:8700,1]))){
 mat[row(mat) == col(mat)]- -Inf
 nas- which(is.na(x[1:8700,1]))
 ord- order(mat[station, ], decreasing = TRUE)[-c(1,
ncol(mat))]
 for(y in ord){
 if(all(!is.na(df.list[[y]][1:8700,1][nas]))){
 xx- df.list[[y]][1:8700,1]
 new- data.frame(xx=xx)
 x[1:8700,1][nas]- predict(lm(x[1:8700,1]~xx,
na.action=na.exclude), new)[nas]
 break
 }
 }
 }
 x
 }

 n- length(df.list)
 nms- names(df.list)
 max.cor- sapply(seq.int(n), get.max.cor, corhiver2008capt1)
 df.list- lapply(seq.int(n), f)
 df.list- lapply(seq.int(n), g)
 names(df.list)- nms
 df.list
 }

 refill- process.all(lst, corhiver2008capt1)
 refill- as.data.frame(refill)

The error is when refill is created. It applies process.all in which
na.fill is also used. Do you see perhaps any error or missing code which
could create this NA problem when I introduce only NAs files?

--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-ignore-NA-with-NA-or-NULL-tp4632287p4632388.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] Fourier descriptors created in a loop

2012-06-05 Thread aledanda
Hi All,

Here is the problem: I'm trying to generate a number of Fourier Descriptors
figures for an experiment.
All I need is that they are created within a  loop and saved with sequential
names (e.g., s1_1.png, s1_2.png etc..) in my directory. 

I created a nested loop with a counter for the different amplitudes for the
actual shapes and a counter for the file names.  

This script:


*count - seq(1, 7, 0.06)

for (i in 1:count){
  for (s in 1:length(count)){

png(~/Desktop/EMAS/FD_stimuli/s1_,s,.png)

plot(create.fourier.descriptor(amplitude = c(0, i, 0, 0)));

dev.off()

  }
}*

 gives me the following error:

/Error in switch(units, `in` = res, cm = res/2.54, mm = res/25.4, px = 1) * 
: 
  non-numeric argument to binary operator
In addition: Warning message:
In 1:count : numerical expression has 101 elements: only the first used/

it seems to be a problem with the resolution of each picture which is
different one form the other. In principle this shouldn't be a problem if
every time a new png is created.

could you help me with this?
Thank you very much
Best,

Ale

--
View this message in context: 
http://r.789695.n4.nabble.com/Fourier-descriptors-created-in-a-loop-tp4632414.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] plot background - excel gradient style background ?

2012-06-05 Thread jcrosbie
I'm not the one who is choosing to use gradient background. It's our company
policy.  

--
View this message in context: 
http://r.789695.n4.nabble.com/plot-background-excel-gradient-style-background-tp4632138p4632409.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] need descriptive help

2012-06-05 Thread mkm1616
Hi all, I'm new to using R, and apologize for simplicity of this
question.

I'm using a data set with over 60,000 observations, Two variables are
patient ID, and cost incurred by the patient.  I'd like to generate
frequency/table by patient and cost IF the total cost is over 2000.

Right now I'm using:

by(x$cost, x$patient, sum)

but this generates a huge list for each patient.

What is the best way to either (1) export the output into a csv so I
can visually inspect each patient or more helpful (2) create the table
IF sum of cost  1000

Thanks!

__
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] nls: how do you know if the model is significant?

2012-06-05 Thread Nerak
Hi all,
I'm struggling with nls. How do you know if your model is significant? For a
lm, you get a p-value, but you don't get it for a nls. Is there a way to
calculate it?

For a lm I use this:
  a-summary(lm(model ~obs))
  f.stat-a$fstatistic
  p.value-1-pf(f.stat[value],f.stat[numdf],f.stat[dendf])

Is there something similar for a nls?


The kind of output that I get is:


Formula: y ~ exp.f(x, a, b)

Parameters:
   Estimate Std. Error t value Pr(|t|)
a 1.381e+02  1.192e+01  11.583 3.19e-08 ***
b 1.790e-02  2.459e-03   7.279 6.19e-06 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 13.21 on 13 degrees of freedom

Number of iterations to convergence: 6 
Achieved convergence tolerance: 9.123e-06 


I know that my parameters are significant but I need to say something about
the whole model.

Many thanks,
Nerak




--
View this message in context: 
http://r.789695.n4.nabble.com/nls-how-do-you-know-if-the-model-is-significant-tp4632401.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] multiple comparisons with generalised least squares

2012-06-05 Thread racmar
Hi Sandy,

I was wondering if you ever recieved an answer regarding the use of multiple
comparisons for gls models? 
I have also been searching various forums and books to see if there are any
methods I could use and have only found people, such as yourself, asking the
same question. 

Many thanks if you can give any assistance,

Rachel

--
View this message in context: 
http://r.789695.n4.nabble.com/multiple-comparisons-with-generalised-least-squares-tp3441513p4632412.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] rowSums problem

2012-06-05 Thread alonis10
I'm having a very frustrating problem, trying to find the inverse distance
squared weighted interpolants of some weather data.

I have a data frame of weights, which sum to 1.  I have attached the weights
data. I also have a data frame of temperatures at 48 grid points, which I
have also attached.

Now, all I need to do is multiply all of the rows of the temperature data
frame by the weights (element-wise), and sum across the columns. 

However, when I try to use the most obvious approach, 

temp3880W -  weight3880*temp[,(3:50)]
temp3880W - rowsum(temp3880W)


I get the wrong result:


head(temp3880W)
 1  2  3  4  5  6 
-0.4904454 -1.2728543 -1.5360133 -0.2687030 62.3048012  6.2610305 



I've only been successful by using a for loop which is far too slow:

temp3880 - rep(0,length(temp$Year))

for (i in 1:length(temp$Year)) {
wmul - weight3880*as.vector(temp[i,(3:50)])
temp3880[i] - sum(wmul)
}


This gives the result

head(temp3880)
[1] -6.936374 -9.617799 -7.227260  1.135293  8.973817 13.632454



Can anyone point out to me what is going wrong here? I've tried the first
approach with smaller data frames and vectors and it seems to work fine, so
I must be making a mistake somewhere...

Thank you!





--
View this message in context: 
http://r.789695.n4.nabble.com/rowSums-problem-tp4632405.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] rowSums problem

2012-06-05 Thread alonis10
http://r.789695.n4.nabble.com/file/n4632406/temp3880.csv temp3880.csv 
http://r.789695.n4.nabble.com/file/n4632406/weight3880.csv weight3880.csv 

Here are the files I promised to upload.

--
View this message in context: 
http://r.789695.n4.nabble.com/rowSums-problem-tp4632405p4632406.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] need descriptive help

2012-06-05 Thread Bert Gunter
1. Before you post to this list again, please read An Introd to R --
or other basic R tutorial. Intro ships with every R installation.
There's a reason for this -- to avoid badgering this list with basic R
queries that minimal homework could answer.

2. However, see also ?table and links therein.

3. ?[ and ?subset are also relevant.

-- Bert

On Tue, Jun 5, 2012 at 8:34 AM, mkm1616 mkm1...@gmail.com wrote:
 Hi all, I'm new to using R, and apologize for simplicity of this
 question.

 I'm using a data set with over 60,000 observations, Two variables are
 patient ID, and cost incurred by the patient.  I'd like to generate
 frequency/table by patient and cost IF the total cost is over 2000.

 Right now I'm using:

 by(x$cost, x$patient, sum)

 but this generates a huge list for each patient.

 What is the best way to either (1) export the output into a csv so I
 can visually inspect each patient or more helpful (2) create the table
 IF sum of cost  1000

 Thanks!

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.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] nls: how do you know if the model is significant?

2012-06-05 Thread Bert Gunter
I suggest you consult a local statistician. You could also post to a
statistical help list like stats.stackexchange.com. Your query has
nothing to do with R, but is rather about the meaningfulness (or lack
thereof) of statistical significance in nonlinear modeling.

-- Bert

On Tue, Jun 5, 2012 at 6:49 AM, Nerak nera...@hotmail.com wrote:
 Hi all,
 I'm struggling with nls. How do you know if your model is significant? For a
 lm, you get a p-value, but you don't get it for a nls. Is there a way to
 calculate it?

 For a lm I use this:
  a-summary(lm(model ~obs))
  f.stat-a$fstatistic
  p.value-1-pf(f.stat[value],f.stat[numdf],f.stat[dendf])

 Is there something similar for a nls?


 The kind of output that I get is:


 Formula: y ~ exp.f(x, a, b)

 Parameters:
   Estimate Std. Error t value Pr(|t|)
 a 1.381e+02  1.192e+01  11.583 3.19e-08 ***
 b 1.790e-02  2.459e-03   7.279 6.19e-06 ***
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 Residual standard error: 13.21 on 13 degrees of freedom

 Number of iterations to convergence: 6
 Achieved convergence tolerance: 9.123e-06


 I know that my parameters are significant but I need to say something about
 the whole model.

 Many thanks,
 Nerak




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/nls-how-do-you-know-if-the-model-is-significant-tp4632401.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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.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] need descriptive help

2012-06-05 Thread Rui Barradas

Hello,

Try

Total - aggregate(cost~patient, data=x)
Total[Total$cost  1000, ]

As for writing to a csv file, see ?write.csv

Hope this helps,

Rui Barradas

Em 05-06-2012 16:34, mkm1616 escreveu:

Hi all, I'm new to using R, and apologize for simplicity of this
question.

I'm using a data set with over 60,000 observations, Two variables are
patient ID, and cost incurred by the patient.  I'd like to generate
frequency/table by patient and cost IF the total cost is over 2000.

Right now I'm using:

by(x$cost, x$patient, sum)

but this generates a huge list for each patient.

What is the best way to either (1) export the output into a csv so I
can visually inspect each patient or more helpful (2) create the table
IF sum of cost  1000

Thanks!

__
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] NADA Applied to my Data

2012-06-05 Thread Rich Shepard

  I need a nudge in the right direction to get started using NADA. I bought
Helsel's second addition and am currently reading it; NADA is installed in
R.

  My data has been restructured with a couple of awk scripts. The data frame
structure now has a flag if the quantity is censored (ceneq1 column) as well
as a lower and upper limit for censored data. For present purposes, interval
censoring can be ignored. The data frame structure is now:

str(waterchem)
'data.frame':   46551 obs. of  7 variables:
 $ site: Factor w/ 126 levels BC-0.5,BC-1,..: 22 22 22 13 3 13 ...
 $ sampdate: Date, format: 1996-05-22 1996-07-19 ...
 $ param   : Factor w/ 58 levels -0.100,AGP,..: 47 58 10 16 16 26 ...
 $ quant   : num  0.01 7.69 0.02 63.8 120 0.02 399 439 2 433 ...
 $ ceneq1  : int  1 0 0 0 0 0 0 0 0 0 ...
 $ low : num  0 7.69 0.02 63.8 120 0.02 399 439 2 433 ...
 $ high: num  0.01 7.69 0.02 63.8 120 0.02 399 439 2 433 ...

  What I want to first learn is how to specify a box plot (and whether I can
use the lattice package) for specific chemicals.

?cenboxplot shows me the arguments, but I'm not entering them correctly, or
there's a prerequisite step I need to take:

cenboxplot(waterchem$quant, waterchem$ceneq1, group='SO4', log=T, range=1.5)
Error in function (classes, fdef, mtable)  :
  unable to find an inherited method for function ros, for signature
numeric, integer

  Perhaps cenboxplot is looking for a separate data set and not a data
frame? Or, perhaps I need to melt and re-cast the data frame to the wide
format from the current narrow format? Pointers appreciated.

Rich

__
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] community finding in a graph and heatplot

2012-06-05 Thread Aziz, Muhammad Fayez

Superb. It works. The results loo great. I just tweaked the function a little 
bit to suit my needs though. I passed merges and vcount separately as 
fgc$merges and vcount(g). The vcount attribute was not there in fgc object. 
Also, I removed the last row from the merges matrix before returning as it was 
adding the very root level undesired by the heatmap.2 function I was using. The 
final function looks like this:

# To generate a complete dendogram from disconnected subgraphs in merges given 
by fgc
complete.dend - function(merges, vcount) {
  if (nrow(merges)  vcount-1) {
miss - seq_len(vcount + nrow(merges))[-as.vector(merges)]
miss - c(miss, seq_len(length(miss)-2) + vcount+nrow(merges))
miss - matrix(miss, byrow=TRUE, ncol=2)
merges - rbind(merges, miss)
  }
  storage.mode(merges) - integer

  merges[-nrow(merges),] # skip last row
}

Thank you so much Gabor for this custom complete.dend fucntion. I couldn't find 
it in the regular igraph library 
(http://igraph.sourceforge.net/doc/R/00Index.html).

Best,
Fayez


From: csardi.ga...@gmail.com [csardi.ga...@gmail.com] on behalf of Gábor Csárdi 
[csa...@rmki.kfki.hu]
Sent: Monday, June 04, 2012 6:33 PM
To: Aziz, Muhammad Fayez
Cc: r-help@r-project.org; Caetano-Anolles, Gustavo
Subject: Re: [R] community finding in a graph and heatplot

On Sun, Jun 3, 2012 at 4:11 PM, Aziz, Muhammad Fayez az...@illinois.edu wrote:

 Hmm interesting. To come to think of it there could be many disconnected 
 components in the graph and thus there should be a generic way to either 
 mitigate the disconnectedness in the dendrogram or in the original graph. I 
 had no luck in finding such a trick though google search. I then ran the 
 script on minute-scale graphs and have following results:

 1) disconnected graph with three modules:

 *Vertices 9
 *Edges
 1 2 1
 2 3 1
 3 1 1
 4 5 1
 5 6 1
 6 4 1
 7 8 1
 8 9 1
 9 7 1

 corresponding fgc$merges matrix:

 [,1] [,2]
 [1,]10
 [2,]29
 [3,]76
 [4,]8   11
 [5,]43
 [6,]5   13

 2) connected graph by adding links 1-2 and 4-7 in graph 1):

 *Vertices 9
 *Edges
 1 2 1
 2 3 1
 3 1 1
 4 5 1
 5 6 1
 6 4 1
 7 8 1
 8 9 1
 9 7 1
 1 4 1
 4 7 1

 corresponding fgc$merges matrix:

 [,1] [,2]
 [1,]21
 [2,]09
 [3,]87
 [4,]6   11
 [5,]54
 [6,]3   13
 [7,]   14   12
 [8,]   15   10

 There needs to be a generic way to get fgc$merges of the form 2) from 1). 
 Hints please.

Well, how do you merge the unconnected components? I guess you could
come up with an order based on modularity, or just merge them in
arbitrary order. The following is from igraph 0.6, and I haven't tried
it on your data, but it might just work. It merges the individual
subtrees in arbitrary order.

complete.dend - function(comm) {
  merges - comm$merges
  if (nrow(merges)  comm$vcount-1) {
miss - seq_len(comm$vcount + nrow(merges))[-as.vector(merges)]
miss - c(miss, seq_len(length(miss)-2) + comm$vcount+nrow(merges))
miss - matrix(miss, byrow=TRUE, ncol=2)
merges - rbind(merges, miss)
  }
  storage.mode(merges) - integer

  merges
}

Best,
Gabor

[...]

__
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] par and complex graph

2012-06-05 Thread Prof Brian Ripley

On 05/06/2012 11:17, Francesco Nutini wrote:


Dear R-Users, I'd like to have some tips about printing graph.
I use the command par to print more graphs in one window:par(mfrow=c(6,1)); 
par(oma=c(2.5, 2.5, 2.5, 2.5));  par(mar=c(0.5,4, 0.5, 0.5))

But this command doesn't run with complex graphic command (i.e. xyplot, ternaryplot).How 
can I print more than one graph per page, when I work with this elaborated 
graph?Many thanks!Francesco


xyplot does lattice (hence grid) plots: you need to read ?print.trellis 
to find out how to lay those out. par() applies only to base graphics.


As for ternaryplot: it depends which package you got it from (and there 
is more than one on CRAN).




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


That does mean you, too.

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


[R] propensity score matching estimates?

2012-06-05 Thread Dustin Fife
I'm using the Match package to do propensity score matching. Here's some
example code that shows the problem that I'm having (much of this code is
taken from the Match package documentation):

*data(lalonde)
glm1  - glm(treat~age + I(age^2) + educ + I(educ^2) + black +
 hisp + married + nodegr + re74  + I(re74^2) + re75 + I(re75^2)
+
 u74 + u75, family=binomial, data=lalonde)
X  - glm1$fitted
Y  - lalonde$re78
Tr  - lalonde$treat

# one-to-one matching with replacement (the M=1 option).
# Estimating the treatment effect on the treated (the estimand option
defaults to ATT).
rr  - Match(Y=Y, Tr=Tr, X=X, M=1);*

And here's where the 'problem' occurs:

*summary(rr)  # gives an estimate of 2153.3
mean(rr$mdata$Y[rr$index.treated])-mean(rr$mdata$Y[rr$index.control])  #
gives an estimate of 1083.848
*
Notice that when I simply subtract the means from one another, I get a
different estimate (1083.848) than when the algorithm outputs (2153.3). It
seems that the obvious answer is that I'm not computing the estimate
properly. If so, how is it computed?

One more related question. I'm actually trying to do propensity score
matching to estimate the effect of treatment on a dichotomous variable.
Would the function change at all if the estimated effect is on a
dichotomous scale?


-- 
Dustin Fife
PhD Student
Quantitative Psychology
University of Oklahoma

[[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] registry vulnerabilities in R

2012-06-05 Thread Paul Martin

Update:

The IT people agreed to test R separately. R is now approved and RStudio 
is not.
The folks at RStudio are baffled as to why all those registry entries 
are being
recorded. They directed me to the source code which details the known 
accesses
to the registry during installation. I have not yet followed the link. I 
suspect the
registry vulnerability software is flawed, or perhaps their procedures. 
(Are they

installing into a clean image? No idea.)

So, limited progress. I may just move my R work to Linux, where the 
rules are

different.

Thank you, everyone.

Paul Martin

On 5/9/2012 12:57 PM, Richard M. Heiberger wrote:

One more item.  Have you given a copy of the document
R: Regulatory Compliance and Validation Issues A Guidance Document
for the Use of R in Regulated Clinical Trial Environments
http://www.r-project.org/doc/R-FDA.pdf
to your security office?

It addresses overlapping, not identical, security issues.

Rich

On 5/9/12, Paul Martinpamar...@alum.mit.edu  wrote:

I don't have much new to add, but I want to make some clarifying comments:

First, there are clearly workarounds available. I am using one now. R is
installed on a personal laptop which I bring to work every day. I take
extreme care with the nature of the files I move back and forth, and
none of this is classified. This is common practice here. Yes, it would
be nice if I could get R onto my desktop machine at work. It would save
me burning CDs to move plots back and forth. But it's not the end of the
world. My ability to get work done is not the issue here.

The issue is the following: Is there anything her which is of concern to
the R community? I suspect the answer is no, but cannot say anything for
sure at this point.

The registry analysis tool looks like it is custom software developed by
the Air Force. I can't get any specific information beyond that. That is
unfortunate, since it would be nice if the tests could be duplicated and
confirmed.

We will get separate tests on R without RStudio.

The registry analysis reports results in two sections: Registry entries
added and registry entries modified. There were no vulnerabilities found
in the entries modified section. All of the vulnerabilities are listed
under entries added.

I will let you know if I find out anything else. Certainly the isolated
test of the R software without RStudio will be of interest.

Thank you all or your comments,

Paul Martin

On 5/9/2012 10:00 AM, Barry Rowlingson wrote:

Someone said:
Once R is accepted, you could ask for an RStudio test if you want.

   I had another thought shortly after my initial email. Suppose yes, R
is accepted. Great. You run R.

   Then you think, Oh, I need ggplot2 (yes you do). Do you then have
to get security clearance for every package you want to download from
CRAN?

Barry


__
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] Non-linear curve fitting (nls): starting point and quality of fit

2012-06-05 Thread Greg Snow
One thing to note is that there are more than one model that can be
called exponential.  Two of the common ones are:

y = exp( a + b*x + error )
y = exp( a + b*x ) + error

The common way to fit the first is to take the log of both sides and
just fit a linear model with log(y), I expect (but am not sure) that
that is what Excel does.  It is likely that the reason you get
different results is that you are fitting different models with the 2
programs.  You first need to decide which is the correct model (and it
may be different from the 2 already mentioned), then worry about
fitting that model and what goes with that.

On Mon, Jun 4, 2012 at 6:19 AM, Nerak nera...@hotmail.com wrote:
 Hi all,

 Like a lot of people I noticed that I get different results when I use nls
 in R compared to the exponential fit in excel. A bit annoying because often
 the R^2 is higher in excel but when I'm reading the different topics on this
 forum I kind of understand that using R is better than excel?

  (I don't really understand how the difference occurs, but I understand that
 there is a different way in fitting, in excel a single value can make the
 difference, in R it looks at the whole function? I read this: Fitting a
 function is an approximation, trying to find a minimum. Think of frozen
 mountain lake surrounded by mountains. Excel's Solver will report the
 highest tip of the snowflake on the lake, if it finds it. nls will find out
 that the lake is essentially flat compare to the surrounding and tell you
 this fact in unkind word. )


 I have several questions about nls:

 1. The nls method doesn't give an R^2. But I want to determine the quality
 of the fit. To understand how to use nls I read Technical note: Curve
 fitting with the R environment for Statistical Computing. In that document
 they suggested this to calculate R^2:

 RSS.p-sum(residuals(fit)^2)
  TSS-sum((y-mean(y))^2)
  r.squared-1-(RSS.p/TSS)
  LIST.rsq-r.squared

 (with fit my results of the nls: formula y ~ exp.f(x, a, b) : y :
 a*exp(-b*x))

 While I was reading on the internet to find a possible reason why I get
 different results using R and excel, I also read lots of different things
 about the R^2 problem in nls.

 Is the method I'm using now ok, or should someone suggest to use something
 else?

 2. Another question I have is like a lot of people about the singular
 gradient problem. I didn't know the best way to chose my starting values for
 my coefficients. when it was too low, I got this singular gradient error.
 Raising the value helped me to get rid of that error. Changing that value
 didn't change my coefficients nor R^2. I was wondering if that's ok, just to
 raise the starting value of one of my coefficients?

 The only things that change are the Achieved convergence tolerance and
 number of iterations to convergence. P values, residual standard error and
 the coefficients have always exactly the same results. What does the
 achieved convergence tolerance actually mean? What are its implications? (I
 suppose the time to calculate it changes)

 (the most useful information about nls and singular gradient error i found
 is this one (and that's why I started playing with changing the starting
 values):
  if the estimate of the rank that results is less than the number of
 columns in the gradient (the number of nonlinear parameters), or less than
 the number of rows (the number of observations), nls stops.)


 I hope someone can help me with this questions. I would like to know what's
 happening and not just having to accept the results I get now :).

 Kind regards,

 Nerak


 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Non-linear-curve-fitting-nls-starting-point-and-quality-of-fit-tp4632295.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.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.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] Fourier descriptors created in a loop

2012-06-05 Thread David Winsemius


On Jun 5, 2012, at 11:50 AM, aledanda wrote:


Hi All,

Here is the problem: I'm trying to generate a number of Fourier  
Descriptors

figures for an experiment.


Somehow I'm guessing that this will involve load an unnamed package.  
Yep:


 ?create.fourier.descriptor
No documentation for ‘create.fourier.descriptor’ in specified packages  
and libraries:

you could try ‘??create.fourier.descriptor’


All I need is that they are created within a  loop and saved with  
sequential

names (e.g., s1_1.png, s1_2.png etc..) in my directory.

I created a nested loop with a counter for the different amplitudes  
for the

actual shapes and a counter for the file names.

This script:


*count - seq(1, 7, 0.06)

for (i in 1:count){


I was also  wondering what would happen when you passed a vector to  
the : operator. A warning at the very least. What was the point of  
this outer loop?




 for (s in 1:length(count)){

   png(~/Desktop/EMAS/FD_stimuli/s1_,s,.png)

   plot(create.fourier.descriptor(amplitude = c(0, i, 0, 0)));

   dev.off()

 }
}*

 gives me the following error:

/Error in switch(units, `in` = res, cm = res/2.54, mm = res/25.4, px  
= 1) *

:
 non-numeric argument to binary operator


Makes me wonder if this package's code has caused the interpreter to  
attempt something illegal with the 'in' control construct.


 in-5
Error: unexpected 'in' in in

 `in` -5
 in
Error: unexpected 'in' in in
 rm(`in`)


In addition: Warning message:
In 1:count : numerical expression has 101 elements: only the first  
used/


Oh... there it is.



it seems to be a problem with the resolution of each picture which is
different one form the other. In principle this shouldn't be a  
problem if

every time a new png is created.

could you help me with this?
Thank you very much
Best,

Ale

--
View this message in context: 
http://r.789695.n4.nabble.com/Fourier-descriptors-created-in-a-loop-tp4632414.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.


David Winsemius, MD
West Hartford, CT

__
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] rowSums problem

2012-06-05 Thread Rui Barradas

Hello,

The files you've uploaded are the weights file and the results file, not 
the original temp.csv.
So this is untested but it seems you have a standard matrix multiply 
problem.


temp3880W - temp[, 3:50] %*% weight3880

Hope this helps,

Rui Barradas

Em 05-06-2012 15:48, alonis10 escreveu:

I'm having a very frustrating problem, trying to find the inverse distance
squared weighted interpolants of some weather data.

I have a data frame of weights, which sum to 1.  I have attached the weights
data. I also have a data frame of temperatures at 48 grid points, which I
have also attached.

Now, all I need to do is multiply all of the rows of the temperature data
frame by the weights (element-wise), and sum across the columns.

However, when I try to use the most obvious approach,

temp3880W-  weight3880*temp[,(3:50)]
temp3880W- rowsum(temp3880W)


I get the wrong result:


head(temp3880W)
  1  2  3  4  5  6
-0.4904454 -1.2728543 -1.5360133 -0.2687030 62.3048012  6.2610305



I've only been successful by using a for loop which is far too slow:

temp3880- rep(0,length(temp$Year))

for (i in 1:length(temp$Year)) {
wmul- weight3880*as.vector(temp[i,(3:50)])
temp3880[i]- sum(wmul)
}


This gives the result

head(temp3880)
[1] -6.936374 -9.617799 -7.227260  1.135293  8.973817 13.632454



Can anyone point out to me what is going wrong here? I've tried the first
approach with smaller data frames and vectors and it seems to work fine, so
I must be making a mistake somewhere...

Thank you!





--
View this message in context: 
http://r.789695.n4.nabble.com/rowSums-problem-tp4632405.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.


Re: [R] rowSums problem

2012-06-05 Thread John Kane
I am having a problem visualizing what you are doing here.  

What I see is a temp file of 760 elements.  From my point of view and reading 
in your data it would have a have dim(760, 1)  but your code seems to suggest 
that it is not a single vector.

Again I must be missing something completely as I would have thought that the 
output would have been a vector.  

Could exporting  the csv files have somehow mixed up the data structure that 
you are working with?

You might want to provide the two data files using the dput() command.  



John Kane
Kingston ON Canada


 -Original Message-
 From: vashchyshy...@gmail.com
 Sent: Tue, 5 Jun 2012 07:48:51 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] rowSums problem
 
 I'm having a very frustrating problem, trying to find the inverse
 distance
 squared weighted interpolants of some weather data.
 
 I have a data frame of weights, which sum to 1.  I have attached the
 weights
 data. I also have a data frame of temperatures at 48 grid points, which I
 have also attached.
 
 Now, all I need to do is multiply all of the rows of the temperature data
 frame by the weights (element-wise), and sum across the columns.
 
 However, when I try to use the most obvious approach,
 
 temp3880W -  weight3880*temp[,(3:50)]
 temp3880W - rowsum(temp3880W)
 
 
 I get the wrong result:
 
 
 head(temp3880W)
  1  2  3  4  5  6
 -0.4904454 -1.2728543 -1.5360133 -0.2687030 62.3048012  6.2610305
 
 
 
 I've only been successful by using a for loop which is far too slow:
 
 temp3880 - rep(0,length(temp$Year))
 
 for (i in 1:length(temp$Year)) {
 wmul - weight3880*as.vector(temp[i,(3:50)])
 temp3880[i] - sum(wmul)
 }
 
 
 This gives the result
 
 head(temp3880)
 [1] -6.936374 -9.617799 -7.227260  1.135293  8.973817 13.632454
 
 
 
 Can anyone point out to me what is going wrong here? I've tried the first
 approach with smaller data frames and vectors and it seems to work fine,
 so
 I must be making a mistake somewhere...
 
 Thank you!
 
 
 
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/rowSums-problem-tp4632405.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.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

__
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] Good Decision Trees with Product Purchased Data?

2012-06-05 Thread VikR
A client has inquired about producing a decision tree from data which could
include:

- ID of brand purchased
- Importance ratings (1-10 scale) for a number of relevant attributes
(price, strength, recommended by a friend, etc.)  In other words, a rating
of how important each attribute is in the decision as to which brand to
purchase.

I've just run a test decision tree using the closest thing to a similar data
set, that I have at hand .  But only one attribute was selected for
plotting.  I used the Tree package for this test.

Question:
- Does one usually get good decision trees using data of this kind?

Thanks very much in advance to all for any info.

--
View this message in context: 
http://r.789695.n4.nabble.com/Good-Decision-Trees-with-Product-Purchased-Data-tp4632438.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] Good Decision Trees with Product Purchased Data?

2012-06-05 Thread Bert Gunter
Post on a statistics or data mining discussion site (e.g.
stats.stackexchange.com). There are tons of different algorithms for
fitting decision trees, and you are more likely to get an informative
discussion on their relative strengths and weaknesses there than here.
This is really NOT an R question.

-- Bert

Also, see below for a comment.

On Tue, Jun 5, 2012 at 1:42 PM, VikR v...@mindspring.com wrote:
 A client has inquired about producing a decision tree from data which could
 include:

 - ID of brand purchased
 - Importance ratings (1-10 scale) for a number of relevant attributes
 (price, strength, recommended by a friend, etc.)  In other words, a rating
 of how important each attribute is in the decision as to which brand to
 purchase.

 I've just run a test decision tree using the closest thing to a similar data
 set, that I have at hand .  But only one attribute was selected for
 plotting.  I used the Tree package for this test.

 Question:
 - Does one usually get good decision trees using data of this kind?
???
Define: one (who?)
Define: usually
Define: good
Define: data of this kind


 Thanks very much in advance to all for any info.

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Good-Decision-Trees-with-Product-Purchased-Data-tp4632438.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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.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] How do I obtain the current active path of a function that's being called?

2012-06-05 Thread Michael
Hi all,

How do I obtain the current active path of a function that's being called?

That's to say, I have several source files and they all contain definition
of function A.

I would like to figure out which function A and from which file is the one
that's being called and is currently active?

Thanks a lot!

[[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] Seeking pointers to various regression techniques with R?

2012-06-05 Thread Michael
I read your website but still don't know the difference between the three
formulas...

Thank you!

On Mon, Jun 4, 2012 at 11:14 PM, Joshua Wiley jwiley.ps...@gmail.comwrote:

 Hi Michael,

 This is far from exhaustive (I wrote it as an introduction some years
 ago) but you may find it useful to start:
 https://joshuawiley.com/R/formulae_in_R.aspx

 Cheers,

 Josh

 On Mon, Jun 4, 2012 at 9:06 PM, Michael comtech@gmail.com wrote:
  Hi all,
 
  Could you please point me to good materials on various
  tricks/intuitions/techniques of regression, and hopefully in R?
 
  For example, what does lm(y~ x * w - 1) mean vs. lm(y ~ x/w -1 ) vs. lm
 (y
  ~ x:w-1), etc...
 
  I just found that even simple linear regression is not that simple and
  there are a lot of tricks/techniques in using them...
 
  Hopefully I can find good materials on these!
 
  Thank you!
 
 [[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.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.



 --
 Joshua Wiley
 Ph.D. Student, Health Psychology
 Programmer Analyst II, Statistical Consulting Group
 University of California, Los Angeles
 https://joshuawiley.com/


[[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] Regions of significance plots with ggplot2

2012-06-05 Thread Paul Murrell

Hi

Here's one way to approach it ...

ggplot(data.frame(x=1:10, y=1:10)) +
  geom_polygon(aes(x=xx, y=yy), fill=grey70,
   data=data.frame(xx=c(0, 0, 4, 4), yy=c(0, 11, 11, 0))) +
  geom_point(aes(x=x, y=y))

... (supply a separate data source for the background region polygon).

Paul

On 4/06/2012 4:18 a.m., Dominic Comtois wrote:

I'd like to create a plot similar to this one from Kochanska et al.
(Development and Psychopathology, 2011):



  http://pages.videotron.com/do999/r-help/Kochanska_graph_ros.jpg
http://pages.videotron.com/do999/r-help/Kochanska_graph_ros.jpg



I am new to ggplot2 and can't see any obvious way to create distinct
coloured regions for the background, nor can I find any relevant examples.



Any guidance appreciated.



DC



PS: The context is practically the same as the one from the image (Gene x
Environment interaction study). I used the following tool to find the
regions of significance, if this is of interest to anyone:
http://www.quantpsy.org/interact/mlr2
http://www.quantpsy.org/interact/mlr2




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


--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
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] Regions of significance plots with ggplot2

2012-06-05 Thread baptiste auguie
Hi,

On 6 June 2012 08:58, Paul Murrell p.murr...@auckland.ac.nz wrote:
 Hi

 Here's one way to approach it ...

 ggplot(data.frame(x=1:10, y=1:10)) +
  geom_polygon(aes(x=xx, y=yy), fill=grey70,
               data=data.frame(xx=c(0, 0, 4, 4), yy=c(0, 11, 11, 0))) +
  geom_point(aes(x=x, y=y))

 ... (supply a separate data source for the background region polygon).

and note that you can use +/- Inf for convenience,

ggplot(data.frame(x=1:10, y=1:10)) +
  annotate(polygon, x=c(-Inf, -Inf, 4, 4), y=c(-Inf, Inf, Inf, -Inf),
  fill=grey70, alpha =0.5) +
 geom_point(aes(x=x, y=y))

HTH,

baptiste


 Paul

 On 4/06/2012 4:18 a.m., Dominic Comtois wrote:

 I'd like to create a plot similar to this one from Kochanska et al.
 (Development and Psychopathology, 2011):



  http://pages.videotron.com/do999/r-help/Kochanska_graph_ros.jpg
 http://pages.videotron.com/do999/r-help/Kochanska_graph_ros.jpg



 I am new to ggplot2 and can't see any obvious way to create distinct
 coloured regions for the background, nor can I find any relevant examples.



 Any guidance appreciated.



 DC



 PS: The context is practically the same as the one from the image (Gene x
 Environment interaction study). I used the following tool to find the
 regions of significance, if this is of interest to anyone:
 http://www.quantpsy.org/interact/mlr2
 http://www.quantpsy.org/interact/mlr2




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


 --
 Dr Paul Murrell
 Department of Statistics
 The University of Auckland
 Private Bag 92019
 Auckland
 New Zealand
 64 9 3737599 x85392
 p...@stat.auckland.ac.nz
 http://www.stat.auckland.ac.nz/~paul/

 __
 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] Good Decision Trees with Product Purchased Data?

2012-06-05 Thread VikR
 Define: one (who?) 

The individual analyzing the data.

Define: usually 

More than 50% of the time.

 Define: good 

A decision tree including branches on at least 2 variables.

 Define: data of this kind 

I believe I may have specified this in my original post:

 - ID of brand purchased 
 - Importance ratings (1-10 scale) for a number of relevant attributes 
 (price, strength, recommended by a friend, etc.)  In other words, a rating 
 of how important each attribute is in the decision as to which brand to 
 purchase. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Good-Decision-Trees-with-Product-Purchased-Data-tp4632438p4632444.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] plot background - excel gradient style background ?

2012-06-05 Thread Greg Snow
Well that answers the question as answer.  So while you are working
within the system to get your company to change the policy you can use
rasterImage to add a gradient background to the plot, then use points
or lines or other functions to put the parts of interest back on top
of the gradient (if it is not obvious how to do this then give us more
detail of the types of plots you are doing, a reproducible example is
best, and we can give more detail on how to do this).

On Tue, Jun 5, 2012 at 9:07 AM, jcrosbie ja...@crosb.ie wrote:
 I'm not the one who is choosing to use gradient background. It's our company
 policy.

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/plot-background-excel-gradient-style-background-tp4632138p4632409.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.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.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] Seeking pointers to various regression techniques with R?

2012-06-05 Thread Andrew Miles
The R book by Michael Crawley has some discussion the type of R syntax you are 
looking for in the chapter on statistical modeling.  As for the formulae you 
gave...

lm(y ~ x*w - 1)  fits an interaction between x and w without an intercept, 
along with the main effects for x and w
lm(y ~ x:w - 1)  fits just the interaction between x and w without an 
intercept, and without the main effects for x and w
lm(y ~ x/w - 1)  I believe this fits the nested factor w inside of x

Andrew Miles


On Jun 5, 2012, at 4:58 PM, Michael wrote:

 I read your website but still don't know the difference between the three
 formulas...
 
 Thank you!
 
 On Mon, Jun 4, 2012 at 11:14 PM, Joshua Wiley jwiley.ps...@gmail.comwrote:
 
 Hi Michael,
 
 This is far from exhaustive (I wrote it as an introduction some years
 ago) but you may find it useful to start:
 https://joshuawiley.com/R/formulae_in_R.aspx
 
 Cheers,
 
 Josh
 
 On Mon, Jun 4, 2012 at 9:06 PM, Michael comtech@gmail.com wrote:
 Hi all,
 
 Could you please point me to good materials on various
 tricks/intuitions/techniques of regression, and hopefully in R?
 
 For example, what does lm(y~ x * w - 1) mean vs. lm(y ~ x/w -1 ) vs. lm
 (y
 ~ x:w-1), etc...
 
 I just found that even simple linear regression is not that simple and
 there are a lot of tricks/techniques in using them...
 
 Hopefully I can find good materials on these!
 
 Thank you!
 
   [[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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 --
 Joshua Wiley
 Ph.D. Student, Health Psychology
 Programmer Analyst II, Statistical Consulting Group
 University of California, Los Angeles
 https://joshuawiley.com/
 
 
   [[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.


Re: [R] How do I obtain the current active path of a function that's being called?

2012-06-05 Thread Greg Snow
There are several ways that a function can come into being within R,
it can be sourced from a file like in your case, but it could also be
typed in by hand at the command prompt, or created by another
function, etc.  So R does not in general keep links to the files from
which the file was generated.  Some of the development programs for R
(such as rstudio) may keep track of this for you.  Or you could put
some unique assignment at the start of each version of the function
then just look at the code for the function to see what that
assignment is.  Unfortunately an R only general solution would need
ESP of some sort and my version of an esp package is still very
pre-alpha, it suggests amply dromedary support effect damper
photogenic nonce and unless that means something to you I don't think
it will be much help for a while.  You will need to find a way to keep
track for yourself.

On Tue, Jun 5, 2012 at 2:58 PM, Michael comtech@gmail.com wrote:
 Hi all,

 How do I obtain the current active path of a function that's being called?

 That's to say, I have several source files and they all contain definition
 of function A.

 I would like to figure out which function A and from which file is the one
 that's being called and is currently active?

 Thanks a lot!

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



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.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] How do I obtain the current active path of a function that's being called?

2012-06-05 Thread Andrew Miles
Can you provide an example of the code file that you use to call the different 
functions?  Without that it might be hard for people to answer your question.

Offhand, I'd say that it is whatever version of function A was called last.  If 
you are loading functions into the workspace, they are treated as any other 
object, which is to say that you can only have one function of the same name at 
a time.  Hence whenever you call a source file to load in function A, the old 
function A gets overwritten.

Andrew Miles


On Jun 5, 2012, at 4:58 PM, Michael wrote:

 Hi all,
 
 How do I obtain the current active path of a function that's being called?
 
 That's to say, I have several source files and they all contain definition
 of function A.
 
 I would like to figure out which function A and from which file is the one
 that's being called and is currently active?
 
 Thanks a lot!
 
   [[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.


Re: [R] Seeking pointers to various regression techniques with R?

2012-06-05 Thread Peter Ehlers

You mention 3 models. In all of them, the '-1' simply removes
the intercept term; help('formula') explains the use of '-'
in general.

1. lm(y~ x * w - 1)  is clearly explained in help('formula');
2. lm(y~ x:w - 1)   ditto (and this is a model to avoid);
3. lm(y~ x/w - 1)   this is equivalent to lm(y~ x + w %in% x - 1)
where the %in% operator is explained in help('formula'). A good
and simple example is found in the MASS book (chapter 6) the code
for which is available in the 'Scripts' subfolder of library/MASS
of your R installation.

Peter Ehlers


On 2012-06-05 13:58, Michael wrote:

I read your website but still don't know the difference between the three
formulas...

Thank you!

On Mon, Jun 4, 2012 at 11:14 PM, Joshua Wileyjwiley.ps...@gmail.comwrote:


Hi Michael,

This is far from exhaustive (I wrote it as an introduction some years
ago) but you may find it useful to start:
https://joshuawiley.com/R/formulae_in_R.aspx

Cheers,

Josh

On Mon, Jun 4, 2012 at 9:06 PM, Michaelcomtech@gmail.com  wrote:

Hi all,

Could you please point me to good materials on various
tricks/intuitions/techniques of regression, and hopefully in R?

For example, what does lm(y~ x * w - 1) mean vs. lm(y ~ x/w -1 ) vs. lm

(y

~ x:w-1), etc...

I just found that even simple linear regression is not that simple and
there are a lot of tricks/techniques in using them...

Hopefully I can find good materials on these!

Thank you!

[[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.htmlhttp://www.r-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.




--
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/



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


Re: [R] Seeking pointers to various regression techniques with R?

2012-06-05 Thread Michael
Thank you!

But could you please explain why the 2nd formula is a model to avoid?
Thanks again!
On Tue, Jun 5, 2012 at 6:18 PM, Peter Ehlers ehl...@ucalgary.ca wrote:

 You mention 3 models. In all of them, the '-1' simply removes
 the intercept term; help('formula') explains the use of '-'
 in general.

 1. lm(y~ x * w - 1)  is clearly explained in help('formula');
 2. lm(y~ x:w - 1)   ditto (and this is a model to avoid);
 3. lm(y~ x/w - 1)   this is equivalent to lm(y~ x + w %in% x - 1)
 where the %in% operator is explained in help('formula'). A good
 and simple example is found in the MASS book (chapter 6) the code
 for which is available in the 'Scripts' subfolder of library/MASS
 of your R installation.

 Peter Ehlers



 On 2012-06-05 13:58, Michael wrote:

  I read your website but still don't know the difference between the
 three
 formulas...

 Thank you!

 On Mon, Jun 4, 2012 at 11:14 PM, Joshua Wileyjwiley.ps...@gmail.com**
 wrote:

  Hi Michael,

 This is far from exhaustive (I wrote it as an introduction some years
 ago) but you may find it useful to start:
 https://joshuawiley.com/R/**formulae_in_R.aspxhttps://joshuawiley.com/R/formulae_in_R.aspx

 Cheers,

 Josh

 On Mon, Jun 4, 2012 at 9:06 PM, Michaelcomtech@gmail.com  wrote:

 Hi all,

 Could you please point me to good materials on various
 tricks/intuitions/techniques of regression, and hopefully in R?

 For example, what does lm(y~ x * w - 1) mean vs. lm(y ~ x/w -1 ) vs. lm

 (y

 ~ x:w-1), etc...

 I just found that even simple linear regression is not that simple and
 there are a lot of tricks/techniques in using them...

 Hopefully I can find good materials on these!

 Thank you!

[[alternative HTML version deleted]]

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide

 http://www.R-project.org/**posting-guide.htmlhttp://www.r-project.org/posting-guide.html
 http://www.**r-project.org/posting-guide.**htmlhttp://www.r-project.org/posting-guide.html


 and provide commented, minimal, self-contained, reproducible code.




 --
 Joshua Wiley
 Ph.D. Student, Health Psychology
 Programmer Analyst II, Statistical Consulting Group
 University of California, Los Angeles
 https://joshuawiley.com/


[[alternative HTML version deleted]]

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 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] How do I obtain the current active path of a function that's being called?

2012-06-05 Thread Michael
Thanks so much for your help!

I'd like but however I couldn't provide the code since they are not in
public domain...

But lets imagine I inherited a big pile of R projects/codes from other
people and there are lots of sources in the programs.

And there are many definitions of function A in the directories.

I wanted to put a breakpoint into the relavant function A that's
currently in the workspace, i.e. the one I am using...

To insert a breakpoint, I need to find its location in the file system... I
need to find where it is...

Simply searching by the name in the file system gave lots of hits...

Thank you!

On Tue, Jun 5, 2012 at 4:35 PM, Andrew Miles rstuff.mi...@gmail.com wrote:

 Can you provide an example of the code file that you use to call the
 different functions?  Without that it might be hard for people to answer
 your question.

 Offhand, I'd say that it is whatever version of function A was called
 last.  If you are loading functions into the workspace, they are treated as
 any other object, which is to say that you can only have one function of
 the same name at a time.  Hence whenever you call a source file to load in
 function A, the old function A gets overwritten.

 Andrew Miles


 On Jun 5, 2012, at 4:58 PM, Michael wrote:

  Hi all,
 
  How do I obtain the current active path of a function that's being
 called?
 
  That's to say, I have several source files and they all contain
 definition
  of function A.
 
  I would like to figure out which function A and from which file is the
 one
  that's being called and is currently active?
 
  Thanks a lot!
 
 [[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.htmlhttp://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] Seeking pointers to various regression techniques with R?

2012-06-05 Thread Bert Gunter
OY!

Have you had any courses in linear models/regression? If so, it's the
so-called effects hierarchy principle: generally one does not
expect interactions -- 2nd order effects -- when main effects -- first
order effects -- are absent.

If not, it's difficult to explain, but it certainly has nothing to do
with R and you should post on a statistical list, take a course,
consult a statistician, search the web, take it offlist with Peter ...

-- Bert

On Tue, Jun 5, 2012 at 4:47 PM, Michael comtech@gmail.com wrote:
 Thank you!

 But could you please explain why the 2nd formula is a model to avoid?
 Thanks again!
 On Tue, Jun 5, 2012 at 6:18 PM, Peter Ehlers ehl...@ucalgary.ca wrote:

 You mention 3 models. In all of them, the '-1' simply removes
 the intercept term; help('formula') explains the use of '-'
 in general.

 1. lm(y~ x * w - 1)  is clearly explained in help('formula');
 2. lm(y~ x:w - 1)   ditto (and this is a model to avoid);
 3. lm(y~ x/w - 1)   this is equivalent to lm(y~ x + w %in% x - 1)
 where the %in% operator is explained in help('formula'). A good
 and simple example is found in the MASS book (chapter 6) the code
 for which is available in the 'Scripts' subfolder of library/MASS
 of your R installation.

 Peter Ehlers



 On 2012-06-05 13:58, Michael wrote:

  I read your website but still don't know the difference between the
 three
 formulas...

 Thank you!

 On Mon, Jun 4, 2012 at 11:14 PM, Joshua Wileyjwiley.ps...@gmail.com**
 wrote:

  Hi Michael,

 This is far from exhaustive (I wrote it as an introduction some years
 ago) but you may find it useful to start:
 https://joshuawiley.com/R/**formulae_in_R.aspxhttps://joshuawiley.com/R/formulae_in_R.aspx

 Cheers,

 Josh

 On Mon, Jun 4, 2012 at 9:06 PM, Michaelcomtech@gmail.com  wrote:

 Hi all,

 Could you please point me to good materials on various
 tricks/intuitions/techniques of regression, and hopefully in R?

 For example, what does lm(y~ x * w - 1) mean vs. lm(y ~ x/w -1 ) vs. lm

 (y

 ~ x:w-1), etc...

 I just found that even simple linear regression is not that simple and
 there are a lot of tricks/techniques in using them...

 Hopefully I can find good materials on these!

 Thank you!

        [[alternative HTML version deleted]]

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide

 http://www.R-project.org/**posting-guide.htmlhttp://www.r-project.org/posting-guide.html
 http://www.**r-project.org/posting-guide.**htmlhttp://www.r-project.org/posting-guide.html


 and provide commented, minimal, self-contained, reproducible code.




 --
 Joshua Wiley
 Ph.D. Student, Health Psychology
 Programmer Analyst II, Statistical Consulting Group
 University of California, Los Angeles
 https://joshuawiley.com/


        [[alternative HTML version deleted]]

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.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] How do I obtain the current active path of a function that's being called?

2012-06-05 Thread David Winsemius


On Jun 5, 2012, at 7:51 PM, Michael wrote:


Thanks so much for your help!

I'd like but however I couldn't provide the code since they are not in
public domain...

But lets imagine I inherited a big pile of R projects/codes from other
people and there are lots of sources in the programs.

And there are many definitions of function A in the directories.

I wanted to put a breakpoint into the relavant function A that's
currently in the workspace, i.e. the one I am using...

To insert a breakpoint, I need to find its location in the file  
system... I

need to find where it is...

Simply searching by the name in the file system gave lots of hits...


You could go through and label each of the `A` functions with a  
comment that designated the file from which they were loaded.


 func - function() x
 comment(func) - test
 comment(func)
[1] test

--
David.



Thank you!

On Tue, Jun 5, 2012 at 4:35 PM, Andrew Miles  
rstuff.mi...@gmail.com wrote:



Can you provide an example of the code file that you use to call the
different functions?  Without that it might be hard for people to  
answer

your question.

Offhand, I'd say that it is whatever version of function A was called
last.  If you are loading functions into the workspace, they are  
treated as
any other object, which is to say that you can only have one  
function of
the same name at a time.  Hence whenever you call a source file to  
load in

function A, the old function A gets overwritten.

Andrew Miles


On Jun 5, 2012, at 4:58 PM, Michael wrote:


Hi all,

How do I obtain the current active path of a function that's being

called?


That's to say, I have several source files and they all contain

definition

of function A.

I would like to figure out which function A and from which file is  
the

one

that's being called and is currently active?

Thanks a lot!

 [[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.htmlhttp://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.


David Winsemius, MD
West Hartford, CT

__
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 obtain the current active path of a function that's being called?

2012-06-05 Thread Richard M. Heiberger
I think your best option is to invest time in learning how to build an R
package, and then
package each project.  Conflicting names are not a problem when you have
them inside package
namespaces.  See the extensions document in R in the R distribution
R-2.15.0/doc/manual/R-exts.html

One way to handle breakpoints is with the ess-tracebug function inside ESS
inside emacs
http://code.google.com/p/ess-tracebug/
http://ess.r-project.org/
The
http://biostat.mc.vanderbilt.edu/wiki/Main/UseR-2012
conference is next week in Nashville.

We have a tutorial on ESS, which will include an introduction to
ess-tracebug, on Tuesday morning.

Rich
On Tue, Jun 5, 2012 at 8:12 PM, David Winsemius dwinsem...@comcast.netwrote:


 On Jun 5, 2012, at 7:51 PM, Michael wrote:

 Thanks so much for your help!

 I'd like but however I couldn't provide the code since they are not in
 public domain...

 But lets imagine I inherited a big pile of R projects/codes from other
 people and there are lots of sources in the programs.

 And there are many definitions of function A in the directories.

 I wanted to put a breakpoint into the relavant function A that's
 currently in the workspace, i.e. the one I am using...

 To insert a breakpoint, I need to find its location in the file system...
 I
 need to find where it is...

 Simply searching by the name in the file system gave lots of hits...


 You could go through and label each of the `A` functions with a comment
 that designated the file from which they were loaded.

  func - function() x
  comment(func) - test
  comment(func)
 [1] test

 --
 David.



 Thank you!

 On Tue, Jun 5, 2012 at 4:35 PM, Andrew Miles rstuff.mi...@gmail.com
 wrote:

 Can you provide an example of the code file that you use to call the
 different functions?  Without that it might be hard for people to answer
 your question.

 Offhand, I'd say that it is whatever version of function A was called
 last.  If you are loading functions into the workspace, they are treated
 as
 any other object, which is to say that you can only have one function of
 the same name at a time.  Hence whenever you call a source file to load
 in
 function A, the old function A gets overwritten.

 Andrew Miles


 On Jun 5, 2012, at 4:58 PM, Michael wrote:

 Hi all,

 How do I obtain the current active path of a function that's being

 called?


 That's to say, I have several source files and they all contain

 definition

 of function A.

 I would like to figure out which function A and from which file is the

 one

 that's being called and is currently active?

 Thanks a lot!

 [[alternative HTML version deleted]]

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide

 http://www.R-project.org/**posting-guide.htmlhttp://www.r-project.org/posting-guide.html
 http://www.**r-project.org/posting-guide.**htmlhttp://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-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html http://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 David Winsemius, MD
 West Hartford, CT


 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 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] How do I obtain the current active path of a function that's being called?

2012-06-05 Thread David Winsemius


On Jun 5, 2012, at 8:35 PM, arun wrote:




Hi Dave,

I am interested in your suggestion.  But, look at this scenario.

func-function()x
comment(func)-test
comment(func)

[1] test


func-function()y
comment(func)-test2
comment(func)

[1] test2

func-function()x
comment(func)

NULL

func-function()y
comment(func)

NULL


Does it imply that it needs different objects?
Thanks,


I think it implies that I had one beer too many.

--  
David.


- Original Message -
From: David Winsemius dwinsem...@comcast.net
To: Michael comtech@gmail.com
Cc: r-help r-h...@stat.math.ethz.ch
Sent: Tuesday, June 5, 2012 8:12 PM
Subject: Re: [R] How do I obtain the current active path of a  
function that's being called?



On Jun 5, 2012, at 7:51 PM, Michael wrote:


Thanks so much for your help!

I'd like but however I couldn't provide the code since they are not  
in

public domain...

But lets imagine I inherited a big pile of R projects/codes from  
other

people and there are lots of sources in the programs.

And there are many definitions of function A in the directories.

I wanted to put a breakpoint into the relavant function A that's
currently in the workspace, i.e. the one I am using...

To insert a breakpoint, I need to find its location in the file  
system... I

need to find where it is...

Simply searching by the name in the file system gave lots of hits...


You could go through and label each of the `A` functions with a  
comment that designated the file from which they were loaded.



func - function() x
comment(func) - test
comment(func)

[1] test

--David.



Thank you!

On Tue, Jun 5, 2012 at 4:35 PM, Andrew Miles  
rstuff.mi...@gmail.com wrote:



Can you provide an example of the code file that you use to call the
different functions?  Without that it might be hard for people to  
answer

your question.

Offhand, I'd say that it is whatever version of function A was  
called
last.  If you are loading functions into the workspace, they are  
treated as
any other object, which is to say that you can only have one  
function of
the same name at a time.  Hence whenever you call a source file to  
load in

function A, the old function A gets overwritten.

Andrew Miles


On Jun 5, 2012, at 4:58 PM, Michael wrote:


Hi all,

How do I obtain the current active path of a function that's being

called?


That's to say, I have several source files and they all contain

definition

of function A.

I would like to figure out which function A and from which file  
is the

one

that's being called and is currently active?

Thanks a lot!

  [[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.htmlhttp://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.


David Winsemius, MD
West Hartford, CT

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



David Winsemius, MD
West Hartford, CT

__
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] GSL Random Number generation and Quasi-Random Sequences.

2012-06-05 Thread Keith Weintraub
Folks,

Can you point me to any examples of using the GSL library to generate 
correlated uniform random variables?

I want to generate correlated defaults among portfolios of loans.

Currently I generate simulations by using rmvsnorm (and then inverting using 
the standard normal distribution function). Is there any advantage to using the 
GSL functionality to generate the simulations?

Any examples of using Sobol sequences for this type of application. 

Please feel free to point me to another site or resource if appropriate.

Thanks,
KW

--


[[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] Converiting longitude/latitude to utm

2012-06-05 Thread Boris Beranger
Thank you David  Michael for your answers.
It makes more sense now!

Cheers,
Boris

2012/6/6 David L Carlson dcarl...@tamu.edu

 You might try R-Sig-Geo for the reasons, but you need to include the UTM
 zone to convert:

 SP-SpatialPoints(cbind(126.59,-14.30),proj4string=CRS(+proj=longlat))
 SP

 SpatialPoints:
 coords.x1 coords.x2
 [1,]126.59 -14.3
 Coordinate Reference System (CRS) arguments: +proj=longlat +ellps=WGS84

 coordinatesUTM-spTransform(SP,CRS(+proj=utm +zone=52))
 coordinatesUTM

 SpatialPoints:
 coords.x1 coords.x2
 [1,]  240015.6  -1582256
 Coordinate Reference System (CRS) arguments: +proj=utm +zone=52
 +ellps=WGS84

 --
 David L Carlson
 Associate Professor of Anthropology
 Texas AM University
 College Station, TX 77843-4352



  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
  project.org] On Behalf Of Boris Beranger
  Sent: Tuesday, June 05, 2012 3:29 AM
  To: R-help@r-project.org
  Subject: [R] Converiting longitude/latitude to utm
 
  Dear all,
 
  I have been trying to convert coordinates from longitude/latitude to
  utm
  but I got an error. As soon as the longitude coordinate is greater than
  90,
  I get the folloowing error message:  error in pj_transform: latitude
  or
  longitude exceeded limits
 
  Here is what I did:
 
   SP-SpatialPoints(cbind(126.59,-
  14.30),proj4string=CRS(+proj=longlat))
  coordinatesUTM-spTransform(SP,CRS(+proj=utm))
 
  Error in spTransform(SP, CRS(+proj=utm)) :
error in pj_transform: latitude or longitude exceeded limits
 
  Can someone explain me what I did wrong? I am using coordinates of
  Australia so the range of my longitudes is around [110,150] and the one
  of
  my latitudes [-10,-45].
 
  Thanks in advance,
 
  Cheers,
  Boris
 
[[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.


Re: [R] How to calculate chi sqaure value from statistical value and degrees of freedom?

2012-06-05 Thread Özgür Asar
Hi,

Actually, pchisq(q,df) calculates the cumulative distribution function by
default.

To calculate the p-value, you can use either

1-pchisq(q,df)

or

pchisq(q,df,lower.tail=FALSE)

PS: I checked, the p value yielded by R and the calculator for which you
give a link, for some q and df values, and these two are same.

Best
Ozgur

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-calculate-chi-sqaure-value-from-statistical-value-and-degrees-of-freedom-tp4632385p4632470.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] How to Rank clusters

2012-06-05 Thread shilpi harpavat


Hi,
I have say 1000 different Independent  Variables which have each been 
classified into diiferent clusters using some clustering method.
I want to show these 1000 varaible in a report, but want some criterion to rank 
them so i can show the most significant ones (based on the cluster groups) 
first.
Any ideas on what Statistics we could use really appreciated.
Thanks
SH
  
[[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] Summarizing a matrix

2012-06-05 Thread Rui Barradas

Hello,

Better yet is function aggregate.

# Create some data matrix
Y - matrix(c(sample(80, 507, TRUE), sample(-1:1, 4*507, TRUE)), ncol=5)

X - aggregate(Y[, 5]~Y[, 1], Y, sum) # In your case Y[, 4] not Y[, 1]


Hope this helps,

Rui Barradas

Em 05-06-2012 09:53, Özgür Asar escreveu:

Hi,

x-matrix(0,80,ncol=1)

will create x matrix with all elements 0 (to be filled by the sums that you
need)

sum(y[y[,4]==1,5])

will calculate the sum of 5th column of y with 4th column=1

Similarly,

sum(y[y[,4]==80,5])

  will calculate the sum of 5th column of y with 4th column=80.

You can adapt this to your case, with simple loops, etc.

Hope this helps.
Ozgur

--
View this message in context: 
http://r.789695.n4.nabble.com/Summarizing-a-matrix-tp4632319p4632381.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] load coda in BRugs to perfor diagnostics

2012-06-05 Thread Guillaume2883
Dear all,

I just wrote a script to have each of my three mcmc chins running on a
different computer core to improve computation speed. To do it I use the
function sfLapply from the package snowfall.
Before using parallell computation, I did my diagnostic analyses just after
the model updating, but now I have to save the coda before. 
Using the CODA package, it is possible to load the outputs in a mcmc.list to
perform some diagnostics but it doesn't work with functions from the BRugs
package such as samplesBgr. 
Can you explain what should I do to read coda files with BRugs ? 

Thanking you in advance

Guillaume

--
View this message in context: 
http://r.789695.n4.nabble.com/load-coda-in-BRugs-to-perfor-diagnostics-tp4632420.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] Do YOU know an equation for splines (ns)?

2012-06-05 Thread Ranae
Hi, 

I am looking at the change in N concentration in plant roots over 4 time
points and I have fit a spline to the data using ns and lme: 

fit10 - lme( N~ns(day, 3), data = rcn10G) 

I may want to adjust the model a little bit, but for now, let's assume it's
good.  I get output for the fixed effects: 

Fixed: N ~ ns(day, 3) 
(Intercept) ns(day, 3)1 ns(day, 3)2 ns(day, 3)3 
 1.15676524  0.14509171  0.04459627  0.09334428 
  
and coefficients for each experimental unit in my experiment: 

   (Intercept) ns(day, 3)1 ns(day, 3)2 ns(day, 3)3 
241.050360 -0.42666159 -0.56290877 -0.10714407 
131.104464 -0.30825350 -0.53311653 -0.05558150 
311.147878 -0.14548512 -0.78673906 -0.07231781 
461.177781 -0.22278380 -0.80278177 -0.02321460 
151.144215 -0.04484519 -0.06084798  0.07633663 
321.213007  0.00741061  0.03896933  0.15325849 
231.274615  0.16477514  0.00872224  0.23128320 
411.215626  0.57050767  0.11415467  0.10608867 
431.134203  0.48070741  0.72112899  0.18108193 
121.091422  0.39563632  1.01521528  0.22597459 
211.100631  0.44589314  0.98526322  0.23535739 
351.226980  0.82419937  0.39809568  0.16900841 

NOW, I want to write a spline function where I can incorporate these
coefficients to get the predicted N concentration value for each day. 
However, I am having trouble finding the right spline equation, since there
are many forms on the internets.   

I know it won't be a simple one, but can some one direct me to the equation
that would be best to use for ns? 

Thanks a lot, 

Ranae 


--
View this message in context: 
http://r.789695.n4.nabble.com/Do-YOU-know-an-equation-for-splines-ns-tp4632440.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] need descriptive help

2012-06-05 Thread mkm1616
Was it really necessary to reply with sarcasm i.e. badgering the list.

The point of an open community is to seek advice.  i mentioned I was
new to R and apologized to the community.  A simple response with some
guidance would be helpful.

I'm looking at other posts, there are some other simple questions.

Bert, why don'tyou go give them all an etiquette lesson



On Jun 5, 11:13 am, Bert Gunter gunter.ber...@gene.com wrote:
 1. Before you post to this list again, please read An Introd to R --
 or other basic R tutorial. Intro ships with every R installation.
 There's a reason for this -- to avoid badgering this list with basic R
 queries that minimal homework could answer.

 2. However, see also ?table and links therein.

 3. ?[ and ?subset are also relevant.

 -- Bert





 On Tue, Jun 5, 2012 at 8:34 AM, mkm1616 mkm1...@gmail.com wrote:
  Hi all, I'm new to using R, and apologize for simplicity of this
  question.

  I'm using a data set with over 60,000 observations, Two variables are
  patient ID, and cost incurred by the patient.  I'd like to generate
  frequency/table by patient and cost IF the total cost is over 2000.

  Right now I'm using:

  by(x$cost, x$patient, sum)

  but this generates a huge list for each patient.

  What is the best way to either (1) export the output into a csv so I
  can visually inspect each patient or more helpful (2) create the table
  IF sum of cost  1000

  Thanks!

  __
  r-h...@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 --

 Bert Gunter
 Genentech Nonclinical Biostatistics

 Internal Contact Info:
 Phone: 467-7374
 Website:http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pd...

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.- Hide 
 quoted text -

 - Show quoted text -

__
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] need descriptive help

2012-06-05 Thread arun
Hi,

Try this example:
set.seed(1)

dat2-data.frame(patient=rep(c(1:20),5),cost=rnorm(100,15,1))
agg1-aggregate(dat2,by=list(dat2$patient),FUN=sum)
 agg2-agg1$cost 75
agg3-data.frame(agg1[agg2,2:3])


A.K.



- Original Message -
From: mkm1616 mkm1...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Tuesday, June 5, 2012 11:34 AM
Subject: [R] need descriptive help

Hi all, I'm new to using R, and apologize for simplicity of this
question.

I'm using a data set with over 60,000 observations, Two variables are
patient ID, and cost incurred by the patient.  I'd like to generate
frequency/table by patient and cost IF the total cost is over 2000.

Right now I'm using:

by(x$cost, x$patient, sum)

but this generates a huge list for each patient.

What is the best way to either (1) export the output into a csv so I
can visually inspect each patient or more helpful (2) create the table
IF sum of cost  1000

Thanks!

__
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] nls: how do you know if the model is significant?

2012-06-05 Thread mkm1616
Here goes bert again with etiquette lessons.

Why are you so crabby?

On Jun 5, 11:16 am, Bert Gunter gunter.ber...@gene.com wrote:
 I suggest you consult a local statistician. You could also post to a
 statistical help list like stats.stackexchange.com. Your query has
 nothing to do with R, but is rather about the meaningfulness (or lack
 thereof) of statistical significance in nonlinear modeling.

 -- Bert





 On Tue, Jun 5, 2012 at 6:49 AM, Nerak nera...@hotmail.com wrote:
  Hi all,
  I'm struggling with nls. How do you know if your model is significant? For a
  lm, you get a p-value, but you don't get it for a nls. Is there a way to
  calculate it?

  For a lm I use this:
   a-summary(lm(model ~obs))
   f.stat-a$fstatistic
   p.value-1-pf(f.stat[value],f.stat[numdf],f.stat[dendf])

  Is there something similar for a nls?

  The kind of output that I get is:

  Formula: y ~ exp.f(x, a, b)

  Parameters:
    Estimate Std. Error t value Pr(|t|)
  a 1.381e+02  1.192e+01  11.583 3.19e-08 ***
  b 1.790e-02  2.459e-03   7.279 6.19e-06 ***
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

  Residual standard error: 13.21 on 13 degrees of freedom

  Number of iterations to convergence: 6
  Achieved convergence tolerance: 9.123e-06

  I know that my parameters are significant but I need to say something about
  the whole model.

  Many thanks,
  Nerak

  --
  View this message in 
  context:http://r.789695.n4.nabble.com/nls-how-do-you-know-if-the-model-is-sig...
  Sent from the R help mailing list archive at Nabble.com.

  __
  r-h...@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 --

 Bert Gunter
 Genentech Nonclinical Biostatistics

 Internal Contact Info:
 Phone: 467-7374
 Website:http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pd...

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.- Hide 
 quoted text -

 - Show quoted text -

__
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] Improper coding for an offset in vglm()?

2012-06-05 Thread Christopher R. Dolanc

Hello R-help.

I believe I may be coding the offset incorrectly in my formula. I am 
testing significance between different group pairings using the VGAM 
package. My data are zero-truncated and poisson-distributed and 
overdispersed, so I'm using the posnegbinomial function in vglm (code 
below). I've spent a very long time working out this model and am pretty 
sure it's the best for my data, but I have several examples of groups 
with very similar means that come out significant. I'm looking at 
differences in density between 2 data sources (see attached file), but 
the plot size varies between the 2, so I am using plot Area as an 
offset and running tests on Stems. I've attached a sample where the 
means for density are 26.4 vs. 25.2 with clearly overlapping error bars, 
yet the test comes out significant. (A Wilcoxan test on density also 
comes out significant.) Just to check, I did a t-test on density, which 
was non-significant, and a t-test on Stems, which WAS significant. This 
leads me to believe that my vglm model is not accounting for the area 
offset (and thus density) and is just running the model straight on 
Stems. Here's the code:


vglm(Stems~Data + offset(log(Area)), family=posnegbinomial, data=...)

I've tried changing the family to pospoisson and it makes no 
difference. I've also tried taking out the log part of the offset, just 
to see what would happen, but couldn't get the model to run. I'm 
currently working with R 2.14.1.


I'd love any ideas you may have on possible solutions.

Chris

--
Christopher R. Dolanc
Post-doctoral Researcher
University of Montana and UC-Davis


DataPlotStems   AreaDensity
FIA 8.87E+121   665.010315.03736
FIA 2.51E+132   672.45  29.74199
FIA 8.94E+123   619.986948.38812
FIA 2.38E+131   601.457616.62628
FIA 1.31E+132   634.697631.51107
FIA 2.30E+131   659.391515.1655
FIA 2.99E+132   634.697631.51107
FIA 2.40E+131   659.391515.1655
FIA 8.87E+121   665.010315.03736
FIA 2.40E+131   665.010315.03736
FIA 2.51E+131   666.838814.99613
FIA 2.30E+131   601.457616.62628
FIA 2.36E+131   599.042316.69331
FIA 8.94E+121   624.354216.01655
FIA 2.51E+132   672.45  29.74199
FIA 2.94E+131   659.391515.1655
FIA 2.51E+131   666.838814.99613
FIA 2.29E+131   661.814115.10998
FIA 2.51E+131   672.45  14.87099
FIA 2.38E+131   669.743 14.9311
FIA 2.99E+132   672.45  29.74199
FIA 2.42E+131   652.372315.32867
FIA 2.29E+131   634.697615.75554
FIA 2.30E+131   628.595215.90849
FIA 1.31E+133   671.242844.69321
FIA 2.36E+131   671.611 14.88957
FIA 8.94E+122   619.986932.25875
FIA 1.31E+131   634.697615.75554
FIA 2.37E+131   659.391515.1655
FIA 2.38E+131   601.457616.62628
FIA 2.38E+132   670.308429.83701
FIA 2.30E+131   669.112814.94516
FIA 2.37E+132   168.1125118.96795
FIA 1.32E+133   644.090346.57732
FIA 2.99E+131   645.840615.4837
FIA 2.37E+131   649.202815.40351
FIA 2.94E+132   659.391530.331
FIA 2.30E+133   659.391545.49649
FIA 8.87E+121   669.112814.94516
FIA 2.42E+131   525.095219.04416
FIA 1.31E+133   589.211450.91551
FIA 8.94E+123   624.354248.04965
FIA 2.29E+131   613.221616.30732
FIA 2.43E+132   498.757740.09963
FIA 1.32E+132   659.391530.331
FIA 2.43E+131   550.892518.15236
FIA 1.31E+131   613.221616.30732
FIA 2.29E+131   634.697615.75554
FIA 2.37E+134   613.221665.22927
FIA 2.30E+133   661.814145.32995
FIA 2.43E+132   525.095238.08833
FIA 1.31E+131   512.366119.51729
FIA 8.89E+121   463.758621.56294
FIA 2.29E+131   634.697615.75554
FIA 2.50E+131   550.892518.15236
FIA 8.92E+121   672.45  14.87099
FIA 2.38E+131   669.112814.94516
FIA 1.31E+131   634.697615.75554
FIA 2.30E+134   659.391560.66199
FIA 2.40E+131   

Re: [R] need descriptive help

2012-06-05 Thread mkm1616
Thank you Rui. Appreciate the help.

Apologies for badgering the msg board. lol

On Jun 5, 11:28 am, Rui Barradas ruipbarra...@sapo.pt wrote:
 Hello,

 Try

 Total - aggregate(cost~patient, data=x)
 Total[Total$cost  1000, ]

 As for writing to a csv file, see ?write.csv

 Hope this helps,

 Rui Barradas

 Em 05-06-2012 16:34, mkm1616 escreveu:





  Hi all, I'm new to using R, and apologize for simplicity of this
  question.

  I'm using a data set with over 60,000 observations, Two variables are
  patient ID, and cost incurred by the patient.  I'd like to generate
  frequency/table by patient and cost IF the total cost is over 2000.

  Right now I'm using:

  by(x$cost, x$patient, sum)

  but this generates a huge list for each patient.

  What is the best way to either (1) export the output into a csv so I
  can visually inspect each patient or more helpful (2) create the table
  IF sum of cost  1000

  Thanks!

  __
  r-h...@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.- Hide 
 quoted text -

 - Show quoted text -

__
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] Trouble with Functions

2012-06-05 Thread dougmcintosh
Hi guys,

I'm a new to R and following along with Tutorials using this book:
http://www.amazon.com/Practical-Statistical-Analysis-Non-structured-Applications/dp/012386979X

In one of them, they use the twitteR package and describe the following
function (see below). From what I can tell from the documentation (R),
there's a method to call it directly in an interactive session. The way it's
presented in the book, however, it appears it's formatted for a text file
that (I'm assuming) you call using source(). At any rate, when I read it
into the session using source I get errors and I can't find documentation on
what's wrong (or tell from the feedback). Hoping you can help!

/Implementing Our Sentiment Scoring Algorithm


To score each tweet, our score.sentiment() function uses laply() to iterate
through the input text. It strips punctuation and control characters from
each line using R’s regular expression-powered substitution function, gsub()
and uses match() against each word list to find matches:/

score.sentiment = function(sentences, pos.words, neg.words,
.progress=’none’)

{
require(plyr)
require(stringr)

# we got a vector of sentences. plyr will handle a list
# or a vector as an “l” for us
# we want a simple array of scores back, so we use
# “l” + “a” + “ply” = “laply”:

scores = laply(sentences, function(sentence, pos.words, neg.words) {

# clean up sentences with R’s regex-driven global substitute, gsub():

sentence = gsub(‘[[:punct:]]’, ”, sentence)
sentence = gsub(‘[[:cntrl:]]’, ”, sentence)
sentence = gsub(‘\\d+’, ”, sentence)

# and convert to lower case:
sentence = tolower(sentence)

# split into words. str_split is in the stringr package
word.list = str_split(sentence, ‘\\s+’)

# sometimes a list() is one level of hierarchy too much
words = unlist(word.list)

# compare our words to the dictionaries of positive  negative terms
pos.matches = match(words, pos.words)
neg.matches = match(words, neg.words)

# match() returns the position of the matched term or NA
# we just want a TRUE/FALSE:

pos.matches = !is.na(pos.matches)
neg.matches = !is.na(neg.matches)

# and conveniently enough, TRUE/FALSE will be treated as 1/0 by sum():
score = sum(pos.matches) - sum(neg.matches)
return(score)
}, pos.words, neg.words, .progress=.progress)

scores.df = data.frame(score=scores, text=sentences)
return(scores.df)
}



--
View this message in context: 
http://r.789695.n4.nabble.com/Trouble-with-Functions-tp4632456.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] need descriptive help

2012-06-05 Thread arun
Hi,

Oops! I selected the wrong columns in the previous reply.
Try this:

 set.seed(1)
 
 dat2-data.frame(patient=rep(c(1:20),5),cost=rnorm(100,15,1))
 agg1-aggregate(dat2,by=list(dat2$patient),FUN=sum)
  agg2-agg1$cost 75
 agg3-data.frame(agg1[agg2,c(1,3)])
 names(agg3)-c(patient,cost)
 agg3






- Original Message -
From: mkm1616 mkm1...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Tuesday, June 5, 2012 11:34 AM
Subject: [R] need descriptive help

Hi all, I'm new to using R, and apologize for simplicity of this
question.

I'm using a data set with over 60,000 observations, Two variables are
patient ID, and cost incurred by the patient.  I'd like to generate
frequency/table by patient and cost IF the total cost is over 2000.

Right now I'm using:

by(x$cost, x$patient, sum)

but this generates a huge list for each patient.

What is the best way to either (1) export the output into a csv so I
can visually inspect each patient or more helpful (2) create the table
IF sum of cost  1000

Thanks!

__
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] Trouble with Functions

2012-06-05 Thread dougmcintosh
FYI - here are the errors (I can get rid of the first one by removing the
progress parameter - which I understand controls whether a progress bar is
displayed). The second one stops at the gsub call.

Maybe if someone could give me a properly formatted example I could work
from instead?

Thanks!
(the caret is underneath the ? after progress in the first case, and under
the parenthesis in the second)
 source('/Documents/score.txt')
Error in source(Documents/score.txt) : 
  /Users/dougmcintosh/Documents/score.txt:1:73: unexpected input
1: score.sentiment = function(sentences, pos.words, neg.words, .progress = ?
   
 source('/Documents/score.txt')
Error in source(Documents/score.txt) : 
  /Users/dougmcintosh/Documents/score.txt:15:17: unexpected input
14: 
15: sentence = gsub(?



--
View this message in context: 
http://r.789695.n4.nabble.com/Trouble-with-Functions-tp4632456p4632460.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] preserving date formats in functions

2012-06-05 Thread jween
Hi there!

I have two date columns in a dataframe I need to selectively collapse based
on missing values and which date comes first (imported from an text file).
This is what I did:

RHSSP$CT- as.POSIXct(RHSSP$CT, 
format='%m/%d/%y %H:%M')
RHSSP$MRI   - as.POSIXct(RHSSP$MRI, 
format='%m/%d/%y %H:%M')
RHSSP$Scan  -
ifelse(is.na(RHSSP$MRI),RHSSP$CT,ifelse(is.na(RHSSP$CT),RHSSP$MRI,ifelse(RHSSP$CTRHSSP$MRI,RHSSP$MRI,RHSSP$CT)))

RHSSP$CT and RHSSP$MRI remain properly formatted (e.g.: 2011-06-21 22:31:00
PDT) BUT RHSSP$Scan does not (e.g.: 1294076700)

I can't figure out how to maintain the proper format during the replacement.
Looks like the replacement inherits the ifelse comparison format.

Any suggestions?

Many thanks

Jon

--
View this message in context: 
http://r.789695.n4.nabble.com/preserving-date-formats-in-functions-tp4632435.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] rowSums problem

2012-06-05 Thread alonis10
This is precisely what I needed; I can't believe how simple it is. Thanks!

--
View this message in context: 
http://r.789695.n4.nabble.com/rowSums-problem-tp4632405p4632461.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] Piecewise Lasso Regression

2012-06-05 Thread Lucas Santana dos Santos
Hi All,


I am trying to fit a piecewise lasso regression, but package Segmented does not 
work with Lars objects.
Does any know of any package or implementation of piecewise lasso regression?

Thanks,

Lucas
__
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 obtain the current active path of a function that's being called?

2012-06-05 Thread arun


Hi Dave,

I am interested in your suggestion.  But, look at this scenario.
 func-function()x
 comment(func)-test
 comment(func)
[1] test

 func-function()y
 comment(func)-test2
 comment(func)
[1] test2
 func-function()x
 comment(func)
NULL
 func-function()y
 comment(func)
NULL


Does it imply that it needs different objects?
Thanks,


A.K







- Original Message -
From: David Winsemius dwinsem...@comcast.net
To: Michael comtech@gmail.com
Cc: r-help r-h...@stat.math.ethz.ch
Sent: Tuesday, June 5, 2012 8:12 PM
Subject: Re: [R] How do I obtain the current active path of a function that's 
being called?


On Jun 5, 2012, at 7:51 PM, Michael wrote:

 Thanks so much for your help!
 
 I'd like but however I couldn't provide the code since they are not in
 public domain...
 
 But lets imagine I inherited a big pile of R projects/codes from other
 people and there are lots of sources in the programs.
 
 And there are many definitions of function A in the directories.
 
 I wanted to put a breakpoint into the relavant function A that's
 currently in the workspace, i.e. the one I am using...
 
 To insert a breakpoint, I need to find its location in the file system... I
 need to find where it is...
 
 Simply searching by the name in the file system gave lots of hits...

You could go through and label each of the `A` functions with a comment that 
designated the file from which they were loaded.

 func - function() x
 comment(func) - test
 comment(func)
[1] test

--David.

 
 Thank you!
 
 On Tue, Jun 5, 2012 at 4:35 PM, Andrew Miles rstuff.mi...@gmail.com wrote:
 
 Can you provide an example of the code file that you use to call the
 different functions?  Without that it might be hard for people to answer
 your question.
 
 Offhand, I'd say that it is whatever version of function A was called
 last.  If you are loading functions into the workspace, they are treated as
 any other object, which is to say that you can only have one function of
 the same name at a time.  Hence whenever you call a source file to load in
 function A, the old function A gets overwritten.
 
 Andrew Miles
 
 
 On Jun 5, 2012, at 4:58 PM, Michael wrote:
 
 Hi all,
 
 How do I obtain the current active path of a function that's being
 called?
 
 That's to say, I have several source files and they all contain
 definition
 of function A.
 
 I would like to figure out which function A and from which file is the
 one
 that's being called and is currently active?
 
 Thanks a lot!
 
      [[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.htmlhttp://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.

David Winsemius, MD
West Hartford, CT

__
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 to compute boundaries for bivariate normal distribution in group sequential design

2012-06-05 Thread jeka12386
Hi all

Dear all, 
I need to compute boundaries for 3 stages group sequential design with 2
variables using Simpson’s integration method. 
There is a r program written by Michael A. Proschant et Al. (2006)
(Statistical Monitoring of Clinical Trials: A Unified Approach) – see file
attached – to calculate boundaries for 1 variable only. 
Does anyone know how this program can be modified to incorporate a second
variable? Or propose an alternative solution please?

Many thanks 

Jeka

http://r.789695.n4.nabble.com/file/n4632450/Boundary.R Boundary.R 

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-compute-boundaries-for-bivariate-normal-distribution-in-group-sequential-design-tp4632450.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] ggplot incorrect legend

2012-06-05 Thread jcrosbie
How do I create a legend with ggplot?

I think should be getting the FuelTypeNum in the legend. 

Plot:
http://r.789695.n4.nabble.com/file/n4632471/Rplot.jpeg 

My code is:
ggplot(data=tempTable, aes(x=Bands8, y=SubPercent, fill=FuelTypeNum)) +
  geom_bar(position=stack, stat=identity) +
  scale_colour_hue('my legend', breaks = levels(tempTable$FuelTypeNum),
labels=c('Bio', 'Coal', 'Gas', 'Hydro','Other'))


tempTable:
   FuelTypeNum Bands8 AvailableMW AvailableMWNewFormat   SubPercent
11PB0  185351  185.351 4.355864e-03
22PB02599475325994.753 6.108928e-01
34PB0 1369528 1369.528 3.218476e-02
45PB01452252114522.521 3.412883e-01
5   10PB0  479915  479.915 1.127830e-02
62PB1   48229   48.229 5.736753e-02
75PB1  792473  792.473 9.426325e-01
82PB21179240211792.402 7.914544e-01
94PB2   27187   27.187 1.824672e-03
10   5PB2 2770769 2770.769 1.859619e-01
11  10PB2  309303  309.303 2.075906e-02
12   1PB3  480.048 3.983475e-05
13   2PB3  136844  136.844 1.135656e-01
14   4PB3   65079   65.079 5.400845e-02
15   5PB3  793226  793.226 6.582909e-01
16  10PB3  209781  209.781 1.740953e-01
17   1PB4   22113   22.113 4.340998e-02
18   2PB4   57843   57.843 1.135515e-01
19   4PB4   20315   20.315 3.988033e-02
20   5PB4  382714  382.714 7.513050e-01
21  10PB4   26414   26.414 5.185326e-02
22   1PB5   39173   39.173 3.232381e-02
23   2PB5  174913  174.913 1.443304e-01
24   4PB5  103542  103.542 8.543824e-02
25   5PB5  874764  874.764 7.218162e-01
26  10PB5   19501   19.501 1.609135e-02
27   1PB6   40.004 4.550429e-06
28   2PB6  175038  175.038 1.991245e-01
29   4PB6   91547   91.547 1.041445e-01
30   5PB6  610371  610.371 6.943625e-01
31  10PB620782.078 2.363948e-03
32   1PB7   36103   36.103 1.109041e-02
33   2PB7  210681  210.681 6.471866e-02
34   4PB7  739013  739.013 2.270159e-01
35   5PB7 2239824 2239.824 6.880469e-01

--
View this message in context: 
http://r.789695.n4.nabble.com/ggplot-incorrect-legend-tp4632471.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] How to calculate chi sqaure value from statistical value and degrees of freedom?

2012-06-05 Thread Manish Gupta
Hi, 

My input is chi square statistical value and degrees of freedom. But i m
getting different p values with the above formula.

I double checked my values with the below calculator. 

http://vassarstats.net/tabs.html#csq

Pls help me out.  

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-calculate-chi-sqaure-value-from-statistical-value-and-degrees-of-freedom-tp4632385p4632467.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] Combine subsets by factor level

2012-06-05 Thread lglucia
I'm attempting to change a data set by compressing rows into columns.
Currently there are several rows that all have information about one
patient, but at different cycles. I'm trying to make each patient only
have one row in the data set.

Does anyone know a good way to combine data sets by factor level? I've
separated the groups into different subsets by cycle, but not every patient
has data for every cycle (i.e. there are 1200 who have cycle 0, but only 200
of those have a cycle 1, and a different number have cycles higher than
that, etc). I then made the patient number the identifying label. If there
is a way to column-combine these subsets by the factor level of these
patient names, and leave any patients that are missing a cycle as NA?

If anyone has insight on how to do this, or a better way to complete what
I'm trying to do, I'd appreciate it!

--
View this message in context: 
http://r.789695.n4.nabble.com/Combine-subsets-by-factor-level-tp4632472.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] How do I obtain the current active path of a function that's being called?

2012-06-05 Thread Greg Snow
You can use the debug, fix, or edit functions to insert break points
into the version of the function in memory without needing to edit the
original source code.

On Tue, Jun 5, 2012 at 5:51 PM, Michael comtech@gmail.com wrote:
 Thanks so much for your help!

 I'd like but however I couldn't provide the code since they are not in
 public domain...

 But lets imagine I inherited a big pile of R projects/codes from other
 people and there are lots of sources in the programs.

 And there are many definitions of function A in the directories.

 I wanted to put a breakpoint into the relavant function A that's
 currently in the workspace, i.e. the one I am using...

 To insert a breakpoint, I need to find its location in the file system... I
 need to find where it is...

 Simply searching by the name in the file system gave lots of hits...

 Thank you!

 On Tue, Jun 5, 2012 at 4:35 PM, Andrew Miles rstuff.mi...@gmail.com wrote:

 Can you provide an example of the code file that you use to call the
 different functions?  Without that it might be hard for people to answer
 your question.

 Offhand, I'd say that it is whatever version of function A was called
 last.  If you are loading functions into the workspace, they are treated as
 any other object, which is to say that you can only have one function of
 the same name at a time.  Hence whenever you call a source file to load in
 function A, the old function A gets overwritten.

 Andrew Miles


 On Jun 5, 2012, at 4:58 PM, Michael wrote:

  Hi all,
 
  How do I obtain the current active path of a function that's being
 called?
 
  That's to say, I have several source files and they all contain
 definition
  of function A.
 
  I would like to figure out which function A and from which file is the
 one
  that's being called and is currently active?
 
  Thanks a lot!
 
         [[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.htmlhttp://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.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.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] How do I obtain the current active path of a function that's being called?

2012-06-05 Thread Bert Gunter
See also ?trace ,?debugger, ?traceback and links therein.

-- Bert

On Tue, Jun 5, 2012 at 9:48 PM, Greg Snow 538...@gmail.com wrote:
 You can use the debug, fix, or edit functions to insert break points
 into the version of the function in memory without needing to edit the
 original source code.

 On Tue, Jun 5, 2012 at 5:51 PM, Michael comtech@gmail.com wrote:
 Thanks so much for your help!

 I'd like but however I couldn't provide the code since they are not in
 public domain...

 But lets imagine I inherited a big pile of R projects/codes from other
 people and there are lots of sources in the programs.

 And there are many definitions of function A in the directories.

 I wanted to put a breakpoint into the relavant function A that's
 currently in the workspace, i.e. the one I am using...

 To insert a breakpoint, I need to find its location in the file system... I
 need to find where it is...

 Simply searching by the name in the file system gave lots of hits...

 Thank you!

 On Tue, Jun 5, 2012 at 4:35 PM, Andrew Miles rstuff.mi...@gmail.com wrote:

 Can you provide an example of the code file that you use to call the
 different functions?  Without that it might be hard for people to answer
 your question.

 Offhand, I'd say that it is whatever version of function A was called
 last.  If you are loading functions into the workspace, they are treated as
 any other object, which is to say that you can only have one function of
 the same name at a time.  Hence whenever you call a source file to load in
 function A, the old function A gets overwritten.

 Andrew Miles


 On Jun 5, 2012, at 4:58 PM, Michael wrote:

  Hi all,
 
  How do I obtain the current active path of a function that's being
 called?
 
  That's to say, I have several source files and they all contain
 definition
  of function A.
 
  I would like to figure out which function A and from which file is the
 one
  that's being called and is currently active?
 
  Thanks a lot!
 
         [[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.htmlhttp://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.



 --
 Gregory (Greg) L. Snow Ph.D.
 538...@gmail.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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.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] Do YOU know an equation for splines (ns)?

2012-06-05 Thread Bert Gunter
Does
?predict.ns
not do what you want without having to explicitly manipulate the spline basis?

-- Bert

On Tue, Jun 5, 2012 at 1:56 PM, Ranae ranae.diet...@gmail.com wrote:
 Hi,

 I am looking at the change in N concentration in plant roots over 4 time
 points and I have fit a spline to the data using ns and lme:

 fit10 - lme( N~ns(day, 3), data = rcn10G)

 I may want to adjust the model a little bit, but for now, let's assume it's
 good.  I get output for the fixed effects:

 Fixed: N ~ ns(day, 3)
 (Intercept) ns(day, 3)1 ns(day, 3)2 ns(day, 3)3
  1.15676524  0.14509171  0.04459627  0.09334428

 and coefficients for each experimental unit in my experiment:

   (Intercept) ns(day, 3)1 ns(day, 3)2 ns(day, 3)3
 24    1.050360 -0.42666159 -0.56290877 -0.10714407
 13    1.104464 -0.30825350 -0.53311653 -0.05558150
 31    1.147878 -0.14548512 -0.78673906 -0.07231781
 46    1.177781 -0.22278380 -0.80278177 -0.02321460
 15    1.144215 -0.04484519 -0.06084798  0.07633663
 32    1.213007  0.00741061  0.03896933  0.15325849
 23    1.274615  0.16477514  0.00872224  0.23128320
 41    1.215626  0.57050767  0.11415467  0.10608867
 43    1.134203  0.48070741  0.72112899  0.18108193
 12    1.091422  0.39563632  1.01521528  0.22597459
 21    1.100631  0.44589314  0.98526322  0.23535739
 35    1.226980  0.82419937  0.39809568  0.16900841

 NOW, I want to write a spline function where I can incorporate these
 coefficients to get the predicted N concentration value for each day.
 However, I am having trouble finding the right spline equation, since there
 are many forms on the internets.

 I know it won't be a simple one, but can some one direct me to the equation
 that would be best to use for ns?

 Thanks a lot,

 Ranae


 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Do-YOU-know-an-equation-for-splines-ns-tp4632440.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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.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] Ifelse on matrix using a vector argument

2012-06-05 Thread Özgür Asar
Hi,

A practical way migh be

 out-rep(matrix(arg),4)-ma
 out[2,]--out[2,];out[5,]--out[5,]
 out
 [,1] [,2] [,3] [,4]
[1,]  0.8  0.4 0.80  1.0
[2,]  1.0  0.0 1.00  0.3
[3,]  0.7  0.9 0.65  1.0
[4,]  1.0  0.5 0.60  0.9
[5,]  0.5  1.0 0.00  1.0

Best
Ozgur


--
View this message in context: 
http://r.789695.n4.nabble.com/Ifelse-on-matrix-using-a-vector-argument-tp4632485p4632487.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] Math labels in .eps files

2012-06-05 Thread Fredrik Karlsson
Dear Professor Ripley,

Thank you for your prompt answer. Indeed, cairo_ps solved the problem for me.

Thank you!

Fredrik 

5 jun 2012 kl. 11:51 skrev Prof Brian Ripley rip...@stats.ox.ac.uk:

 On 04/06/2012 17:25, Fredrik Karlsson wrote:
 Dear list,
 
 I have non-ascii labels that I want to include somethow in a .eps file for
 inclusion into a LateX document. Is this possible?
 
 What I see is that the (attached)  png file looks ok but the .eps renders
 all non-ascii labels at the bottom as [..].
 
 
 I've searched around enough to learn that including math labels in a .eps
 is a problem. Hower, is there a solution too somewhere?
 
 I don't think it is a problem: see ?plotmath.  But the problem here is that 
 you seem to want glyphs not in the plotmath set.
 
 You have neither told us your platform nor the R code you used (as requested 
 in the posting guide), so we cannot reproduce this.  But see ?postscript and 
 its section 'Encodings'.  You need to specify a PostScript encoding which 
 contains your glyphs ... if there is one. Note too
 
 See Also:
 
 ‘cairo_ps’ for another device that can produce PostScript.
 
 -- 
 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.