Re: [R] lm and time series.

2008-09-06 Thread rkevinburton
That is the thing. As a new comer to 'R' I don't understand how to write a 
formula when all I have is a time series. I don't know how to express the 
independent and dependent variables in a formula when the object is a time 
series. So please just solve this simple example and I will extrapolate from 
there.

Say the units of the time series is days and the value at each point is the 
response. If I wanted to fit a straiight line through the following time series:

y - 4:7
t - ts(y)

So this is saying to me something like 4 units were sold on the first day, 5 on 
the second, 6 on the third, and 7 on the fourth.

So given the time series t I want to find the slope and inercept:

y = m*x + b

with x in days and the respoinse would be the number of units sold. I need to 
find 'm' and 'b'. If all I have is t (the time series above) then what would be 
the formula, and for that matter the arguments to lm to give the desired result?

fit - lm(???)

Thank you.

Kevin

 stephen sefick [EMAIL PROTECTED] wrote: 
 So you want time as the independent variable?  Let's say that the
 units of y in your first example were seconds- couldn't you just use a
 regular lm and say that the units were seconds, minutes, or what ever?
  I am probably out of my league here, but I am just not understanding
 what it is that you want.  a time series is just a series of data
 points indexed by time.  Arima maybe, or some other cool times series
 modeling approach- wavelet, spectral density- for frequency domain
 type things...  What are you trying to accomplish?
 
 On Fri, Sep 5, 2008 at 5:47 PM,  [EMAIL PROTECTED] wrote:
  I want to fit a function to time series. If I had:
 
  x - 1:4
  y - 1:4
 
  lm(y~x)
 
  This would fit a simple line to the four points. But if it is represented 
  as a time series
 
  x - 1:4
  t - ts(x)
 
  lm()
 
  So I have a time series in the object t. How do I write a formula for lm? 
  What do I put in the formula for x and y when I only have t (the time 
  series).
 
  Kevin
 
   stephen sefick [EMAIL PROTECTED] wrote:
  what do you want to do?
 
  On Fri, Sep 5, 2008 at 3:22 PM,  [EMAIL PROTECTED] wrote:
   I am sorry but I looked at ?lm and could not see any guidance on 
   writting a formula. If I have two arrays or a data set then I know how 
   to do that (y ~ x) but for a time series I am not sure how to write y or 
   x.
  
   Thank you.
  
   Kevin
  
    Gabor Grothendieck [EMAIL PROTECTED] wrote:
   The Time Series section in ?lm should be self explanatory.   If you are 
   using
   diff's and lag's then look at the dyn package.
  
   On Fri, Sep 5, 2008 at 12:25 PM,  [EMAIL PROTECTED] wrote:
I did a ?lm and it said basically to be careful when using lm and a 
time series. But my question is probably more to do with my 
inexperience that anything. If I have a time series object 'ti' how 
do I write the formula? The response is the value at any particular 
time and the time is basically the index of the time series. But I 
don't know how to put that into a formula.
   
Thank you.
   
Kevin
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide 
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
 
 
 
  --
  Stephen Sefick
  Research Scientist
  Southeastern Natural Sciences Academy
 
  Let's not spend our time and resources thinking about things that are
  so little or so large that all they really do for us is puff us up and
  make us feel like gods. We are mammals, and have not exhausted the
  annoying little problems of being mammals.
 
-K. Mullis
 
 
 
 
 
 -- 
 Stephen Sefick
 Research Scientist
 Southeastern Natural Sciences Academy
 
 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods. We are mammals, and have not exhausted the
 annoying little problems of being mammals.
 
   -K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] annotating objects in workspace

2008-09-06 Thread Prof Brian Ripley

See ?comment

On Fri, 5 Sep 2008, Alexy Khrabrov wrote:

Is there a way to associate descriptions with the objects in the workspace, 
and later retrieve them to know what the object was created for?


Thanks,
Alexy

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


--
Brian D. Ripley,  [EMAIL PROTECTED]
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] lm and time series.

2008-09-06 Thread Achim Zeileis

On Fri, 5 Sep 2008, [EMAIL PROTECTED] wrote:

That is the thing. As a new comer to 'R' I don't understand how to write 
a formula when all I have is a time series. I don't know how to express 
the independent and dependent variables in a formula when the object is 
a time series. So please just solve this simple example and I will 
extrapolate from there.


Say the units of the time series is days and the value at each point is 
the response. If I wanted to fit a straiight line through the following 
time series:


y - 4:7
t - ts(y)

So this is saying to me something like 4 units were sold on the first 
day, 5 on the second, 6 on the third, and 7 on the fourth.


So given the time series t I want to find the slope and inercept:

y = m*x + b

with x in days and the respoinse would be the number of units sold. I 
need to find 'm' and 'b'. If all I have is t (the time series above) 
then what would be the formula, and for that matter the arguments to lm 
to give the desired result?


fit - lm(???)


y - ts(4:7)
lm(y ~ time(y))

And as previously pointed out to you: To preserve the time series 
properties, look at ?lm, the dynlm and dyn packages.

Z


Thank you.

Kevin

 stephen sefick [EMAIL PROTECTED] wrote:

So you want time as the independent variable?  Let's say that the
units of y in your first example were seconds- couldn't you just use a
regular lm and say that the units were seconds, minutes, or what ever?
 I am probably out of my league here, but I am just not understanding
what it is that you want.  a time series is just a series of data
points indexed by time.  Arima maybe, or some other cool times series
modeling approach- wavelet, spectral density- for frequency domain
type things...  What are you trying to accomplish?

On Fri, Sep 5, 2008 at 5:47 PM,  [EMAIL PROTECTED] wrote:

I want to fit a function to time series. If I had:

x - 1:4
y - 1:4

lm(y~x)

This would fit a simple line to the four points. But if it is represented as a 
time series

x - 1:4
t - ts(x)

lm()

So I have a time series in the object t. How do I write a formula for lm? What 
do I put in the formula for x and y when I only have t (the time series).

Kevin

 stephen sefick [EMAIL PROTECTED] wrote:

what do you want to do?

On Fri, Sep 5, 2008 at 3:22 PM,  [EMAIL PROTECTED] wrote:

I am sorry but I looked at ?lm and could not see any guidance on writting a 
formula. If I have two arrays or a data set then I know how to do that (y ~ x) 
but for a time series I am not sure how to write y or x.

Thank you.

Kevin

 Gabor Grothendieck [EMAIL PROTECTED] wrote:

The Time Series section in ?lm should be self explanatory.   If you are using
diff's and lag's then look at the dyn package.

On Fri, Sep 5, 2008 at 12:25 PM,  [EMAIL PROTECTED] wrote:

I did a ?lm and it said basically to be careful when using lm and a time 
series. But my question is probably more to do with my inexperience that 
anything. If I have a time series object 'ti' how do I write the formula? The 
response is the value at any particular time and the time is basically the 
index of the time series. But I don't know how to put that into a formula.

Thank you.

Kevin


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





--
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

  -K. Mullis







--
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] request

2008-09-06 Thread Ram Kumar Basnet
hi 
I am expecting the mails that will flow in R- help after subscribing this but 
could not. Can you provide me the right form.
Thanks.


  
[[alternative HTML version deleted]]

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


[R] request: most repeated sequnce

2008-09-06 Thread Muhammad Azam
Dear R community
Hope every one be in best of his/her health. I have a situation in which there 
are s-sectors. Each sector is further divided into r-rows and c-columns. All it 
makes an array having dimension (r,c,s). e.g.

x=c(1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,3,3,3,4,4,4,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,
0,0,0,0,0,0,1,2,2,2,2,2,0,3,3,0,4,4,0,0,0,0,0,0)
x=array(x,dim=c(3,6,5))
 x
, , 1

 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]100000
[2,]100000
[3,]100000

, , 2

 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]123000
[2,]123000
[3,]120000

, , 3

 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]123400
[2,]123400
[3,]134000

, , 4

 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]123400
[2,]123400
[3,]123400

, , 5

 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]120000
[2,]223400
[3,]223400 

I want to get the most repeated sequence (row-wise) of values in each sector. 
e.g. in sector 1 i.e. , , 1
the most repeated sequence is 1 (ignoring zeros). In , , 2 the most repeated 
sequence is 1  2  3. Similarly in last sector i.e. 
 , , 5 such sequence is  2  2  3  4. Any body can help to solve this problem. 
Thanks


best regards
Muhammad Azam



  
[[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] Hopefully an easy error bar question

2008-09-06 Thread Brown, Heidi
Hi im trying to add error bars to my barplots, there very basic, i have a few 
grapghs where the y variable is different but on all the X variable is Age 
(Adult and Juvenile) however this is split into two levels so i have males and 
females, so my graph basically has four bars on it.
 
I know how to add eror bars for instance when there is only one level eg lookng 
at the diffrence between male and female lizards and tree height and have used 
the code:
 
error.bars-function(yv,z,nn) {
 xv-
barplot(yv,ylim=c(0,(max(yv)+max(z))),names=nn,ylab=deparse(substitute(yv)
))
g=(max(xv)-min(xv))/50
for (i in 1:length(xv)) {
lines(c(xv[i],xv[i]),c(yv[i]+z[i],yv[i]-z[i]))
lines(c(xv[i]-g,xv[i]+g),c(yv[i]+z[i], yv[i]+z[i]))
lines(c(xv[i]-g,xv[i]+g),c(yv[i]-z[i], yv[i]-z[i]))
}}
 
Have then worked out the standard errors and added that using:
 
se-c()
 
and then added the final bit of code:
 
labels-as.character(levels(Sex2))
ybar-as.vector(tapply(Height2,Sex2,mean))
error.bars(ybar,se,labels)

So i was wondering, in order to get error bars on my barplot with two levels do 
i need to change the last bit of code. For example im looking at mean body 
condition (y) against age (x) and sex (level), i tried to change the code to 
the following but it didnt work, any suggestions?

labels-as.character(levels(list(sex,Age)))
ybar-as.vector(tapply(ConditionIndex,sex,Age,mean))
error.bars(ybar,se,labels)

 

 



[[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] Plotting the complex fft in 3D?

2008-09-06 Thread Martin Maechler
Just another remakr on this thread.

I you have  time series and think about its fourier transform
(EE language) then you should know that the statistical language
of that is spectral analysis or maybe
 frequency domain time-series analysis
and the R function to consider should definitely be

spectrum()  which is a wrapper (among others) to spec.pgram()
-- which calls fft() -- for computing the so-called
periodogram.
If you learn more about the topic, you will learn that in almost
all cases you'd consider a *smoothed* version of the
periodogram, etc etc (because the so-called *raw* periodgram is
*in*consistent as an estimate fo the underlying true spectrum).
The Time-Series chapter/section of the MASS book is very helpful
here, IIRC.

Martin Maechler, ETH Zurich



 OB == Oliver Bandel [EMAIL PROTECTED]
 on Thu,  4 Sep 2008 23:16:07 +0200 writes:

OB Zitat von Duncan Murdoch [EMAIL PROTECTED]:
 On 04/09/2008 4:44 PM, Oliver Bandel wrote:
  Zitat von Duncan Murdoch [EMAIL PROTECTED]:
 
  Oliver Bandel wrote:
  Hello,
 
 
OB [...]


 plot3d doesn't support that directly, but you could plot with
 type='n',
 then use segments3d to add the lines.
 
 
  BTW: how to change the perspective? I did not found an
  angle-parameter for the plot3d()-function.
 
 Just grab it with your mouse and drag.

OB Wow, coool! :-)

OB Well, rgl I think gl stands for OpenGl.

OB Fine. :-)


 Alternatively,
 play3d(spin3d())
 will spin it, or par3d(userMatrix=rotationMatrix(...)) for a fixed
 setting.

OB Ok, some thinsg to play with.

OB Thank you.


OB Ciao,
OB Oliver

OB __
OB R-help@r-project.org mailing list
OB https://stat.ethz.ch/mailman/listinfo/r-help
OB PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
OB 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] [R-pkgs] New caret packages

2008-09-06 Thread Max
New major versions of the caret packages (caret 3.37, caretLSF 1.23 and
caretNWS 0.23) have been uploaded to CRAN.

caret is a package for building and evaluating a wide variety of predictive
models. There are functions for pre-processing, tuning models using
resampling, visualizing the results, calculating performance and estimating
variable importance.  caretNWS and caretLSF are two parallel processing
versions that can reduce the training time when multiple compute nodes are
available.

The project is now hosted on R-Forge. The homepage is

   http://caret.r-forge.r-project.org/

