Re: [R] Reading in .aux (ESRI raster files) into R

2010-09-27 Thread JoH

Thank you Barry
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Reading-in-aux-ESRI-raster-files-into-R-tp2553544p2715015.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] textplot

2010-09-27 Thread trb1

Hi all,

Please can you help me to add text to a plot. 

I would like 5 graphical plots and 1 text plot. I use
par(mfrow=c(2,3))
then 
textplot()
I would like to add various pieces of information to the text plot,
i.e. some individual values, a table of statistics, some sentences.

Is there any easy way of doing this or am I forced to construct a very
complicated dataframe?
Is this even possible?
Examples would be appreciated...

Thanks...
-- 
View this message in context: 
http://r.789695.n4.nabble.com/textplot-tp2715028p2715028.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] a very basic question: calling c function from R

2010-09-27 Thread teetee

Hi, Duncan Murdoch...

i m facing same pro here..
n i m a very new user for R...
i m just start using it now for my final year project...
i wan to know how to run outside R???
i have no idea about it...
can u help me???
appreciate for your helping...
-- 
View this message in context: 
http://r.789695.n4.nabble.com/a-very-basic-question-calling-c-function-from-R-tp883154p2714989.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] Odp: Object Browser

2010-09-27 Thread Petr PIKAL
Hi
I noticed that nobody answered your question yet so here is my try.

If you want to see what objects are in your environment you can use ls() 
but its output is only names of objects. Here is a function I use a long 
time for checking what objects are there, their type, size and possibly 
rows columns. You can modify it to give you some more info but usually it 
is not needed.

Regards
Petr

ls.objects - function (pos = 1, pattern, order.by) 
{
napply - function(names, fn) sapply(names, function(x) fn(get(x, 
pos = pos)))
names - ls(pos = pos, pattern = pattern)
obj.class - napply(names, function(x) as.character(class(x))[1])
obj.mode - napply(names, mode)
obj.type - ifelse(is.na(obj.class), obj.mode, obj.class)
obj.size - napply(names, object.size)
obj.dim - t(napply(names, function(x) as.numeric(dim(x))[1:2]))
vec - is.na(obj.dim)[, 1]  (obj.type != function)
obj.dim[vec, 1] - napply(names, length)[vec]
out - data.frame(obj.type, obj.size, obj.dim)
names(out) - c(Type, Size, Rows, Columns)
if (!missing(order.by)) 
out - out[order(out[[order.by]]), ]
out
}


r-help-boun...@r-project.org napsal dne 24.09.2010 23:04:20:

 
 What's the best object browser?
 
 Dear all,
 
 I have tried all the popular R IDE or editors like Eclipse, Komodo, JGR,
 Revolution...
 They all have fancy fucntions like auto completion, syntax highlight
 BUT, I JUST WANT A OBJECT BROWSER!
 
 The easiest way to view objects in R console is fix(), but you have no
 global view of all the objects in the workspace.
 Revolution has the best object browser so far, but this thing is way too
 big...
 Eclipse all has automatically object browser, but you can't only see the
 basic summary info. and it's really tricky to configure StatET.
 Jgr is very handy, when you double click the object name, you can view 
the
 object in a spreadsheet like using fix(), but you have to press the
 Refresh button each time you want to see the updated objects...
 
 So, is there any thing like the combination of eclipse and Jgr?
 If not, I am interested to develope something to fulfill this simple but
 very important function. But right now I have no idea where to start. 
Any
 suggestions?
 
 
 Peter
 
 
 
 
 
 
 
 
 
 -- 
 View this message in context: 
http://r.789695.n4.nabble.com/Object-Browser-
 tp2594912p2594912.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] textplot

2010-09-27 Thread Tal Galili
Have a look at
?textplot
From the
gplots
package:
http://cran.r-project.org/web/packages/gplots/index.html



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Mon, Sep 27, 2010 at 9:48 AM, trb1 thomasrbol...@yahoo.co.uk wrote:


 Hi all,

 Please can you help me to add text to a plot.

 I would like 5 graphical plots and 1 text plot. I use
 par(mfrow=c(2,3))
 then
 textplot()
 I would like to add various pieces of information to the text plot,
 i.e. some individual values, a table of statistics, some sentences.

 Is there any easy way of doing this or am I forced to construct a very
 complicated dataframe?
 Is this even possible?
 Examples would be appreciated...

 Thanks...
 --
 View this message in context:
 http://r.789695.n4.nabble.com/textplot-tp2715028p2715028.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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

2010-09-27 Thread Maayt

Thanks for the help, I start to get reasonable errors on the model...
I finally turned to the simpler lm() fitting. As my data from which I fit
has only 8 points in each case, I guess it does not make much sense to
downweight outliers and use rlm() in this case. 



-- 
View this message in context: 
http://r.789695.n4.nabble.com/Uncertainty-propagation-tp2713499p2715085.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] Fitting with error on data

2010-09-27 Thread Maayt

As this forum proved to be very helpful, I got another question...
I'd like to fit data points on which I have an error, dx and dy, on each x
and y. What would be the common procedure to fit this data by a linear model
taking into account uncertainty on each point? Would weighting each point by
1/sqrt(dx2+dy2) (and taking dx and dy as relative errors) in a lm() fit do
the job? I would like to propagate uncertainty of the points into the
uncertainty of the fit, would that be the case?

Thanks for all the help
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Fitting-with-error-on-data-tp2715100p2715100.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] Some questions about string processing

2010-09-27 Thread Michael Hopkins


Thanks Phil, very helpful and works as advertised.  

Any thoughts on the second question?

(P.S. for anyone digging this up in the future, there's a comma missing after 
the formula in lm())


On 24 Sep 2010, at 18:16, Phil Spector wrote:

 Michael -
   You're doing too much work half the time, and not enough
 the other half :-).  Try this (untested):
 
 auto_io = function(data_name,factors){
   resp_data =  read.table(data_name, header = TRUE )
   temp_model = lm(formula(paste('y',factors,sep='~')) data = resp_data )
   . . .
 
   - Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
 
 
 On Fri, 24 Sep 2010, Michael Hopkins wrote:
 
 
 
 Hi all
 
 A couple of questions about string processing from someone who has only 
 scratched the surface so far.
 
 1) I am wanting to send some strings into a function to allow flexibility 
 inside.  My first idea has been e.g.
 
 auto_io - function( var_string, factors ) {
 #  e.g. var_string sent as test_file.txt  factors sent as x1 + x2 + x3
 
 # input
  data_name   - get( var_string )
 
 #term_list   - get( factors )
 
  resp_data   - read.table( data_name, 
 header = TRUE )
 
 # fit
  temp_model  -  lm( y ~ factors, data = resp_data )
 
  etc...
 
 Neither the read.table() nor the lm() are working because in each case the 
 string is not converted or understood properly.  I'm sure this is possible 
 (and in fact probably easy) but haven't yet seen the light.  Could someone 
 illuminate me here?
 
 2) I will be wanting to process strings as lists of strings.  For instance, 
 I might instead want to send factors above as x1  x2  x3 and add the + 
 when I need them, or perhaps * instead, and also look at sub-models by 
 removing parts of the string etc.  What functions should I be looking at 
 here and are there any examples available?
 
 Thanks in advance.  Feel free to CC me on your reply.
 
 
 Michael Hopkins
 Algorithm and Statistical Modelling Expert
 
 Upstream
 23 Old Bond Street
 London
 W1S 4PZ
 
 Mob +44 0782 578 7220
 DL   +44 0207 290 1326
 Fax  +44 0207 290 1321
 
 hopk...@upstreamsystems.com
 www.upstreamsystems.com
 
 IMPORTANT NOTICE
 The information in this e-mail and any attached files is...{{dropped:22}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 




Michael Hopkins
Algorithm and Statistical Modelling Expert
 
Upstream
23 Old Bond Street
London
W1S 4PZ

Mob +44 0782 578 7220
DL   +44 0207 290 1326
Fax  +44 0207 290 1321

hopk...@upstreamsystems.com
www.upstreamsystems.com
 
IMPORTANT NOTICE
The information in this e-mail and any attached files is CONFIDENTIAL and may 
be legally privileged or prohibited from disclosure and unauthorised use. The 
views of the author may not necessarily reflect those of Upstream S.A. It is 
intended solely for the addressee, or the employee or agent responsible for 
delivering such materials to the addressee. If you have received this message 
in error please return it to the sender then delete the email and destroy any 
copies of it. If you are not the intended recipient, any form of reproduction, 
dissemination, copying, disclosure, modification, distribution and/or 
publication, or any action taken or omitted to be taken in reliance upon this 
message or its attachments is prohibited and may be unlawful. At present the 
integrity of e-mail across the Internet cannot be guaranteed and messages sent 
via this medium are potentially at risk. All liability is excluded to the 
extent permitted by law for any claims arising as a result of the u!
 se of this medium to transmit information by or to Upstream S.A.




[[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] store matrix in an arrary

2010-09-27 Thread wesley mathew
Dear All

I want to store matrix in an array
Suppose  s-array(0,4)
for(i in 1:4)
s[i] - read_matrix(a,2,2)
But the error - number of items to replace is not a multiple of replacement
length.
Can you suggest me any alternative method for storing a matrix in an array.
Thanks In advance.
Kind Regards
Wesley C Mathew

[[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] store matrix in an arrary

2010-09-27 Thread Edwin Groot
On Mon, 27 Sep 2010 11:12:26 +0100
 wesley mathew wesleycmat...@gmail.com wrote:
 Dear All
 
 I want to store matrix in an array
 Suppose  s-array(0,4)
 for(i in 1:4)
 s[i] - read_matrix(a,2,2)
 But the error - number of items to replace is not a multiple of
 replacement
 length.
 Can you suggest me any alternative method for storing a matrix in an
 array.
 Thanks In advance.
 Kind Regards
 Wesley C Mathew
 

Wesley,
I don't know what your read_matrix() function is doing.
What you made is a 1-dimensional array of 4 elements. If your
read_matrix() function returns more than one element per call, that is
the source of your error message. It means you tried to store something
in s[] that goes beyond its dimensions.

Edwin
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
-- 
Dr. Edwin Groot, postdoctoral associate
AG Laux
Institut fuer Biologie III
Schaenzlestr. 1
79104 Freiburg, Deutschland
+49 761-2032945

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

2010-09-27 Thread Jorge Ivan Velez
Hi Wesley,

Try this (untested):

s - array(0, dim = c(2, 2, 4))

for(i in 1:4)

  s[, ,i] - read_matrix(a, 2, 2)


Another (untested) option wold be

s0 - lapply(1:4, function(i) read_matrix(a, 2, 2))
s0

HTH,
Jorge



On Mon, Sep 27, 2010 at 6:12 AM, wesley mathew  wrote:

 Dear All

 I want to store matrix in an array
 Suppose  s-array(0,4)
 for(i in 1:4)
 s[i] - read_matrix(a,2,2)
 But the error - number of items to replace is not a multiple of replacement
 length.
 Can you suggest me any alternative method for storing a matrix in an array.
 Thanks In advance.
 Kind Regards
 Wesley C Mathew

[[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] a very basic question: calling c function from R

2010-09-27 Thread Duncan Murdoch

On 27/09/2010 2:45 AM, teetee wrote:

Hi, Duncan Murdoch...

i m facing same pro here..
n i m a very new user for R...
i m just start using it now for my final year project...
i wan to know how to run outside R???
i have no idea about it...
can u help me???
appreciate for your helping...


You should ask your instructor.

Duncan Murdoch

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

2010-09-27 Thread pj-uk

Hi,

I have a function that generates a set of data but I am having problems
determining the parameters using the nls fitting procedure.

 

MH-function(field,diameter,mu=10e-7,sig=0.1,Ms=100,chi=0){
#variables mu, sig, chi, Ms
#input: field and diameter
#all in CGS
rho - 5
kb - 1.38e-16
t - 300
length.d-length(diameter)
length.H-length(field)
M-double(length.H)
for (i in 1:length.H){
S1-0
S2-0
H - field[i]
for (j in 1:length.d){
d-diameter[j]
vol - 4/3*pi*(d/2)^3
lognorm - 
1/(d*sig*sqrt(2*pi))*exp(-(log(d)-log(mu))^2/(2*sig^2))
lang - 1/tanh(Ms*rho*vol*H/(kb*t))-1/(Ms*rho*vol*H/(kb*t))
S1 - S1 + lognorm*vol*lang
S2 - S2 + lognorm*vol  
}
M[i] - Ms*S1/S2 + chi*H
}
M
}

### I can calculate a set of data:

htest- (-10:10)*200
dtest- (5:15)*1e-7
mtest- MH(field=htest,diameter=dtest)

### However when I try to reverse engineer to calculate the parameters mu,
sig, chi and Ms I run into problems.  Could anyone shed some light on this
problem?

fit - nls(M~MH(H,(5:15)*1e-7,mu,sig,Ms,chi),data=df,start=list(mu=10e-7,
sig=0.1, chi=0, Ms=100))

### Thanks, Paul
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Fitting-problem-tp2715234p2715234.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] legend

2010-09-27 Thread threshold

Thanks David, works fine! 
robert
-- 
View this message in context: 
http://r.789695.n4.nabble.com/legend-tp2550747p2715250.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] Data frame self-join with no duplicates

2010-09-27 Thread Xin Zhang
Suppose I have the following data frame (df):

YearPrice
---
200110
200220
200330

I would like to produce another data frame like this:

a.Yeara.Priceb.Yearb.Price

200220200110
200330200110
200330200220

In SQL, this can be done as

select a.*, b.*
from df as a, df as b
where a.Year  b.Year

How do I do this efficiently in R?

Many thanks.

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


[R] Odp: Fitting problem

2010-09-27 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 27.09.2010 13:13:28:

 
 Hi,
 
 I have a function that generates a set of data but I am having problems
 determining the parameters using the nls fitting procedure.
 
  
 
 MH-function(field,diameter,mu=10e-7,sig=0.1,Ms=100,chi=0){
 #variables mu, sig, chi, Ms
 #input: field and diameter
 #all in CGS
 rho - 5
 kb - 1.38e-16
 t - 300
 length.d-length(diameter)
 length.H-length(field)
 M-double(length.H)
 for (i in 1:length.H){
S1-0
S2-0
H - field[i]
for (j in 1:length.d){
   d-diameter[j]
   vol - 4/3*pi*(d/2)^3
   lognorm - 1/(d*sig*sqrt(2*pi))*exp(-(log(d)-log(mu))^2/(2*sig^2))
   lang - 1/tanh(Ms*rho*vol*H/(kb*t))-1/(Ms*rho*vol*H/(kb*t))
   S1 - S1 + lognorm*vol*lang
   S2 - S2 + lognorm*vol 
}
M[i] - Ms*S1/S2 + chi*H 
 }
 M
 }
 
 ### I can calculate a set of data:
 
 htest- (-10:10)*200
 dtest- (5:15)*1e-7
 mtest- MH(field=htest,diameter=dtest)
 
 ### However when I try to reverse engineer to calculate the parameters 
mu,
 sig, chi and Ms I run into problems.  Could anyone shed some light on 
this
 problem?

What problem? I get

 fit - 
nls(M~MH(H,(5:15)*1e-7,mu,sig,Ms,chi),data=df,start=list(mu=10e-7,
+ sig=0.1, chi=0, Ms=100))
Error in nls(M ~ MH(H, (5:15) * 1e-07, mu, sig, Ms, chi), data = df, start 
= list(mu = 1e-06,  : 
  'data' must be a list or an environment

evidently I have df only as function for density of F distribution.

One comment. If you looked into help page you could find this warning
Warning
Do not use nls on artificial zero-residual data.

Which I suppose you have. So add some noise to it.

Regards
Petr


 
 fit - 
nls(M~MH(H,(5:15)*1e-7,mu,sig,Ms,chi),data=df,start=list(mu=10e-7,
 sig=0.1, chi=0, Ms=100))
 
 ### Thanks, Paul
 -- 
 View this message in context: 
http://r.789695.n4.nabble.com/Fitting-problem-
 tp2715234p2715234.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] Fitting problem

2010-09-27 Thread pj-uk

Oops I forgot to add another line to the code (see below)!!  You could add
some noise if you want to.  Generating the data from the function was merely
a way to test if the fitting procedure works - I have experimental data that
should allow me to calculate the parameters mu, sig, chi and Ms based upon
my input M, H and diameter.

df - data.frame(H=htest,M=mtest)
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Fitting-problem-tp2715234p2715271.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] Data frame self-join with no duplicates

2010-09-27 Thread Dennis Murphy
Hi:

One option is to read your data frame into R and then use your SQL code in
conjunction with the sqldf package. It uses SQLite as its engine.

HTH,
Dennis


On Mon, Sep 27, 2010 at 4:29 AM, Xin Zhang xin.zh...@gmail.com wrote:

 Suppose I have the following data frame (df):

 YearPrice
 ---
 200110
 200220
 200330

 I would like to produce another data frame like this:

 a.Yeara.Priceb.Yearb.Price
 
 200220200110
 200330200110
 200330200220

 In SQL, this can be done as

 select a.*, b.*
 from df as a, df as b
 where a.Year  b.Year

 How do I do this efficiently in R?

 Many thanks.

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


[[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] cluster analysis and supervised classification: an alternative to knn1?

2010-09-27 Thread abanero

Hi Ulrich,
 I'm studying the principles of Affinity Propagation and I'm really glad to
use your package (apcluster) in order to cluster my data.  I have just an
issue to solve..

If I apply the funcion: apcluster(sim) 

where sim is the matrix of dissimilarities, sometimes I encounter the
warning message:

Algorithm did not converge. Turn on details
and call plot() to monitor net similarity. Consider
increasing maxits and convits, and, if oscillations occur
also increasing damping factor lam.
 
with  too high number of clusters.
 
I thought to solve the problem setting the argument p of the function
apcluster() to mean(PreferenceRange(sim)):


apcluster(sim, p=mean(preferenceRange(sim)))

and actually it seems to be a good solution because I don't receive any
warning message and the number of cluster is slower.

Do you think it's a good solution? I submitt that I have to use apcluster()
in an automatic procedure so I can't manipulate directly the arguments of
the funcion.

Thanks in advance.
Giuseppe
-- 
View this message in context: 
http://r.789695.n4.nabble.com/cluster-analysis-and-supervised-classification-an-alternative-to-knn1-tp2231656p2715278.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] Data frame self-join with no duplicates

2010-09-27 Thread Xin Zhang
Thanks Dennis.  I will explore that.

On Mon, Sep 27, 2010 at 7:45 AM, Dennis Murphy djmu...@gmail.com wrote:
 Hi:

 One option is to read your data frame into R and then use your SQL code in
 conjunction with the sqldf package. It uses SQLite as its engine.

 HTH,
 Dennis


 On Mon, Sep 27, 2010 at 4:29 AM, Xin Zhang xin.zh...@gmail.com wrote:

 Suppose I have the following data frame (df):

 Year    Price
 ---
 2001    10
 2002    20
 2003    30

 I would like to produce another data frame like this:

 a.Year    a.Price    b.Year    b.Price
 
 2002    20    2001    10
 2003    30    2001    10
 2003    30    2002    20

 In SQL, this can be done as

 select a.*, b.*
 from df as a, df as b
 where a.Year  b.Year

 How do I do this efficiently in R?

 Many thanks.

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



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


Re: [R] Fitting problem

2010-09-27 Thread Petr PIKAL
r-help-boun...@r-project.org napsal dne 27.09.2010 13:36:51:

 
 Oops I forgot to add another line to the code (see below)!!  You could 
add

I do not have the previous code, I do not keep mails.

 some noise if you want to.  Generating the data from the function was 
merely

You want to add some noise. nls ***does not work*** for artificial data 
without noise as stated in help page.

Regards
Petr

 a way to test if the fitting procedure works - I have experimental data 
that
 should allow me to calculate the parameters mu, sig, chi and Ms based 
upon
 my input M, H and diameter.
 
 df - data.frame(H=htest,M=mtest)
 -- 
 View this message in context: 
http://r.789695.n4.nabble.com/Fitting-problem-
 tp2715234p2715271.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] Problem with unlist

2010-09-27 Thread Ben Bolker
Luis Felipe Parra felipe.parra at quantil.com.co writes:

 
  Hello, I am trying to unlist a list, which is attached, and I am having the
 problem that when I unlist it the number of elements changes from 5065 to
 5084
 
   x - lapply(SumaPluvi, FUN=[, 1);
  n - sapply(x, FUN=length);
  print(table(n));
 n
1
 5065
  print(which(n != 1));
 integer(0)
  length(unlist(lapply(SumaPluvi, FUN=[, 1)))
 [1] 5081
 
 
 I dont now why, but when I unlist it the number of elements changes from
 5065 to 5084 even if there is no list element with length greater than one.
 Do you know what can be happening?
 

  We probably won't be able to get farther without a reproducible
example.  One brute-force way of finding the problem is by bisection:
i.e., try the first and last halves of your list separately, and see
if either one individually shows a similar problem.  Proceed recursively
until you localize the problem ...

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 95% CI of Kaplan-Meier survival in package survival

2010-09-27 Thread Terry Therneau
 My result using Kaplan-Meier estimate in survival package was
 inconsistent with that from Minitab. The survival probabilities are
 same, but their 95% are different.

 Confidence intervals for a survival curve may be calcualted on the
linear (poor performance), log (good), log-log (good), or logit (good)
scales.  I expect that Minitab and S default to different choices.  See
the conf.type argument in help(survfit.formula).

Terry Therneau

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

2010-09-27 Thread Nilza BARROS
Dear R users,

How could I managed graphics in GIF  format? What I have been doing is
graphics in *.ps or *.eps and after I convert them using CONVERT (from
ImageMagick) but the output quality is not good.  Since these graphics will
be use for other users they must have a better image quality.

I really appreciate any help,

-- 
Abraço,
Nilza Barros

[[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] Output Graphics GIF

2010-09-27 Thread Nilza BARROS
 Dear R users,

How could I managed graphics in GIF  format? What I have been doing is
graphics in *.ps or *.eps and after I convert them using CONVERT (from
ImageMagick) but the output quality is not good.  Since these graphics will
be use for other users they must have a better image quality.

I really appreciate any help,

-- 
Abraço,
Nilza Barros



-- 
Abraço,
Nilza Barros

[[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] Fitting problem

2010-09-27 Thread pj-uk

 Updated!

 

MH-function(field,diameter,mu=10e-7,sig=0.1,Ms=100,chi=0){ 
#variables mu, sig, chi, Ms 
#input: field and diameter 
#all in CGS 
rho - 5 
kb - 1.38e-16 
t - 300 
length.d-length(diameter) 
length.H-length(field) 
M-double(length.H) 
for (i in 1:length.H){ 
S1-0 
S2-0 
H - field[i] 
for (j in 1:length.d){ 
d-diameter[j] 
vol - 4/3*pi*(d/2)^3 
lognorm -
1/(d*sig*sqrt(2*pi))*exp(-(log(d)-log(mu))^2/(2*sig^2)) 
lang - 1/tanh(Ms*rho*vol*H/(kb*t))-1/(Ms*rho*vol*H/(kb*t)) 
S1 - S1 + lognorm*vol*lang 
S2 - S2 + lognorm*vol  
} 
M[i] - Ms*S1/S2 + chi*H
} 
M 
} 

###

htest- (-10:10)*200 
dtest- (5:15)*1e-7 
mtest- MH(field=htest,diameter=dtest) + rnorm(21)  ##also added some
noise!! 
df - data.frame(H=htest,M=mtest) 

fit - nls(M~MH(H,(5:15)*1e-7,mu,sig,Ms,chi),data=df,start=list(mu=10e-7,
sig=0.1, chi=0, Ms=100)) 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Fitting-problem-tp2715234p2715350.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] Data frame self-join with no duplicates

2010-09-27 Thread jim holtman
try sqldf:

 require(sqldf)
 x - read.table(textConnection(YearPrice
+ 200110
+ 200220
+ 200330), as.is=TRUE, header=TRUE)
 sqldf(select a.*, b.*
+ from x as a, x as b
+ where a.Year  b.Year, method='raw')
  Year Price Year Price
1 200220 200110
2 200330 200110
3 200330 200220




On Mon, Sep 27, 2010 at 7:29 AM, Xin Zhang xin.zh...@gmail.com wrote:
 Suppose I have the following data frame (df):

 Year    Price
 ---
 2001    10
 2002    20
 2003    30

 I would like to produce another data frame like this:

 a.Year    a.Price    b.Year    b.Price
 
 2002    20    2001    10
 2003    30    2001    10
 2003    30    2002    20

 In SQL, this can be done as

 select a.*, b.*
 from df as a, df as b
 where a.Year  b.Year

 How do I do this efficiently in R?

 Many thanks.

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




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


[R] Date/Time format

2010-09-27 Thread Costas

 Hello,

Is it possible to instruct (permanently) R to write on csv (and read 
from csv) time series, where the time stamp has a particular format:


say:

-mm-dd

i.e.,
as in

format(Sys.Date(), %Y-%m-%d)

Many thanks in advance,
Costas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] conditional assignment of colors in xyplot()

2010-09-27 Thread nathan pellegrin
# Dear R Community,

# I have this data frame:

df1 - data.frame(
F1 = factor( c( rep(D1,12),rep(D2,12),rep(D3,12) ) ),
F2 = factor( rep( rep( paste(O,1:6,sep=), rep(2,6) ), 3) ),
F3 = factor( rep( c(V1,V2), 18 ) ),
S1 =
c(8.840955e-02,2.546822e-01,7.562658e-01,8.801181e-01,6.041766e-02,2.172731e-01,6.542187e-98,
7.067840e-04,1.430933e-01,9.764401e-01,1.380848e-05,1.192620e-01,9.107259e-01,1.235232e-01,
3.021847e-01,1.331351e-01,5.272103e-01,3.663577e-01,1.539690e-38,2.224451e-01,2.873052e-01,
5.110313e-01,7.840802e-01,8.210762e-10,1.553356e-01,4.173335e-01,5.964021e-01,4.955694e-01,
8.849240e-02,5.739598e-01,1.879075e-17,1.071003e-03,7.298928e-01,6.347287e-01,8.884034e-01,
4.460295e-11),
S2 =
c(1.32249139,1.02831831,-0.09650252,-0.05454486,2.62105492,2.00310250,8.07269064,
-1.55397883,1.77390551,0.04161954,7.14188540,-2.98033713,-0.49904251,-0.74309058,
-0.49904251,-0.74309058,1.22492623,-1.79003492,7.60003121,-0.74549596,2.53418936,
-1.60112296,0.67131380,-15.31744351,-0.18380339,0.28628435,-0.18380339,0.28628435,
2.96108998,1.18267783,5.78419118,2.70861763,0.66287857,1.10397741,0.27160971,
-15.37506924) )


# Two of the factors are used to define an array
# of panels with the third showing up as bars along the x axis.
# How do I color the bars according to their sign (red  0, blue  0)
# conditional on the value of S2  .025 - in which case color them gray?
# Initially, I tried to pass a character vector specifying colors,
# which does not achieve the desired result:

library(lattice)
library(latticeExtra)

df1$barcols - ifelse(df1$S1 .025, gray, ifelse( df1$S2  0,
blue,red))

 ctp - xyplot(S2 ~ F2 | F1 + F3,
  data=df1, as.table=TRUE, ylim=c(-10,10),
panel = function(x,y){
  panel.barchart(x,y,horizontal=FALSE, origin=0,
  col=df1$barcols ) } )
useOuterStrips(ctp)

# Any help you can provide would be greatly appreciated.
# Thank you!

# nathan.pelleg...@gmail.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] Output Graphics GIF

2010-09-27 Thread Barry Rowlingson
On Mon, Sep 27, 2010 at 1:39 PM, Nilza BARROS nilzabar...@gmail.com wrote:
 Dear R users,

 How could I managed graphics in GIF  format? What I have been doing is
 graphics in *.ps or *.eps and after I convert them using CONVERT (from
 ImageMagick) but the output quality is not good.  Since these graphics will
 be use for other users they must have a better image quality.

 The png() graphics driver will produce bitmap graphics which should
convert better to a gif. PostScript is a vector format, so there may
be all sorts of things going on.

 Just feed png() with the width and height you want for your gif and
then you wont have to resize as part of the conversion process.

 Also, GIFs are pretty old-tech these days, so if you could persuade
your other users to switch to png files, its a big win.

Barry

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


Re: [R] plotting multiple animal tracks against Date/Time

2010-09-27 Thread Gabor Grothendieck
On Mon, Sep 27, 2010 at 10:01 AM, Struve, Juliane
j.str...@imperial.ac.uk wrote:
 Hi,

 I am sorry that my question wasn not very clearly formulated.  My real data 
 comes in 47 .csv files, one for each of 47 individual, for example:

 ,Fish_ID,Date,R2sqrt
 1,1646,2006-08-18 08:48:59,0
 2,1646,2006-08-18 09:53:20,100

 I would like to read the data for all individuals in the for loop below and 
 then combine them in a zoo object in order to plot them together.  My 
 question is : How do I need to set up the for loop to deal with several 
 individuals ? I have put question marks the bits that I am missing.

  I very much appreciate your help.

 Regards,

 Juliane


 ReleaseDates - read.csv(file=ReleaseDates,head=TRUE,sep=,)
 #reads in the individuals and their release dates

 for (i in 1:length(ReleaseDates)){
  Fish_ID - ReleaseDates$Fish_ID[i]
  ??? - 
 read.zoo(file=paste(Results,Fish_ID,sep=_),index.column=3,header=TRUE,FUN=as.chron,sep=,)
 #reads in data for each in Fish_ID
 }
  z - na.approx(cbind(???), na.rm = FALSE)
 plot(z)


Try this (untested):

library(zoo)

filenames - paste(Results, ReleaseDates$Fish_ID, sep = _)

# list of zoo objects removing 1st two columns in each file

Lz - lapply(filenames, read.zoo, header = TRUE, FUN = as.chron,
  sep = ,, colClasses = c(NULL, NULL, character, numeric))

z - do.call(merge, Lz)
colnames(z) - as.character(ReleaseDates$Fish_ID)

# plot in single panel
plot(na.approx(z), screen = 1)


-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Output Graphics GIF

2010-09-27 Thread Tal Galili
I am guessing you are saving the plot using the menu system.

If that is the case, have a look at:

?pdf
?png

Generally, I like saving my graphics to pdf since it is vectorized.

Cheers,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Mon, Sep 27, 2010 at 2:39 PM, Nilza BARROS nilzabar...@gmail.com wrote:

 Dear R users,

 How could I managed graphics in GIF  format? What I have been doing is
 graphics in *.ps or *.eps and after I convert them using CONVERT (from
 ImageMagick) but the output quality is not good.  Since these graphics will
 be use for other users they must have a better image quality.

 I really appreciate any help,

 --
 Abraço,
 Nilza Barros

[[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] plotting multiple animal tracks against Date/Time

2010-09-27 Thread Struve, Juliane
Hi,

I am sorry that my question wasn not very clearly formulated.  My real data 
comes in 47 .csv files, one for each of 47 individual, for example:

,Fish_ID,Date,R2sqrt
1,1646,2006-08-18 08:48:59,0
2,1646,2006-08-18 09:53:20,100

I would like to read the data for all individuals in the for loop below and 
then combine them in a zoo object in order to plot them together.  My question 
is : How do I need to set up the for loop to deal with several individuals ? I 
have put question marks the bits that I am missing.

 I very much appreciate your help.

Regards,

Juliane 


ReleaseDates - read.csv(file=ReleaseDates,head=TRUE,sep=,)
#reads in the individuals and their release dates  

for (i in 1:length(ReleaseDates)){
  Fish_ID - ReleaseDates$Fish_ID[i]
  ??? - 
read.zoo(file=paste(Results,Fish_ID,sep=_),index.column=3,header=TRUE,FUN=as.chron,sep=,)
#reads in data for each in Fish_ID  
}
  z - na.approx(cbind(???), na.rm = FALSE)
plot(z)




From: Gabor Grothendieck [ggrothendi...@gmail.com]
Sent: 24 September 2010 22:08
To: Struve, Juliane
Cc: r-help@r-project.org
Subject: Re: [R] plotting multiple animal tracks against Date/Time


On Fri, Sep 24, 2010 at 4:16 PM, Struve, Juliane j.str...@imperial.ac.uk 
wrote:

Hi again,

when applying the code to my real data I need to deal with a large number of 
individuals and massive data sets. I am using the code below to read in the 
data for different individuals, and would like to create the Lines within the 
loop. But Lines needs to have the variable Fish_ID somehow included in the 
name, as otherwise the string will be overwritten on each execution. How can I 
create a different Lines for each Fish_ID ? Or is there a better way of doing 
this ? Sorry, this is surely a beginner's question.

Thank you very much for your help.

Regards,

Juliane 

ReleaseDates - read.csv(file=ReleaseDates.csv,head=TRUE,sep=,)
for (i in 1:length(ReleaseDates$Fish_ID)){
Fish_ID - ReleaseDates$Fish_ID[i]
Data - read.csv(paste(Fish_ID))
Lines - paste(Data$Date,Data$Distance)
print Lines 
}





That was just an example.   The purpose of Lines was to make the example self 
contained and reproducible. In reality you dont use Lines at all.  Also your 
post suggested that they were in separate files since you had headings on each 
one.  If that is not the case then you just read it all at once using read.zoo. 
  z - read.zoo(ReleaseDates.csv, split = Fish_ID, header = TRUE, sep = ,, 
...whatever...)


There are three vignettes (pdf documents) that come with zoo.  Read them all 
and read the help page of read.zoo.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Modify the vertex label

2010-09-27 Thread anderson nuel
Dear r-help,

I create a graph of my baysian network. I use the package igraph. The names
of vertex are within the circle, I would leave them outside the circle?

 E(g)$color - black

 tkplot(g, ,vertex.label=names,layout=layout.kamada.kawai,
edge.color=E(g)$color)


Best Regards

[[alternative HTML version deleted]]

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


[R] name ONLY one column

2010-09-27 Thread Lorenzo Cattarino
Hi R-users

 

I can not change the name of one column only of my matrix.

 

my_matrix - matrix (1:12,ncol=3)

 

colnames(my_matrix)[1] - 'myname'

 

Error in dimnames(x) - dn : 

  length of 'dimnames' [2] not equal to array extent

 

thank you for your help

 

Lorenzo


[[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] make changes in existing vector with the apply function?

2010-09-27 Thread Jonas Sundberg

Hi, I'm trying to make some changes in a vector according to some conditions. 
It takes too long time however with vector length  10 and I guess a better 
way would be using the apply function. I cannot sort out how, however. 
As a for/if loop:
for (i in 1:length(PrH)) {
if (is.finite(PrH[i]) == F  tempHER  tempSPR) {PrH[i] - 1 }
if (is.finite(PrH[i]) == F  tempHER  tempSPR) {PrH[i] - 0 }}
PrH, tempSPR and tempHER are equally long vectors. 
Thanks in advance!Jonas


  
[[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] max length of a factor variable

2010-09-27 Thread Richard Mott

Hi

Is there a maximum length for the character string representing a level 
of a factor?  I have a set of several million variables, each a factor 
of length 19. Each factor level is a character string which in some 
cases can be many thousands of characters long.  I am trying to find out 
why my analysis fails - I just wanted to rule out the possibility that 
the internal factor conversion has a problem parsing long strings.


Thanks

Richard
--

Richard Mott   | Wellcome Trust Centre
tel 01865 287588   | for Human Genetics
fax 01865 287697   | Roosevelt Drive, Oxford OX3 7BN

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

2010-09-27 Thread statquant2

thank you very much for this sql package, the thing is that thoses table I
read are loaded into memory once and for all, and then we work with the
data.frames...
Do you think then that this is going to be quicker (as I would have thougth
that building the SQL DB from the flat file would already be a long
process...)?
For the RData file it is not possible as those files are shared to them into
RData, on the write side the file writte are read by other apps so the csv
format can't be changed.

Looking forward to read from you
Thanks
-- 
View this message in context: 
http://r.789695.n4.nabble.com/efficient-equivalent-to-read-csv-write-csv-tp2714325p2715275.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] Basis functions of cubic regression spline in mgcv

2010-09-27 Thread sw283

The functional form is given in chapter 4 of my book:

Wood S.N. (2006) Generalized Additive Models: An Introduction with R.  
Chapman and Hall/CRC Press. (reserve your copy now for christmas)


... but note that by default mgcv reparameterises so that the  
identifiability constraints on the smooths are satisfied automatically  
(also covered in chapter 4 of the same book).


You can get at the evaluated basis functions from the columns of the  
result of predict.gam(...,type=lpmatrix) - see help files for  
details. The penalty matrices are stored in the `smooth' list element  
of the fitted `gam' object. For example x$smooth[[1]]$S[[1]].


best,
Simon

Quoting Yan Li leemom.atlanta2...@gmail.com:


I have a question about the basis functions of cubic regression spline in
mgcv.  Are there some ways I can get the exact forms of the basis functions
and the penalty matrix that are used in mgcv?  Thanks in advance!

Yan

[[alternative HTML version deleted]]

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




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


[R] bwplot superpose panel.points from another dataframe

2010-09-27 Thread Christophe Bouffioux
Hi everybody,

using bwplot for producing panel boxplot with 3 dimensions
i want to add a mark on each boxplot representing one individual (on all its
dimensions)
till now, i didn't succeed getting the desired solution
I want as well to keep the median symbols as a line

Many thanks for your help
christophe

here is the tested code:


library(lattice)
ex - data.frame(v1 = log(abs(rt(180, 3)) + 1),
 v2 = rep(c(2007, 2006, 2005), 60),
 z  = rep(c(a, b, c, d, e, f), e = 30))
# the individual to be marked
ex2 - data.frame(v1b = log(abs(rt(18, 3)) + 1),
 v2 = rep(c(2007, 2006, 2005), 6),
 z  = rep(c(a, b, c, d, e, f), e = 3))
ex3 - merge(ex, ex2, by=c(v2,z))

bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2),
   pch = |,
   par.settings = list(
   plot.symbol = list(alpha = 1, col = transparent,cex = 1,pch = 20)),
   panel = function(x, y){
panel.bwplot(x, y)
X - tapply(ex3$v1b, ex3[,c(1,2)], max)
Y - seq(length(unique(ex3[,c(1,2)])))
panel.points(X, Y, pch = 17, col = red)
})

[[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] Good documentation about Sweave

2010-09-27 Thread statquant2

Thank you all for those great links, I will look at those.
Thanks again

Colin
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Good-documentation-about-Sweave-tp2714326p2715280.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] pairs and mfrow

2010-09-27 Thread Mike Harwood
Is there an alternative to par(mfrow=c(2,1)) to get stacked scatterplot
matrixes generated with pairs?

I am using version 2.11.1 on Windows XP.  The logic I am using follows, and
the second pairs plot replaces the first plot in the current graphics
device, which is not what I expected (or desired).

par(mfrow=c(2,1))
pairs(b2007, main=6/2000 - 12/2006)
pairs(a2007, main=1/2007 - 06/2009)

Thanks in advance!

Mike

[[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] name ONLY one column

2010-09-27 Thread Ista Zahn
Hi Lorenzo,
The problem is that my_matrix does not have dimnames. See below.

my_matrix - matrix (1:12,ncol=3)
str(my_matrix) ## does not have dimnames
dimnames(my_matrix) ## dimnames is NULL

colnames(my_matrix) - myname # fails because you are trying to
alter the value of something that does not exist
## solution: Set colnames
colnames(my_matrix) - 1:dim(my_matrix)[2]
str(my_matrix) # my_matrix now has colnames
colnames(my_matrix)[1] - myname # and now we can alter them

On Mon, Sep 27, 2010 at 8:26 AM, Lorenzo Cattarino
l.cattar...@uq.edu.au wrote:
 Hi R-users



 I can not change the name of one column only of my matrix.



 my_matrix - matrix (1:12,ncol=3)



 colnames(my_matrix)[1] - 'myname'



 Error in dimnames(x) - dn :

  length of 'dimnames' [2] not equal to array extent



 thank you for your help



 Lorenzo


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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


Re: [R] name ONLY one column

2010-09-27 Thread Pedersen Jon
Hi,
It is because the column names do not exist. If you cast the matrix as a
data frame your code would work.
jon

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Lorenzo Cattarino
Sent: 27. september 2010 10:27
To: r-help@r-project.org
Subject: [R] name ONLY one column

Hi R-users

 

I can not change the name of one column only of my matrix.

 

my_matrix - matrix (1:12,ncol=3)

 

colnames(my_matrix)[1] - 'myname'

 

Error in dimnames(x) - dn : 

  length of 'dimnames' [2] not equal to array extent

 

thank you for your help

 

Lorenzo


[[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] name ONLY one column

2010-09-27 Thread Ivan Calandra
  Hi,

I'm not sure it's even possible (and if it is I don't know how, but I'm 
no expert).

But I think it doesn't make much sense to have only one named column. 
Just give it a vector:
vect_names - c(myname1, myname2, myname3)
colnames(my_matrix) - vect_names

HTH,
Ivan


Le 9/27/2010 10:26, Lorenzo Cattarino a écrit :
 Hi R-users



 I can not change the name of one column only of my matrix.



 my_matrix- matrix (1:12,ncol=3)



 colnames(my_matrix)[1]- 'myname'



 Error in dimnames(x)- dn :

length of 'dimnames' [2] not equal to array extent



 thank you for your help



 Lorenzo


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


-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php


[[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] efficient equivalent to read.csv / write.csv

2010-09-27 Thread Gabor Grothendieck
On Mon, Sep 27, 2010 at 7:49 AM, statquant2 statqu...@gmail.com wrote:

 thank you very much for this sql package, the thing is that thoses table I
 read are loaded into memory once and for all, and then we work with the
 data.frames...
 Do you think then that this is going to be quicker (as I would have thougth
 that building the SQL DB from the flat file would already be a long
 process...)?

Even including that read.csv.sql is typically several times faster
than unoptimized read.csv for large files.   See the introductory
remarks on the sqldf home page which specifically address that.
http://sqldf.googlecode.com

In fact, just try it and see whether its ok for you.  Its just one
line of code to read in a file.

-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Modify the vertex label

2010-09-27 Thread Gábor Csárdi
Hi,

set the 'vertex.label.dist' parameter:

g - graph.ring(10)
tkplot(g, vertex.label.dist=1, layout=layout.circle)

See ?igraph.plotting for details.

Best,
Gabor

On Mon, Sep 27, 2010 at 11:18 AM, anderson nuel anderson@gmail.com wrote:
 Dear r-help,

 I create a graph of my baysian network. I use the package igraph. The names
 of vertex are within the circle, I would leave them outside the circle?

 E(g)$color - black

 tkplot(g, ,vertex.label=names,layout=layout.kamada.kawai,
 edge.color=E(g)$color)


 Best Regards

        [[alternative HTML version deleted]]

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




-- 
Gabor Csardi gabor.csa...@unil.ch     UNIL DGM

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

2010-09-27 Thread Czerminski, Ryszard
Is there an easy way to control smoothness of the contour lines?

In the plot I am working on due to the undersampling the contour
lines I am getting are jugged, but it is clear by eye these should
be basically straight lines.

In maps package I found smooth.map function, but maybe there is a more
generic way
of accomplishing the same thing.

Ideally there would be an option to control smoothness of the contour
lines
in contourplot(), or levelplot(), but I cannot find a way to do it.

Best regards,

Ryszard Czerminski
AstraZeneca Pharmaceuticals LP
35 Gatehouse Drive
Waltham, MA 02451
USA
781-839-4304
ryszard.czermin...@astrazeneca.com


--
Confidentiality Notice: This message is private and may ...{{dropped:11}}

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

2010-09-27 Thread Ralf B
Hi all,

I tried to install the rimage in order to get to the function
?read.jpeg. However, I get this error, independent what mirror I
choose:

install.packages(rimage)
--- Please select a CRAN mirror for use in this session ---
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
  package ‘rimage’ is not available


Does anybody know what happend with the package? Is there an
alternative, I simply want to draw a background picture for a plot
using the standard graphics package.

Thanks,
Ralf

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

2010-09-27 Thread Kennedy

Hi,

I want to perform a hierarchical clustering using the median as linkage
metric. As I understand it the function hcluster in package amap have this
option but it does not produce the results that I expect.

In the example below M is a matrix of similarities that is transformed into
a matrix of dissimilarities D. 
 D
 [,1] [,2] [,3] [,4] [,5]
[1,]  1.0  0.9  0.2  0.2  0.1
[2,]  0.9  1.0  0.7  1.0  0.0
[3,]  0.2  0.7  1.0  0.8  0.8
[4,]  0.2  1.0  0.8  1.0  0.5
[5,]  0.1  0.0  0.8  0.5  1.0

Since [2,5]=0 the objects 2 and 5 should be grouped together in the first
step as is done by the agnes function but hcluster start by clustering
objects 3 and 4. Why is this?

Regards

Henrik

library(cluster)
library(amap)

# Create matrix M
M - matrix(nr=5,nc=5)
M[,1] - c(0,1,8,8,9) 
M[,2] - c(1,0,3,0,10)
M[,3] - c(8,3,0,2,2)
M[,4] - c(8,0,2,0,5)
M[,5] - c(9,10,2,5,0)

# Create matrix D
n - dim(M)[1]
o - matrix(1,n,n)
mn - (1/max(M))*M
D - o-mn

# Clustering using hcluster
ce - hcluster(D,link=median)
plot(ce)

# Clustering using agnes
av - agnes(D,diss=T,method=average)
pltree(av)
-- 
View this message in context: 
http://r.789695.n4.nabble.com/hcluster-with-linkage-median-tp2715585p2715585.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] smooth contour lines

2010-09-27 Thread Duncan Murdoch

 On 27/09/2010 11:11 AM, Czerminski, Ryszard wrote:

Is there an easy way to control smoothness of the contour lines?

In the plot I am working on due to the undersampling the contour
lines I am getting are jugged, but it is clear by eye these should
be basically straight lines.


Straight lines should come out straight in our current scheme.  I 
suspect your data contains rounding error or other noise, so the actual 
contours aren't straight.


Curves are currently an issue:  the contouring scheme will generate 
polygonal contours.  If the grid you pass is too coarse, you'll see it.  
For example,


 x - 1:5
 y - 1:5
 z - outer(x, y, function(x,y) (x-2)^2 + (y-3)^2)
 contour(x,y,z)

gives ugly contours.  The solution to this problem is to use a finer grid:

 x - seq(1, 5, len=20)
 y - seq(1, 5, len=20)
 z - outer(x, y, function(x,y) (x-2)^2 + (y-3)^2)
 contour(x,y,z)

makes them look quite smooth.  So for your problem, I'd fit a nice 
smooth model to your data, then evaluate it on a fine grid, and you'll 
get nice smooth contours.


Duncan Murdoch


In maps package I found smooth.map function, but maybe there is a more
generic way
of accomplishing the same thing.

Ideally there would be an option to control smoothness of the contour
lines
in contourplot(), or levelplot(), but I cannot find a way to do it.

Best regards,

Ryszard Czerminski
AstraZeneca Pharmaceuticals LP
35 Gatehouse Drive
Waltham, MA 02451
USA
781-839-4304
ryszard.czermin...@astrazeneca.com


--
Confidentiality Notice: This message is private and may ...{{dropped:11}}

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

2010-09-27 Thread Peter Langfelder
On Mon, Sep 27, 2010 at 8:22 AM, Kennedy henrik.aldb...@gmail.com wrote:

 Hi,

 I want to perform a hierarchical clustering using the median as linkage
 metric. As I understand it the function hcluster in package amap have this
 option but it does not produce the results that I expect.

 In the example below M is a matrix of similarities that is transformed into
 a matrix of dissimilarities D.
 D
     [,1] [,2] [,3] [,4] [,5]
 [1,]  1.0  0.9  0.2  0.2  0.1
 [2,]  0.9  1.0  0.7  1.0  0.0
 [3,]  0.2  0.7  1.0  0.8  0.8
 [4,]  0.2  1.0  0.8  1.0  0.5
 [5,]  0.1  0.0  0.8  0.5  1.0

 Since [2,5]=0 the objects 2 and 5 should be grouped together in the first
 step as is done by the agnes function but hcluster start by clustering
 objects 3 and 4. Why is this?



From reading the hcluster help file I get the sense that the input is
_not_ the distance matrix, but a numeric matrix from which the
distance is computed. I think you should simply look at hclust since
that does implement the median method.

Peter

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


Re: [R] Newbie Correspondence Analysis Question

2010-09-27 Thread Gavin Simpson
On Sun, 2010-09-26 at 09:41 -0700, Vik Rubenfeld wrote:
 I'm experienced in statistics, but I am a first-time R user.  I would like to 
 use R for correspondence analysis.  I have installed R (Mac OSX). I have used 
 the package installer to install the CA package.  I have run the following 
 line with no errors to read in the data for a table:
 
   NonLuxury - read.table(/Users/myUserName/Desktop/nonLuxury.data.txt)
 
 The R online help appears to suggest that the following line should come next:
 
corresp(NonLuxury)
 
 However, I get the error message:
 
   Error: could not find function corresp

You do need to load packages before you can use functions that are
contained within those packages.

For `corresp`, try

require(MASS)
corresp(NonLuxury)

The MASS packages comes with R as a recommended package, so it should
already be installed.

HTH

G

  
 The CA manual appears to suggest that the following line should come next:
 
ca(NonLuxury)
 
 Again, I get the error message:
 
   Error: could not find function ca
 
 What am I missing? Thanks very much in advance to all for any info.
 
 
 -Vik
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] hcluster with linkage median

2010-09-27 Thread Peter Langfelder
On Mon, Sep 27, 2010 at 8:22 AM, Kennedy henrik.aldb...@gmail.com wrote:

 Hi,

 I want to perform a hierarchical clustering using the median as linkage
 metric. As I understand it the function hcluster in package amap have this
 option but it does not produce the results that I expect.

Also, if you have a large(r) data set, the package flashClust provides
a much faster (n^2 vs. n^3) replacement for hclust with exactly the
same results.

Peter

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


[R] Issue increasing DPI on a png output of a plot

2010-09-27 Thread Justin Fincher
Howdy,
  I have created a set of plots, but I wish to increase the dpi to 300
(instead of the default 72).  From the documentation, I thought that
the res parameter to png should accomplish this, but it appears to
greatly alter the appearance of my plot. (plot area becomes smaller,
plot lines become thicker, etc.)  It is my understanding that
increasing the dpi should not change the look of the plot, just the
quality.  Any help in recreating my plots in 300 dpi would be greatly
appreciated.

- Fincher

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

2010-09-27 Thread Justin Fincher
Howdy,
  I have created a set of plots, but I wish to increase the dpi to 300
(instead of the default 72).  From the documentation, I thought that
the res parameter to png should accomplish this, but it appears to
greatly alter the appearance of my plot. (plot area becomes smaller,
plot lines become thicker, etc.)  It is my understanding that
increasing the dpi should not change the look of the plot, just the
quality.  Any help in recreating my plots in 300 dpi would be greatly
appreciated.

- Fincher

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

2010-09-27 Thread Titus von der Malsburg
Dear list!

 gregexpr(a+(b+), abcdaabbc)
[[1]]
[1] 1 5
attr(,match.length)
[1] 2 4

What I want is the offsets of the matches for the group (b+), i.e. 2
and 7, not the offsets of the complete matches.  Is there a way in R
to get that?

I know about gsubgn and strapply, but they only give me the strings
matched by groups not their offsets.

I could write something myself that first takes the above matches
(ab and aabb) and then searches again using only the group (b+).
For this to work, I'd have to parse the regular expression and search
several times ( 2, for nested groups) instead of just once.  But I'm
sure there is a better way to do this.

Thanks for any suggestion!

   Titus

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

2010-09-27 Thread Dimitri Liakhovitski
Dear R-ers!

Asking for your help with building the stacked area chart for the
following simple data (several variables - with date on the X axis):

### Creating a data set
my.data-data.frame(date=c(20080301,20080402,20080503,20090301,20090402,20090503,20100301,20100402,20100503),
x=c(1.1,1.0,1.6,1,2,1.5,2.1,1.3,1.9),y=c(-4,-3,-6,-5,-7,-5.2,-6,-4,-4.9),
z=c(-0.2,-0.3,-0.4,-0.1,-0.2,-0.05,-0.2,-0.15,-0.06),a=c(4,3,5,5,6,7,5,6,4))
my.data$date-as.character(my.data$date)
my.data$date-as.Date(my.data$date,%Y%m%d)
(my.data)

I'd like the variables whose column values sum up to a negative number
to be below zero on that chart and those that add up to a positive
number to be above zero in the chart. I am calculating values for ylim
and for the order of the variable entry (bottom up) like this:

positives-which(colSums(my.data[2:ncol(my.data)])0) # which vars
have positive column sums?
negatives-which(colSums(my.data[2:ncol(my.data)])0) # which vars
have negative column sums?

y.max-1.1*max(rowSums(my.data[names(positives)])) # the max on the y
axis of the chart
y.min-1.1*min(rowSums(my.data[names(negatives)])) # the min on the y
axis of the chart
ylim - c(y.min, y.max)  # ylim for the stacked area chart

order.positives-rev(rank(positives))
order.negatives-rev(rank(negatives))
order-c(order.negatives,order.positives)
order.of.vars-names(order)   # the order of variables on the chart - bottom up
### so, the bottom-most area should be for z, and the second from the
bottom area- for y (above z) - they'll be below zero
### and above zero we'll have a first and x second (on top of a).

Thanks a lot for your advice!

-- 
Dimitri Liakhovitski
Ninah Consulting
www.ninah.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] Issue increasing DPI on a png output of a plot

2010-09-27 Thread Peter Langfelder
On Mon, Sep 27, 2010 at 8:48 AM, Justin Fincher finc...@cs.fsu.edu wrote:
 Howdy,
  I have created a set of plots, but I wish to increase the dpi to 300
 (instead of the default 72).  From the documentation, I thought that
 the res parameter to png should accomplish this, but it appears to
 greatly alter the appearance of my plot. (plot area becomes smaller,
 plot lines become thicker, etc.)  It is my understanding that
 increasing the dpi should not change the look of the plot, just the
 quality.  Any help in recreating my plots in 300 dpi would be greatly
 appreciated.

In short, instead of increasing res, increase width and height. The
difference is that if you increase res, font sizes, line thicknesses
etc scale up in pixels so as to remain constant in terms of inches
(since you are increasing the number of pixels per inch). When you
increase width and height, the font sizes etc. remain constant in
terms of pixels since resolution also remains constant.

Peter

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


Re: [R] Normalizing Vector with Negative Numbers

2010-09-27 Thread Greg Snow
You can use the scale function, just use the minimum instead of the mean and 
the range instead of the standard deviation.

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Gundala Viswanath
 Sent: Sunday, September 26, 2010 6:23 PM
 To: r-h...@stat.math.ethz.ch
 Subject: [R] Normalizing Vector with Negative Numbers
 
 Dear expert,
 
 I have a series of number that looks like this
 
 x - c(-0.005282,
 0.000314,
 0.002851,
 -2.5059217162,
 -0.007545,
 -1.0317758496,
 0.001598,
 -1.2981735068,
 0.072411)
 
 How can I normalize it in R so that the new numbers
 is ranging from 0 to 1 ?
 
 
 - G.V.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] make changes in existing vector with the apply function?

2010-09-27 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Jonas Sundberg
 Sent: Monday, September 27, 2010 1:43 AM
 To: r-help@r-project.org
 Subject: [R] make changes in existing vector with the apply function?
 
 
 Hi, I'm trying to make some changes in a vector according to 
 some conditions. It takes too long time however with vector 
 length  10 and I guess a better way would be using the 
 apply function. I cannot sort out how, however. 
 As a for/if loop:
 for (i in 1:length(PrH)) {
 if (is.finite(PrH[i]) == F  tempHER  tempSPR) {PrH[i] - 1 }
 if (is.finite(PrH[i]) == F  tempHER  tempSPR) {PrH[i] - 0 }}
 PrH, tempSPR and tempHER are equally long vectors. 

Did that code ever work?  I would have thought that
your tempHER and tempSPR would require a [i] after them.
(Otherwise you would get warnings and incorrect results.)

If so, a first step is to replace your for loop with
PrH[!is.finite(PrH)  tempHERtempSPR] - 1
PrH[!is.finite(PrH)  tempHERtempSPR] - 0
Read the '[' as 'such that' when using logical-valued
subscripts.

If time or memory is at a premium you may get slightly
better mileage from more complicated code.  E.g.,
in the following we compute is.inite(PrH) only once
and use the fact that as.integer maps TRUE and FALSE
to 1 and 0, respectively:
PrHIsInfinite - !is.finite(PrH)
PrH[PrHIsInfinite] - 
as.integer(tempHER[PrHIsInfinite]tempSPR[PrHIsInfinite])
I haven't tested any of this.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 Thanks in advance!Jonas
 
 
   
   [[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] bwplot superpose panel.points from another dataframe

2010-09-27 Thread Peter Ehlers

On 2010-09-27 4:54, Christophe Bouffioux wrote:

bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2),
pch = |,
par.settings = list(
plot.symbol = list(alpha = 1, col = transparent,cex = 1,pch = 20)),
panel = function(x, y){
 panel.bwplot(x, y)
 X- tapply(ex3$v1b, ex3[,c(1,2)], max)
 Y- seq(length(unique(ex3[,c(1,2)])))
 panel.points(X, Y, pch = 17, col = red)
 })



Perhaps this is what you're trying to achieve:

 bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2),
   panel = function(x, y){
panel.bwplot(x, y, pch=|)
X - tapply(ex3$v1b, ex3[, 1:2], max)
Y - seq(nrow(unique(ex3[, 1:2])))
panel.points(X, Y, pch = 17, col = red)
})

(I didn't see any need for your par.settings.)

I'm not crazy about the way you define X,Y. I think
I would augment the data frame appropriately instead.

  -Peter Ehlers

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

2010-09-27 Thread Greg Snow
The rimage package appears to have been abandoned.  One option is the EBImage 
package from Bioconductor.

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Ralf B
 Sent: Monday, September 27, 2010 9:12 AM
 To: r-help Mailing List
 Subject: [R] rimage package problems
 
 Hi all,
 
 I tried to install the rimage in order to get to the function
 ?read.jpeg. However, I get this error, independent what mirror I
 choose:
 
 install.packages(rimage)
 --- Please select a CRAN mirror for use in this session ---
 Warning message:
 In getDependencies(pkgs, dependencies, available, lib) :
   package 'rimage' is not available
 
 
 Does anybody know what happend with the package? Is there an
 alternative, I simply want to draw a background picture for a plot
 using the standard graphics package.
 
 Thanks,
 Ralf
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] pairs and mfrow

2010-09-27 Thread Greg Snow
Why do you want 2 pairs plots on the same device?  There may be a better 
approach to what you want to do.

You could use splom from the lattice package along with the print.trellis 
function to put 2 on the same page.

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Mike Harwood
 Sent: Monday, September 27, 2010 6:51 AM
 To: r-help@r-project.org
 Subject: [R] pairs and mfrow
 
 Is there an alternative to par(mfrow=c(2,1)) to get stacked scatterplot
 matrixes generated with pairs?
 
 I am using version 2.11.1 on Windows XP.  The logic I am using follows,
 and
 the second pairs plot replaces the first plot in the current graphics
 device, which is not what I expected (or desired).
 
 par(mfrow=c(2,1))
 pairs(b2007, main=6/2000 - 12/2006)
 pairs(a2007, main=1/2007 - 06/2009)
 
 Thanks in advance!
 
 Mike
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] calculating mean and s.d. from a two-column table

2010-09-27 Thread Jonas Josefsson
I have a two-column table as follows where age is in the 1st column and 
the number of individuals is in the 2nd.


age;no
1;21
2;31
3;9
4;12
5;6


Can I use mean() and sd() to calculate the mean and standard deviation 
from this or do I have to manually multiplicate 21*1+31*2 etc. / N?


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


Re: [R] calculating mean and s.d. from a two-column table

2010-09-27 Thread Peter Langfelder
On Mon, Sep 27, 2010 at 9:34 AM, Jonas Josefsson
jo...@runtimerecords.net wrote:
 I have a two-column table as follows where age is in the 1st column and the
 number of individuals is in the 2nd.

 age;no
 1;21
 2;31
 3;9
 4;12
 5;6

You can use the following trick:

x = rep(age, no)

This repeats age[1] no[1]-times, age[2] no[2]-times, etc...

then use the usual mean and sd on x.

Peter

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


Re: [R] Regular expressions: offsets of groups

2010-09-27 Thread jim holtman
try this:

 x -  gregexpr(a+(b+), abcdaabbcaaacaaab)
 justA -  gregexpr(a+, abcdaabbcaaacaaab)
 # find matches in 'x' for 'justA'
 indx - which(justA[[1]] %in% x[[1]])
 # now determine where 'b' starts
 justA[[1]][indx] + attr(justA[[1]], 'match.length')[indx]
[1]  2  7 17



On Mon, Sep 27, 2010 at 11:48 AM, Titus von der Malsburg
malsb...@gmail.com wrote:
 Dear list!

 gregexpr(a+(b+), abcdaabbc)
 [[1]]
 [1] 1 5
 attr(,match.length)
 [1] 2 4

 What I want is the offsets of the matches for the group (b+), i.e. 2
 and 7, not the offsets of the complete matches.  Is there a way in R
 to get that?

 I know about gsubgn and strapply, but they only give me the strings
 matched by groups not their offsets.

 I could write something myself that first takes the above matches
 (ab and aabb) and then searches again using only the group (b+).
 For this to work, I'd have to parse the regular expression and search
 several times ( 2, for nested groups) instead of just once.  But I'm
 sure there is a better way to do this.

 Thanks for any suggestion!

   Titus

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

2010-09-27 Thread Titus von der Malsburg
Thank you Jim, but just as the solution that I discussed, your
proposal involves deconstructing the pattern and searching several
times.  I'm looking for a general and efficient solution.  Internally,
the regexpr engine has all necessary information after one pass
through the string.  What I need is an interface that exposes this
information.

  Titus

On Mon, Sep 27, 2010 at 6:43 PM, jim holtman jholt...@gmail.com wrote:
 try this:

 x -  gregexpr(a+(b+), abcdaabbcaaacaaab)
 justA -  gregexpr(a+, abcdaabbcaaacaaab)
 # find matches in 'x' for 'justA'
 indx - which(justA[[1]] %in% x[[1]])
 # now determine where 'b' starts
 justA[[1]][indx] + attr(justA[[1]], 'match.length')[indx]
 [1]  2  7 17



 On Mon, Sep 27, 2010 at 11:48 AM, Titus von der Malsburg
 malsb...@gmail.com wrote:
 Dear list!

 gregexpr(a+(b+), abcdaabbc)
 [[1]]
 [1] 1 5
 attr(,match.length)
 [1] 2 4

 What I want is the offsets of the matches for the group (b+), i.e. 2
 and 7, not the offsets of the complete matches.  Is there a way in R
 to get that?

 I know about gsubgn and strapply, but they only give me the strings
 matched by groups not their offsets.

 I could write something myself that first takes the above matches
 (ab and aabb) and then searches again using only the group (b+).
 For this to work, I'd have to parse the regular expression and search
 several times ( 2, for nested groups) instead of just once.  But I'm
 sure there is a better way to do this.

 Thanks for any suggestion!

   Titus

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

2010-09-27 Thread Titus von der Malsburg
On Mon, Sep 27, 2010 at 7:16 PM, Henrique Dallazuanna www...@gmail.com wrote:
 You've tried:

 gregexpr(b+, abcdaabbc)

But this would match the third occurrence of b+ in abcdaabbcbb.  But
in this example I'm only interested in b+ if it's preceded by a+.

  Titus

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

2010-09-27 Thread Gabor Grothendieck
On Mon, Sep 27, 2010 at 11:48 AM, Titus von der Malsburg
malsb...@gmail.com wrote:
 Dear list!

 gregexpr(a+(b+), abcdaabbc)
 [[1]]
 [1] 1 5
 attr(,match.length)
 [1] 2 4

 What I want is the offsets of the matches for the group (b+), i.e. 2
 and 7, not the offsets of the complete matches.  Is there a way in R
 to get that?

 I know about gsubgn and strapply, but they only give me the strings
 matched by groups not their offsets.

 I could write something myself that first takes the above matches
 (ab and aabb) and then searches again using only the group (b+).
 For this to work, I'd have to parse the regular expression and search
 several times ( 2, for nested groups) instead of just once.  But I'm
 sure there is a better way to do this.


Try this zero width negative look behind expression:

 gregexpr((?!a+)(b+), abcdaabbc, perl = TRUE)
[[1]]
[1] 2 7
attr(,match.length)
[1] 1 2

See ?regexp for more info.

-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Regular expressions: offsets of groups

2010-09-27 Thread Titus von der Malsburg
On Mon, Sep 27, 2010 at 7:29 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Try this zero width negative look behind expression:

 gregexpr((?!a+)(b+), abcdaabbc, perl = TRUE)
 [[1]]
 [1] 2 7
 attr(,match.length)
 [1] 1 2

Thanks Gabor, but this gives me the same result as

  gregexpr(b+, abcdaabbc, perl = TRUE)

which is wrong if the string is abcdaabbcbbb.

  Titus

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

2010-09-27 Thread Henrique Dallazuanna
You could do this:

gregexpr(ab+, abcdaabbcbb)[[1]] + 1

On Mon, Sep 27, 2010 at 2:25 PM, Titus von der Malsburg
malsb...@gmail.comwrote:

 On Mon, Sep 27, 2010 at 7:16 PM, Henrique Dallazuanna www...@gmail.com
 wrote:
  You've tried:
 
  gregexpr(b+, abcdaabbc)

 But this would match the third occurrence of b+ in abcdaabbcbb.  But
 in this example I'm only interested in b+ if it's preceded by a+.

  Titus




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[alternative HTML version deleted]]

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


[R] [R-pkgs] Bayesian Fractional Polynomials package bfp on CRAN

2010-09-27 Thread Daniel Sabanés Bové
 Fractional polynomials (FPs) are an automatic way of fitting 
non-linear, parametric effects. The R-package mfp implements a 
frequentist inference approach for FP models. Recently, we have proposed 
a Bayesian inference approach for normal FP models, which is based on 
the quasi-default hyper-/g/ prior for the regression coefficients [1]. 
This approach is implemented in the new R-package bfp.


The R-package bfp (current version: 0.0-17) is now available on CRAN [2].
The current development version is (still) available on R-Forge [3].

For a quick start try:

install.packages(bfp)
library(bfp)
example(BmaSamples)

and if you have more time, to reproduce results from the paper [1]:

demo(ozone)

Questions, suggestions or critique are very welcome!

Best regards,
Daniel

[1] Statistics  Computing paper: 
http://dx.doi.org/10.1007/s11222-010-9170-7

[2] CRAN: http://cran.r-project.org/web/packages/bfp/index.html
[3] R-Forge: http://r-forge.r-project.org/projects/bfp/

___
R-packages mailing list
r-packa...@r-project.org
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] [R-pkgs] Deducer 0.4-1 and JGR 1.7-2 released