The package currently includes model tuning/resampling for the following
models: lm, single trees (C4.5, rpart, ctree, logistic model trees), mars
(via earth), boosted models (ada, gbm, blackboost, glmboost, gamboost,
logitboost), bagged models (trees, earth, fda), randomforests (randomforest
and cforest), rule-based models (Ripper and M5 prime), discriminant models
(lda, fda, rda, ssda, slda), kernel methods (lssvm, ksvm, rvm, gausspr),
nnet, nnet with initial pca step, multinom, pls, plsda, gpls, nearest
shrunken centroids, the lasso, the elastic net, supervised pca, knn, lvq and
NaiveBayes.

Recent changes include:
 - Estimation of class probabilities from PLS discriminant analysis using
Bayes rule (in addition to softmax)
- Added predict.train and predit.list
- More lattice plots to visualize resampling results (xyplot, stripplot,
densitplot, histogram)
- User-specified performance metrics for resampling
- User-specified algorithms for determining the optimal tuning parameters
(instead of highest/lowest)
- A CHANGES files now exists to track the specifics of the version changes
 
Max

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] new to R

2008-09-06 Thread sudeshna

hi im starting with R.have no idea to start...plz help
-- 
View this message in context: 
http://www.nabble.com/new-to-R-tp19342903p19342903.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] new to R

2008-09-06 Thread Paul Smith
On Sat, Sep 6, 2008 at 5:10 AM, sudeshna [EMAIL PROTECTED] wrote:

 hi im starting with R.have no idea to start...plz help

Search the Internet for online tutorials and/or read an introductory
book (search for them, e.g., on Amazon.Com).

Good luck,

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] new to R

2008-09-06 Thread Jim Lemon

sudeshna wrote:

hi im starting with R.have no idea to start...plz help
  

Hi sudeshna,
There are several beginner's guides on the CRAN website. Go to:

http://cran.r-project.org

and select Contributed (second last option on the left).

Jim

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


Re: [R] Hopefully an easy error bar question

2008-09-06 Thread Jim Lemon

Brown, Heidi wrote:

Hi im trying to add error bars to my barplots, there very basic, i have a few 
grapghs where the y variable is different but on all the X variable is Age 
(Adult and Juvenile) however this is split into two levels so i have males and 
females, so my graph basically has four bars on it.
 
I know how to add eror bars for instance when there is only one level eg lookng at the diffrence between male and female lizards and tree height and have used the code:
 
error.bars-function(yv,z,nn) {

 xv-
barplot(yv,ylim=c(0,(max(yv)+max(z))),names=nn,ylab=deparse(substitute(yv)
))
g=(max(xv)-min(xv))/50
for (i in 1:length(xv)) {
lines(c(xv[i],xv[i]),c(yv[i]+z[i],yv[i]-z[i]))
lines(c(xv[i]-g,xv[i]+g),c(yv[i]+z[i], yv[i]+z[i]))
lines(c(xv[i]-g,xv[i]+g),c(yv[i]-z[i], yv[i]-z[i]))
}}
 
Have then worked out the standard errors and added that using:
 
se-c()
 
and then added the final bit of code:
 
labels-as.character(levels(Sex2))

ybar-as.vector(tapply(Height2,Sex2,mean))
error.bars(ybar,se,labels)

So i was wondering, in order to get error bars on my barplot with two levels do 
i need to change the last bit of code. For example im looking at mean body 
condition (y) against age (x) and sex (level), i tried to change the code to 
the following but it didnt work, any suggestions?

labels-as.character(levels(list(sex,Age)))
ybar-as.vector(tapply(ConditionIndex,sex,Age,mean))
error.bars(ybar,se,labels)
  

Hi Heidi,
I think you may be having trouble with the x positions of the error 
bars. barplot returns these positions, so if you prepend xpos- to the 
barplot call, it will give you the positions for your error bars.


Jim

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


Re: [R] Plotting the complex fft in 3D?

2008-09-06 Thread Oliver Bandel
Hello Martin,

Zitat von Martin Maechler [EMAIL PROTECTED]:

 Just another remakr on this thread.

 I you have  time series and think about its fourier transform
 (EE language) then you should know that the statistical language
 of that is spectral analysis or maybe
  frequency domain time-series analysis
 and the R function to consider should definitely be
[...]

Yes, I'm coming from the EE world, but I also know the other terms.
The term spectral analysis is also used in EE, maybe not that often.
Also frequency domain time-series analysis is used in EE, but
maybe only at the university, later at the job, short terms
spectral analysis or fft are used. (But it may differ from country
to country.)


I tried spectrum now on my example data, and it looks quite different
to the result of fft().
It looks very close to what one gets as output from a spectrum analyzer
(measurement harware).
So it's quite nice to use this. :-)




 spectrum()  which is a wrapper (among others) to spec.pgram()
 -- which calls fft() -- for computing the so-called
 periodogram.
 If you learn more about the topic, you will learn that in almost
 all cases you'd consider a *smoothed* version of the
 periodogram, etc etc (because the so-called *raw* periodgram is
 *in*consistent as an estimate fo the underlying true spectrum).

Well, what do you mean with inconcistent?
And why is spectrum() better?

Do you talk about things like windowing for becoming more appropriate
results?

Even if the output from spectrum() looks more like what I know from
measurement hardware, it might not always be better.
Can yo explain, why better using this?
The FFT only creates coefficients for certain seperated
frequencies. It depends on number of samlpes how accurate the
result is. And if the samples aren't an integer multiple of the
frequency in the measured signal, this creates errors in the results.

Possibly this is, what you are talking about?

Why is spectrum() better? Would be nice to have an explanation,
on how it's results are created, so that I can understand,
when which kind of analysis is better.

For the non-EE analysis, why is there fft() used and not
spectrum()?

For what kind of analysis is what function better?


 The Time-Series chapter/section of the MASS book is very helpful
 here, IIRC.

MASS book? Do you mean the documentation of the MASS package?

Well, so much packages R is very powerful and provides a lot of
things.

But where to start?

Any idea?  I started with some introductional papers and got a
good overview. But a more systematical approach might be better.

Can you recommend some things to read?
I also have seen that there is one german book about programming in R.
I will look at it in more detail, when the new edition will be published
(sept/oct).

But maybe you can recommend other readings as well?

Thanks,
  Oliver

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] restricted bootstrap

2008-09-06 Thread Prof Brian Ripley

On Thu, 4 Sep 2008, Grant Gillis wrote:


Hello Professor Ripely,

Sorry for not being clear.  I posted after a long day of struggling.  Also
my toy distance matrix should have been symmetrical.

Simply put I have spatially autocorrelated data collected from many points.
I would like to do a linear regression on these data.  To deal with the
autocrrelation I want to resample a subset of my data with replacement but I
need to restrict subsets such that no two locations where data was collected
are closer than Xm apart (further apart than the autocrrelation in the
data).


That is impossible.  Resampling with replacement will give duplicated
locations (with a very high probability) and those have distance zero.

If you want a subsample (necessarily without replacement) you have a 
hard-core point process on a discrete set.  It's possible that the MCMC 
methods we used for Strauss processes can be made to work in that case, 
but it is also possible that the state space is reducible and so more 
elaborate algorithms are needed.


I do think it would be much easier to take autocorrelation into account in 
your linear model fit.  There are many ways to do that, e.g. MASS::lm.gls, 
and in fact uless the correlations are very high OLS is likely to be quite 
efficient (but you need to use e.g. a sandwich estimator to get reliable 
standard errors).



Thanks for having a look at this for me.  I will look up the hard-core
spatial point process.

Grant

2008/9/4 Prof Brian Ripley [EMAIL PROTECTED]


I see nothing here to do with the 'bootstrap', which is sampling with
replacement.

Do you know what you mean exactly by 'randomly sample'?  In general the way
to so this is to sample randomly (uniformly, whatever) and reject samples
that do not meet your restriction.   For some restrictions there are more
efficient algorithms, but I don't understand yours.  (What are the 'rows'?
 Do you want to sample rows in space or xy locations?  How come 'dist' is
not symmetric?)  For some restrictions, an MCMC sampling scheme is needed,
the hard-core spatial point process being a related example.


On Wed, 3 Sep 2008, Grant Gillis wrote:

 Hello List,


I am not sure that I have the correct terminology here (restricted
bootstrap) which may be hampering my archive searches.  I have quite a
large
spatially autocorrelated data set.  I have xy coordinates and the
corresponding pairwise distance matrix (metres) for each row.  I would
like
to randomly sample some number of rows but restricting samples such that
the
distance between them is larger than the threshold of autocorrelation.  I
have been been unsuccessfully trying to link the 'sample' function to
values
in the distance matrix.

My end goal is to randomly sample M thousand rows of data N thousand times
calculating linear regression coefficients for each sample but am stuck on
taking the initial sample. I believe I can figure out the rest.


Example Question

I would like to radomly sample 3 rows further but withe the restriction
that
they are greater than 100m apart

example data:
main data:

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

maindata-cbind(y, x, z, a)

   y x x a
[1,] 1 1 1 3
[2,] 2 3 3 9
[3,] 9 5 5 6
[4,] 5 7 7 4
[5,] 6 9 9 4

distance matrix:
row1-c(0, 123, 567, 89)
row2-c(98, 0, 345, 543)
row3-c(765, 90, 0, 987)
row4-c(654, 8, 99, 0)

dist-rbind(row1, row2, row3, row4)

   [,1] [,2] [,3] [,4]
row10  123  567   89
row2   980  345  543
row3  765   900  987
row4  6548   990

Thanks for all of the help in the past and now

Cheers
Grant

   [[alternative HTML version deleted]]

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



--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  
http://www.stats.ox.ac.uk/~ripley/http://www.stats.ox.ac.uk/%7Eripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595



[[alternative HTML version deleted]]

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



--
Brian D. Ripley,  [EMAIL PROTECTED]
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

[R] Help use try function with boot

2008-09-06 Thread ctu

Hi R users,
Is is possible for me to use the try function with boot? I would to do  
the bootstraping with a nonlinear model(it works well when R  1000).  
But it does not work very well (when R is large) thus I try to use  
try to resolve. I  put the try function in two cases:


case1: put the try in front of the boot


c1.try-try(boot(c1data, statistic = c1.fun, R=3999),silent=T)
c1.try
[1] Error in nls(formula = density ~ nmf(time, alpha, delta, psi,  
tau, gamma),  : \n  Convergence failure: false convergence (8)\n

attr(,class)
[1] try-error

case2: put the try in front of the nls
 c1.nmf-try(nls(density~nmf(time, alpha, delta, psi, tau, gamma),
+algorithm=port,data=c1,
+lower=c(alpha=0.1, delta=0, psi=0.2, tau=1, gamma=-5),
+upper=c(alpha=0.6, delta=0.1, psi=3, tau=7, gamma=2),
+start=c(alpha=0.35, delta=0,  psi=0.99, tau=4.5,  
gamma=-1.2)),silent=T)

c1.try-boot(c1data, statistic = c1.fun, R=3999)
  Error in nls(formula = density ~ nmf(time, alpha, delta, psi, tau,  
gamma),  :

  Convergence failure: iteration limit reached without convergence

Any suggestion will be helpful.
Many thanks in advance
Chunhao

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Hopefully an easy error bar question

2008-09-06 Thread Frank E Harrell Jr

Brown, Heidi wrote:

Hi im trying to add error bars to my barplots, there very basic, i have a few 
grapghs where the y variable is different but on all the X variable is Age 
(Adult and Juvenile) however this is split into two levels so i have males and 
females, so my graph basically has four bars on it.
 
I know how to add eror bars for instance when there is only one level eg lookng at the diffrence between male and female lizards and tree height and have used the code:
 
error.bars-function(yv,z,nn) {

 xv-
barplot(yv,ylim=c(0,(max(yv)+max(z))),names=nn,ylab=deparse(substitute(yv)
))
g=(max(xv)-min(xv))/50
for (i in 1:length(xv)) {
lines(c(xv[i],xv[i]),c(yv[i]+z[i],yv[i]-z[i]))
lines(c(xv[i]-g,xv[i]+g),c(yv[i]+z[i], yv[i]+z[i]))
lines(c(xv[i]-g,xv[i]+g),c(yv[i]-z[i], yv[i]-z[i]))
}}
 
Have then worked out the standard errors and added that using:
 
se-c()
 
and then added the final bit of code:
 
labels-as.character(levels(Sex2))

ybar-as.vector(tapply(Height2,Sex2,mean))
error.bars(ybar,se,labels)

So i was wondering, in order to get error bars on my barplot with two levels do 
i need to change the last bit of code. For example im looking at mean body 
condition (y) against age (x) and sex (level), i tried to change the code to 
the following but it didnt work, any suggestions?

labels-as.character(levels(list(sex,Age)))
ybar-as.vector(tapply(ConditionIndex,sex,Age,mean))
error.bars(ybar,se,labels)


See http://biostat.mc.vanderbilt.edu/DynamitePlots for many reasons not 
to use dynamite plots.


Frank

--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Test for equality of complicatedly related average correlations

2008-09-06 Thread Ralph79

Dear R-Users,

I am currently looking for a way to test the equality of two correlations
that are related in a very special way. Let me describe the situation with
an example.

- There are 100 respondents, and there are 2 points in time, t=1 and t=2. 

- For each of the respondents and at each of the time points, I have
information on 10 X-variables and on 10 Y-variables. 

- Based on this information, I calculate two correlations for each
respondent: cor(X[t=1],X[t=2]) and cor(Y[t=1],Y[t=2]), with X and Y being
the vectors of the corresponding 10 variables.

- Now I get the average correlations over the whole sample using Fishers
Z-transformation, i.e. I have mean(cor(X[t=1],X[t=2])) and
mean(cor(X[t=1],X[t=2])) and want to know if the mean correlations are
significantly different!


I haven't found any test that deals with exactly my situation. Therefore, I
simply apply a paired t-test based on the individual z-correlations. From
my point of view this should be ok, because of the z's normality. However, I
am unsure if there is a better way to test the hypothesis that I am
interested in?

I'd be grateful for any comment or hint.

Thank you very much,

Ralph

-
Ralph Wirth
University Erlangen-Nuremberg, Chair of Statistics
GfK Group, Department of Methods and Product Development

-- 
View this message in context: 
http://www.nabble.com/Test-for-equality-of-complicatedly-related-average-correlations-tp19346312p19346312.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] loop

2008-09-06 Thread Davide Crapis

I have to calculate a formula that gives me a ten components vector. I want
to see how the components behave at varying the variable i.
But when i run the following function:
 bbayes-c()
 for(i in 1:100) {
+ xx-t(X1_10)%*%X1_10
+ xxmeno1-solve(xx)
+ V-xxmeno1*i
+ Vmeno1-solve(V)
+ tx-t(X1_10)
+ prpar-solve(Vmeno1+xx)
+ snpar-tx%*%y
+ bbayes-prpar%*%snpar
+ }

it oly gives me the vector calculated with the last value of the sequence,
in this case 100.
Could you please suggest how to print all the 100 vectors calculated for i
in 1:100.

Thank you in advance.

Davide Crapis
-- 
View this message in context: 
http://www.nabble.com/loop-tp19346683p19346683.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] request

2008-09-06 Thread stephen sefick
you are subscribed to the r-help list.

On Sat, Sep 6, 2008 at 4:48 AM, Ram Kumar Basnet [EMAIL PROTECTED] wrote:
 hi
 I am expecting the mails that will flow in R- help after subscribing this but 
 could not. Can you provide me the right form.
 Thanks.



[[alternative HTML version deleted]]

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




-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Articles about comparision between R and others softwares

2008-09-06 Thread Muenchen, Robert A (Bob)
Hi Ricardo,

You can search for comparisons by entering the packages that interest
you at:

http://finzi.psych.upenn.edu/search.html 

Michael Mitchell wrote an interesting comparison of SAS, SPSS, Stata and
R at:

http://www.ats.ucla.edu/stat/technicalreports/  

That report says little about R, but Patrick Burns' excellent rejoinder
to that report fills in much of the missing R material. It is at that
link too.

The accuracy of various stat packages, including R, is in:

Keeling, Kellie B. and Pavur, Robert J. A comparative study of the
reliability of nine
statistical software packages. 8, May 1, 2007, Computational Statistics
 Data Analysis,
Vol. 51, pp. 3811-3831.

I've got an 80-page comparison of many features of R to SAS and SPSS at:

http://RforSASandSPSSusers.com 

That document focuses more on the language basics and data management
rather than statistics. My book by the same name adds graphics and basic
statistics to the mix. That should finally be printed in a few weeks.

Cheers,
Bob

=
Bob Muenchen (pronounced Min'-chen), Manager 
Statistical Consulting Center
U of TN Office of Information Technology
200 Stokely Management Center, Knoxville, TN 37996-0520
Voice: (865) 974-5230 
FAX: (865) 974-4810
Email: [EMAIL PROTECTED]
Web: http://oit.utk.edu/scc, 
News: http://listserv.utk.edu/archives/statnews.html
=


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 project.org] On Behalf Of ricardo13
 Sent: Friday, September 05, 2008 3:46 PM
 To: r-help@r-project.org
 Subject: [R] Articles about comparision between R and others softwares
 
 
 Hi
 
 Do you know some articles, papers, something than tell about
 comparision
 between R and others softwares statisticals.
 
 Thank You
 
 Ricardo
 --
 View this message in context: http://www.nabble.com/Articles-about-
 comparision-between-R-and-others-softwares-tp19338210p19338210.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] Plotting the complex fft in 3D?

2008-09-06 Thread Uwe Ligges



Oliver Bandel wrote:

Hello Martin,

Zitat von Martin Maechler [EMAIL PROTECTED]:


Just another remakr on this thread.

I you have  time series and think about its fourier transform
(EE language) then you should know that the statistical language
of that is spectral analysis or maybe
 frequency domain time-series analysis
and the R function to consider should definitely be

[...]

Yes, I'm coming from the EE world, but I also know the other terms.
The term spectral analysis is also used in EE, maybe not that often.
Also frequency domain time-series analysis is used in EE, but
maybe only at the university, later at the job, short terms
spectral analysis or fft are used. (But it may differ from country
to country.)


I tried spectrum now on my example data, and it looks quite different
to the result of fft().
It looks very close to what one gets as output from a spectrum analyzer
(measurement harware).
So it's quite nice to use this. :-)




spectrum()  which is a wrapper (among others) to spec.pgram()
-- which calls fft() -- for computing the so-called
periodogram.
If you learn more about the topic, you will learn that in almost
all cases you'd consider a *smoothed* version of the
periodogram, etc etc (because the so-called *raw* periodgram is
*in*consistent as an estimate fo the underlying true spectrum).


Well, what do you mean with inconcistent?
And why is spectrum() better?

Do you talk about things like windowing for becoming more appropriate
results?

Even if the output from spectrum() looks more like what I know from
measurement hardware, it might not always be better.
Can yo explain, why better using this?
The FFT only creates coefficients for certain seperated
frequencies. It depends on number of samlpes how accurate the
result is. And if the samples aren't an integer multiple of the
frequency in the measured signal, this creates errors in the results.

Possibly this is, what you are talking about?

Why is spectrum() better? Would be nice to have an explanation,
on how it's results are created, so that I can understand,
when which kind of analysis is better.

For the non-EE analysis, why is there fft() used and not
spectrum()?

For what kind of analysis is what function better?



spectrum() and spec.pgram() use fft() to calculate results. But some 
information is thrown away, some information is merged appropriately, 
and maybe tapering and padding is applied. Well, it really depends on 
your tasks which functions to use. I found myself frequently using fft() 
and doing the rest manually, because spectrum() is sometimes too 
intelligent for me ...




The Time-Series chapter/section of the MASS book is very helpful
here, IIRC.


MASS book? Do you mean the documentation of the MASS package?



No, the other way round: the Springer book Modern Applied Statistics 
with S, 4th edition, 2002, by Venables and Ripley has some package 
(MASS) as supplementary material.


Best wishes,
Uwe Ligges




Well, so much packages R is very powerful and provides a lot of
things.

But where to start?

Any idea?  I started with some introductional papers and got a
good overview. But a more systematical approach might be better.

Can you recommend some things to read?
I also have seen that there is one german book about programming in R.
I will look at it in more detail, when the new edition will be published
(sept/oct).

But maybe you can recommend other readings as well?

Thanks,
  Oliver

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] request

2008-09-06 Thread Martin Maechler
 ss == stephen sefick [EMAIL PROTECTED]
 on Sat, 6 Sep 2008 09:40:50 -0400 writes:

ss you are subscribed to the r-help list.

Huh???  How would  *you* know that?

The list of subscribers to R-help is not at all public,
and the fact that Ram Kumar's posting went through may well be
the result of the fact that we have a kind group of R-help
moderators who spend a fraction of their valuable time to let
people occasionally post even if unsubscribed. 
Search for volunteer on
https://stat.ethz.ch/mailman/listinfo/r-help

{please, Ram, also do read the above web page carefully ..}

Regards,
Martin Maechler, 
ETH Zurich (provider of all the @r-project.org mailing lists)


ss On Sat, Sep 6, 2008 at 4:48 AM, Ram Kumar Basnet [EMAIL PROTECTED] 
wrote:
 hi
 I am expecting the mails that will flow in R- help after subscribing 
this but could not. Can you provide me the right form.
 Thanks.
 
 
 
 [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 



ss -- 
ss Stephen Sefick
ss Research Scientist
ss Southeastern Natural Sciences Academy

ss Let's not spend our time and resources thinking about things that are
ss so little or so large that all they really do for us is puff us up and
ss make us feel like gods. We are mammals, and have not exhausted the
ss annoying little problems of being mammals.

ss -K. Mullis

ss __
ss R-help@r-project.org mailing list
ss https://stat.ethz.ch/mailman/listinfo/r-help
ss PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
ss 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] Hopefully an easy error bar question

2008-09-06 Thread Martin Maechler
 FEH == Frank E Harrell [EMAIL PROTECTED]
 on Sat, 06 Sep 2008 07:19:33 -0500 writes:

FEH Brown, Heidi wrote:
 Hi im trying to add error bars to my barplots, there very basic, i have 
a few grapghs where the y variable is different but on all the X variable is 
Age (Adult and Juvenile) however this is split into two levels so i have males 
and females, so my graph basically has four bars on it.
 
 I know how to add eror bars for instance when there is only one level eg 
lookng at the diffrence between male and female lizards and tree height and 
have used the code:
 
   
 error.bars-function(yv,z,nn) {
 xv-
 
barplot(yv,ylim=c(0,(max(yv)+max(z))),names=nn,ylab=deparse(substitute(yv)
 ))

[ omitting the abomination ]

 Have then worked out the standard errors and added that using:
 
 se-c()
 
 and then added the final bit of code:
 
 labels-as.character(levels(Sex2))
 ybar-as.vector(tapply(Height2,Sex2,mean))
 error.bars(ybar,se,labels)
 
 So i was wondering, in order to get error bars on my barplot with two 
levels do i need to change the last bit of code. For example im looking at mean 
body condition (y) against age (x) and sex (level), i tried to change the code 
to the following but it didnt work, any suggestions?
 
 labels-as.character(levels(list(sex,Age)))
 ybar-as.vector(tapply(ConditionIndex,sex,Age,mean))
 error.bars(ybar,se,labels)

FEH See http://biostat.mc.vanderbilt.edu/DynamitePlots for many reasons 
not 
FEH to use dynamite plots.

Ah!  Very good!  Let's hope this eventually leads to progress 
i.e., to much less use of these..

Thank you, Frank!
Martin Maechler, ETH Zurich


FEH -- 
FEH Frank E Harrell Jr   Professor and Chair   School of Medicine
FEH Department of Biostatistics   Vanderbilt University

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

2008-09-06 Thread stephen sefick
I apologize, my naive understanding that if an email was sent to the
list then the sender is subscribed.  However, my hypothesis is
falseifiable.

On Sat, Sep 6, 2008 at 10:33 AM, Martin Maechler
[EMAIL PROTECTED] wrote:
 ss == stephen sefick [EMAIL PROTECTED]
 on Sat, 6 Sep 2008 09:40:50 -0400 writes:

ss you are subscribed to the r-help list.

 Huh???  How would  *you* know that?

 The list of subscribers to R-help is not at all public,
 and the fact that Ram Kumar's posting went through may well be
 the result of the fact that we have a kind group of R-help
 moderators who spend a fraction of their valuable time to let
 people occasionally post even if unsubscribed.
 Search for volunteer on
 https://stat.ethz.ch/mailman/listinfo/r-help

 {please, Ram, also do read the above web page carefully ..}

 Regards,
 Martin Maechler,
 ETH Zurich (provider of all the @r-project.org mailing lists)


ss On Sat, Sep 6, 2008 at 4:48 AM, Ram Kumar Basnet [EMAIL PROTECTED] 
 wrote:
 hi
 I am expecting the mails that will flow in R- help after subscribing 
 this but could not. Can you provide me the right form.
 Thanks.



 [[alternative HTML version deleted]]

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




ss --
ss Stephen Sefick
ss Research Scientist
ss Southeastern Natural Sciences Academy

ss Let's not spend our time and resources thinking about things that are
ss so little or so large that all they really do for us is puff us up and
ss make us feel like gods. We are mammals, and have not exhausted the
ss annoying little problems of being mammals.

ss -K. Mullis

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




-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] new to R

2008-09-06 Thread Liviu Andronic
On 9/6/08, sudeshna [EMAIL PROTECTED] wrote:

  hi im starting with R.have no idea to start...plz help
  --
http://www.math.ilstu.edu/dhkim/Rstuff/Rtutor.html
http://www.statmethods.net/index.html
http://rforsasandspssusers.com/