2010-09-27 Thread Ian Fellows
Hi All,

I would like to announce the release of Deducer 0.4-1 and JGR 1.7-2 to CRAN. 
The updates should be propagating through the mirrors over the next few days. 
On the Deducer side we have a number of nice improvements:

1. A new Text Field Widget for plug-ins is included, which is better suited for 
entering/displaying numeric and short string fields than TextAreaWidget.
2. A new Object Chooser Widget is included, which allows the user to select an 
object from their workspace, possibly of a specific class.
3. Fixed combobox bug on Mac OS 64-bit.
4. Factor editor and Recode dialog handle empty strings.
5. Created menu items for common plotting templates.

The new JGR includes stability fixes along with a few new features.

Bug fixes:
1. Fixed MacOS JavaGD resize deadlock bug
2. Fixed 100% CPU on start-up bug reported on some UNIX systems.
3. Interrupt R button fixed on unix systems 

New Features:
1. Graphics device save support for png, jpeg, bmp, and tiff
2. User control over the menu system has been improved. Added ability to insert 
new menus, menu items, separators, and sub-menus. Menus and menu items can also 
be removed.


Ian Fellows

___
R-packages mailing list
r-packa...@r-project.org
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.


Re: [R] finding big matrix size and SVD

2010-09-27 Thread Natasha Asar
I have 500,00 rows in my matrix and i was wondering whether there is any way to 
get its SVD without breaking it to parts