Rcmdr
rattle
http://www.sciviews.org/_rgui/

http://zoonek2.free.fr/UNIX/48_R/all.html
http://cran.r-project.org/other-docs.html
http://www.r-project.org/doc/bib/R-publications.html
http://cran.r-project.org/manuals.html

Also search this Mailing-List archives. You'll find many pointers lying around.
Good luck,
Liviu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] request: most repeated sequnce

2008-09-06 Thread Muhammad Azam
Dear R community
Initially i thought my problem has been solved but one thing which i found e.g. 
if  
1. All the elements of a sector are zero e.g
, , 7

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]000000000 0
[2,]000000000 0
[3,]000000000 0
[4,]000000000 0
[5,]000000000 0

2. Majority of the rows consist of zeros e.g.
, , 5

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]440000000 0
[2,]440000000 0
[3,]000000000 0
[4,]000000000 0
[5,]000000000 0

Actually
zeros are not my values. I get values and fill the remaining parts with
zeros like x=array(0,dim=c(3,6,5)). Now according to first strategy
000000000 0 are most repeated
sequence of rows in both of above cases. But i don't want to consider
cases where all elements are zeros and interested to get  44   
0000000 0 or just  4   4  in case 2. 
Thanks and best regards

Muhammad Azam





- Original Message 
From: jim holtman [EMAIL PROTECTED]
To: Muhammad Azam [EMAIL PROTECTED]
Cc: R Help r-help@r-project.org; R-help request [EMAIL PROTECTED]
Sent: Saturday, September 6, 2008 2:39:19 PM
Subject: Re: [R] request: most repeated sequnce

Here is a start.  You can delete the zeros:

 x=c(1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,3,3,3,4,4,4,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,
+ 0,0,0,0,0,0,1,2,2,2,2,2,0,3,3,0,4,4,0,0,0,0,0,0)
 x=array(x,dim=c(3,6,5))
 apply(x,3,function(.mat){
+ rows - table(apply(.mat,1,function(z){
+ paste(z,collapse=' ')
+ }))
+ names(rows[which.max(rows)])
+ })
[1] 1 0 0 0 0 0 1 2 3 0 0 0 1 2 3 4 0 0 1 2 3 4 0 0 2 2 3 4 0 0


On Sat, Sep 6, 2008 at 4:54 AM, Muhammad Azam [EMAIL PROTECTED] wrote:
 Dear R community
 Hope every one be in best of his/her health. I have a situation in which 
 there are s-sectors. Each sector is further divided into r-rows and 
 c-columns. All it makes an array having dimension (r,c,s). e.g.

 x=c(1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,3,3,3,4,4,4,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,
 0,0,0,0,0,0,1,2,2,2,2,2,0,3,3,0,4,4,0,0,0,0,0,0)
 x=array(x,dim=c(3,6,5))
 x
 , , 1

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]100000
 [2,]100000
 [3,]100000

 , , 2

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]123000
 [2,]123000
 [3,]120000

 , , 3

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]123400
 [2,]123400
 [3,]134000

 , , 4

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]123400
 [2,]123400
 [3,]123400

 , , 5

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]120000
 [2,]223400
 [3,]223400

 I want to get the most repeated sequence (row-wise) of values in each sector. 
 e.g. in sector 1 i.e. , , 1
 the most repeated sequence is 1 (ignoring zeros). In , , 2 the most repeated 
 sequence is 1  2  3. Similarly in last sector i.e.
  , , 5 such sequence is  2  2  3  4. Any body can help to solve this problem. 
 Thanks


 best regards
 Muhammad Azam