because if R can only read about 1000 columns then to have a rectangular matrix 
(diagonal i think they are called) I will need to have only 1000 rows

I want to know how i can do this? 

natasha




From: Steve Lianoglou mailinglist.honey...@gmail.com

Cc: R group r-help@r-project.org
Sent: Mon, 27 September, 2010 3:23:58
Subject: Re: [R] finding big matrix size and SVD

Hi,


rote:
 Dear R helpers

 I have a big data sheet (CSV) which I use “read.csv” to read it

 When im trying to get the Dim() it says 38 column which is not correct it
should
 be something about 400.
 I am wondering whether there is any way I can read it right… I have used 
ncol()
 and it’s the same answer

It seems that perhaps the input file isn't well formed, and R can't
correctly identify that each row should have 400 columns?

Maybe you can try to read it in manually (using readLines, for
instance), and strsplit each line so that you can get finer control of
reading the file. Alternatively, you can try and edit the file by hand
to fix it.

 On the other hand I use to get the SVD of it but I have about 500,000 rows so
 considering that it should be rectangular matrix…
 im wondering how this can be possible

I don't follow this part, sorry ... what's the question here?

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



  
[[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] Regular expressions: offsets of groups

2010-09-27 Thread Henrique Dallazuanna
You've tried:

gregexpr(b+, abcdaabbc)


On Mon, Sep 27, 2010 at 12:48 PM, Titus von der Malsburg malsb...@gmail.com
 wrote:

 Dear list!

  gregexpr(a+(b+), abcdaabbc)
 [[1]]
 [1] 1 5
 attr(,match.length)
 [1] 2 4

 What I want is the offsets of the matches for the group (b+), i.e. 2
 and 7, not the offsets of the complete matches.  Is there a way in R
 to get that?

 I know about gsubgn and strapply, but they only give me the strings
 matched by groups not their offsets.

 I could write something myself that first takes the above matches
 (ab and aabb) and then searches again using only the group (b+).
 For this to work, I'd have to parse the regular expression and search
 several times ( 2, for nested groups) instead of just once.  But I'm
 sure there is a better way to do this.

 Thanks for any suggestion!

   Titus

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[alternative HTML version deleted]]

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