[[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?



  
[[alternative HTML version deleted]]

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


Re: [R] subsetting a data frame

2008-09-06 Thread joseph
Hello
How can I change the function to get the rows with the sum (x+y+z) = 10?
Thank you very much
Joseph



- Original Message 
From: Marc Schwartz [EMAIL PROTECTED]
To: joseph [EMAIL PROTECTED]
Cc: r-help@r-project.org
Sent: Wednesday, September 3, 2008 3:24:58 PM
Subject: Re: [R] subsetting a data frame

on 09/03/2008 05:06 PM joseph wrote:
 I have a data frame that looks like this:
 V1 V2 V3
 ab0:1:12
 df1:2:1
 cd1:0:9
 where V3 is in the form x:y:z
 Can someone show me how to subset the rows where the values of x, y and z = 
 10: 
 V1 V2 V3
 df1:2:1
 cd1:0:9
 Thanks
 Joseph


How about this:



 DF[sapply(strsplit(as.character(DF$V3), :),
function(i) all(as.numeric(i) = 10)), ]
  V1 V2V3
2  d  f 1:2:1
3  c  d 1:0:9


Basically, use strsplit() to break apart 'V3':

 strsplit(as.character(DF$V3), :)
[[1]]
[1] 0  1  12

[[2]]
[1] 1 2 1

[[3]]
[1] 1 0 9


The use sapply() to crawl the list, converting the elements to numerics
and do the value comparison:

 sapply(strsplit(as.character(DF$V3), :),
 function(i) all(as.numeric(i) = 10))
[1] FALSE  TRUE  TRUE


The above then returns the logical vector to subset the rows of 'DF'.

HTH,

Marc Schwartz


  
[[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] Mode value

2008-09-06 Thread Carlos Morales
Hello everyone,


I would like to know if there is any function to calculate the mode value, or I 
have to build one to do it.


Thanks so much
Carlos




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Mode value

2008-09-06 Thread stephen sefick
look here:
http://www.nabble.com/how-to-calculate-the-mode-of-a-continuous-variable-td19214243.html#a19214243

On Sat, Sep 6, 2008 at 1:24 PM, Carlos Morales
[EMAIL PROTECTED] wrote:
 Hello everyone,


 I would like to know if there is any function to calculate the mode value, or 
 I have to build one to do it.


 Thanks so much
 Carlos




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




-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Mode value

2008-09-06 Thread milton ruser
Hi Carolos,

I know that it is not a elegant soluction, but may work. Almost for integer
values. Take care with float values.


modevalue-function(x)
 {
 x.freq-data.frame(table(x))
 x.freq.max-max(x.freq$Freq)
 x.freq.selected-subset(x.freq, x.freq$Freq==x.freq.max)
 return(c(unlist(x.freq.selected$x)))
 }
x-sample(x=0:10, size=200, replace=T)
modevalue(x)



On Sat, Sep 6, 2008 at 2:24 PM, Carlos Morales
[EMAIL PROTECTED]wrote:

 Hello everyone,


 I would like to know if there is any function to calculate the mode value,
 or I have to build one to do it.


 Thanks so much
 Carlos




 __
 R-help@r-project.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] Hopefully an easy error bar question

2008-09-06 Thread Ben Bolker
Martin Maechler maechler at stat.math.ethz.ch writes:

 
  FEH == Frank E Harrell f.harrell at vanderbilt.edu
  on Sat, 06 Sep 2008 07:19:33 -0500 writes:
 
 FEH See http://biostat.mc.vanderbilt.edu/DynamitePlots for many reasons 
 not 
 FEH to use dynamite plots.
 
 Ah!  Very good!  Let's hope this eventually leads to progress 
 i.e., to much less use of these..
 
 Thank you, Frank!
 Martin Maechler, ETH Zurich
 
 FEH -- 

  Yes, but:

http://emdbolker.wikidot.com/blog:dynamite

(repeats Frank's criticisms, but also raises
the point that boxplots show the range of the
data, but not much about the statistical inferences
on the data ...)

  comments welcome.

  Ben Bolker

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


Re: [R] subsetting a data frame

2008-09-06 Thread joseph
Hi Jorge
I got the rows where V3 looks like this  10:10:10;  Ithe sum here is 30 and not 
10.
I want the rows where the sum is 10 for exaple 5:5:0 and 2:2:6 

thanks 
Joseph


- Original Message 
From: Jorge Ivan Velez [EMAIL PROTECTED]
To: joseph [EMAIL PROTECTED]
Sent: Saturday, September 6, 2008 10:43:09 AM
Subject: Re: [R] subsetting a data frame



Dear Joseph,

Try


 DF[sapply(strsplit(as.character(DF$V3), :),
   function(i) all(as.numeric(i) == 10)), ]

HTH,

Jorge



On Sat, Sep 6, 2008 at 1:24 PM, joseph [EMAIL PROTECTED] wrote:

Hello
How can I change the function to get the rows with the sum (x+y+z) = 10?
Thank you very much
Joseph




- Original Message 
From: Marc Schwartz [EMAIL PROTECTED]
To: joseph [EMAIL PROTECTED]
Cc: r-help@r-project.org
Sent: Wednesday, September 3, 2008 3:24:58 PM
Subject: Re: [R] subsetting a data frame

on 09/03/2008 05:06 PM joseph wrote:
 I have a data frame that looks like this:
 V1 V2 V3
 ab0:1:12
 df1:2:1
 cd1:0:9
 where V3 is in the form x:y:z
 Can someone show me how to subset the rows where the values of x, y and z = 
 10:
 V1 V2 V3
 df1:2:1
 cd1:0:9
 Thanks
 Joseph


How about this:



 DF[sapply(strsplit(as.character(DF$V3), :),
   function(i) all(as.numeric(i) = 10)), ]
 V1 V2V3
2  d  f 1:2:1
3  c  d 1:0:9


Basically, use strsplit() to break apart 'V3':

 strsplit(as.character(DF$V3), :)
[[1]]
[1] 0  1  12

[[2]]
[1] 1 2 1

[[3]]
[1] 1 0 9


The use sapply() to crawl the list, converting the elements to numerics
and do the value comparison:

 sapply(strsplit(as.character(DF$V3), :),
function(i) all(as.numeric(i) = 10))
[1] FALSE  TRUE  TRUE


The above then returns the logical vector to subset the rows of 'DF'.

HTH,

Marc Schwartz




   [[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] Mode value

2008-09-06 Thread Jonathan Baron
On 09/06/08 17:24, Carlos Morales wrote:
 Hello everyone,
 
 
 I would like to know if there is any function to calculate the mode value, or 
 I have 
 to build one to do it.

I just did this the other day.  Funny you should ask.  It finds the
mode of each row of a matrix called Pbest.

Pbest.p - apply(Pbest,1,function(x) 
 x[which.max(as.vector(table(x)))][1])

So to get the mode of a vector v1, the following should work (but I
haven't tried it):

v1[which.max(as.vector(table(v1)))][1]

-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 use try function with boot

2008-09-06 Thread ctu

Hi Jinsong,
I try to put the try in the c1.fun but it still does not work. Do  
you mean this?



c1.fun-try(function(data,i){

+  d-data
+  d$density-d$fitted+d$res[i]
+  coef(update(c1.nmf,data=d))
+  } ,silent=T)

c1.try-boot(c1data, statistic = c1.fun, R=5000)

Error in nls(formula = density ~ nmf(time, alpha, delta, psi, tau, gamma),  :
  Convergence failure: false convergence (8)

Thanks
Chunhao


Quoting Jinsong Zhao [EMAIL PROTECTED]:


[EMAIL PROTECTED] wrote:

Hi R users,
Is is possible for me to use the try function with boot? I would to  
 do the bootstraping with a nonlinear model(it works well when R
1000). But it does not work very well (when R is large) thus I try   
to use try to resolve. I  put the try function in two cases:


case1: put the try in front of the boot


c1.try-try(boot(c1data, statistic = c1.fun, R=3999),silent=T)
c1.try
[1] Error in nls(formula = density ~ nmf(time, alpha, delta, psi,   
tau, gamma),  : \n  Convergence failure: false convergence (8)\n

attr(,class)
[1] try-error

case2: put the try in front of the nls
c1.nmf-try(nls(density~nmf(time, alpha, delta, psi, tau, gamma),
+algorithm=port,data=c1,
+lower=c(alpha=0.1, delta=0, psi=0.2, tau=1, gamma=-5),
+upper=c(alpha=0.6, delta=0.1, psi=3, tau=7, gamma=2),
+start=c(alpha=0.35, delta=0,  psi=0.99, tau=4.5,   
gamma=-1.2)),silent=T)

c1.try-boot(c1data, statistic = c1.fun, R=3999)
 Error in nls(formula = density ~ nmf(time, alpha, delta, psi, tau,  
 gamma),  :

 Convergence failure: iteration limit reached without convergence

Any suggestion will be helpful.
Many thanks in advance
Chunhao



put try() in your statistic function. in your case, it may be inside
the c1.fun function.

HTH,
Jinsong


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


Re: [R] subsetting a data frame

2008-09-06 Thread stephen sefick
#something like this?
V1 - c(1:10)
V2 - c(0,5,7,8,1,6,5,13,7,0)
V3 - c(9,5,6,8,1,7,5,33,88,0)
z - cbind(V1,V2,V3)
row.sums - rowSums(z)
d - cbind(z, row.sums)
subset(d, row.sums==10)

On Sat, Sep 6, 2008 at 2:25 PM, joseph [EMAIL PROTECTED] wrote:
 Hi Jorge
 I got the rows where V3 looks like this  10:10:10;  Ithe sum here is 30 and 
 not 10.
 I want the rows where the sum is 10 for exaple 5:5:0 and 2:2:6

 thanks
 Joseph


 - Original Message 
 From: Jorge Ivan Velez [EMAIL PROTECTED]
 To: joseph [EMAIL PROTECTED]
 Sent: Saturday, September 6, 2008 10:43:09 AM
 Subject: Re: [R] subsetting a data frame



 Dear Joseph,

 Try


  DF[sapply(strsplit(as.character(DF$V3), :),
   function(i) all(as.numeric(i) == 10)), ]

 HTH,

 Jorge



 On Sat, Sep 6, 2008 at 1:24 PM, joseph [EMAIL PROTECTED] wrote:

 Hello
 How can I change the function to get the rows with the sum (x+y+z) = 10?
 Thank you very much
 Joseph




 - Original Message 
 From: Marc Schwartz [EMAIL PROTECTED]
 To: joseph [EMAIL PROTECTED]
 Cc: r-help@r-project.org
 Sent: Wednesday, September 3, 2008 3:24:58 PM
 Subject: Re: [R] subsetting a data frame

 on 09/03/2008 05:06 PM joseph wrote:
 I have a data frame that looks like this:
 V1 V2 V3
 ab0:1:12
 df1:2:1
 cd1:0:9
 where V3 is in the form x:y:z
 Can someone show me how to subset the rows where the values of x, y and z = 
 10:
 V1 V2 V3
 df1:2:1
 cd1:0:9
 Thanks
 Joseph


 How about this:



 DF[sapply(strsplit(as.character(DF$V3), :),
   function(i) all(as.numeric(i) = 10)), ]
  V1 V2V3
 2  d  f 1:2:1
 3  c  d 1:0:9


 Basically, use strsplit() to break apart 'V3':

 strsplit(as.character(DF$V3), :)
 [[1]]
 [1] 0  1  12

 [[2]]
 [1] 1 2 1

 [[3]]
 [1] 1 0 9


 The use sapply() to crawl the list, converting the elements to numerics
 and do the value comparison:

 sapply(strsplit(as.character(DF$V3), :),
function(i) all(as.numeric(i) = 10))
 [1] FALSE  TRUE  TRUE


 The above then returns the logical vector to subset the rows of 'DF'.

 HTH,

 Marc Schwartz




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




-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

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


Re: [R] subsetting a data frame

2008-09-06 Thread stephen sefick
Sorry I didn't read the problem carefully.

On Sat, Sep 6, 2008 at 2:53 PM, Jorge Ivan Velez
[EMAIL PROTECTED] wrote:

 Hi Joseph,
 Try this:
 # Data set
 DF=read.table(textConnection(V1 V2 V3
 ab0:1:12
 df1:2:1
 cd1:0:9
 be2:2:6
 fc5:5:0),header=TRUE)
 closeAllConnections()

 target=10
  DF[sapply(strsplit(as.character(DF$V3), :), function(x)
 sum(as.numeric(x))== target), ]

 HTH,
 Jorge


 On Sat, Sep 6, 2008 at 2:25 PM, joseph [EMAIL PROTECTED] wrote:

 Hi Jorge
 I got the rows where V3 looks like this  10:10:10;  Ithe sum here is 30
 and not 10.
 I want the rows where the sum is 10 for exaple 5:5:0 and 2:2:6
 thanks
 Joseph

 - Original Message 
 From: Jorge Ivan Velez [EMAIL PROTECTED]
 To: joseph [EMAIL PROTECTED]
 Sent: Saturday, September 6, 2008 10:43:09 AM
 Subject: Re: [R] subsetting a data frame


 Dear Joseph,
 Try

  DF[sapply(strsplit(as.character(DF$V3), :),
function(i) all(as.numeric(i) == 10)), ]
 HTH,
 Jorge

 On Sat, Sep 6, 2008 at 1:24 PM, joseph [EMAIL PROTECTED] wrote:

 Hello
 How can I change the function to get the rows with the sum (x+y+z) = 10?
 Thank you very much
 Joseph



 - Original Message 
 From: Marc Schwartz [EMAIL PROTECTED]
 To: joseph [EMAIL PROTECTED]
 Cc: r-help@r-project.org
 Sent: Wednesday, September 3, 2008 3:24:58 PM
 Subject: Re: [R] subsetting a data frame

 on 09/03/2008 05:06 PM joseph wrote:
  I have a data frame that looks like this:
  V1 V2 V3
  ab0:1:12
  df1:2:1
  cd1:0:9
  where V3 is in the form x:y:z
  Can someone show me how to subset the rows where the values of x, y and
  z = 10:
  V1 V2 V3
  df1:2:1
  cd1:0:9
  Thanks
  Joseph


 How about this:



  DF[sapply(strsplit(as.character(DF$V3), :),
function(i) all(as.numeric(i) = 10)), ]
  V1 V2V3
 2  d  f 1:2:1
 3  c  d 1:0:9


 Basically, use strsplit() to break apart 'V3':

  strsplit(as.character(DF$V3), :)
 [[1]]
 [1] 0  1  12

 [[2]]
 [1] 1 2 1

 [[3]]
 [1] 1 0 9


 The use sapply() to crawl the list, converting the elements to numerics
 and do the value comparison:

  sapply(strsplit(as.character(DF$V3), :),
 function(i) all(as.numeric(i) = 10))
 [1] FALSE  TRUE  TRUE


 The above then returns the logical vector to subset the rows of 'DF'.

 HTH,

 Marc Schwartz



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







-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 address last and all but last column in dataframe

2008-09-06 Thread drflxms
Dear R-colleagues,

another question from a newbie: I am creating a lot of simple
pivot-charts from my raw data using the reshape-package. In these charts
we have medical doctors judging videos in the columns and the videos
they judge in the rows. Simple example of chart/data.frame input with
two categories 1/0:

video 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

1  1 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
2  2 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  1
3  3 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
4  4 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
5  5 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  1  0
6  6 0 0 0 0 0 0 0 0 0  0  0  0  0  1  0  0  0  0  0  0  0
7  7 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
8  8 0 0 0 0 0 0 0 0 0  0  0  0  0  0  1  0  0  0  0  0  0
9  9 0 0 0 0 0 0 0 0 0  1  0  1  1  0  1  1  0  0  0  1  0
1010 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0

I recently learned, that I can easily create a confusion matrix out of
this data using the following commands:

pairs-data.frame(pred=factor(unlist(input[2:21])),ref=factor(input[,22]))
pred-pairs$pred
ref - pairs$ref
library (caret)
confusionMatrix(pred, ref, positive=1)

- where column 21 is the reference/goldstandard.

My problem is now, that I analyse data.frames with an unknown count of
columns. So to get rid of the first and last column for the pred
variable and to select the last column for the ref variable, I have to
look at the data.frame before doing the above commands to set the proper
column numbers.

It would be very comfortable, if I could address the last column not by
number (where I have to count beforehand) but by a variable last column.

Probably there is a more easy solution for this problem using the names
of the columns as well: the reference is always number 21 the first
column is always called video. So I tried:

attach(input)
pairs-data.frame(pred=factor(unlist(input[[,-c(video,21)]])),ref=factor(input[[21]]))

which does not work unfortunately :-(.

I'd be very happy in case someone could help me out, cause I am really
tired of counting - there are a lot of tables to analyse...

Cheers and greetings from Munich,
Felix

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] I don't know how to run a r-code written in emacs

2008-09-06 Thread Luisa

Hi,
I just installed R, I'm  work in UBUNTU and  I don't have idea about how to
run a r-code written in emacs
into the shell. 
Well I am in a shell, and obviously I can run simple commands over there,
Must I  compile the program? if yes, How must I do that?
what is the extension?

I really appreciate your help 
 
-- 
View this message in context: 
http://www.nabble.com/I-don%27t-know-how-to-run-a-r-code-written-in-emacs-tp19348030p19348030.html
Sent from the R help mailing list archive at Nabble.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] how to address last and all but last column in dataframe

2008-09-06 Thread David Winsemius
Not sure where your input came from. It's not in a format I would  
have expected of an R object and the first line is not in a form that  
would be particularly easy to read into a valid R object. Numbers are  
no legitimate object names. It's also not clear what you want to do  
with the duplicated line numbers at the beginning. Your question  
implies that you do not consider them part of the data.


In the future a worked example along the lines of that constructed by  
Jorge Ivan Velez in a recent answer to another question might increase  
chances of a prompt reply with tested code:


# Data set
DF=read.table(textConnection(V1 V2 V3
ab0:1:12
df1:2:1
cd1:0:9
be2:2:6
fc5:5:0),header=TRUE)
closeAllConnections()

The length of a dataframe is the number of columns.

?length

Dataframes can be referenced using the extract operation e.g.   
df[row, col]


?Extract   # for additional information on indexing using  column  
vectors.


So:

video[ ,length(video)]  #should return the last column vector although  
it will be no longer be named.


The rest of the dataframe with intact column names could be obtained  
with:


video[  ,-length(video)]

--
David Winsemius


On Sep 6, 2008, at 3:00 PM, drflxms wrote:


Dear R-colleagues,

another question from a newbie: I am creating a lot of simple
pivot-charts from my raw data using the reshape-package. In these  
charts

we have medical doctors judging videos in the columns and the videos
they judge in the rows. Simple example of chart/data.frame input  
with

two categories 1/0:

video 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

1  1 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
2  2 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  1
3  3 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
4  4 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
5  5 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  1  0
6  6 0 0 0 0 0 0 0 0 0  0  0  0  0  1  0  0  0  0  0  0  0
7  7 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
8  8 0 0 0 0 0 0 0 0 0  0  0  0  0  0  1  0  0  0  0  0  0
9  9 0 0 0 0 0 0 0 0 0  1  0  1  1  0  1  1  0  0  0  1  0
1010 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0

I recently learned, that I can easily create a confusion matrix out of
this data using the following commands:

pairs-data.frame(pred=factor(unlist(input[2:21])),ref=factor(input[, 
22]))

pred-pairs$pred
ref - pairs$ref
library (caret)
confusionMatrix(pred, ref, positive=1)

- where column 21 is the reference/goldstandard.

My problem is now, that I analyse data.frames with an unknown count of
columns. So to get rid of the first and last column for the pred
variable and to select the last column for the ref variable, I  
have to
look at the data.frame before doing the above commands to set the  
proper

column numbers.

It would be very comfortable, if I could address the last column not  
by
number (where I have to count beforehand) but by a variable last  
column.


Probably there is a more easy solution for this problem using the  
names

of the columns as well: the reference is always number 21 the first
column is always called video. So I tried:

attach(input)
pairs-data.frame(pred=factor(unlist(input[[,-c(video, 
21)]])),ref=factor(input[[21]]))


which does not work unfortunately :-(.

I'd be very happy in case someone could help me out, cause I am really
tired of counting - there are a lot of tables to analyse...

Cheers and greetings from Munich,
Felix

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] LME prediction - object not subsettable?

2008-09-06 Thread Rebecca Sela
I fit a random effects linear model to data, and then tried to use it to 
predict, but I got this error:
 predict(lmeObject, newdata, level=0)
Error in eval(mCall$fixed)[-2] : object is not subsettable

This is a new error for me.  It still occurs if I change the level to 1 or if I 
change the data for prediction back to the original dataset to which the lme 
model was fitted.

Can anyone help?

Thank you in advance!

Rebecca

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 address last and all but last column in dataframe

2008-09-06 Thread drflxms
Hello Mr. Burns, Hello Mr. Dwinseminus

thank you very much for your incredible quick and efficient reply! I was
completely successful with the following command:

pairs-data.frame(pred=factor(unlist(input[,-c(1,ncol(input))])),ref=factor(input[,ncol(input)]))

In case of the input example data.frame I sent with my question the
above code is equivalent to:
 
pairs-data.frame(pred=factor(unlist(input[2:17])),ref=factor(input[,18]))

Great! That is exactly what I was looking for! This simple code will
save me hours!

Patrick, your book looks in fact very interesting and will be my perfect
reading material for the following nights :-) (probably not only the
first chapter ;-). Thanks for the hint - and the free book of course.

David, the input data.frame is the result of the reshape-command I
performed. I just copied it from the R-console into the e-mail. In fact
the first column video is not part of the data, but needed for
analysis with kappam.fleiss function of the irr-package. Sorry, you are
absolutely correct, I should have mentioned this in my question. I will
improve when I ask my next question :-).

Again I like to thank you for your help and wish you a pleasant Sunday.
Greetings from Munich,
Felix

Patrick Burns wrote:
 If I understand properly, you want

 input[, -c(1, ncol(input))]

 rather than

 input[[, -c(video, 21)]]

 Chapter 1 of S Poetry might be of interest to you.

 Patrick Burns
 [EMAIL PROTECTED]
 +44 (0)20 8525 0696
 http://www.burns-stat.com
 (home of S Poetry and A Guide for the Unwilling S User)

 drflxms wrote:
 Dear R-colleagues,

 another question from a newbie: I am creating a lot of simple
 pivot-charts from my raw data using the reshape-package. In these charts
 we have medical doctors judging videos in the columns and the videos
 they judge in the rows. Simple example of chart/data.frame input with
 two categories 1/0:

 video 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

 1  1 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
 2  2 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  1
 3  3 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
 4  4 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
 5  5 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  1  0
 6  6 0 0 0 0 0 0 0 0 0  0  0  0  0  1  0  0  0  0  0  0  0
 7  7 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
 8  8 0 0 0 0 0 0 0 0 0  0  0  0  0  0  1  0  0  0  0  0  0
 9  9 0 0 0 0 0 0 0 0 0  1  0  1  1  0  1  1  0  0  0  1  0
 1010 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0

 I recently learned, that I can easily create a confusion matrix out of
 this data using the following commands:

 pairs-data.frame(pred=factor(unlist(input[2:21])),ref=factor(input[,22]))

 pred-pairs$pred
 ref - pairs$ref
 library (caret)
 confusionMatrix(pred, ref, positive=1)

 - where column 21 is the reference/goldstandard.

 My problem is now, that I analyse data.frames with an unknown count of
 columns. So to get rid of the first and last column for the pred
 variable and to select the last column for the ref variable, I have to
 look at the data.frame before doing the above commands to set the proper
 column numbers.

 It would be very comfortable, if I could address the last column not by
 number (where I have to count beforehand) but by a variable last
 column.

 Probably there is a more easy solution for this problem using the names
 of the columns as well: the reference is always number 21 the first
 column is always called video. So I tried:

 attach(input)
 pairs-data.frame(pred=factor(unlist(input[[,-c(video,21)]])),ref=factor(input[[21]]))


 which does not work unfortunately :-(.

 I'd be very happy in case someone could help me out, cause I am really
 tired of counting - there are a lot of tables to analyse...

 Cheers and greetings from Munich,
 Felix

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] I don't know how to run a r-code written in emacs

2008-09-06 Thread Wensui Liu
did you install ess for emacs?

On Sat, Sep 6, 2008 at 11:52 AM, Luisa [EMAIL PROTECTED] wrote:

 Hi,
 I just installed R, I'm  work in UBUNTU and  I don't have idea about how to
 run a r-code written in emacs
 into the shell.
 Well I am in a shell, and obviously I can run simple commands over there,
 Must I  compile the program? if yes, How must I do that?
 what is the extension?

 I really appreciate your help

 --
 View this message in context: 
 http://www.nabble.com/I-don%27t-know-how-to-run-a-r-code-written-in-emacs-tp19348030p19348030.html
 Sent from the R help mailing list archive at Nabble.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.




-- 
===
WenSui Liu
Acquisition Risk, Chase
Email : [EMAIL PROTECTED]
Blog : statcompute.spaces.live.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] subsetting a data frame

2008-09-06 Thread Jorge Ivan Velez
Hi Joseph,
Try this:

# Data set
DF=read.table(textConnection(V1 V2 V3
ab0:1:12
df1:2:1
cd1:0:9
be2:2:6
fc5:5:0),header=TRUE)
closeAllConnections()

target=10
 DF[sapply(strsplit(as.character(DF$V3), :), function(x)
sum(as.numeric(x))== target), ]


HTH,

Jorge



On Sat, Sep 6, 2008 at 2:25 PM, joseph [EMAIL PROTECTED] wrote:

 Hi Jorge
 I got the rows where V3 looks like this  10:10:10;  Ithe sum here is 30 and
 not 10.
 I want the rows where the sum is 10 for exaple 5:5:0 and 2:2:6
 thanks
 Joseph

 - Original Message 
 From: Jorge Ivan Velez [EMAIL PROTECTED]
 To: joseph [EMAIL PROTECTED]
 Sent: Saturday, September 6, 2008 10:43:09 AM
 Subject: Re: [R] subsetting a data frame


 Dear Joseph,
 Try


  DF[sapply(strsplit(as.character(DF$V3), :),
function(i) all(as.numeric(i) == 10)), ]

 HTH,

 Jorge


 On Sat, Sep 6, 2008 at 1:24 PM, joseph [EMAIL PROTECTED] wrote:

 Hello
 How can I change the function to get the rows with the sum (x+y+z) = 10?
 Thank you very much
 Joseph



 - Original Message 
 From: Marc Schwartz [EMAIL PROTECTED]
 To: joseph [EMAIL PROTECTED]
 Cc: r-help@r-project.org
 Sent: Wednesday, September 3, 2008 3:24:58 PM
 Subject: Re: [R] subsetting a data frame

 on 09/03/2008 05:06 PM joseph wrote:
  I have a data frame that looks like this:
  V1 V2 V3
  ab0:1:12
  df1:2:1
  cd1:0:9
  where V3 is in the form x:y:z
  Can someone show me how to subset the rows where the values of x, y and
 z = 10:
  V1 V2 V3
  df1:2:1
  cd1:0:9
  Thanks
  Joseph


 How about this:



  DF[sapply(strsplit(as.character(DF$V3), :),
function(i) all(as.numeric(i) = 10)), ]
  V1 V2V3
 2  d  f 1:2:1
 3  c  d 1:0:9


 Basically, use strsplit() to break apart 'V3':

  strsplit(as.character(DF$V3), :)
 [[1]]
 [1] 0  1  12

 [[2]]
 [1] 1 2 1

 [[3]]
 [1] 1 0 9


 The use sapply() to crawl the list, converting the elements to numerics
 and do the value comparison:

  sapply(strsplit(as.character(DF$V3), :),
 function(i) all(as.numeric(i) = 10))
 [1] FALSE  TRUE  TRUE


 The above then returns the logical vector to subset the rows of 'DF'.

 HTH,

 Marc Schwartz



 [[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] plot a list

2008-09-06 Thread stephen sefick
i have a list of 6 each containing a dataframe of 96 observations as a
zoo object.  Is there a way to plot these in one frame
par(mfrow=c(3,2))

this is what I tried
lapply(d, FUN=plot)

I can provide data, list is large.
thanks

-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

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


Re: [R] I don't know how to run a r-code written in emacs

2008-09-06 Thread Marianne Promberger
On Saturday, 06 September 2008, 08:52 (UTC-0700), Luisa wrote:
 
 Hi,
 I just installed R, I'm  work in UBUNTU and  I don't have idea about how to
 run a r-code written in emacs
 into the shell. 
 Well I am in a shell, and obviously I can run simple commands over there,
 Must I  compile the program? 

Which program? Emacs? If you've installed R, you can read a txt file
of R code into your R session with 

source(/path/if/any/file.R)

 what is the extension?

not sure what you mean. It makes sense to save files with R commands
with the .R extension, but AFAIK it's not obligatory.

If you don't have ess, I think you can get that, too, with aptitude
install ess.

Then, in Emacs, you can open R with M-x R. You can now copypaste
(killyank) R code from your text file to the R buffer; alternatively
there are special commands available, look at the menu in Emacs. If
you have Emacs anyway, ESS is much more convenient than running from
the console.

m.



-- 
Marianne Promberger
Graduate student in Psychology
http://www.psych.upenn.edu/~mpromber

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Axis tick label format and rotation

2008-09-06 Thread Kurt Newman

Please tell me how to format data in a data frame so when currency amount is 
displayed in a chart the axis tick labels contain leading $ signs.

Please also tell me if it is possible to rotate x axis labels using ggplot2.

Thank you,
Kurt

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Test for equality of complicatedly related average correlations

2008-09-06 Thread Adam D. I. Kramer

Hi Ralph,

I had the same problem you do a few months ago, and realized that
the question I had (does time show a different effect for X than Y) was not
best modeled as differences between correlations across individuals, but as
whether time interacts with condition.

I answered this question with

library(nlme)
lme(obs ~ cond*time, random=~cond*time|subj)


...where obs is the responses on the X or Y variable, cond is a factor of
either X or Y, and subj is your subject variable. This fits a heirarchical
linear model to the data. The relationship between X and time is sig. diff.
from the relationship between Y and time if the cond:time fixed effect is
true.

This approach makes better use of your data, because when you correlate the
observations, you're effectively losing variability (because correlations
are doubly standardized) as well as degrees of freedom (you have 9 df within
each individual, but each correlation is only one number).

--Adam

On Sat, 6 Sep 2008, Ralph79 wrote:



Dear R-Users,

I am currently looking for a way to test the equality of two correlations
that are related in a very special way. Let me describe the situation with
an example.

- There are 100 respondents, and there are 2 points in time, t=1 and t=2.

- For each of the respondents and at each of the time points, I have
information on 10 X-variables and on 10 Y-variables.

- Based on this information, I calculate two correlations for each
respondent: cor(X[t=1],X[t=2]) and cor(Y[t=1],Y[t=2]), with X and Y being
the vectors of the corresponding 10 variables.

- Now I get the average correlations over the whole sample using Fishers
Z-transformation, i.e. I have mean(cor(X[t=1],X[t=2])) and
mean(cor(X[t=1],X[t=2])) and want to know if the mean correlations are
significantly different!


I haven't found any test that deals with exactly my situation. Therefore, I
simply apply a paired t-test based on the individual z-correlations. From
my point of view this should be ok, because of the z's normality. However, I
am unsure if there is a better way to test the hypothesis that I am
interested in?

I'd be grateful for any comment or hint.

Thank you very much,

Ralph

-
Ralph Wirth
University Erlangen-Nuremberg, Chair of Statistics
GfK Group, Department of Methods and Product Development

--
View this message in context: 
http://www.nabble.com/Test-for-equality-of-complicatedly-related-average-correlations-tp19346312p19346312.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] I don't know how to run a r-code written in emacs

2008-09-06 Thread Nicky Chorley
2008/9/6 Luisa [EMAIL PROTECTED]:

 Hi,
 I just installed R, I'm  work in UBUNTU and  I don't have idea about how to
 run a r-code written in emacs
 into the shell.
 Well I am in a shell, and obviously I can run simple commands over there,
 Must I  compile the program? if yes, How must I do that?
 what is the extension?

You don't need to compile anything and you can use .R as an extension
for your R scripts (I believe someone else has suggested this already
though). What I usually do to run my scripts, is something like the
following:

R  foo.R,

where foo.R is the name of the script. The man page for R suggests
this usage (admittedly, though, it's perhaps not obvious) and there
are options listed in it that you may want to use.

For what it's worth, it makes no difference which editor you use to
write your code in.

Regards,

Nicky Chorley

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Area of density

2008-09-06 Thread pragmatic

BIG THANKS!!! ))
-- 
View this message in context: 
http://www.nabble.com/Area-of-density-tp19338958p19351299.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] re ferring to a group of vectors without explicit enumeration

2008-09-06 Thread shalu

I am trying to define 25 vectors of varying lengths, say y1 to y25 in a loop,
and then store the results of some computations in them. My problem is about
using some sort of concatenation for names. For example, instead of
initializing each of y1 through y25, I would like to do it in a loop.
Similar to cat and paste for texts, is there anyway of using yi for the
vector name where i ranges from 1 to 25, so ultimately it refers to the
vector y1,..,y25?
Varying lengths is not a problem. To start with each has only length 1 and
then I will be adding to each vector based on some results.
-- 
View this message in context: 
http://www.nabble.com/referring-to-a-group-of-vectors-without-explicit-enumeration-tp19351518p19351518.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] re ferring to a group of vectors without explicit enumeration

2008-09-06 Thread Ben Bolker
shalu shahlar at hotmail.com writes:

 
 
 I am trying to define 25 vectors of varying lengths, say y1 to y25 in a loop,
 and then store the results of some computations in them. My problem is about
 using some sort of concatenation for names. For example, instead of
 initializing each of y1 through y25, I would like to do it in a loop.
 Similar to cat and paste for texts, is there anyway of using yi for the
 vector name where i ranges from 1 to 25, so ultimately it refers to the
 vector y1,..,y25?
 Varying lengths is not a problem. To start with each has only length 1 and
 then I will be adding to each vector based on some results.

  I think this is essentially

http://cran.r-project.org/doc/FAQ/R-FAQ.html
#How-can-I-turn-a-string-into-a-variable?

[URL broken in order to make Gmane happy, reassemble it 
in your browser]

  the short answer: assign(), but it would work better
to use a list instead.

  Ben Bolker

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


[R] Sweave and/or beamer issue

2008-09-06 Thread Michael Kubovy
Dear Friends,

I not sure whether this is an Sweave or a beamer problem.

The Rnw file:

\documentclass[compress,smaller]{beamer}
%\documentclass{article}
%\usepackage{beamerarticle}

\usepackage{Sweave}

\title{Psychophysics II}
\date{September 9, 2008}

\begin{document}

\frame{
\begin{Schunk}
\begin{Sinput}
  ro - 0.2
  c - seq(from = -3, to = 4, by = 0.1)
  fn - 1 - pnorm(c)
  fo - 1 - pnorm(c, mean = 1)
  h - fo + ro - ro * fo
  f - fn
  plot(h ~ f, type = l, asp = 1, xlim = c(0.01, 1.01), ylim =  
c(0.01, 1.01), las = 1, xlab = p(yes | old),
+ ylab = p(yes | new), main = Dual-process model,  
p(recollection) = 0.2)
\end{Sinput}
\end{Schunk}
\includegraphics{20080909test-model}

}

\end{document}

The resulting LaTeX
***FAILS: *

Runaway argument?
  ro - 0.2  c - seq(from = -3, to = 4, by = 0.1)  fn - 1 - pnorm 
\ETC.
! Paragraph ended before [EMAIL PROTECTED] was complete.
to be read again
\par
l.27 }

?

**
But when the Rnw file starts:
**
%\documentclass[compress,smaller]{beamer}
\documentclass{article}
\usepackage{beamerarticle}

***IT DOES NOT FAIL: *

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/




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

2008-09-06 Thread jim holtman
I would suggest that you use a 'list' since it seems that the result
is more than a single value:


bbayes-list()
for(i in 1:100) {
xx-t(X1_10)%*%X1_10
xxmeno1-solve(xx)
V-xxmeno1*i
Vmeno1-solve(V)
tx-t(X1_10)
prpar-solve(Vmeno1+xx)
snpar-tx%*%y
bbayes[[i]]-prpar%*%snpar
}



On Sat, Sep 6, 2008 at 9:29 AM, Davide Crapis [EMAIL PROTECTED] wrote:

 I have to calculate a formula that gives me a ten components vector. I want
 to see how the components behave at varying the variable i.
 But when i run the following function:
 bbayes-c()
 for(i in 1:100) {
 + xx-t(X1_10)%*%X1_10
 + xxmeno1-solve(xx)
 + V-xxmeno1*i
 + Vmeno1-solve(V)
 + tx-t(X1_10)
 + prpar-solve(Vmeno1+xx)
 + snpar-tx%*%y
 + bbayes-prpar%*%snpar
 + }

 it oly gives me the vector calculated with the last value of the sequence,
 in this case 100.
 Could you please suggest how to print all the 100 vectors calculated for i
 in 1:100.

 Thank you in advance.

 Davide Crapis
 --
 View this message in context: 
 http://www.nabble.com/loop-tp19346683p19346683.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.




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

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] request: most repeated sequnce

2008-09-06 Thread jim holtman
This may come closer since it removes the zeros before comparison:

 x=c(1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,3,3,3,4,4,4,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,
+ 0,0,0,0,0,0,1,2,2,2,2,2,0,3,3,0,4,4,0,0,0,0,0,0)
 x=array(x,dim=c(3,6,5))
 apply(x,3,function(.mat){
+rows - table(apply(.mat,1,function(z){
+# remove the zeros
+z - z[z != 0]
+if (length(z) == 0) return(NULL)
+paste(z,collapse=' ')
+}))
+names(rows[which.max(rows)])
+ })
[1] 1   1 2 3   1 2 3 4 1 2 3 4 2 2 3 4





On Sat, Sep 6, 2008 at 12:48 PM, Muhammad Azam [EMAIL PROTECTED] wrote:
 Dear R community
 Initially i thought my problem has been solved but one thing which i found 
 e.g. if
 1. All the elements of a sector are zero e.g
 , , 7

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]000000000 0
 [2,]000000000 0
 [3,]000000000 0
 [4,]000000000 0
 [5,]000000000 0

 2. Majority of the rows consist of zeros e.g.
 , , 5

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]440000000 0
 [2,]440000000 0
 [3,]000000000 0
 [4,]000000000 0
 [5,]000000000 0

 Actually
 zeros are not my values. I get values and fill the remaining parts with
 zeros like x=array(0,dim=c(3,6,5)). Now according to first strategy
 000000000 0 are most repeated
 sequence of rows in both of above cases. But i don't want to consider
 cases where all elements are zeros and interested to get  44
 0000000 0 or just  4   4  in case 2.
 Thanks and best regards

 Muhammad Azam





 - Original Message 
 From: jim holtman [EMAIL PROTECTED]
 To: Muhammad Azam [EMAIL PROTECTED]
 Cc: R Help r-help@r-project.org; R-help request [EMAIL PROTECTED]
 Sent: Saturday, September 6, 2008 2:39:19 PM
 Subject: Re: [R] request: most repeated sequnce

 Here is a start.  You can delete the zeros:

 x=c(1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,3,3,3,4,4,4,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,
 + 0,0,0,0,0,0,1,2,2,2,2,2,0,3,3,0,4,4,0,0,0,0,0,0)
 x=array(x,dim=c(3,6,5))
 apply(x,3,function(.mat){
 + rows - table(apply(.mat,1,function(z){
 + paste(z,collapse=' ')
 + }))
 + names(rows[which.max(rows)])
 + })
 [1] 1 0 0 0 0 0 1 2 3 0 0 0 1 2 3 4 0 0 1 2 3 4 0 0 2 2 3 4 0 0


 On Sat, Sep 6, 2008 at 4:54 AM, Muhammad Azam [EMAIL PROTECTED] wrote:
 Dear R community
 Hope every one be in best of his/her health. I have a situation in which 
 there are s-sectors. Each sector is further divided into r-rows and 
 c-columns. All it makes an array having dimension (r,c,s). e.g.

 x=c(1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,3,3,3,4,4,4,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,
 0,0,0,0,0,0,1,2,2,2,2,2,0,3,3,0,4,4,0,0,0,0,0,0)
 x=array(x,dim=c(3,6,5))
 x
 , , 1

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]100000
 [2,]100000
 [3,]100000

 , , 2

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]123000
 [2,]123000
 [3,]120000

 , , 3

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]123400
 [2,]123400
 [3,]134000

 , , 4

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]123400
 [2,]123400
 [3,]123400

 , , 5

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]120000
 [2,]223400
 [3,]223400

 I want to get the most repeated sequence (row-wise) of values in each 
 sector. e.g. in sector 1 i.e. , , 1
 the most repeated sequence is 1 (ignoring zeros). In , , 2 the most repeated 
 sequence is 1  2  3. Similarly in last sector i.e.
  , , 5 such sequence is  2  2  3  4. Any body can help to solve this 
 problem. Thanks


 best regards
 Muhammad Azam