Re: [R] Split-split plot design with aov function in R

2010-09-27 Thread Muhammad Yaseen
*Hello,

I'm new to R and trying to do Split Split Plot Design analysis with aov
function in R. Sharing any worked example and suggestion will be highly
appreciated. Thanks

Regards!
*
-- 
*

Muhammad Yaseen
*

[[alternative HTML version deleted]]

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


Re: [R] Split-split plot design with aov function in R

2010-09-27 Thread Sunny Srivastava
http://www.amazon.com/Statistical-Design-George-Casella/dp/1441926143/ref=sr_1_1?s=gatewayie=UTF8qid=1285609902sr=8-1

Hello Mohd. Yaseen,
Please check out the book by Dr. Casella and his website
www.stat.ufl.edu/~casella for the relevant R codes. Chapter 5 of this book
talks about Split Split Plot designs.

Thanks and Best Regards,
S.

P.S. : Please refrain from reposting your questions. Senior members of this
list are not too happy when you post the same question twice. It is just a
friendly advice.
http://www.amazon.com/Statistical-Design-George-Casella/dp/1441926143/ref=sr_1_1?s=gatewayie=UTF8qid=1285609902sr=8-1

On Mon, Sep 27, 2010 at 12:42 PM, Muhammad Yaseen myaseen...@gmail.comwrote:

 *Hello,

 I'm new to R and trying to do Split Split Plot Design analysis with aov
 function in R. Sharing any worked example and suggestion will be highly
 appreciated. Thanks

 Regards!
 *
 --
 *

 Muhammad Yaseen
 *