[[alternative HTML version deleted]]

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




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

 What is the problem that you are trying to solve?




[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 

Re: [R] re ferring to a group of vectors without explicit enumeration

2008-09-06 Thread jim holtman
I would suggest that you use a list to store the values since it is
easier to create and reference:

 output - list()
 for (i in 1:10) output[[i]] - seq(i)

 output
[[1]]
[1] 1

[[2]]
[1] 1 2

[[3]]
[1] 1 2 3

[[4]]
[1] 1 2 3 4

[[5]]
[1] 1 2 3 4 5

[[6]]
[1] 1 2 3 4 5 6

[[7]]
[1] 1 2 3 4 5 6 7

[[8]]
[1] 1 2 3 4 5 6 7 8

[[9]]
[1] 1 2 3 4 5 6 7 8 9

[[10]]
 [1]  1  2  3  4  5  6  7  8  9 10




On Sat, Sep 6, 2008 at 5:33 PM, shalu [EMAIL PROTECTED] wrote:

 I am trying to define 25 vectors of varying lengths, say y1 to y25 in a loop,
 and then store the results of some computations in them. My problem is about
 using some sort of concatenation for names. For example, instead of
 initializing each of y1 through y25, I would like to do it in a loop.
 Similar to cat and paste for texts, is there anyway of using yi for the
 vector name where i ranges from 1 to 25, so ultimately it refers to the
 vector y1,..,y25?
 Varying lengths is not a problem. To start with each has only length 1 and
 then I will be adding to each vector based on some results.
 --
 View this message in context: 
 http://www.nabble.com/referring-to-a-group-of-vectors-without-explicit-enumeration-tp19351518p19351518.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.




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

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Sweave and/or beamer issue

2008-09-06 Thread Andrew Robinson
Hi Michael,

I think that beamer needs that frames that contain any verbatim text
or R output to be declared as fragile.

Try

\begin{frame}[fragile]

...

\end{frame}

On Sat, Sep 06, 2008 at 06:22:41PM -0400, Michael Kubovy wrote:
 Dear Friends,
 
 I not sure whether this is an Sweave or a beamer problem.
 
 The Rnw file:
 
 \documentclass[compress,smaller]{beamer}
 %\documentclass{article}
 %\usepackage{beamerarticle}
 
 \usepackage{Sweave}
 
 \title{Psychophysics II}
 \date{September 9, 2008}
 
 \begin{document}
 
 \frame{
 \begin{Schunk}
 \begin{Sinput}
   ro - 0.2
   c - seq(from = -3, to = 4, by = 0.1)
   fn - 1 - pnorm(c)
   fo - 1 - pnorm(c, mean = 1)
   h - fo + ro - ro * fo
   f - fn
   plot(h ~ f, type = l, asp = 1, xlim = c(0.01, 1.01), ylim =  
 c(0.01, 1.01), las = 1, xlab = p(yes | old),
 + ylab = p(yes | new), main = Dual-process model,  
 p(recollection) = 0.2)
 \end{Sinput}
 \end{Schunk}
 \includegraphics{20080909test-model}
 
 }
 
 \end{document}
 
 The resulting LaTeX
 ***FAILS: *
 
 Runaway argument?
   ro - 0.2  c - seq(from = -3, to = 4, by = 0.1)  fn - 1 - pnorm 
 \ETC.
 ! Paragraph ended before [EMAIL PROTECTED] was complete.
 to be read again
 \par
 l.27 }
 
 ?
 
 **
 But when the Rnw file starts:
 **
 %\documentclass[compress,smaller]{beamer}
 \documentclass{article}
 \usepackage{beamerarticle}
 
 ***IT DOES NOT FAIL: *
 
 _
 Professor Michael Kubovy
 University of Virginia
 Department of Psychology
 USPS: P.O.Box 400400Charlottesville, VA 22904-4400
 Parcels:Room 102Gilmer Hall
  McCormick RoadCharlottesville, VA 22903
 Office:B011+1-434-982-4729
 Lab:B019+1-434-982-4751
 Fax:+1-434-982-4766
 WWW:http://www.people.virginia.edu/~mk9y/
 
 
 
 
   [[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.

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] re ferring to a group of vectors without explicit enumeration

2008-09-06 Thread David Winsemius


On Sep 6, 2008, at 6:07 PM, Ben Bolker wrote:


shalu shahlar at hotmail.com writes:


I am trying to define 25 vectors of varying lengths, say y1 to y25  
in a loop,
and then store the results of some computations in them. My problem  
is about

using some sort of concatenation for names. For example, instead of
initializing each of y1 through y25, I would like to do it in a loop.
Similar to cat and paste for texts, is there anyway of using yi  
for the
vector name where i ranges from 1 to 25, so ultimately it refers to  
the

vector y1,..,y25?
Varying lengths is not a problem. To start with each has only  
length 1 and

then I will be adding to each vector based on some results.


 I think this is essentially

http://cran.r-project.org/doc/FAQ/R-FAQ.html
#How-can-I-turn-a-string-into-a-variable?

[URL broken in order to make Gmane happy, reassemble it
in your browser]

 the short answer: assign(), but it would work better
to use a list instead.


It may help to consider these options:

 varnames - paste(y, 1:25, sep=)
 varnames
 [1] y1  y2  y3  y4  y5  y6  y7  y8  y9  y10  
y11 y12 y13 y14 y15 y16 y17 y18 y19

[20] y20 y21 y22 y23 y24 y25
 varlist - list(paste(varbl, 1:25, sep=))
 varlist
[[1]]
 [1] varbl1  varbl2  varbl3  varbl4  varbl5  varbl6   
varbl7  varbl8  varbl9  varbl10 varbl11
[12] varbl12 varbl13 varbl14 varbl15 varbl16 varbl17  
varbl18 varbl19 varbl20 varbl21 varbl22

[23] varbl23 varbl24 varbl25

--
David Winsemius

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 address last and all but last column in dataframe

2008-09-06 Thread David Winsemius


On Sep 6, 2008, at 4:24 PM, drflxms wrote:


Hello Mr. Burns, Hello Mr. Dwinseminus


snip



David, the input data.frame is the result of the reshape-command I
performed. I just copied it from the R-console into the e-mail. In  
fact

the first column video is not part of the data, but needed for
analysis with kappam.fleiss function of the irr-package. Sorry, you  
are
absolutely correct, I should have mentioned this in my question. I  
will

improve when I ask my next question :-).



I have not yet picked up facility with reshape. Is there a method  
using reshape to take its screen output and return a dataframe?


--
David Winsemius, MD

Again I like to thank you for your help and wish you a pleasant  
Sunday.

Greetings from Munich,
Felix

Patrick Burns wrote:

If I understand properly, you want

input[, -c(1, ncol(input))]

rather than

input[[, -c(video, 21)]]

Chapter 1 of S Poetry might be of interest to you.

Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and A Guide for the Unwilling S User)

drflxms wrote:

Dear R-colleagues,

another question from a newbie: I am creating a lot of simple
pivot-charts from my raw data using the reshape-package. In these  
charts

we have medical doctors judging videos in the columns and the videos
they judge in the rows. Simple example of chart/data.frame input  
with

two categories 1/0:

video 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

1  1 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
2  2 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  1
3  3 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
4  4 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
5  5 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  1  0
6  6 0 0 0 0 0 0 0 0 0  0  0  0  0  1  0  0  0  0  0  0  0
7  7 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0
8  8 0 0 0 0 0 0 0 0 0  0  0  0  0  0  1  0  0  0  0  0  0
9  9 0 0 0 0 0 0 0 0 0  1  0  1  1  0  1  1  0  0  0  1  0
1010 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0

I recently learned, that I can easily create a confusion matrix  
out of

this data using the following commands:

pairs- 
data.frame(pred=factor(unlist(input[2:21])),ref=factor(input[,22]))


pred-pairs$pred
ref - pairs$ref
library (caret)
confusionMatrix(pred, ref, positive=1)

- where column 21 is the reference/goldstandard.

My problem is now, that I analyse data.frames with an unknown  
count of

columns. So to get rid of the first and last column for the pred
variable and to select the last column for the ref variable, I  
have to
look at the data.frame before doing the above commands to set the  
proper

column numbers.

It would be very comfortable, if I could address the last column  
not by

number (where I have to count beforehand) but by a variable last
column.

Probably there is a more easy solution for this problem using the  
names
of the columns as well: the reference is always number 21 the  
first

column is always called video. So I tried:

attach(input)
pairs-data.frame(pred=factor(unlist(input[[,-c(video, 
21)]])),ref=factor(input[[21]]))



which does not work unfortunately :-(.

I'd be very happy in case someone could help me out, cause I am  
really

tired of counting - there are a lot of tables to analyse...

Cheers and greetings from Munich,
Felix

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] plot a list

2008-09-06 Thread Gabor Grothendieck
Please read the last line to every message to r-help. In particular
this question needs to include a cut down version of the data.

I'll take a guess at what it looks like:

library(zoo)
L - list(a = zoo(1:3), b = zoo(4:5))
plot(do.call(merge, L))


On Sat, Sep 6, 2008 at 4:47 PM, stephen sefick [EMAIL PROTECTED] wrote:
 i have a list of 6 each containing a dataframe of 96 observations as a
 zoo object.  Is there a way to plot these in one frame
 par(mfrow=c(3,2))

 this is what I tried
 lapply(d, FUN=plot)

 I can provide data, list is large.
 thanks

 --
 Stephen Sefick
 Research Scientist
 Southeastern Natural Sciences Academy

 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods. We are mammals, and have not exhausted the
 annoying little problems of being mammals.

-K. Mullis

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Sweave and/or beamer issue

2008-09-06 Thread Duncan Murdoch

On 06/09/2008 6:38 PM, Andrew Robinson wrote:

Hi Michael,

I think that beamer needs that frames that contain any verbatim text
or R output to be declared as fragile.

Try

\begin{frame}[fragile]

...

\end{frame}


The declaration I usually use is containsverbatim, but it probably 
does the same thing as fragile.


Duncan Murdoch



On Sat, Sep 06, 2008 at 06:22:41PM -0400, Michael Kubovy wrote:

Dear Friends,

I not sure whether this is an Sweave or a beamer problem.

The Rnw file:

\documentclass[compress,smaller]{beamer}
%\documentclass{article}
%\usepackage{beamerarticle}

\usepackage{Sweave}

\title{Psychophysics II}
\date{September 9, 2008}

\begin{document}

\frame{
\begin{Schunk}
\begin{Sinput}
  ro - 0.2
  c - seq(from = -3, to = 4, by = 0.1)
  fn - 1 - pnorm(c)
  fo - 1 - pnorm(c, mean = 1)
  h - fo + ro - ro * fo
  f - fn
  plot(h ~ f, type = l, asp = 1, xlim = c(0.01, 1.01), ylim =  
c(0.01, 1.01), las = 1, xlab = p(yes | old),
+ ylab = p(yes | new), main = Dual-process model,  
p(recollection) = 0.2)

\end{Sinput}
\end{Schunk}
\includegraphics{20080909test-model}

}

\end{document}

The resulting LaTeX
***FAILS: *

Runaway argument?
  ro - 0.2  c - seq(from = -3, to = 4, by = 0.1)  fn - 1 - pnorm 
\ETC.

! Paragraph ended before [EMAIL PROTECTED] was complete.
to be read again
\par
l.27 }

?

**
But when the Rnw file starts:
**
%\documentclass[compress,smaller]{beamer}
\documentclass{article}
\usepackage{beamerarticle}

***IT DOES NOT FAIL: *

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/




[[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] plot a list

2008-09-06 Thread stephen sefick
the plot(do.call(merge, z.l)) works on the following data well.  Is
there a way to get control of xlim so that it plots each individual
graph shows only the one day (figures the x axis on the range of the
data for each plot individually) and control labeling?  Thanks in
advance, and sorry for not putting an example in the first email.

#here is a made up example
library(chron)
library(zoo)
t1 - chron(1/1/2006, 00:01:00)
t2 - chron(1/1/2006, 23:46:00)
deltat - times(00:15:00)
tt - seq(t1, t2, by = times(00:15:00))
DO - rnorm(96)
Temp - rnorm(96)
a - cbind(Temp, DO)


t3 - chron(12/1/2006, 00:01:00)
t4 - chron(12/1/2006, 23:46:00)
deltat - times(00:15:00)
tt.2 - seq(t3, t4, by = times(00:15:00))
DO.2 - rnorm(96)
Temp.2- rnorm(96)
b - cbind(Temp.2, DO.2)

z1 - zoo(a, tt)
z2 - zoo(b, tt.2)

z.l - list(z1,z2)
plot(do.call(merge, z.l))

On Sat, Sep 6, 2008 at 7:22 PM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
 Please read the last line to every message to r-help. In particular
 this question needs to include a cut down version of the data.

 I'll take a guess at what it looks like:

 library(zoo)
 L - list(a = zoo(1:3), b = zoo(4:5))
 plot(do.call(merge, L))


 On Sat, Sep 6, 2008 at 4:47 PM, stephen sefick [EMAIL PROTECTED] wrote:
 i have a list of 6 each containing a dataframe of 96 observations as a
 zoo object.  Is there a way to plot these in one frame
 par(mfrow=c(3,2))

 this is what I tried
 lapply(d, FUN=plot)

 I can provide data, list is large.
 thanks

 --
 Stephen Sefick
 Research Scientist
 Southeastern Natural Sciences Academy

 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods. We are mammals, and have not exhausted the
 annoying little problems of being mammals.

-K. Mullis

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





-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 a list

2008-09-06 Thread Gabor Grothendieck
Try xyplot.zoo with scale = list(relation = free)
specifying xlim as shown below:

library(zoo)
library(lattice)
zm - do.call(merge, z.l)
xlim - lapply(zm, function(x) range(time(na.omit(x
xyplot(zm, xlim = xlim, scale = list(relation = free))

On Sat, Sep 6, 2008 at 7:49 PM, stephen sefick [EMAIL PROTECTED] wrote:
 the plot(do.call(merge, z.l)) works on the following data well.  Is
 there a way to get control of xlim so that it plots each individual
 graph shows only the one day (figures the x axis on the range of the
 data for each plot individually) and control labeling?  Thanks in
 advance, and sorry for not putting an example in the first email.

 #here is a made up example
 library(chron)
 library(zoo)
 t1 - chron(1/1/2006, 00:01:00)
 t2 - chron(1/1/2006, 23:46:00)
 deltat - times(00:15:00)
 tt - seq(t1, t2, by = times(00:15:00))
 DO - rnorm(96)
 Temp - rnorm(96)
 a - cbind(Temp, DO)


 t3 - chron(12/1/2006, 00:01:00)
 t4 - chron(12/1/2006, 23:46:00)
 deltat - times(00:15:00)
 tt.2 - seq(t3, t4, by = times(00:15:00))
 DO.2 - rnorm(96)
 Temp.2- rnorm(96)
 b - cbind(Temp.2, DO.2)

 z1 - zoo(a, tt)
 z2 - zoo(b, tt.2)

 z.l - list(z1,z2)
 plot(do.call(merge, z.l))

 On Sat, Sep 6, 2008 at 7:22 PM, Gabor Grothendieck
 [EMAIL PROTECTED] wrote:
 Please read the last line to every message to r-help. In particular
 this question needs to include a cut down version of the data.

 I'll take a guess at what it looks like:

 library(zoo)
 L - list(a = zoo(1:3), b = zoo(4:5))
 plot(do.call(merge, L))


 On Sat, Sep 6, 2008 at 4:47 PM, stephen sefick [EMAIL PROTECTED] wrote:
 i have a list of 6 each containing a dataframe of 96 observations as a
 zoo object.  Is there a way to plot these in one frame
 par(mfrow=c(3,2))

 this is what I tried
 lapply(d, FUN=plot)

 I can provide data, list is large.
 thanks

 --
 Stephen Sefick
 Research Scientist
 Southeastern Natural Sciences Academy

 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods. We are mammals, and have not exhausted the
 annoying little problems of being mammals.

-K. Mullis

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





 --
 Stephen Sefick
 Research Scientist
 Southeastern Natural Sciences Academy

 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods. We are mammals, and have not exhausted the
 annoying little problems of being mammals.

-K. Mullis


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Hopefully an easy error bar question

2008-09-06 Thread Frank E Harrell Jr

Ben Bolker wrote:

Martin Maechler maechler at stat.math.ethz.ch writes:


FEH == Frank E Harrell f.harrell at vanderbilt.edu
on Sat, 06 Sep 2008 07:19:33 -0500 writes:
FEH See http://biostat.mc.vanderbilt.edu/DynamitePlots for many reasons not 
FEH to use dynamite plots.


Ah!  Very good!  Let's hope this eventually leads to progress 
i.e., to much less use of these..


Thank you, Frank!
Martin Maechler, ETH Zurich

FEH -- 


  Yes, but:

http://emdbolker.wikidot.com/blog:dynamite

(repeats Frank's criticisms, but also raises
the point that boxplots show the range of the
data, but not much about the statistical inferences
on the data ...)

  comments welcome.

  Ben Bolker


Hi Ben,

I enjoyed the blog.

Depending on the sample size I prefer extended box plots (e.g., 
?panel.bpplot in the Hmisc package) with raw data superimposed.  The 
3-number summary from the box plot does not contain enough information 
when the sample size is moderate or large IMHO.  But for small samples, 
raw data points supplemented by the 3 quartiles and the mean work well.


Frank

--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Label 2 groups in PCA different colours

2008-09-06 Thread pgseye

Hi,

I'm wanting to do a PCA on some data which is comprised of two different
groups (to see how well the groups are discriminated). Is there a way to
change the colour of the datapoints in a biplot so that I can easily see
which group is which (eg objects 1-100, red, 101-200, black).

Might be simple, but I'm new to R and can't seem to find how to do this.

Thanks.

Paul
-- 
View this message in context: 
http://www.nabble.com/Label-2-groups-in-PCA-different-colours-tp19354077p19354077.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] Corrupted PDF files

2008-09-06 Thread Gabor Grothendieck
Its a FAQ:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f

On Sat, Sep 6, 2008 at 9:47 PM, Nathan Teuscher [EMAIL PROTECTED] wrote:
 I have the following code that when executed from the command line
 works properly and produces a proper PDF. When the script is executed,
 the PDF produced is considered corrupt. I am using R 2.7.2 on Mac OSX
 10.5.4. Thank you in advance for the help!

 library(lattice)
 pdf(file=CLDiag2.pdf)
 xyplot(
   CL ~ HT + WT + AGE + CREA + SEX,
   data=data2,
   outer=TRUE,
   scales=list(x=list(relation=free)),
   panel=function(...){
panel.loess(..., col=red)
panel.xyplot(..., pch=.)
}
 )
 dev.off()


 Nathan Teuscher
 [EMAIL PROTECTED]





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