[[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] compare two matrices

2010-09-27 Thread xinxin xx

Hi everyone:

 

  I have a kinda easy question but i do not know how to solve that in a simple 
way.

  I want to compare the rows of two matrices. 

  

  col1 - c(1,2,3,4,5,6)

  col2 - c(6,5,4,3,2,1)

  m -  cbind(col1, col2)

  

  col3 - c(1,3,2,6)

  col4 - c(6,3,5,1)

  n - cbind(col3, col4)

 

  In matrix n,  for example the first row is (1,6), it is also some row in 
matrix m, i want the code results TRUE.  then for the 2nd row (3,3), it 
should be FALSE. 

  So in this case it should be (TRUE, FALSE, TRUE, TRUE)

 

  I tried %in% or is.element for a row in n and matrix m, but it does not work. 

  I think I can also write two loops to compare the rows of m and n one by one, 
but it takes a long time to run.

  Could anyone tell me how to solve this?

 

 

Thank you very much!!

 
  
[[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] stacked area chart

2010-09-27 Thread Dimitri Liakhovitski
I found a solution to my original question (see code below).
But I have a question about cosmetics, which I always find very challenging.
1. How can I make all dates appear on the X axis (rotated at 90
degrees vs. horizontal)?
2. How can I create vertical grid lines so that at each date there is
a gridline?
3. How can I create a legend for colors, but not on top of the graph
but on the right side, outside of the graph (because in my real data
set I have a lot of variables - so that there'll never be enough space
for the legend in the graph itself)

Thanks a lot!
Dimitri


### Creating a data set with both positives and negatives
my.data-data.frame(date=c(20080301,20080402,20080503,20090301,20090402,20090503,20100301,20100402,20100503),
x=c(1.1,1.0,1.6,1,2,1.5,2.1,1.3,1.9),y=c(-4,-3,-6,-5,-7,-5.2,-6,-4,-4.9),
z=c(-0.2,-0.3,-0.4,-0.1,-0.2,-0.05,-0.2,-0.15,-0.06),a=c(10,13,15,15,16,17,15,16,14))
my.data$date-as.character(my.data$date)
my.data$date-as.Date(my.data$date,%Y%m%d)
(my.data)

positives-which(colSums(my.data[2:ncol(my.data)])0) # which vars
have positive column sums?
negatives-which(colSums(my.data[2:ncol(my.data)])0) # which vars
have negative column sums?

y.max-1.1*max(rowSums(my.data[names(positives)])) # the max on the y
axis of the chart
y.min-1.1*min(rowSums(my.data[names(negatives)])) # the min on the y
axis of the chart
ylim - c(y.min, y.max)
order.positives-rev(rank(positives))
order.of.pos.vars-names(order.positives)
order.negatives-rev(rank(negatives))
order.of.neg.vars-names(order.negatives)
order-c(order.negatives,order.positives)
order.of.vars-names(order)   # the order of variables on the chart -
from the bottom up
### so, the bottom-most area should be for z, the second from the
bottom area- for y (above z)

all.colors-c('red','blue','green','orange','yellow','purple')
xx - c(my.data$date, rev(my.data$date))
bottom.y.coordinates-rowSums(my.data[names(negatives)])

plot(x=my.data$date, y=bottom.y.coordinates, ylim=ylim, col='white',
type='l', xaxt='n',
ylab='Title for Y', xlab='Date', main='Chart Title')

for(var in order.of.neg.vars){
top.line.coords-bottom.y.coordinates-my.data[[var]]
bottom.coords-c(bottom.y.coordinates,rev(top.line.coords))
polygon(xx,bottom.coords,col=all.colors[which(names(my.data) %in% var)])
bottom.y.coordinates-top.line.coords
}

for(var in order.of.pos.vars){
top.line.coords-bottom.y.coordinates+my.data[[var]]
bottom.coords-c(bottom.y.coordinates,rev(top.line.coords))
polygon(xx,bottom.coords,col=all.colors[which(names(my.data) %in% var)])
bottom.y.coordinates-top.line.coords
}



On Mon, Sep 27, 2010 at 11:47 AM, Dimitri Liakhovitski
dimitri.liakhovit...@gmail.com wrote:
 Dear R-ers!

 Asking for your help with building the stacked area chart for the
 following simple data (several variables - with date on the X axis):

 ### Creating a data set
 my.data-data.frame(date=c(20080301,20080402,20080503,20090301,20090402,20090503,20100301,20100402,20100503),
 x=c(1.1,1.0,1.6,1,2,1.5,2.1,1.3,1.9),y=c(-4,-3,-6,-5,-7,-5.2,-6,-4,-4.9),
 z=c(-0.2,-0.3,-0.4,-0.1,-0.2,-0.05,-0.2,-0.15,-0.06),a=c(4,3,5,5,6,7,5,6,4))
 my.data$date-as.character(my.data$date)
 my.data$date-as.Date(my.data$date,%Y%m%d)
 (my.data)

 I'd like the variables whose column values sum up to a negative number
 to be below zero on that chart and those that add up to a positive
 number to be above zero in the chart. I am calculating values for ylim
 and for the order of the variable entry (bottom up) like this:

 positives-which(colSums(my.data[2:ncol(my.data)])0) # which vars
 have positive column sums?
 negatives-which(colSums(my.data[2:ncol(my.data)])0) # which vars
 have negative column sums?

 y.max-1.1*max(rowSums(my.data[names(positives)])) # the max on the y
 axis of the chart
 y.min-1.1*min(rowSums(my.data[names(negatives)])) # the min on the y
 axis of the chart
 ylim - c(y.min, y.max)  # ylim for the stacked area chart

 order.positives-rev(rank(positives))
 order.negatives-rev(rank(negatives))
 order-c(order.negatives,order.positives)
 order.of.vars-names(order)   # the order of variables on the chart - bottom 
 up
 ### so, the bottom-most area should be for z, and the second from the
 bottom area- for y (above z) - they'll be below zero
 ### and above zero we'll have a first and x second (on top of a).

 Thanks a lot for your advice!

 --
 Dimitri Liakhovitski
 Ninah Consulting
 www.ninah.com




-- 
Dimitri Liakhovitski
Ninah Consulting
www.ninah.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] compare two matrices

2010-09-27 Thread Dimitris Rizopoulos

one way is the following:

col1 - c(1,2,3,4,5,6)
col2 - c(6,5,4,3,2,1)
m - cbind(col1, col2)
col3 - c(1,3,2,6)
col4 - c(6,3,5,1)
n - cbind(col3, col4)

ind.n - do.call(paste, c(as.data.frame(n), sep = \r))
ind.m - do.call(paste, c(as.data.frame(m), sep = \r))
ind.n %in% ind.m


I hope it helps.

Best,
Dimitris


On 9/27/2010 8:00 PM, xinxin xx wrote:


Hi everyone:



   I have a kinda easy question but i do not know how to solve that in a simple 
way.

   I want to compare the rows of two matrices.



   col1- c(1,2,3,4,5,6)

   col2- c(6,5,4,3,2,1)

   m-  cbind(col1, col2)



   col3- c(1,3,2,6)

   col4- c(6,3,5,1)

   n- cbind(col3, col4)



   In matrix n,  for example the first row is (1,6), it is also some row in matrix m, i 
want the code results TRUE.  then for the 2nd row (3,3), it should be FALSE.

   So in this case it should be (TRUE, FALSE, TRUE, TRUE)



   I tried %in% or is.element for a row in n and matrix m, but it does not work.

   I think I can also write two loops to compare the rows of m and n one by 
one, but it takes a long time to run.

   Could anyone tell me how to solve this?





Thank you very much!!



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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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

2010-09-27 Thread Gabor Grothendieck
On Mon, Sep 27, 2010 at 1:34 PM, Titus von der Malsburg
malsb...@gmail.com wrote:
 On Mon, Sep 27, 2010 at 7:29 PM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:
 Try this zero width negative look behind expression:

 gregexpr((?!a+)(b+), abcdaabbc, perl = TRUE)
 [[1]]
 [1] 2 7
 attr(,match.length)
 [1] 1 2

 Thanks Gabor, but this gives me the same result as

  gregexpr(b+, abcdaabbc, perl = TRUE)

 which is wrong if the string is abcdaabbcbbb.


Sorry, try this:

  gregexpr((?=a)b+, abcdaabbcbbb, perl = TRUE)
[[1]]
[1] 2 7
attr(,match.length)
[1] 1 2

Note that it does not give the same answer as:

  gregexpr(b+, abcdaabbcbbb, perl = TRUE)
[[1]]
[1]  2  7 10
attr(,match.length)
[1] 1 2 3


 gregexpr((?=a)b+, abcdaabbcbbb, perl = TRUE)




-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Problem with unlist

2010-09-27 Thread Henrik Bengtsson
On Mon, Sep 27, 2010 at 5:27 AM, Ben Bolker bbol...@gmail.com wrote:
 Luis Felipe Parra felipe.parra at quantil.com.co writes:


  Hello, I am trying to unlist a list, which is attached, and I am having the
 problem that when I unlist it the number of elements changes from 5065 to
 5084

   x - lapply(SumaPluvi, FUN=[, 1);
  n - sapply(x, FUN=length);
  print(table(n));
 n
    1
 5065
  print(which(n != 1));
 integer(0)
  length(unlist(lapply(SumaPluvi, FUN=[, 1)))
 [1] 5081
 

 I dont now why, but when I unlist it the number of elements changes from
 5065 to 5084 even if there is no list element with length greater than one.
 Do you know what can be happening?


  We probably won't be able to get farther without a reproducible
 example.  One brute-force way of finding the problem is by bisection:
 i.e., try the first and last halves of your list separately, and see
 if either one individually shows a similar problem.  Proceed recursively
 until you localize the problem ...

...and as alternative, my most recent post did contain an updated code
snippet that is likely to find list elements generating more than one
value.

/Henrik


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Ordered logit with polr won't match SPSS output

2010-09-27 Thread Ben Hunter
I am learning R via a textbook that performs analysis with SPSS and SAS. In
trying to reproduce the results for an ordinal logit model, I get very
similar point estimates for my cut-off points, but the parameters for the
covariate q60 do not match. The estimate for q51 also matches. Is this
because I need to change a base case for the ordered covariate q60? Can this
be done in or is it always the first case?

mod-polr(as.ordered(q43j)~as.ordered(q60)+q51, method=logistic)

Perhaps a book using R would be a better idea, but it's the content and
price (free) of this book that I like.

Thanks a lot,

Ben

[[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] margin control in lattice package

2010-09-27 Thread Jonathan Flowers
Hi Peter,

Thank you for your thoughtful reply.  I am tweaking the setting print
settings you suggested.  It looks like this is going to solve my problem.
Thanks very much for help.

Jonathan

On Sat, Sep 25, 2010 at 6:00 PM, Peter Ehlers ehl...@ucalgary.ca wrote:

 On 2010-09-25 8:59, Jonathan Flowers wrote:

 Hi all,

 I am difficulty with simple layout of plots in the lattice package

 I have created a series of levelplots and would like to plot them to a
 single device, but need to reduce the margin areas.  This is easily
 accomplished with par(oma) and par(mar) in the base graphics package but I
 am having problems finding the equivalent features in the lattice package.
 Ideally, I would like to reduce the amount of white space among plots in
 the
 following example. Thanks in advance.

 library(lattice)
 p1- levelplot( matrix(c(1:25),nr=5,nc=5),row.
 values=1:5,column.values=1:5)
 p2- levelplot(matrix
 (rnorm(25),nr=5,nc=5),row.values=1:5,column.values=1:5)
 p3- levelplot(
 matrix(c(1:25),nr=5,nc=5),row.values=1:5,column.values=1:5)
 p4- levelplot(matrix
 (rnorm(25),nr=5,nc=5),row.values=1:5,column.values=1:5)

 print(p1,split=c(1,1,2,2),more=T)
 print(p2,split=c(2,1,2,2),more=T)
 print(p3,split=c(1,2,2,2),more=T)
 print(p4,split=c(2,2,2,2))

 Thanks in advance,

 Jonathan


 Here are a couple of things you can play with.

 First, the default for the matrix method of levelplot() is to
 produce square plots using the argument aspect=iso. So
 unless you set aspect=some other value or fill, you can
 only reduce the outer white space at the expense of
 increasing the inner white space. To reduce the outer white
 space but keep the aspect=iso, you can set the size of
 the graphics device and then fiddle with the top.padding
 and/or bottom.padding components of the layout.heights
 parameter. Something like this:

 ## some simple data
  m - matrix(1:25, nr=5)

 ## create 4 (identical for illustration only) plots
  p1 - p2 - p3 - p4 - levelplot(m, aspect=iso,
   par.settings=list(layout.heights=list(top.padding=-2)))

 ## open a trellis device (I'm on Windows)
  trellis.device(windows, height=6, width=7)

 ## print the plots
  print(p1, split=c(1,1,2,2), more=TRUE)
  print(p2, split=c(2,1,2,2), more=TRUE)
  print(p3, split=c(1,2,2,2), more=TRUE)

  print(p4, split=c(2,2,2,2))


 ## alternatively, use aspect=fill and adjust size in the
 ## print() calls
  p1 - p2 - p3 - p4 - levelplot(m, aspect=fill)

  trellis.device(windows, height=6, width=7)

  print(p1, split=c(1,1,2,2),
panel.height=list(x=2, units=in), more=TRUE)

  print(p2, split=c(2,1,2,2),
panel.height=list(x=2, units=in), more=TRUE)

  print(p3, split=c(1,2,2,2),
panel.height=list(x=2, units=in), more=TRUE)
  print(p4, split=c(2,2,2,2),
panel.height=list(x=2, units=in))


 Probably the best way, if your levels are roughly the same
 for all plots, is to convert your data to a data frame,
 define a 4-level factor, and create a standard 4-panel plot
 instead of using the 'split' argument.

  -Peter Ehlers


[[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] scientific vs. fixed notation in xyplot()

2010-09-27 Thread array chip
Hi I am using xyplot() to plot on the log scale by using scale=list(log=T) 
argument. For example:

xyplot(1:10~1:10, scales=list(log=T))

But the axis labels are printed as scientific notation (10^0.0, etc), instead 
of 
fixed notation. How can I change that to fixed notation?

options(scipen=4) doesn't work on xyplot()

Thanks

John

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


[R] Sample size estimation for non-inferiority log-rank and Wilcoxon rank-sum tests

2010-09-27 Thread Paul Miller
Hello Everyone,
 
I'm trying to conduct a couple of power analyses and was hoping someone might 
be able to help. I want to estimate the sample size that would be necessary to 
adequately power a couple of non-inferiority tests. The first would be a 
log-rank test and the second would be a Wilcoxon rank-sum test. I want to be 
able to determine the sample size that would be necessary to test for a 3 day 
difference in median recovery time between 2 groups of cancer patients. 
 
Both of these tests are infeasible using SAS Proc Power and I haven't been able 
to find information about how to do them using either SAS or R.
 
Does anyone know how to perform either of these calculations? If so, I'd 
greatly appreciate it if you could share a couple of examples.
 
 
Thanks,
 
Paul


[[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] scientific vs. fixed notation in xyplot()

2010-09-27 Thread Henrique Dallazuanna
Try this:

 xyplot(1:10~1:10, scales=list(log = T, labels = round(log(1:10), 4)))


On Mon, Sep 27, 2010 at 4:10 PM, array chip arrayprof...@yahoo.com wrote:

 Hi I am using xyplot() to plot on the log scale by using scale=list(log=T)
 argument. For example:

 xyplot(1:10~1:10, scales=list(log=T))

 But the axis labels are printed as scientific notation (10^0.0, etc),
 instead of
 fixed notation. How can I change that to fixed notation?

 options(scipen=4) doesn't work on xyplot()

 Thanks

 John

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[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] Percentages and lattice

2010-09-27 Thread Mark Noworolski
What I'm trying to do is to figure out how to create lattice charts of
%right by region, or alternatively, by date from a dataset of observations
that looks something like this:

date,location,region,correct
2010-09-10,a,r1,yes
2010-09-10,a,r1,yes
2010-09-10,a,r1,no
2010-09-11,a,r1,yes
2010-09-01,b,r1,yes
2010-09-02,b,r1,no
2010-09-01,a,r2,yes
2010-09-02,a,r2,no
2010-09-02,a,r2,yes
2010-09-02,a,r2,no
2010-09-03,a,r2,yes
etc.

I get that I can do something like:
tmp-xtabs(~correct+region+date,t)

This gets me partway by providing counts. The thing that I'm missing here is
how get from this to being able to plot, for example, a family of
lattice-style curves that looks something like:

%right (by region) on the y axis, with the x axis being the date

I've tried something
like barchart(xtabs(~correct+region+date,t),stack=F,auto.key=T) which gets
me close with the counts of observations, but I really am after the
proportions evaluated by region, not the counts.

I don't see how to marginalize prop.table properly to give me my answer
either (if, in region 1, on a given day, all are correct - then that number
should be 100% on the chart/graph, independent of what happened in region
2)- but I'm quite sure that I'm missing something obvious here.

Any suggestions would be appreciated.
Thanks,
mark

[[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] Percentages and lattice

2010-09-27 Thread Phil Spector

Mark -
   Here's one way to get the percentages you want.  Suppose your
data frame is called df:

correct  = subset(as.data.frame(with(df,table(date,region,correct))),
  correct=='yes')
all = as.data.frame(with(df,table(date,region)))
names(all)[3] = 'Total'
both = merge(correct,all)
both$Pct = both$Freq / both$Total * 100

- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu



On Mon, 27 Sep 2010, Mark Noworolski wrote:


What I'm trying to do is to figure out how to create lattice charts of
%right by region, or alternatively, by date from a dataset of observations
that looks something like this:

date,location,region,correct
2010-09-10,a,r1,yes
2010-09-10,a,r1,yes
2010-09-10,a,r1,no
2010-09-11,a,r1,yes
2010-09-01,b,r1,yes
2010-09-02,b,r1,no
2010-09-01,a,r2,yes
2010-09-02,a,r2,no
2010-09-02,a,r2,yes
2010-09-02,a,r2,no
2010-09-03,a,r2,yes
etc.

I get that I can do something like:
tmp-xtabs(~correct+region+date,t)

This gets me partway by providing counts. The thing that I'm missing here is
how get from this to being able to plot, for example, a family of
lattice-style curves that looks something like:

%right (by region) on the y axis, with the x axis being the date

I've tried something
like barchart(xtabs(~correct+region+date,t),stack=F,auto.key=T) which gets
me close with the counts of observations, but I really am after the
proportions evaluated by region, not the counts.

I don't see how to marginalize prop.table properly to give me my answer
either (if, in region 1, on a given day, all are correct - then that number
should be 100% on the chart/graph, independent of what happened in region
2)- but I'm quite sure that I'm missing something obvious here.

Any suggestions would be appreciated.
Thanks,
mark

[[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] scientific vs. fixed notation in xyplot()

2010-09-27 Thread array chip
Thanks for the suggestion. But my example is just an example, I would prefer to 
have some generalized solution, like what options(scipen=4) does in general 
graphics, which usually gave pretty axis labels as well.

Any suggestions?

Thanks

John



From: Henrique Dallazuanna www...@gmail.com

Cc: r-help@r-project.org
Sent: Mon, September 27, 2010 12:16:31 PM
Subject: Re: [R] scientific vs. fixed notation in xyplot()

Try this:

 xyplot(1:10~1:10, scales=list(log = T, labels = round(log(1:10), 4)))





Hi I am using xyplot() to plot on the log scale by using scale=list(log=T)
argument. For example:

xyplot(1:10~1:10, scales=list(log=T))

But the axis labels are printed as scientific notation (10^0.0, etc), instead 
of
fixed notation. How can I change that to fixed notation?

options(scipen=4) doesn't work on xyplot()

Thanks

John

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



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O



  
[[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] Sample size estimation for non-inferiority log-rank and Wilcoxon rank-sum tests

2010-09-27 Thread Andrew Miles
I haven't done much with the type of data you're working with, but  
here is a post that lists a few packages for doing sample size  
calculations in R.  Perhaps one of them will be helpful.

https://stat.ethz.ch/pipermail/r-help/2008-February/154223.html

Andrew Miles

On Sep 27, 2010, at 2:09 PM, Paul Miller wrote:

 Hello Everyone,

 I'm trying to conduct a couple of power analyses and was hoping  
 someone might be able to help. I want to estimate the sample size  
 that would be necessary to adequately power a couple of non- 
 inferiority tests. The first would be a log-rank test and the second  
 would be a Wilcoxon rank-sum test. I want to be able to determine  
 the sample size that would be necessary to test for a 3 day  
 difference in median recovery time between 2 groups of cancer  
 patients.

 Both of these tests are infeasible using SAS Proc Power and I  
 haven't been able to find information about how to do them using  
 either SAS or R.

 Does anyone know how to perform either of these calculations? If so,  
 I'd greatly appreciate it if you could share a couple of examples.


 Thanks,

 Paul


   [[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] Variation of predictor of linear model

2010-09-27 Thread Yi Du
Hi folks,

I use lm to run regression and I don't know how to predict dependent
variable based on the model.

I used predict.lm(model, newdata=80), but it gave me warnings.

Also, how can I get the variance of dependent variable based on model.
Thanks.

[[alternative HTML version deleted]]

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


Re: [R] scientific vs. fixed notation in xyplot()

2010-09-27 Thread Don McKenzie
This is quite elegant (thanks) and brings up a problem I could not  
solve awhile back, although Dr. Sarkar did his best to help.

How do I do the same thing in a panel plot?

e.g., toy example

temp.df - data.frame(X=seq(1,100,by=1),Y=seq(1,50.5,by=.5),class=rep 
(c(A,B),each=50))
xyplot(Y ~ X | class,data=temp.df,scales=list(x=round(log(1:100),  
4),y=round(log(1:50.5), 4),log=T))


gives me the right points on the page but still gives axis labels in  
scientific notation.


If I try to specify labels as a list I get an error message

 xyplot(Y ~ X | class,data=temp.df,scales=list(log = T, labels =  
list(x=round(log(1:100), 4),y=round(log(1:50.5), 4


Error in construct.scales(log = TRUE, labels = list(x = c(0, 0.6931,  
1.0986,  :
  the at and labels components of scales may not be lists when  
relation = same


Syntax problem in this last command?

Thanks


On 27-Sep-10, at 12:16 PM, Henrique Dallazuanna wrote:


Try this:

 xyplot(1:10~1:10, scales=list(log = T, labels = round(log(1:10), 4)))


On Mon, Sep 27, 2010 at 4:10 PM, array chip  
arrayprof...@yahoo.com wrote:


Hi I am using xyplot() to plot on the log scale by using scale=list 
(log=T)

argument. For example:

xyplot(1:10~1:10, scales=list(log=T))

But the axis labels are printed as scientific notation (10^0.0, etc),
instead of
fixed notation. How can I change that to fixed notation?

options(scipen=4) doesn't work on xyplot()

Thanks

John


--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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


Don McKenzie, Research Ecologist
Pacific WIldland Fire Sciences Lab
US Forest Service

Affiliate Professor
School of Forest Resources, College of the Environment
CSES Climate Impacts Group
University of Washington

desk: 206-732-7824
cell: 206-321-5966
d...@uw.edu
donaldmcken...@fs.fed.us

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Alphabetical sequence of data along the x-axis in a box plot

2010-09-27 Thread Hughes, Ed
Hello All,

 

I noticed when I generated some boxplots, the data is presented in
alphabetical order along the x-axis (the data in this case was the four
quandrants of a sample area (NE,NW, SE, SW) that was my first column of
data).  Is there a way to have R plot the data in a different order?  I
imagine you could use a dummy variable, but didn't know if there might
be a simple argument  that will address this? 

 

Thanks for any guidance,

Eddie Hughes

 

 


[[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] plot single part of the country using gadm map

2010-09-27 Thread Paul Murrell

Hi

carolina plescia wrote:

Dear all,

in GADM map there are three levels (nation, province and precinct) for each
country of the world but for all of them you are never able to plot only one
part of a chosen country.


The Spatial object you get when you read in the shapefile has 
convenient subsetting methods defined.  For example ...


library(maptools)

italy - readShapeSpatial(ITA_adm1)
plot(italy)

liguria - italy[italy$NAME_1 == Liguria, ]
plot(liguria)

Is that what you are after?

Paul


To be sure, I am trying to plot only one region of “Italy” and colour the
different precincts in it. So far I am able to colour only the part of my
interest but the programme still plot the whole country.

Is that a way to have only a chosen part of the country (ie. region or
state) with all the specific subunits in it?

I have tried also to plot and then zoom but the “zoom” function seems to
work only with “plot” while gadm map uses ”spplot”.

Anyone knows if the zoom command works also with spplot?

Any suggestions?

Thank you very much.
Carolina



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

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


Re: [R] Variation of predictor of linear model

2010-09-27 Thread Joshua Wiley
Hi,

Try this:

# using the iris dataset
mydat - iris
mymodel - lm(Sepal.Length ~ Petal.Length + Species, data = mydat)
summary(mymodel)
newdat - data.frame(Petal.Length = seq(1, 10, by = .1),
 Species = factor(rep(virginica, 91)))

results - predict(object = mymodel, newdata = newdat, se.fit = TRUE)

results

The main lesson is that generally newdata should be a data frame with
columns that have the same name as the predictors (IVs) in your model.
 I'm not exactly sure what you mean by variance of dependent variable
based on model.  Do you want its total variance, residual variance,
___ ?

Cheers,

Josh

On Mon, Sep 27, 2010 at 12:58 PM, Yi Du abraham...@gmail.com wrote:
 Hi folks,

 I use lm to run regression and I don't know how to predict dependent
 variable based on the model.

 I used predict.lm(model, newdata=80), but it gave me warnings.

 Also, how can I get the variance of dependent variable based on model.
 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.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


Re: [R] Alphabetical sequence of data along the x-axis in a box plot

2010-09-27 Thread Joshua Wiley
Hi Eddie,

I've been on a role with the iris data, so I figure why stop.
Assuming that one variable is a factor, you can easily reverse it, and
if you want fine tuned control, then just reorder the levels.  Here is
an example:

dat - iris
boxplot(Sepal.Length ~ Species, data = dat)
boxplot(Sepal.Length ~ rev(Species), data = dat)
# They had been ordered alphabetically, now I am changing them
dat$Species - factor(dat$Species, levels = c(versicolor,
virginica, setosa),
  labels = c(versicolor, virginica, setosa))
boxplot(Sepal.Length ~ Species, data = dat)

Cheers,

Josh

On Mon, Sep 27, 2010 at 12:59 PM, Hughes, Ed ehug...@conshelf.com wrote:
 Hello All,



 I noticed when I generated some boxplots, the data is presented in
 alphabetical order along the x-axis (the data in this case was the four
 quandrants of a sample area (NE,NW, SE, SW) that was my first column of
 data).  Is there a way to have R plot the data in a different order?  I
 imagine you could use a dummy variable, but didn't know if there might
 be a simple argument  that will address this?



 Thanks for any guidance,

 Eddie Hughes






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




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


Re: [R] Alphabetical sequence of data along the x-axis in a box plot

2010-09-27 Thread Peter Alspach
Tena koe Eddie

One way:

eddie - data.frame(grp=rep(c('small','medium','large','very large'), each=20), 
wgt=rnorm(80, 100, 10))
with(eddie, plot(grp, wgt))
eddie$grp - factor(eddie$grp, levels=c('small','medium','large','very large'))
with(eddie, plot(grp, wgt))

HTH ...

Peter Alspach

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Hughes, Ed
 Sent: Tuesday, 28 September 2010 9:00 a.m.
 To: r-help@r-project.org
 Subject: [R] Alphabetical sequence of data along the x-axis in a box
 plot
 
 Hello All,
 
 
 
 I noticed when I generated some boxplots, the data is presented in
 alphabetical order along the x-axis (the data in this case was the four
 quandrants of a sample area (NE,NW, SE, SW) that was my first column of
 data).  Is there a way to have R plot the data in a different order?  I
 imagine you could use a dummy variable, but didn't know if there might
 be a simple argument  that will address this?
 
 
 
 Thanks for any guidance,
 
 Eddie Hughes
 
 
 
 
 
 
   [[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.

The contents of this e-mail are confidential and may be subject to legal 
privilege.
 If you are not the intended recipient you must not use, disseminate, 
distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received 
this
 e-mail in error, please notify the sender and delete all material pertaining 
to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the 
individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.

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

2010-09-27 Thread emorway

Hello-

After looking through ?spplot, I would expect that I could specify the
values of the cuts:

...‘cuts’ number of cuts or the actual cuts to use...

So in the following command, 

spplot(lzm.krige.dir[var1.pred], scales=list(draw=TRUE),
xlab=Easting,ylab=Northing,
 
cuts=seq(0.0,0.4,by=0.01),key.space=right,cex=1.1,col.regions=terrain.colors(41),
  main=Specific Yield Layer 1,sp.layout=list(pts))

I get the following warning messages and the plot is a solid color:

Warning messages:
1: In if (length.out == 0L) integer(0L) else if (One) seq_len(length.out)
else if (missing(by)) { :
  the condition has length  1 and only the first element will be used
2: In if (length.out  2L) if (from == to) rep.int(from, length.out) else
as.vector(c(from,  :
  the condition has length  1 and only the first element will be used

Looking at Edzer's response to a post:
http://r.789695.n4.nabble.com/using-spplot-sp-package-with-5-quantiles-td836245.html#a836246

it reinforces to me the idea that I should be able to specify where the cuts
should occur.  I'm not sure what to do with the warning message and my
google searches have been unfruitful.

Some supplemental information that might be helpful:

range(data.frame(lzm.krige.dir[var1.pred])[,1])
[1] 0.1277067 0.2933876

I give the range of the plotted values because it varies between datasets
and I would like the color scale to remain fixed between images rather than
changing image to image making visual comparison's more difficult.

Any suggestions would be greatly appreciated,
Eric


-- 
View this message in context: 
http://r.789695.n4.nabble.com/spplot-cuts-tp2716237p2716237.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.


  1   2   >