Re: [R] Simulating data (stupid question)

2009-08-25 Thread Liviu Andronic
Hello
Your attachement didn't seem to get through.
You can simulate data using rnorm() or any of the r*() functions [1].
You can also use it to add noise to a custom function that you use to
generate your specific data.
Liviu

[1] http://www.statmethods.net/management/functions.html



On 8/25/09, KABELI MEFANE kabelimef...@yahoo.co.uk wrote:
 Dear All

  I know that you do not have to help me but please do, i am new to R as a CPI 
 compiler, i just need to do a sample to see which sampling method best works 
 in different situations, therefore since this is for practice purposes nobody 
 will finance a real project thats why i need you to help me direct me as to 
 how simulate data (just direct me,not 100% help). See my attachment for 
 problem formulation, you can even suggest a different problem and how i can 
 simulate



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




-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

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

2009-08-25 Thread Gabor Grothendieck
My prior solution was not correct.

If the idea is to combine each row of x with each row
of y then convert the matrices to data frames and
perform and outer join with SQL like this:

library(sqldf)

X - as.data.frame(x)
Y - as.data.frame(y)

as.matrix(sqldf(select * from X, Y, method = raw))

See http://sqdfl.googlecode.com

On Mon, Aug 24, 2009 at 1:10 PM, Gabor
Grothendieckggrothendi...@gmail.com wrote:
 Try this:

 kronecker(cbind(x, y), rep(1, 3))


 On Mon, Aug 24, 2009 at 12:16 PM, Daniel Nordlunddjnordl...@verizon.net 
 wrote:
 If I have two matrices like

 x - matrix(rep(c(1,2,3),3),3)
 y - matrix(rep(c(4,5,6),3),3)

 How can I combine  them to get ?

 1 1 1 4 4 4
 1 1 1 5 5 5
 1 1 1 6 6 6
 2 2 2 4 4 4
 2 2 2 5 5 5
 2 2 2 6 6 6
 3 3 3 4 4 4
 3 3 3 5 5 5
 3 3 3 6 6 6

 The number of rows and the actual numbers above are unimportant, they are 
 given so as to illustrate how I want to combine the matrices.  I.e., I am 
 looking for a general way to combine the first row of x with each row of y, 
 then the second row of x with y, 

 Thanks,

 Dan

 Daniel Nordlund
 Bothell, WA USA

 Thanks for

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



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


Re: [R] R with MPI

2009-08-25 Thread Martin Morgan
Hi Polemon --

polemon wrote:
 On Mon, Aug 24, 2009 at 2:20 PM, polemon pole...@gmail.com wrote:
 
 Hello, I plan to use R with my cluster with OpenMPI.
 I need the packaged 'snow' and 'Rmpi' for that, however, I get an error
 while downloading and installing them:
 When I do a:
 install.packages(Rmpi, dependencies=T)

 I get this error:
 checking for mpi.h... no
 Try to find libmpi.so or libmpich.a
 checking for main in -lmpi... no
 libmpi not found. exiting...

 However, mpi.h is present via the openmpi-devel package on my RHEL 5.3.

This is a configuration error, try install.pacakges(Rmpi,
dependencies=TRUE, configure.args=--with-mpi=/folder/with/mpiheaders).
More below

 Some of those packages need sprng 2.0 (rsprng, for instance, which is a
 dependency for another MPI-related package). Sprng 2.0, however, isn't in
 developement for years, I wonder how I am supposed to keep my software up to
 date...

rsprng is listed as 'Suggests' for both Rmpi and snow, so don't need to
be installed for successful Rmpi or snow installation.

Your message in the next post is that

 library(Rmpi)
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared library '/opt/R/lib64/R/library/Rmpi/libs/Rmpi.so':
  libmpi.so.0: cannot open shared object file: No such file or directory
Error in library(Rmpi) : .First.lib failed for 'Rmpi'
Error in dyn.unload(file.path(libpath, libs, paste(Rmpi,
.Platform$dynlib.ext,  :
  dynamic/shared library '/opt/R/lib64/R/library/Rmpi/libs/Rmpi.so' was not
loaded


This is a run-time error, and is because your mpi installation has not
registered the location of the shared object libraries (or has not been
compiled as a shared object?) correctly. See the system command
'ldconfig', or as a workaround launch R with something like

  LD_LIBRARY_PATH=/path/to/libmpifolder R

I'm guessing that path is /usr/lib64/openmpi/1.2.7-gcc/lib, but I didn't
look carefully enough at your solution to installing Rmpi to know for sure.

For more help, try the R-sig-HPC mailing list, for instance Hao Yu's
response to this

  https://stat.ethz.ch/pipermail/r-sig-hpc/2009-August/000329.html

thread.

Martin


 Any ideas on how to workaround that mpi.h problem?

 Please help,

 --polemon

 
 I did as described here:
 http://www.cybaea.net/Blogs/Data/R-tips-Installing-Rmpi-on-Fedora-Linux.html
 
 Since Fedora and RHEL are pretty equal, I gave that installation a shot, and
 from what I can tell, I got pretty far.
 The package installed well, but when I try to load it with library(Rmpi):
 
 library(Rmpi)
 Error in dyn.load(file, DLLpath = DLLpath, ...) :
   unable to load shared library '/opt/R/lib64/R/library/Rmpi/libs/Rmpi.so':
   libmpi.so.0: cannot open shared object file: No such file or directory
 Error in library(Rmpi) : .First.lib failed for 'Rmpi'
 Error in dyn.unload(file.path(libpath, libs, paste(Rmpi,
 .Platform$dynlib.ext,  :
   dynamic/shared library '/opt/R/lib64/R/library/Rmpi/libs/Rmpi.so' was not
 loaded
 
 As you can see, R is installed in /opt/R, libmpi.so.0 is available:
 
 /usr/lib/lam/lib/libmpi.so.0
 /usr/lib/lam/lib/libmpi.so.0.0.0
 /usr/lib/openmpi/1.2.7-gcc/lib/libmpi.so
 /usr/lib/openmpi/1.2.7-gcc/lib/libmpi.so.0
 /usr/lib/openmpi/1.2.7-gcc/lib/libmpi.so.0.0.0
 /usr/lib64/lam/lib/libmpi.so.0
 /usr/lib64/lam/lib/libmpi.so.0.0.0
 /usr/lib64/openmpi/1.2.7-gcc/lib/libmpi.so
 /usr/lib64/openmpi/1.2.7-gcc/lib/libmpi.so.0
 /usr/lib64/openmpi/1.2.7-gcc/lib/libmpi.so.0.0.0
 
 What should I do, to make Rmpi available in R?
 
 Cheers,
 
 --polemon
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] how to apply a date format for data frame

2009-08-25 Thread rajclinasia

Hi Everyone,

i have a data frame like this

  labels starts  ends priorities
1  firsttask  37987 38049  1
2 secondtask  38019 38112  2
3  thirdtask  38049 38144  3
4 fourthtask  38081 38207  4
5  fifthtask  38112 38239  5

now i want to apply a date format for the two variables they are starts
and ends. 
please help in this aspect it would be appreciable.
Thanks in Advance.
-- 
View this message in context: 
http://www.nabble.com/how-to-apply-a-date-format-for-data-frame-tp25129192p25129192.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] comparing tables from replicated data

2009-08-25 Thread Troels Ring
Dear friends, I'm examining the characteristics of two models that both 
fit the sodium concentration in 16 pigs quite well under treatment or 
control conditions. The more complicated model is by anova better than 
the less complicated model.  To take it further I have generated 
replicate data using the independent variables and parameter estimates 
under the two models. A clinically important criterion is the change in 
sodium concentration during the experiment, and as expected due to the 
character of the treatment this is larger in all the treated animals 
(n=10) as compared to the controls (n=6). This is also the case for 1000 
replicated sets under the more complex model while quite a few of 
misclassifications (control animal change  treated animal change) 
occurs under the less complex model. To understand (a bit at least) what 
goes on I have tried to see the observed data under random group 
assignment in the hope to be able to compare directly and formally the 
results from the replicates under the two models.
Here are the observed changes in the 16 pigs and grp1 is treated and 2 
is control.


grp - as.factor(c(rep(1,10),rep(2,6)))
val - c(6,12,11,11,11,13,15,13,11,11,2,3,1,1,1,2)
test - sum(val[grp==1]max(val[grp==2])) # 0

#Now under random perturbations of group assignments,
#what would occur???

TT - NULL
for (i in 1:1000){
ind - sample(c(1:16),16,replace=FALSE)
grp1 - grp[ind]
TT[i] - sum(val1[grp1==1]max(val1[grp1==2]))
}
hist(TT)
table(TT)
TT
  0123456789   10
  25  126  407  408  1179 1026 3171  879 3850

For the less complex model, the results on 1000 replicates are 
evidently better than the TT default

table(test11b)
test11b
 0   1   2   3   4   5   6   7   8   9  10
279 294 191 114  53  40  17   6   3   2   1

and for the more advanced model I get even more convincing
table(test11d)
test11d
  0
1000

Clinically I can say that it is bad to have 1 in 16 misclassified and 
therefore judge the complicated model better, but others might disagree. 
Also it is not too good that the method here is insensitive to the size 
of the changes.


I hope some of you will have remarks on this problem.

Best wishes
Troels

--

Troels Ring - -
Department of nephrology - - 
Aalborg Hospital 9100 Aalborg, Denmark - -

+45 99326629 - -
tr...@gvdnet.dk

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

2009-08-25 Thread ogbos okike
Hi Uwe,
I am pleased to inform you that this problem has, following your hint, been
resolved.  I installed 64-bit version of R and I was alright.
Thanks again for your time.
Ogbos

2009/6/24 Uwe Ligges lig...@statistik.tu-dortmund.de



 ogbos okike wrote:

 Hi,
 I have a data of size 981.1MB(1028707715) and I intend to calculate the
 length of the data using tapply function in R. I was able to read the data
 into R but when I tried to use the factor function, I had an error message
 Error: cannot allocate vector of size 2.0 Gb.
 Can anybody tell me what to do? I have tried to increase the size of the
 memory but I am not sure if R recognizes it as the error message persists.
 Is there any other thing I need to do for R to recognize the memory
 increase?



 My guess is that this is a 32-bit version of R?
 You need some 64-bit OS and 64-bit R or try to decrease the amount/size of
 objects that are in the same time in your memory.

 Best,
 Uwe Ligges


  Thank you so much for any help.
 Ogbos

[[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] robust method to obtain a correlation coeff?

2009-08-25 Thread Christian Meesters
Hi,

Thanks for all the answers. Think with your help I got it now. It was
apparently a typical newbie question. I'll try omitting NAs globally in
this case.

Thanks,
Christian

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


Re: [R] how to apply a date format for data frame

2009-08-25 Thread Uwe Ligges



rajclinasia wrote:

Hi Everyone,

i have a data frame like this

  labels starts  ends priorities
1  firsttask  37987 38049  1
2 secondtask  38019 38112  2
3  thirdtask  38049 38144  3
4 fourthtask  38081 38207  4
5  fifthtask  38112 38239  5

now i want to apply a date format for the two variables they are starts
and ends. 



Would be helpful to know which date format and what the coding means.

Uwe Ligges




please help in this aspect it would be appreciable.
Thanks in Advance.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Filling in empty arrays/lists from using paste function

2009-08-25 Thread Uwe Ligges
I highly suggest to rethink your problem in a way that you store the 
things labelled, e.g., TA1 to TA5 (as well as all the others) as the 
elements of a list TA. This way you have just one object TA that can 
easily be accessed by index operations and the code looks much cleaner 
in the end.


Best,
Uwe Ligges


Steven Kang wrote:

Dear R users,

I am trying to fill in arrays (5 different according to distinct id)
from objects produced from arbitrary data set below.

  a -
data.frame(id=rep(c(idA1,idA2,idA3,idA4,idA5),2),pro=c(bb,uu,ee,tt,uu,gg,tt,bb,gg,ee),sal=rpois(10,2))

  idpro sal
1  idA1  bb   2
2  idA2  uu   0
3  idA3  ee   3
4  idA4  tt   2
5  idA5  uu   4
6  idA1  gg   3
7  idA2  tt   0
8  idA3  bb   1
9  idA4  gg   0
10 idA5  ee   5
My desired outputs (5 arrays/lists classified according to distinct id
field) are as follow:


TA1

bb ee gg tt uu
 2  0  3  0  0


TA2

bb ee gg tt uu
 0  0  0  0  0


TA3

bb ee gg tt uu
 1  3  0  0  0

.. similarly for TA4  TA5.

The above results were produced using TA1 -
c(bb=TA1.bb,ee=TA1.ee,gg=TA1.gg,tt=TA1.tt,uu=TA1.uu), TA2 -
c(bb=TA2.bb,ee=TA2.ee,gg=TA2.gg,tt=TA2.tt,uu=TA2.uu*)* etc for TA3~TA5.
Although these generate the output I desire, I would like to use a single
statement for producing 5 different arrays (instead of 5 different
statements)

I have tried the following codes, however the last statement (paste(T,
substring(i,3,4), sep=) - c(bb ..) gives error message reading Error
in paste(T, substring(i, 3, 4), sep = ) - c(bb = paste(paste(T,
: target of assignment expands to non-language object

for (i in unique(a$id))
  for (j in unique(a$pro))
assign(paste(paste(T, substring(i,3,4), sep=), j, sep=.),
sum(subset(a, a$id == i  a$pro == j)$sal))
paste(T, substring(i,3,4), sep=) - c(bb=paste(paste(T,
substring(i,3,4), sep=),j, sep=.),ee=paste(paste(T, substring(i,3,4),
sep=),j, sep=.),

gg=paste(paste(T, substring(i,3,4), sep=),j,
sep=.),tt=paste(paste(T, substring(i,3,4), sep=),j, sep=.),

uu=paste(paste(T,
substring(i,3,4), sep=),j, sep=.))

Your solution to this problem would be highly appreciated.



Steve

[[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] Between-group variance from ANOVA

2009-08-25 Thread Mark Difford

Hi Emma,

 ...from this I can read the within-group variance. can anyone tell me how
 i may find 
 out the between-group variance?

But it's in the table, above the within-group variance. Remember that F is
the ratio of these two quantities, i.e. the mean of the group variances
divided by the mean of the within-group variances . I will work with my
example since you never set seed so your answers are different from mine
(which really does not help matters).

set.seed(7) 
TDat - data.frame(response = c(rnorm(100, 5, 2), rnorm(100, 20, 2))) 
TDat$group - gl(2, 100, labels=c(A,B))
summary(aov(response ~ group, data=TDat))

11225.25/3.64
[1] 3083.86

There is some rounding error on the mean squares (i.e. mean variances) but F
is correct. Using estimates calculated by a different route we have:

11225.249057/3.639801
[1] 3084.028

Does this answer your question?

Regards, Mark.


emj83 wrote:
 
 I have done this in R and this is the following ANOVA table I get:
 
 summary(aov(response ~ group, data=TDat))
  Df  Sum Sq Mean Sq F valuePr(F)
 group 1 11203.5 11203.5  2505.0  2.2e-16 ***
 Residuals   198   885.5 4.5
 
 The model is response(i,j)= group(i)+ error(i,j),
 
 we assume that group~N(0,P^2) and error~N(0,sigma^2)
 
 I know that sigma^2 is equal to 4.5, how do I find out P^2? 
 
 In the problem that I am trying to apply this to, I have more than 2
 groups. I was hoping there would be a function that helps you do this that
 I don't know about.
 
 
 Thanks for your help Emma
 
 
 
 
 Mark Difford wrote:
 
 Hi Emma,
 
 
 
 R gives you the tools to work this out.
 
 ## Example
 set.seed(7)
 TDat - data.frame(response = c(rnorm(100, 5, 2), rnorm(100, 20, 2)))
 TDat$group - gl(2, 100, labels=c(A,B))
 with(TDat, boxplot(split(response, group)))
 summary(aov(response ~ group, data=TDat))
 
 Regards, Mark.
 
 
 emj83 wrote:
 
 can anyone advise me please?
 
 
 emj83 wrote:
 
 I have done some ANOVA tables for some data that I have, from this I
 can read the within-group variance. can anyone tell me how i may find
 out the between-group variance?
 
 Thanks Emma
 
 
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Between-group-variance-from-ANOVA-tp24954045p25129942.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to apply a date format for data frame

2009-08-25 Thread Stefan Grosse
On Mon, 24 Aug 2009 23:42:11 -0700 (PDT) rajclinasia r...@clinasia.com
wrote:

R   labels starts  ends priorities
R 1  firsttask  37987 38049  1

It is easier with the other data.frame you had with:

   labels   starts ends
1  first task 1-Jan-04 3-Mar-04

and as.Date see
?as.Date

e.g.
as.Date(1-Jan-04,%d-%b-%y)
or for the whole column:

myframe$starts-as.Date(myframe$starts,%d-%b-%y)

now I hope you have learnt how to get the data into a list for the
gantt.chart...

hth
Stefan

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

2009-08-25 Thread Uwe Ligges



R Heberto Ghezzo, Dr wrote:
Hello, I am sorry, I have this problem before and Uwe send me the answer but I misplaced it 


Oh dear! But it is not lost, since the answer to the second part of your 
problem was: Please read the documentation!




and can not find it.

 writing a model for BRugs



library(BRugs)

Loading required package: coda
Loading required package: lattice
Welcome to BRugs running on OpenBUGS version 3.0.3

setwd(c:/tmp)

Error in setwd(c:/tmp) : cannot change working directory



So c:/tmp does not exist or you don't have permissions there?



mo - function(){

+   for (k in 1:p){
+ delta[1,k] ~ dnorm(0,0.1)I(,delta[2,k])
Error: unexpected symbol in:


The answer was: Please read the documentation!

?writeModel (which you want to use on this function) tells you:

As a difference, BUGS syntax allows truncation specification like this: 
dnorm(...) I(...) but this is illegal in R. To overcome this 
incompatibility, use %_% before I(...): dnorm(...) %_% I(...). The dummy 
operator %_% will be removed before the BUGS code is saved. 




  for (k in 1:p){
delta[1,k] ~ dnorm(0,0.1)I

delta[2,k] ~ dnorm(0,0.1)I(delta[1,k],delta[3,k])

Error: unexpected symbol in delta[2,k] ~ dnorm(0,0.1)I

delta[3,k] ~ dnorm(0,0.1)I(delta[2,k],)}

Error: unexpected symbol in delta[3,k] ~ dnorm(0,0.1)I

}

Error: unexpected '}' in }

so R parser does not like the I(,) construct


which is *not* the problem, see above.


Best wishes,
Uwe



, What is the alternative way of propgramming the
constrain I(lower,upper)
Thanks
Heberto Ghezzo
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Re : table function

2009-08-25 Thread Inchallah Yarab
Hi Mark,


Thank you for your answer !! it works but if i have NA in the vector z what i 
shoud do to count its number in Z?
x      y        z
 1    0      100
 5    1      1500
 6    1  NA
 2    2      500
 1    1  NA
 5    2    2000
 8    5    4500
 

i did the same but it gives me this error  message:
 [0 - 1000] [1000 - 3000] 3000 
    0 0 0 
Warning message:
In inherits(x, factor) : NAs introduced by coercion


Thank you 



De : Marc Schwartz marc_schwa...@me.com

Cc : r-help@r-project.org
Envoyé le : Lundi, 24 Août 2009, 18h33mn 52s
Objet : Re: [R] table function

On Aug 24, 2009, at 10:59 AM, Inchallah Yarab wrote:

 hi,
 
 i want to use the function table to build a table not of frequence (number of 
 time the vareable is repeated in a list or a data frame!!) but in function of 
 classes
[[elided Yahoo spam]]
 
 example
 
 x      y        z
 1    0      100
 5    1      1500
 6    1      1200
 2    2      500
 1    1      3500
 5    2    2000
 8    5    4500
 
 i want to do a table summerizing the number of variable where z is in 
 [0-1000],],[1000-3000], [ 3000]
 
 thank you very much for your help


See ?cut, which bins a continuous variable.

 DF
  x y    z
1 1 0  100
2 5 1 1500
3 6 1 1200
4 2 2  500
5 1 1 3500
6 5 2 2000
7 8 5 4500


 table(cut(DF$z, breaks = c(-Inf, 1000, 3000, Inf),
            labels = c(0 - 1000, 1000 - 3000, 3000)))

    0 - 1000 1000 - 3000        3000
          2            3            2

HTH,

Marc Schwartz


  
[[alternative HTML version deleted]]

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


Re: [R] Between-group variance from ANOVA

2009-08-25 Thread Mark Difford

Hi Emma,

...

I forgot to add the tabular ouput, which doesn't help either:

T.sum - summary(aov(response ~ group, data=TDat))
print(T.sum)

 Df  Sum Sq Mean Sq F valuePr(F)
group 1 11225.2 11225.23084  2.2e-16 ***
Residuals   198   720.7 3.6  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

unlist(T.sum)

unlist(T.sum)[5]/unlist(T.sum)[6]
Mean Sq1 
3084.028

Regards, Mark.


Mark Difford wrote:
 
 Hi Emma,
 
 ...from this I can read the within-group variance. can anyone tell me
 how i may find 
 out the between-group variance?
 
 But it's in the table, above the within-group variance. Remember that F
 is the ratio of these two quantities, i.e. the mean of the group variances
 divided by the mean of the within-group variances . I will work with my
 example since you never set seed so your answers are different from mine
 (which really does not help matters).
 
 set.seed(7) 
 TDat - data.frame(response = c(rnorm(100, 5, 2), rnorm(100, 20, 2))) 
 TDat$group - gl(2, 100, labels=c(A,B))
 summary(aov(response ~ group, data=TDat))
 
 11225.25/3.64
 [1] 3083.86
 
 There is some rounding error on the mean squares (i.e. mean variances) but
 F is correct. Using estimates calculated by a different route we have:
 
 11225.249057/3.639801
 [1] 3084.028
 
 Does this answer your question?
 
 Regards, Mark.
 
 
 emj83 wrote:
 
 I have done this in R and this is the following ANOVA table I get:
 
 summary(aov(response ~ group, data=TDat))
  Df  Sum Sq Mean Sq F valuePr(F)
 group 1 11203.5 11203.5  2505.0  2.2e-16 ***
 Residuals   198   885.5 4.5
 
 The model is response(i,j)= group(i)+ error(i,j),
 
 we assume that group~N(0,P^2) and error~N(0,sigma^2)
 
 I know that sigma^2 is equal to 4.5, how do I find out P^2? 
 
 In the problem that I am trying to apply this to, I have more than 2
 groups. I was hoping there would be a function that helps you do this
 that I don't know about.
 
 
 Thanks for your help Emma
 
 
 
 
 Mark Difford wrote:
 
 Hi Emma,
 
 
 
 R gives you the tools to work this out.
 
 ## Example
 set.seed(7)
 TDat - data.frame(response = c(rnorm(100, 5, 2), rnorm(100, 20, 2)))
 TDat$group - gl(2, 100, labels=c(A,B))
 with(TDat, boxplot(split(response, group)))
 summary(aov(response ~ group, data=TDat))
 
 Regards, Mark.
 
 
 emj83 wrote:
 
 can anyone advise me please?
 
 
 emj83 wrote:
 
 I have done some ANOVA tables for some data that I have, from this I
 can read the within-group variance. can anyone tell me how i may find
 out the between-group variance?
 
 Thanks Emma
 
 
 
 
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Between-group-variance-from-ANOVA-tp24954045p25130266.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] table function

2009-08-25 Thread Inchallah Yarab
Hi Mark,


Thank you for your answer !! it works but if i have NA in the vector z what i 
shoud do to count its number in Z?
x      y        z
 1    0      100
 5    1      1500
 6    1  NA
 2    2      500
 1    1  NA
 5    2    2000
 8    5    4500
 

i did the same but it gives me this error  message:
 [0 - 1000] [1000 - 3000] 3000 
    0 0 0 
Warning message:
In inherits(x, factor) : NAs introduced by coercion


Thank you 



De : Marc Schwartz marc_schwa...@me.com

Cc : r-help@r-project.org
Envoyé le : Lundi, 24 Août 2009, 18h33mn 52s
Objet : Re: [R] table function

On Aug 24, 2009, at 10:59 AM, Inchallah Yarab wrote:

 hi,
 
 i want to use the function table to build a table not of frequence (number of 
 time the vareable is repeated in a list or a data frame!!) but in function of 
 classes
[[elided Yahoo spam]]
 
 example
 
 x      y        z
 1    0      100
 5    1      1500
 6    1      1200
 2    2      500
 1    1      3500
 5    2    2000
 8    5    4500
 
 i want to do a table summerizing the number of variable where z is in 
 [0-1000],],[1000-3000], [ 3000]
 
 thank you very much for your help


See ?cut, which bins a continuous variable.

 DF
  x y    z
1 1 0  100
2 5 1 1500
3 6 1 1200
4 2 2  500
5 1 1 3500
6 5 2 2000
7 8 5 4500


 table(cut(DF$z, breaks = c(-Inf, 1000, 3000, Inf),
            labels = c(0 - 1000, 1000 - 3000, 3000)))

    0 - 1000 1000 - 3000        3000
          2            3            2

HTH,

Marc Schwartz


  
[[alternative HTML version deleted]]

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


Re: [R] MSM package and qmatrix

2009-08-25 Thread Peter Adamson

Hi Ross,

For an eleven state model you could define transitions as follows:

transitions_allowed - matrix(c(
  0,1,1,1,1,1,1,1,1,1,1,
  1,0,1,1,1,1,1,1,1,1,1,
  1,1,0,1,1,1,1,1,1,1,1,
  1,1,1,0,1,1,1,1,1,1,1,
  1,1,1,1,0,1,1,1,1,1,1,
  1,1,1,1,1,0,1,1,1,1,1,
  1,1,1,1,1,1,0,1,1,1,1,
  1,1,1,1,1,1,1,0,1,1,1,
  1,1,1,1,1,1,1,1,0,1,1,
  1,1,1,1,1,1,1,1,1,0,1,
  1,1,1,1,1,1,1,1,1,1,0
  ), nrow=11, ncol=11,
  byrow=TRUE,
  dimnames=list(from=1:11,to=1:11))


In your case - I think you may be getting the error message as you have 23
200 201 203 999 as states and not 1 2 3 4 5 6 7 8 9 10.  Try recoding 23 200
201 203 999 to 6 7 8 9 10?

HTH, Peter


Ross Culloch wrote:
 
 Hi R-helpers,
 
 I am having a problem understanding how to construct the qmatrix, i have
 read the help menu for msm but I am still a bit lost. Below is an example
 of one of my transition matrices:
 
 statetable.msm(BEH, ID, data = A1)
 
  to
 from   1  2  3  4  5 23 200 201 203 999
   1   86 11  2 20  1  9   3  11   1  22
   2   18  4  4  4  0  1   1   1   0   1
   35  2  0  5  0  0   2   0   0   3
   4   17  5  5 13  0  4   3   3   0   7
   51  0  1  1  0  0   0   0   0   0
   23   7  3  0  4  0  3   1   3   0   3
   200  5  0  2  3  1  2   1   3   0   3
   201  5  5  3  2  1  0   2   6   1   5
   203  3  0  0  0  0  0   0   0   0   0
   999 18  4  0  5  0  5   7   3   1   0
 
 
 Instantaneous transition IS allowed from state r to state s. But what i
 don't understand is what is the logical way to create the initial
 transition matrix - i've tried to just give even numbers to all transition
 possibilities e.g. every transition given 0.1 or 1, but i get the
 following error message:
 
  Error in msm.check.state(nrow(qmatrix), state, cens$censor) : 
   State vector contains elements not in 1, 2, ... , 10
 
 Does anyone have any suggestions, i can only assume that this is a simple
 problem that i have overlooked because nobody else seems to have asked it!
 
 Any suggestions on how to construct a qmatrix would be much appreciated,
 
 Berst wishes,
 
 Ross
 

-- 
View this message in context: 
http://www.nabble.com/MSM-package-and-qmatrix-tp24796485p25117814.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] hdf5 package segfault when processing large data

2009-08-25 Thread Marcus Daniels

Hi Budi and Bill,

As a workaround, you could try setting your stack limit to a larger 
limit (ulimit -s).   I'll change that to a heap allocation.


Thanks,

Marcus

William Dunlap wrote:

This is probably due to the code in hdf5.c allocating a huge
matrix, buf, on the stack with

883   unsigned char buf[rowcount][size];

It dies with the segmentatio fault (stack overflow, in particular)
at line 898, where it tries to access this buf.

885   for (ri = 0; ri  rowcount; ri++)
886 for (pos = 0; pos  colcount; pos++)
887   {
888 SEXP item = VECTOR_ELT (val, pos);
889 SEXPTYPE type = TYPEOF (item);
890 void *ptr = buf[ri][offsets[pos]];
891
892 switch (type)
893   {
894   case REALSXP:
895 memcpy (ptr, REAL (item)[ri], sizeof
(double));
896 break;
897   case INTSXP:
898 memcpy (ptr, INTEGER (item)[ri], sizeof
(int));
899 break;

The code should use one of the allocators in the R API instead
of putting the big memory block on the stack.

  


The data example, the list continue for more than 250,000 
rows: sample.txt


DateTimef1  f2  f3  f4  f5
2007032807:56   463 463.07  462.9   463.01  1100
2007032807:57   463.01  463.01  463.01  463.01  200


__



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

2009-08-25 Thread mcobb_berkeley

I can't figure out how to customize the order of the panels for effects
plots.  Any help would be appreciated.

Here's my code:

library(effects)

lm.hour3eff-allEffects(lm.hour3, xlevels=list(road=c(0, 1000, 2000, 3000),
trail=c(0, 1000, 2000, 3000)))

plot(lm.hour3eff,road:trail, xlab=Trail Distance (m), ylab=Step Length
(m), main=NULL)



Thanks,
McCrea

-- 
View this message in context: 
http://www.nabble.com/order-of-effects-plot-panels-tp25123680p25123680.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] Monotone Smoothing specifically I splines

2009-08-25 Thread Helen Powell

Hello

I am looking for a function to create an Integrated (I) spline basis, 
somehting similar to the likes of 'bs' and 'ns'. I have come across the 
funcitons,


fda::eval.monfd   Values of a Monotone Functional Data
  Object
fda::/.fd FDA internal functions
fda::monfnEvaluates a monotone function
fda::smooth.monotone
  Monotone Smoothing of Data
mgcv::mono.conMonotonicity constraints for a cubic
  regression spline
splines::backSpline
  Monotone Inverse Spline
stats::isoreg Isotonic / Monotone Regression

but none of these are specifically for an I-spline. Any help would be 
much appreciated.


Helen Powell (Glsagow)

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

2009-08-25 Thread emj83

can anyone advise me please?


emj83 wrote:
 
 I have done some ANOVA tables for some data that I have, from this I can
 read the within-group variance. can anyone tell me how i may find out the
 between-group variance?
 
 Thanks Emma
 

-- 
View this message in context: 
http://www.nabble.com/Between-group-variance-from-ANOVA-tp24954045p25120522.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] allowing line wrap for long strip text in xyplot (lattice)

2009-08-25 Thread Donald Boyd
Hi. Am brand new to R and to mailing lists - have never posted anywhere
before, so hope I do this right.

Am using R 2.9.1 with lattice graphics (just installed, fully up to date).

Am doing trellis xyplot with y (emp=employment), x (yearmo=a time measure)
and conditioning variable (indf - factor describing industry) -- i.e., (emp
~ yearmo | indf), where all three variables are in a dataframe. The
conditioning variable is a factor with a long text description (e.g.,
Offices of bank holding companies and of other holding companies
(60551112) constructed from a much-less-descriptive industry code - in this
case, 60551112). That long text goes into the strip text above each panel.
With default settings the text for many of the factor levels is too long for
the strip area and I simply see some of it but not all of it. I would like
to be able to see the full text description, which means I would like to
allow it to wrap over several lines in the strip area - say 2 or 3 lines.
Note that the text itself does NOT have any embedded line-wrap characters
(\n) and I would like to avoid writing something to guess where to insert
them into each of more than 1,000 levels of the factor. I suspect that
xyplot, perhaps through par.strip.text, has some simple way of allowing it
to do intelligent line wrap. I have searched high and low, but have not
figured this out:
- I have read the lattice documentation but haven't quite figured out from
that what I should do
- I have tried using lines=2 in par.strip.text and lineheight=2 but the
former appears to change the height of the strip area without forcing line
wrap, and the latter as I understand it controls spacing between lines
- I have tried workarounds like using cex=0.2 in par.strip.text to make the
text really small, but it gets hard to read; and I have tried
abbreviate=TRUE in par.strip.text but I would rather have full titles

I am sure there is a really simple solution to this but I can't figure it
out. If anyone could tell me how I can get long strip titles in xyplot to
wrap lines (without inserting \ns in them) I would appreciate it greatly.

Thanks!

Don Boyd

To be more concrete, here is sample code, stripped to its essentials. indf
is the factor that has very long text for some of its levels:

xyplot(emp ~ yearmo | indf,
  data = subset(empall, subset=(yearmo=as.Date(2006/12/01))),
  scales = list(relation=free, x = list(rot = 45)),
  type = b,
  par.strip.text = list(lines=2, cex=.6),
  layout=c(4,3),
  xlab=NULL,
  # put reference lines on the plot
  panel=function(...){
   panel.xyplot(...)
   panel.abline(h=seq(-10,5,by=1))
  }
  )

[[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] Number of CPU's

2009-08-25 Thread Håvard Rue
Any way to get access to the number of CPU's, optionally their type,
from within  R?   In linux I can just read /proc/cpuinfo  but for
win/mac ? 

Thanks!
Håvard

-- 
 Håvard Rue
 Department of Mathematical Sciences
 Norwegian University of Science and Technology
 N-7491 Trondheim, Norway
 Voice: +47-7359-3533URL  : http://www.math.ntnu.no/~hrue  
 Fax  : +47-7359-3524Email: havard@math.ntnu.no

 This message was created in a Microsoft-free computing environment.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fw: Re: Simulating data for sampling (stupid question)

2009-08-25 Thread KABELI MEFANE
Dear All
 
I know that you do not have to help me (as this is not a pure R problem) but 
please do, i am new to R as a CPI compiler, i just need to do a sample to see 
which sampling method best works in different situations, therefore since this 
is for practice purposes nobody will finance a real project thats why i need 
you to help me direct me as to how simulate data (just direct me,not 100% 
help). See my attachment for problem formulation, you can even suggest a 
different problem and how i can simulate it.
 
Problem Formulation: 
  
If I want to measure customer satisfaction on say 5000 business outlets that I 
supply with soft drink. The rating is on a 10 scale point where 1 is lowest and 
10 highest. The outlets range from 1 to 5 (1= big supermarkets, 2= medium, 3= 
Small,  4 = Mini markets, 5 = corner shops).  
  
Data: I have to simulate this sort of data for example 
  





Outlet type 


Population N

Average Buying Power (L/M)

Combined Average Buying

Proportions of total buying


1

50

31000

155

19.9100835


2

200

13500

270

34.6820809


3

350

4500

1575000

20.2312139


4

1000

600

60

7.70712909


5

3400

400

136

17.4694926


Total

5000

5

7785000

100


 

 

 

 

 


 

 

L/M =litres per month

 

 
  
This means I have to simulate 50 outlets of type 1 who buy  between say 2 
and 4 L/M, 200 outlets of type two buying 12000 – 1 L/M,… etc. Also 
I have to simulate ratings randomly from 1 to 10. 
  
I really do not know how to simulate data, after simulating I am going to use 
dollar stratification to sample this data to get info. I want to compare 
different sampling techniques to see which one is best. 
  
My objective is to sample from this data in such a way that my company will 
benefit from this survey. If I use SRS my survey results may show that 
customers are satisfied with average rating of 8, but this sample may not 
include my most valued customers who buy 19 to 54 percent of my stock 
 
Best Regards
R novice


  
[[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] Filling matrix secondary diagonal

2009-08-25 Thread Vaupo

Hi,

how do i fill the secondary diagonals of a matrix?
Is there an funktion like the diag funktion in matlab, where i can specify
the diagonal i´d like to fill?
 
-- 
View this message in context: 
http://www.nabble.com/Filling-matrix-secondary-diagonal-tp25121745p25121745.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] Between-group variance from ANOVA

2009-08-25 Thread emj83

I have done this in R and this is the following ANOVA table I get:

 summary(aov(response ~ group, data=TDat))
 Df  Sum Sq Mean Sq F valuePr(F)
group 1 11203.5 11203.5  2505.0  2.2e-16 ***
Residuals   198   885.5 4.5

The model is response(i,j)= group(i)+ error(i,j),

we assume that group~N(0,P^2) and error~N(0,sigma^2)

I know that sigma^2 is equal to 4.5, how do I find out P^2? 

In the problem that I am trying to apply this to, I have more than 2 groups.
I was hoping there would be a function that helps you do this that I don't
know about.


Thanks for your help Emma




Mark Difford wrote:
 
 Hi Emma,
 
 
 
 R gives you the tools to work this out.
 
 ## Example
 set.seed(7)
 TDat - data.frame(response = c(rnorm(100, 5, 2), rnorm(100, 20, 2)))
 TDat$group - gl(2, 100, labels=c(A,B))
 with(TDat, boxplot(split(response, group)))
 summary(aov(response ~ group, data=TDat))
 
 Regards, Mark.
 
 
 emj83 wrote:
 
 can anyone advise me please?
 
 
 emj83 wrote:
 
 I have done some ANOVA tables for some data that I have, from this I can
 read the within-group variance. can anyone tell me how i may find out
 the between-group variance?
 
 Thanks Emma
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Between-group-variance-from-ANOVA-tp24954045p25122960.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] Creating a simple line graph

2009-08-25 Thread PDXRugger

Hey everyone, 
   Sorry for yet another simple question but hopefully it makes whoever
comes up with the answer feel good about helping others.  I would like to
simply plot the following two sets of data in a line graph.  The one set is
an observed set of points and the latter is the predicted.  I have looked
through the documentation (which makes any graphing very complicated to me)
but i havent found what i need. So for:


Sz= c(h1,h2,h3,h4)
Pred=c(34790.0 ,47559.8, 21197.8, 28198.6)
Obs=c(34740 ,48615 ,20420, 26840)

MeanEst2000.Sz=cbind(Sz,Pred)
LaneCo2000HH.Sz =cbind(Sz,Obs)


 I would like the x-axis to display the labels(Sz) and the y-axis to be the
vlaues

I am currently using the below (wont work with sample data) which gives me
the proportions of the observed versus the predicted in four different
graphs in histogram format.

 panelHist(DataMatrix=t(apply(Hh2000.SnSz, 1, 4)),
   ObsMeans=proportion(rowSums(LaneCo2000HH.SzWk),4),
   Bounds=c(0.95, 1.05)
   )



Also, if there is additional documentation for these operations i would
appreciate any insights./  Thanks

-- 
View this message in context: 
http://www.nabble.com/Creating-a-simple-line-graph-tp25123681p25123681.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] Saving heatmaps as PDFs

2009-08-25 Thread dorothyc

Hi,

I'm trying to save heatmaps as PDFs.  However, the PDF version of the  
heatmaps (Heatmap_CAFvsTNF_run2.pdf) is blurred when compared to its  
counterpart, which was saved manually by using the software  
Grab (Heatmap_CAFvsTNF_run2.tiff).


 -R code
sample_output - stroma_run2
filename - exp_limma_results_final_probesets_Pbelowpoint05.txt

# read in data
my.data - read.delim(filename, sep=\t)
my.dataM -my.data[,2:ncol(my.data)]

	hr - hclust(as.dist(1-cor(t(my.dataM), method=pearson)),  
method=complete)
	hc - hclust(as.dist(1-cor(my.dataM, method=spearman)),  
method=complete)


 # generate heat map
library(gplots)

if  (is.null(sample_output)) {
pdf( Heatmap.pdf)
} else {
pdf(file=paste(Heatmap_, sample_output, .pdf, sep=)) }
  

	heatmap.2(as.matrix(my.dataM),Rowv=as.dendrogram(hr),  
Colv=as.dendrogram(hc),cexRow=0.01,
			cexCol=0.8, dendrogram=none, col=greenred(100),  
scale=row,key=TRUE, trace=none,density.info=none,

symkey=FALSE, main=paste(Heatmap_, sample_output))

   dev.off()

--

Thanks,
Dorothy

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fw: Re: Simulating data (stupid question)

2009-08-25 Thread KABELI MEFANE
Dear All
 
I know that you do not have to help me (as this is not a pure R problem) but 
please do, i am new to R as a CPI compiler, i just need to do a sample to see 
which sampling method best works in different situations, therefore since this 
is for practice purposes nobody will finance a real project thats why i need 
you to help me direct me as to how simulate data (just direct me,not 100% 
help). See my attachment for problem formulation, you can even suggest a 
different problem and how i can simulate it.
 
Problem Formulation: 
 
If I want to measure customer satisfaction on say 5000 business outlets that I 
supply with soft drink. The rating is on a 10 scale point where 1 is lowest and 
10 highest. The outlets range from 1 to 5 (1= big supermarkets, 2= medium, 3= 
Small,  4 = Mini markets, 5 = corner shops).  
 
Data: I have to simulate this sort of data for example
 





Outlet type

Population N

Average Buying Power (L/M)

Combined Average Buying

Proportions of total buying


1

50

31000

155

19.9100835


2

200

13500

270

34.6820809


3

350

4500

1575000

20.2312139


4

1000

600

60

7.70712909


5

3400

400

136

17.4694926


Total

5000

5

7785000

100


 

 

 

 

 


 

 

L/M =litres per month

 

 
 
This means I have to simulate 50 outlets of type 1 who buy  between say 2 
and 4 L/M, 200 outlets of type two buying 12000 – 1 L/M,… etc. Also 
I have to simulate ratings randomly from 1 to 10. 
 
I really do not know how to simulate data, after simulating I am going to use 
dollar stratification to sample this data to get info. I want to compare 
different sampling techniques to see which one is best.
 
My objective is to sample from this data in such a way that my company will 
benefit from this survey. If I use SRS my survey results may show that 
customers are satisfied with average rating of 8, but this sample may not 
include my most valued customers who buy 19 to 54 percent of my stock
 
Best Regards
R novice


  
[[alternative HTML version deleted]]

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


Re: [R] How to create a random matrix

2009-08-25 Thread Tal Galili
Here is another nice way of doing it:

replicate(10, rnorm(20))
# this will give you 10 columns of vectors with 20 random variables taken
from the normal distribution.

If any one got a faster way of doing this, please let me know.

Tal galili






On Tue, Aug 25, 2009 at 1:30 AM, Rolf Turner r.tur...@auckland.ac.nzwrote:


 On 25/08/2009, at 10:17 AM, Peng Yu wrote:

  Hi,

 I did a search but I was able to find how to generate a random matrix.
 Can somebody let me know how to do it?


 Uhhh, generate some random numbers and then arrange them in a matrix?

 ?matrix
 ?runif
 ?rnorm
 ?rgamma
   .
   .
   .

cheers,

Rolf Turner

 ##
 Attention:\ This e-mail message is privileged and confid...{{dropped:9}}


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




-- 
--


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
http://www.r-statistics.com/
http://www.talgalili.com
http://www.biostatistics.co.il

[[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] [] for R

2009-08-25 Thread kfcnhl

I am assuming the variable out is the output parameter.
However, I don't understand what is  out[1+xi*xx0]?
Can someone explain this to me?

Thanks in advance,
Chen


dGEV - function(x, xi, mu = 0, sigma = 1, logvalue=FALSE)
  {
xx - (x-mu)/sigma
#use the new dGumbel which passes mu and sigma:
#if (xi==0) out - dGumbel(xx,logvalue=TRUE)-log(sigma)
if (xi==0) {
   return(out - dGumbel(x, mu, sigma, logvalue));
}

else
  { out - rep(-Inf,length(x))
out[1+xi*xx0] - (-1/xi-1)*log(1+xi*xx[1+xi*xx0]) -
(1+xi*xx[1+xi*xx0])^(-1/xi) -log(sigma)
  }
if (!(logvalue))
  out - exp(out)
out
  }
-- 
View this message in context: 
http://www.nabble.com/---for-R-tp25118139p25118139.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] Creating a simple line graph

2009-08-25 Thread Liviu Andronic
Hello
I couldn't quite understand exactly what graph you are looking for, so
I'd be unable to provide code. Couple of pointers, though.
- Put your data into a data frame and look at Rcmdr Graphs menu. It
can do many types of them, and it should give you enough examples to
get started with.
- Try plot(x, y) and see if it satisfies your needs
- Once you get working the command, try say playwith(plot(x, y))
- Quick-R [1] contains many good examples for beginners.
Best
Liviu

[1] http://www.statmethods.net/graphs/index.html


On 8/24/09, PDXRugger j_r...@hotmail.com wrote:

  Hey everyone,
Sorry for yet another simple question but hopefully it makes whoever
  comes up with the answer feel good about helping others.  I would like to
  simply plot the following two sets of data in a line graph.  The one set is
  an observed set of points and the latter is the predicted.  I have looked
  through the documentation (which makes any graphing very complicated to me)
  but i havent found what i need. So for:


  Sz= c(h1,h2,h3,h4)
  Pred=c(34790.0 ,47559.8, 21197.8, 28198.6)
  Obs=c(34740 ,48615 ,20420, 26840)

  MeanEst2000.Sz=cbind(Sz,Pred)
  LaneCo2000HH.Sz =cbind(Sz,Obs)


   I would like the x-axis to display the labels(Sz) and the y-axis to be the
  vlaues

  I am currently using the below (wont work with sample data) which gives me
  the proportions of the observed versus the predicted in four different
  graphs in histogram format.

   panelHist(DataMatrix=t(apply(Hh2000.SnSz, 1, 4)),
ObsMeans=proportion(rowSums(LaneCo2000HH.SzWk),4),
Bounds=c(0.95, 1.05)
)



  Also, if there is additional documentation for these operations i would
  appreciate any insights./  Thanks

  --
  View this message in context: 
 http://www.nabble.com/Creating-a-simple-line-graph-tp25123681p25123681.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.



-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [Rd] Formulas in gam function of mgcv package

2009-08-25 Thread Corrado
Dear Gavin / Rlings,

thanks for your kind answer and sorry for posting to the dev mailing list.

Concerning the specific of your answer:

I am working with 6 to 36 covariates, and they are all centred and scaled. I 
represented the problem with two variables to simplify the question.

So ideally, the situation is:

1) y ~ s(x1) +  + s(x36)

vs.

2) y~s(x1,  ,x36)

I am trying to build a predictive model. Since the the variables are centred 
and scaled, I think I need an isotropic smooth. I am also interested in having 
the interactions between the variables included, that is not a purely additive 
model.

It is not clear to me when should I give preference to tensor smooths, 
possibly because I have not understood well how they work.

I am reading Wood(2003) as recommended and I have also read rather extensively 
Simon N. Wood. Generalized Additive Models: An Introduction, 2006, but still I 
am stuck. Any additional suggestion or reading recommendation would be greatly 
appreciated.

I have also some difficulties in understanding the values you have chosen for k 
in the first example (why 60?).

Thanks

Best,



On Monday 24 August 2009 17:33:55 Gavin Simpson wrote:
 [Note R-Devel is the wrong list for such questions. R-Help is where this
 should have been directed - redirected there now]

 On Mon, 2009-08-24 at 17:02 +0100, Corrado wrote:
  Dear R-experts,
 
  I have a question on the formulas used in the gam function of the mgcv
  package.
 
  I am trying to understand the relationships between:
 
  y~s(x1)+s(x2)+s(x3)+s(x4)
 
  and
 
  y~s(x1,x2,x3,x4)
 
  Does the latter contain the former? what about the smoothers of all
  interaction terms?

 I'm not 100% certain how this scales to smooths of more than 2
 variables, but Sections 4.10.2 and 5.2.2 of Simon Wood's book GAM: An
 Introduction with R (2006, Chapman Hall/CRC) discuss this for smooths of
 2 variables.

 Strictly y ~ s(x1) + s(x2) is not nested in y ~ s(x1, x2) as the bases
 used to produce the smoothers in the two models may not be the same in
 both models. One option to ensure nestedness is to fit the more
 complicated model as something like this:

 ## if simpler model were: y ~ s(x1, k=20) + s(x2, k = 20)
 y ~ s(x1, k=20) + s(x2, k = 20) + s(x1, x2, k = 60)
   ^
 where the last term (^^^ above) has the same k as used in s(x1, x2)

 Note that these are isotropic smooths; are x1 and x2 measured in the
 same units etc.? Tensor product smooths may be more appropriate if not,
 and if we specify the bases when fitting models s(x1) + s(x2) *is*
 strictly nested in te(x1, x2), eg.

 y ~ s(x1, bs = cr, k = 10) + s(x2, bs = cr, k = 10)

 is strictly nested within

 y ~ te(x1, x2, k = 10)
 ## is the same as y ~ te(x1, x2, bs = cr, k = 10)

 [Note that bs = cr is the default basis in te() smooths, hence we
 don't need to specify it, and k = 10 refers to each individual smooth in
 the te().]

 HTH

 G

  I have (tried to) read the manual pages of gam, formula.gam,
  smooth.terms, linear.functional.terms but could not understand properly.
 
  Regards



-- 
Corrado Topi

Global Climate Change  Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.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.


[R] Odp: Re : table function

2009-08-25 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 25.08.2009 10:08:36:

 Hi Mark,
 
 
 Thank you for your answer !! it works but if i have NA in the vector z 
what 
 i shoud do to count its number in Z?

You do not have NA in z, you manage to convert it somehow to factor. 
Please try to read about data types and its behaviour. Start with this 
chapter
2.8 Other types of objects
in R intro manual which I suppose you have in doc folder of R program 
directory. You possibly can convert it back to numeric by

e.g.

DF$z - as.numeric(as.character(DF$z))

but I presume you need to check your original data maybe by

str(your.data) what mode they are and why they are factor if you expect 
them numeric.

Regards
Petr

 x  yz
  10  100
  51  1500
  61  NA
  22  500
  11  NA
  522000
  854500
  
 
 i did the same but it gives me this error  message:
  [0 - 1000] [1000 - 3000] 3000 
 0 0 0 
 Warning message:
 In inherits(x, factor) : NAs introduced by coercion
 
 
 Thank you 
 
 
 
 De : Marc Schwartz marc_schwa...@me.com
 
 Cc : r-help@r-project.org
 Envoyé le : Lundi, 24 Aoűt 2009, 18h33mn 52s
 Objet : Re: [R] table function
 
 On Aug 24, 2009, at 10:59 AM, Inchallah Yarab wrote:
 
  hi,
  
  i want to use the function table to build a table not of frequence 
(number 
 of time the vareable is repeated in a list or a data frame!!) but in 
function of classes
 [[elided Yahoo spam]]
  
  example
  
  x  yz
  10  100
  51  1500
  61  1200
  22  500
  11  3500
  522000
  854500
  
  i want to do a table summerizing the number of variable where z is in 
 [0-1000],],[1000-3000], [ 3000]
  
  thank you very much for your help
 
 
 See ?cut, which bins a continuous variable.
 
  DF
   x yz
 1 1 0  100
 2 5 1 1500
 3 6 1 1200
 4 2 2  500
 5 1 1 3500
 6 5 2 2000
 7 8 5 4500
 
 
  table(cut(DF$z, breaks = c(-Inf, 1000, 3000, Inf),
 labels = c(0 - 1000, 1000 - 3000, 3000)))
 
 0 - 1000 1000 - 30003000
   232
 
 HTH,
 
 Marc Schwartz
 
 
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

2009-08-25 Thread Tal Galili
Try playing with the
width, height
of the pdf()

Tal





On Tue, Aug 25, 2009 at 2:04 AM, dorothyc dorot...@bcgsc.ca wrote:

 Hi,

 I'm trying to save heatmaps as PDFs.  However, the PDF version of the
 heatmaps (Heatmap_CAFvsTNF_run2.pdf) is blurred when compared to its
 counterpart, which was saved manually by using the software Grab
 (Heatmap_CAFvsTNF_run2.tiff).

  -R code
sample_output - stroma_run2
filename - exp_limma_results_final_probesets_Pbelowpoint05.txt

# read in data
my.data - read.delim(filename, sep=\t)
my.dataM -my.data[,2:ncol(my.data)]

hr - hclust(as.dist(1-cor(t(my.dataM), method=pearson)),
 method=complete)
hc - hclust(as.dist(1-cor(my.dataM, method=spearman)),
 method=complete)

 # generate heat map
library(gplots)

if  (is.null(sample_output)) {
pdf( Heatmap.pdf)
} else {
pdf(file=paste(Heatmap_, sample_output, .pdf, sep=)) }


heatmap.2(as.matrix(my.dataM),Rowv=as.dendrogram(hr),
 Colv=as.dendrogram(hc),cexRow=0.01,
cexCol=0.8, dendrogram=none, col=greenred(100),
 scale=row,key=TRUE, trace=none,density.info=none,
symkey=FALSE, main=paste(Heatmap_, sample_output))

   dev.off()

 --

 Thanks,
 Dorothy

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




-- 
--


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
http://www.r-statistics.com/
http://www.talgalili.com
http://www.biostatistics.co.il

[[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] Odp: Fw: Re: Simulating data for sampling (stupid question)

2009-08-25 Thread Petr PIKAL
Well

you shall consult (surprisingly :-)

?sample function

and for rating

?runif function
as was pointed out earlier

Regards
Petr


r-help-boun...@r-project.org napsal dne 25.08.2009 05:14:00:

 Dear All
 Â 
 I know that you do not have to help me (as this is not a pure R 
problem)Â but 
 please do, i am new to R as a CPI compiler, i just need to do a sample 
to see 
 which sampling method best works in different situations, therefore 
since this
 is for practice purposes nobody will finance a real project thats why i 
need 
 you to help me direct me as to how simulate data (just direct me,not 
100% 
 help). See my attachment for problem formulation, you can even suggest a 

 different problem and how i can simulate it.
 Â 
 Problem Formulation: 
 Â  
 If I want to measure customer satisfaction on say 5000 business outlets 
that I
 supply with soft drink. The rating is on a 10 scale point where 1 is 
lowest 
 and 10 highest. The outlets range from 1 to 5 (1= big supermarkets, 2= 
medium,
 3= Small,  4 = Mini markets, 5 = corner shops).  
 Â  
 Data: I have to simulate this sort of data for example 
 Â  
 
 
 
 
 
 Outlet type 
 
 
 Population N
 
 Average Buying Power (L/M)
 
 Combined Average Buying
 
 Proportions of total buying
 
 
 1
 
 50
 
 31000
 
 155
 
 19.9100835
 
 
 2
 
 200
 
 13500
 
 270
 
 34.6820809
 
 
 3
 
 350
 
 4500
 
 1575000
 
 20.2312139
 
 
 4
 
 1000
 
 600
 
 60
 
 7.70712909
 
 
 5
 
 3400
 
 400
 
 136
 
 17.4694926
 
 
 Total
 
 5000
 
 5
 
 7785000
 
 100
 
 
 Â 
 
 Â 
 
 Â 
 
 Â 
 
 Â 
 
 
 Â 
 
 Â 
 
 L/M =litres per month
 
 Â 
 
 Â 
 Â  
 This means I have to simulate 50 outlets of type 1 who buy  between say 
2
 and 4 L/M, 200 outlets of type two buying 12000 – 1 L/M,… 
etc. 
 Also I have to simulate ratings randomly from 1 to 10. 
 Â  
 I really do not know how to simulate data, after simulating I am going 
to use 
 dollar stratification to sample this data to get info. I want to compare 

 different sampling techniques to see which one is best. 
 Â  
 My objective is to sample from this data in such a way that my company 
will 
 benefit from this survey. If I use SRS my survey results may show that 
 customers are satisfied with average rating of 8, but this sample may 
not 
 include my most valued customers who buy 19 to 54 percent of my stock 
 Â 
 Best Regards
 R novice
 
 
 
[[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] Re : Odp: Re : table function

2009-08-25 Thread Inchallah Yarab
 
Thank you Peter,
in my vector Z i have missing value NA and i want to count its number in the 
vector 
i had did alla this i know the difference between a numeirc and a factor 
the goal of this exercice that to count the number of missing value, number 
betwwen 0-1000 , 1000-3000, 3000.

Thank you again for your help





De : Petr PIKAL petr.pi...@precheza.cz

Cc : r-help@r-project.org
Envoyé le : Mardi, 25 Août 2009, 11h15mn 23s
Objet : Odp: [R] Re : table function

Hi

r-help-boun...@r-project.org napsal dne 25.08.2009 10:08:36:

 Hi Mark,
 
 
 Thank you for your answer !! it works but if i have NA in the vector z
what 
 i shoud do to count its number in Z?

You do not have NA in z, you manage to convert it somehow to factor. 
Please try to read about data types and its behaviour. Start with this 
chapter
2.8 Other types of objects
in R intro manual which I suppose you have in doc folder of R program 
directory. You possibly can convert it back to numeric by

e.g.

DF$z - as.numeric(as.character(DF$z))

but I presume you need to check your original data maybe by

str(your.data) what mode they are and why they are factor if you expect 
them numeric.

Regards
Petr

 x      y        z
  1    0      100
  5    1      1500
  6    1      NA
  2    2      500
  1    1      NA
  5    2    2000
  8    5    4500
  
 
 i did the same but it gives me this error  message:
  [0 - 1000] [1000 - 3000]        3000 
            0            0            0 
 Warning message:
 In inherits(x, factor) : NAs introduced by coercion
 
 
 Thank you 
 
 
 
 De : Marc Schwartz marc_schwa...@me.com
 
 Cc : r-help@r-project.org
 Envoyé le : Lundi, 24 Aoűt 2009, 18h33mn 52s
 Objet : Re: [R] table function
 
 On Aug 24, 2009, at 10:59 AM, Inchallah Yarab wrote:
 
  hi,
  
  i want to use the function table to build a table not of frequence 
(number 
 of time the vareable is repeated in a list or a data frame!!) but in 
function of classes
 [[elided Yahoo spam]]
  
  example
  
  x      y        z
  1    0      100
  5    1      1500
  6    1      1200
  2    2      500
  1    1      3500
  5    2    2000
  8    5    4500
  
  i want to do a table summerizing the number of variable where z is in
 [0-1000],],[1000-3000], [ 3000]
  
  thank you very much for your help
 
 
 See ?cut, which bins a continuous variable.
 
  DF
  x y    z
 1 1 0  100
 2 5 1 1500
 3 6 1 1200
 4 2 2  500
 5 1 1 3500
 6 5 2 2000
 7 8 5 4500
 
 
  table(cut(DF$z, breaks = c(-Inf, 1000, 3000, Inf),
            labels = c(0 - 1000, 1000 - 3000, 3000)))
 
    0 - 1000 1000 - 3000        3000
          2            3            2
 
 HTH,
 
 Marc Schwartz
 
 
 
    [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


  
[[alternative HTML version deleted]]

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


Re: [R] Creating a simple line graph

2009-08-25 Thread Petr PIKAL
Hi

Do not use cbind as it results in matrix and it can have only data of one 
type, in your case character. Use 

MeanEst2000.Sz=data.frame(Sz,Pred) 

instead. And you probably could go step further to put everything into one 
data frame

DF - data.frame(Sz,Pred, Obs)
then 

with(DF, plot(Pred, Obs, axes=F))
axis(2)
axis(1, at=DF$Pred, DF$Sz)
box()

Regards
Petr

r-help-boun...@r-project.org napsal dne 25.08.2009 10:51:16:

 Hello
 I couldn't quite understand exactly what graph you are looking for, so
 I'd be unable to provide code. Couple of pointers, though.
 - Put your data into a data frame and look at Rcmdr Graphs menu. It
 can do many types of them, and it should give you enough examples to
 get started with.
 - Try plot(x, y) and see if it satisfies your needs
 - Once you get working the command, try say playwith(plot(x, y))
 - Quick-R [1] contains many good examples for beginners.
 Best
 Liviu
 
 [1] http://www.statmethods.net/graphs/index.html
 
 
 On 8/24/09, PDXRugger j_r...@hotmail.com wrote:
 
   Hey everyone,
 Sorry for yet another simple question but hopefully it makes 
whoever
   comes up with the answer feel good about helping others.  I would 
like to
   simply plot the following two sets of data in a line graph.  The one 
set is
   an observed set of points and the latter is the predicted.  I have 
looked
   through the documentation (which makes any graphing very complicated 
to me)
   but i havent found what i need. So for:
 
 
   Sz= c(h1,h2,h3,h4)
   Pred=c(34790.0 ,47559.8, 21197.8, 28198.6)
   Obs=c(34740 ,48615 ,20420, 26840)
 
   MeanEst2000.Sz=cbind(Sz,Pred)
   LaneCo2000HH.Sz =cbind(Sz,Obs)
 
 
I would like the x-axis to display the labels(Sz) and the y-axis to 
be the
   vlaues
 
   I am currently using the below (wont work with sample data) which 
gives me
   the proportions of the observed versus the predicted in four 
different
   graphs in histogram format.
 
panelHist(DataMatrix=t(apply(Hh2000.SnSz, 1, 4)),
 ObsMeans=proportion(rowSums(LaneCo2000HH.SzWk),4),
 Bounds=c(0.95, 1.05)
 )
 
 
 
   Also, if there is additional documentation for these operations i 
would
   appreciate any insights./  Thanks
 
   --
   View this message in context: 
http://www.nabble.com/Creating-a-simple-line-
 graph-tp25123681p25123681.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.
 
 
 
 -- 
 Do you know how to read?
 http://www.alienetworks.com/srtest.cfm
 Do you know how to write?
 http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Help on comparing two matrices

2009-08-25 Thread Michael Kogan
David: Ah, so that was the reason! I didn't realize that. :) Ok, so I 
try to go through the code and understand it:


The last line seems to bring the rows into the order given by the 
order command. But how does the order command get the order? Lets look 
into the order function: the Reduce function is applied to all seven 
rows by the sapply command. Which itself  does what?  Reduce(paste, 
sm[x,]) seems to paste all rows while paste means just write next to 
each other as string. So we get one big string consisting of all the 7 
rows inside the order function. But how does the order function get this 
order [1] 7 6 1 3 5 2 4 out of this big string? Sorry, I'm doing my best 
to understand it... :(


Daniel: I think I understand your idea (though not the code yet). So if 
the matrix dimensions are x=x3+x4+x5... and y=y3+y4+y5... (where x_i is 
the number of rows with the sum i) then x3!x4!x5!...y3!y4!y5!... 
combinations have to be checked in the worst case if the matrices are 
equivalent (or in each case if they're not). I think it's a bit 
computationally intensive (since the comparison algorithm has to be used 
many times on many matrices) but if everything else fails, it will do. :)


Thanks to all for your help!
Michael

David Winsemius schrieb:


On Aug 24, 2009, at 4:01 PM, Michael Kogan wrote:

David: Well, e.g. the first row has 2 ones in your output while there 
were no rows with 2 ones in the original matrix. Since the row and 
column sums can't be changed by sorting them, the output matrix can't 
be equivalent to the original one. But that means nothing, maybe it's 
intended and just for comparison reasons? :) But I don't get how the 
ones can get lost by making a string out of the row values...


OK, so shoot me.  I screwed up and forgot to use byrow=TRUE in my scan 
operation. So I ended up with a different starting matrix than you. 
This is what it should have looked like:


 sm - matrix(scan(textConnection(
+ 01110110
+ 11000101
+ 10100011
+ 11001000
+ 10111000
+ 01011000
+ 00000111)), 7, 8, byrow=TRUE)
Read 56 items
 sm
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]01110110
[2,]11000101
[3,]10100011
[4,]11001000
[5,]10111000
[6,]01011000
[7,]00000111
 order(sapply(1:7, function(x) Reduce(paste, sm[x,])) )
[1] 7 6 1 3 5 2 4
 sm[order(sapply(1:7, function(x) Reduce(paste, sm[x,])) ), ]
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]00000111
[2,]01011000
[3,]01110110
[4,]10100011
[5,]10111000
[6,]11000101
[7,]11001000

The process creates a sorted index and then just outputs rows from the 
original matrix, so there cannot be any row that was not there at the 
start. Gabor's solution will do the same operation and certainly looks 
more elegant than mine. (His input operation did the same mutilation 
on your input string as did mine.)




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

2009-08-25 Thread ogbos okike
Good day to you all,
I have lightning data containing date, time, latitude and longitude. I hope
that distribution of latitude and longitude will give number of lightning
occurrence in a region. I have used factor function to sum up the number of
events on latitude and longitude axis and saved as x and y. But when I tried
to plot the two, I had and error message ( Error in image.default(x, y, z) :
increasing 'x' and 'y' values expected). Every other effort I made failed to
be successful - please I am a new user of R. Part of the data I am using is:

latlon
-5.1821 147.4462
-5.1826 147.3733
-5.1680 147.3855
31.4489 -63.2175
28.3199 -62.1831
-18.2495 -44.6471
-11.3654 -42.8249
-2.6652 -73.2344
-13.3543 -56.5338
27.9594 -157.9413
29.4454 -62.0620
-5.1953 116.0678
31.7057 -62.7211
-15.6194 124.6710
-7.1434 -72.2230
-19.1066 -45.6655
I would be extremely grateful should anyone be king enough as to guide me on
how to handle this plot.
Thank you for any help.
Ogbos

[[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] Odp: Re : Odp: Re : table function

2009-08-25 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 25.08.2009 11:28:31:

 Â 
 Thank you Peter,
 in my vector Z i have missing value NA and i want to count its number 
in the vector 
 i had did alla this i know the difference between a numeirc and a factor 


OK. If you know difference between factor and numeric you probably have 
seen
?factor
where is note about how to make NA an extra level

#Here is z
z-c(10,100, 1000, 1200, 2000, 2200, 3000, 3200, 5000, 6000)
#let's put some NA values into it
z[c(2,5)] -NA
#let's make a cut
z.c-cut(z, breaks = c(-Inf, 1000, 3000, Inf), labels = c(0 - 1000, 
1000 - 3000, 3000))
#as you see there are NA values but they are not extra level
z.c
 [1] 0 - 1000 NA 0 - 1000 1000 - 3000 NA 
 [6] 1000 - 3000 1000 - 3000 300030003000 
Levels: 0 - 1000 1000 - 3000 3000
is.na(z.c)
 [1] FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE

# so let's try what help page says
 factor(z.c, exclude=NULL)
 [1] 0 - 1000 NA 0 - 1000 1000 - 3000 NA 
 [6] 1000 - 3000 1000 - 3000 300030003000 
Levels: 0 - 1000 1000 - 3000 3000 NA
# wow we have NA as extra level, let's do table
table(factor(z.c, exclude=NULL))

0 - 1000 1000 - 30003000 NA 
   2332 

Regards
Petr


 the goal of this exercice that to count the number of missing value, 
number 
 betwwen 0-1000 , 1000-3000, 3000.
 
 Thank you again for your help
 
 
 
 
 
 De : Petr PIKAL petr.pi...@precheza.cz
 
 Cc : r-help@r-project.org
 Envoyé le : Mardi, 25 Août 2009, 11h15mn 23s
 Objet : Odp: [R] Re : table function
 
 Hi
 
 r-help-boun...@r-project.org napsal dne 25.08.2009 10:08:36:
 
  Hi Mark,
  
  
  Thank you for your answer !! it works but if i have NA in the vector 
z
 what 
  i shoud do to count its number in Z?
 
 You do not have NA in z, you manage to convert it somehow to factor. 
 Please try to read about data types and its behaviour. Start with this 
 chapter
 2.8 Other types of objects
 in R intro manual which I suppose you have in doc folder of R program 
 directory. You possibly can convert it back to numeric by
 
 e.g.
 
 DF$z - as.numeric(as.character(DF$z))
 
 but I presume you need to check your original data maybe by
 
 str(your.data) what mode they are and why they are factor if you expect 
 them numeric.
 
 Regards
 Petr
 
  x      y        z
   1Â  Â  0Â  Â  Â  100
   5Â  Â  1Â  Â  Â  1500
   6Â  Â  1Â  Â  Â  NA
   2Â  Â  2Â  Â  Â  500
   1Â  Â  1Â  Â  Â  NA
   5Â  Â  2Â  Â  2000
   8Â  Â  5Â  Â  4500
   
  
  i did the same but it gives me this error  message:
 Â  [0 - 1000] [1000 - 3000]Â  Â  Â  Â  3000 
 Â  Â  Â  Â  Â  Â  0Â  Â  Â  Â  Â  Â  0Â  Â  Â  Â  Â  Â  0 
  Warning message:
  In inherits(x, factor) : NAs introduced by coercion
  
  
  Thank you 
  
  
  
  De : Marc Schwartz marc_schwa...@me.com
  
  Cc : r-help@r-project.org
  Envoyé le : Lundi, 24 Aoűt 2009, 18h33mn 52s
  Objet : Re: [R] table function
  
  On Aug 24, 2009, at 10:59 AM, Inchallah Yarab wrote:
  
   hi,
   
   i want to use the function table to build a table not of frequence 
 (number 
  of time the vareable is repeated in a list or a data frame!!) but in 
 function of classes
  [[elided Yahoo spam]]
   
   example
   
   x      y        z
   1Â  Â  0Â  Â  Â  100
   5Â  Â  1Â  Â  Â  1500
   6Â  Â  1Â  Â  Â  1200
   2Â  Â  2Â  Â  Â  500
   1Â  Â  1Â  Â  Â  3500
   5Â  Â  2Â  Â  2000
   8Â  Â  5Â  Â  4500
   
   i want to do a table summerizing the number of variable where z is 
in
  [0-1000],],[1000-3000], [ 3000]
   
   thank you very much for your help
  
  
  See ?cut, which bins a continuous variable.
  
   DF
   x y    z
  1 1 0Â  100
  2 5 1 1500
  3 6 1 1200
  4 2 2Â  500
  5 1 1 3500
  6 5 2 2000
  7 8 5 4500
  
  
   table(cut(DF$z, breaks = c(-Inf, 1000, 3000, Inf),
 Â  Â  Â  Â  Â  Â  labels = c(0 - 1000, 1000 - 3000, 3000)))
  
 Â  Â  0 - 1000 1000 - 3000Â  Â  Â  Â  3000
 Â  Â  Â  Â  Â  2Â  Â  Â  Â  Â  Â  3Â  Â  Â  Â  Â  Â  2
  
  HTH,
  
  Marc Schwartz
  
  
  
 Â  Â  [[alternative HTML version deleted]]
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

Re: [R] problem with BRugs

2009-08-25 Thread Vitalie S.

Hello Uwe,

Just a related question, OpenBugs is using C and T for Censoring and  
Truncation. But this does not seem to work with BRugs.


I am using this document  
http://mathstat.helsinki.fi/openbugs/Manuals/ModelSpecification.html#TheBUGSLanguageStochasticNodes


Thanks,
Vitalie.

On Tue, 25 Aug 2009 10:00:44 +0200, Uwe Ligges  
lig...@statistik.tu-dortmund.de wrote:





R Heberto Ghezzo, Dr wrote:
Hello, I am sorry, I have this problem before and Uwe send me the  
answer but I misplaced it


Oh dear! But it is not lost, since the answer to the second part of your  
problem was: Please read the documentation!




and can not find it.

  writing a model for BRugs



library(BRugs)

Loading required package: coda
Loading required package: lattice
Welcome to BRugs running on OpenBUGS version 3.0.3

setwd(c:/tmp)

Error in setwd(c:/tmp) : cannot change working directory



So c:/tmp does not exist or you don't have permissions there?



mo - function(){

+   for (k in 1:p){
+ delta[1,k] ~ dnorm(0,0.1)I(,delta[2,k])
Error: unexpected symbol in:


The answer was: Please read the documentation!

?writeModel (which you want to use on this function) tells you:

As a difference, BUGS syntax allows truncation specification like this:  
dnorm(...) I(...) but this is illegal in R. To overcome this  
incompatibility, use %_% before I(...): dnorm(...) %_% I(...). The dummy  
operator %_% will be removed before the BUGS code is saved. 




  for (k in 1:p){
delta[1,k] ~ dnorm(0,0.1)I

delta[2,k] ~ dnorm(0,0.1)I(delta[1,k],delta[3,k])

Error: unexpected symbol in delta[2,k] ~ dnorm(0,0.1)I

delta[3,k] ~ dnorm(0,0.1)I(delta[2,k],)}

Error: unexpected symbol in delta[3,k] ~ dnorm(0,0.1)I

}

Error: unexpected '}' in }
 so R parser does not like the I(,) construct


which is *not* the problem, see above.


Best wishes,
Uwe



, What is the alternative way of propgramming the
constrain I(lower,upper)
Thanks
Heberto Ghezzo
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide  
http://www.R-project.org/posting-guide.html

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


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

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



--

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


Re: [R] [] for R

2009-08-25 Thread Vitalie S.

see ?[

  For '['-indexing only: 'i, j, ...' can be logical vectors,
  indicating elements/slices to select.  Such vectors are
  recycled if necessary to match the corresponding extent.  'i,
  j, ...' can also be negative integers, indicating
  elements/slices to leave out of the selection.

so 1+xi*xx0 is a logical vector.




On Mon, 24 Aug 2009 17:33:36 +0200, kfcnhl zhengchenj...@hotmail.com  
wrote:




I am assuming the variable out is the output parameter.
However, I don't understand what is  out[1+xi*xx0]?
Can someone explain this to me?

Thanks in advance,
Chen


dGEV - function(x, xi, mu = 0, sigma = 1, logvalue=FALSE)
  {
xx - (x-mu)/sigma
#use the new dGumbel which passes mu and sigma:
#if (xi==0) out - dGumbel(xx,logvalue=TRUE)-log(sigma)
if (xi==0) {
   return(out - dGumbel(x, mu, sigma, logvalue));
}

else
  { out - rep(-Inf,length(x))
out[1+xi*xx0] - (-1/xi-1)*log(1+xi*xx[1+xi*xx0]) -
(1+xi*xx[1+xi*xx0])^(-1/xi) -log(sigma)
  }
if (!(logvalue))
  out - exp(out)
out
  }



--

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] robust method to obtain a correlation coeff?

2009-08-25 Thread Martin Maechler
 JK == John Kane jrkrid...@yahoo.ca
 on Mon, 24 Aug 2009 10:01:56 -0700 (PDT) writes:

JK I may be misunderstanding the question but would cor(d1,
JK use='complete.obs') or some other variant of use help?

Yes!  I've been a bit appalled to read that nobody else gave
this (in my view  *the correct* !) answer.

Leaving away NA's via na.omit() or similar is more general, but
for cor() definitely less flexible!

Martin Maechler, ETH Zurich


JK --- On Mon, 8/24/09, Christian Meesters
JK meest...@imbie.uni-bonn.de wrote:

 From: Christian Meesters meest...@imbie.uni-bonn.de
 Subject: [R] robust method to obtain a correlation coeff?
 To: r-help@r-project.org Help r-help@r-project.org
 Received: Monday, August 24, 2009, 10:47 AM Hi,
 
 Being a R-newbie I am wondering how to calculate a
 correlation coefficient (preferably with an associated
 p-value) for data like:
 
  d[,1] [1] 25.5 25.3 25.1   NA 23.3 21.5 23.8 23.2 24.2
 22.7 27.6 24.2 ...   d[,2] [1]  0.0 11.1  0.0   NA  0.0
 10.1 10.6  9.5  0.0 57.9  0.0  0.0  ...
 
 Apparently corr(d) from the boot-library fails with NAs
 in the data, also cor.test cannot cope with a different
 number of NAs.  Is there a solution to this problem
 (calculating a correlation coefficient and ignoring
 different number of NAs), e.g. Pearson's corr coeff?
 
 If so, please point me to the relevant piece of
 documentation.
 
 TIA Christian
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do
 read the posting guide
 http://www.R-project.org/posting-guide.html and provide
 commented, minimal, self-contained, reproducible code.
 


  __
JK Be smarter than spam. See how smart SpamGuard is ons in
JK Mail and switch to New Mail today or register for free
JK at http://mail.yahoo.ca

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

2009-08-25 Thread Uwe Ligges



Vitalie S. wrote:

Hello Uwe,

Just a related question, OpenBugs is using C and T for Censoring and 
Truncation. But this does not seem to work with BRugs.


I am using this document 
http://mathstat.helsinki.fi/openbugs/Manuals/ModelSpecification.html#TheBUGSLanguageStochasticNodes 




What's the problem? Error message? Reproducible code?

Specifying, e.g.

model - function()
x ~ dnorm(mu, tau)%_%T(lower, upper)
writeModel(model)

works for me.

Best,
Uwe





Thanks,
Vitalie.

On Tue, 25 Aug 2009 10:00:44 +0200, Uwe Ligges 
lig...@statistik.tu-dortmund.de wrote:





R Heberto Ghezzo, Dr wrote:
Hello, I am sorry, I have this problem before and Uwe send me the 
answer but I misplaced it


Oh dear! But it is not lost, since the answer to the second part of 
your problem was: Please read the documentation!




and can not find it.

  writing a model for BRugs



library(BRugs)

Loading required package: coda
Loading required package: lattice
Welcome to BRugs running on OpenBUGS version 3.0.3

setwd(c:/tmp)

Error in setwd(c:/tmp) : cannot change working directory



So c:/tmp does not exist or you don't have permissions there?



mo - function(){

+   for (k in 1:p){
+ delta[1,k] ~ dnorm(0,0.1)I(,delta[2,k])
Error: unexpected symbol in:


The answer was: Please read the documentation!

?writeModel (which you want to use on this function) tells you:

As a difference, BUGS syntax allows truncation specification like 
this: dnorm(...) I(...) but this is illegal in R. To overcome this 
incompatibility, use %_% before I(...): dnorm(...) %_% I(...). The 
dummy operator %_% will be removed before the BUGS code is saved. 




  for (k in 1:p){
delta[1,k] ~ dnorm(0,0.1)I

delta[2,k] ~ dnorm(0,0.1)I(delta[1,k],delta[3,k])

Error: unexpected symbol in delta[2,k] ~ dnorm(0,0.1)I

delta[3,k] ~ dnorm(0,0.1)I(delta[2,k],)}

Error: unexpected symbol in delta[3,k] ~ dnorm(0,0.1)I

}

Error: unexpected '}' in }
 so R parser does not like the I(,) construct


which is *not* the problem, see above.


Best wishes,
Uwe



, What is the alternative way of propgramming the
constrain I(lower,upper)
Thanks
Heberto Ghezzo
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

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


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

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





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


[R] table, sum, cat function

2009-08-25 Thread Inchallah Yarab
Hi,

the second step in my exercice is to calculate the sum of the amout for each 
class et not the frequency 

i have this vector

x   y
1  100
2  1500 
3  3250
4  6250
5  2000
6   450


i want to use the function table and cat to calculate the sum of the amount in 
each class [0-1000], [1000-3000],[ 3000]

Thank you for your help??

inchallah


  
[[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] Re : Odp: Re : Odp: Re : table function

2009-08-25 Thread Inchallah Yarab
Thank you very much Peter it works!!

the second step is to calculate the sum of variable in each class!!!

how can i do this!!!

thank you in advance

inchallah





De : Petr PIKAL petr.pi...@precheza.cz

Cc : r-help@r-project.org
Envoyé le : Mardi, 25 Août 2009, 11h53mn 21s
Objet : Odp: [R] Re : Odp: Re : table function

Hi

r-help-boun...@r-project.org napsal dne 25.08.2009 11:28:31:

 Â 
 Thank you Peter,
 in my vector Z i have missing value NA and i want to count its number
in the vector 
 i had did alla this i know the difference between a numeirc and a factor


OK. If you know difference between factor and numeric you probably have 
seen
?factor
where is note about how to make NA an extra level

#Here is z
z-c(10,100, 1000, 1200, 2000, 2200, 3000, 3200, 5000, 6000)
#let's put some NA values into it
z[c(2,5)] -NA
#let's make a cut
z.c-cut(z, breaks = c(-Inf, 1000, 3000, Inf), labels = c(0 - 1000,
1000 - 3000, 3000))
#as you see there are NA values but they are not extra level
z.c
[1] 0 - 1000    NA        0 - 1000    1000 - 3000 NA 
[6] 1000 - 3000 1000 - 3000 3000        3000        3000 
Levels: 0 - 1000 1000 - 3000 3000
is.na(z.c)
[1] FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE

# so let's try what help page says
 factor(z.c, exclude=NULL)
[1] 0 - 1000    NA        0 - 1000    1000 - 3000 NA 
[6] 1000 - 3000 1000 - 3000 3000        3000        3000 
Levels: 0 - 1000 1000 - 3000 3000 NA
# wow we have NA as extra level, let's do table
table(factor(z.c, exclude=NULL))

    0 - 1000 1000 - 3000        3000        NA 
          2            3            3            2 

Regards
Petr


 the goal of this exercice that to count the number of missing value, 
number 
 betwwen 0-1000 , 1000-3000, 3000.
 
 Thank you again for your help
 
 
 
 
 
 De : Petr PIKAL petr.pi...@precheza.cz
 
 Cc : r-help@r-project.org
 Envoyé le : Mardi, 25 Août 2009, 11h15mn 23s
 Objet : Odp: [R] Re : table function
 
 Hi
 
 r-help-boun...@r-project.org napsal dne 25.08.2009 10:08:36:
 
  Hi Mark,
  
  
  Thank you for your answer !! it works but if i have NA in the vector
z
 what 
  i shoud do to count its number in Z?
 
 You do not have NA in z, you manage to convert it somehow to factor. 
 Please try to read about data types and its behaviour. Start with this 
 chapter
 2.8 Other types of objects
 in R intro manual which I suppose you have in doc folder of R program 
 directory. You possibly can convert it back to numeric by
 
 e.g.
 
 DF$z - as.numeric(as.character(DF$z))
 
 but I presume you need to check your original data maybe by
 
 str(your.data) what mode they are and why they are factor if you expect
 them numeric.
 
 Regards
 Petr
 
  x      y        z
   1    0      100
   5    1      1500
   6    1      NA
   2    2      500
   1    1      NA
   5    2    2000
   8    5    4500
   
  
  i did the same but it gives me this error  message:
   [0 - 1000] [1000 - 3000]        3000 
             0            0      
       0 
  Warning message:
  In inherits(x, factor) : NAs introduced by coercion
  
  
  Thank you 
  
  
  
  De : Marc Schwartz marc_schwa...@me.com
  
  Cc : r-help@r-project.org
  Envoyé le : Lundi, 24 Aoűt 2009, 18h33mn 52s
  Objet : Re: [R] table function
  
  On Aug 24, 2009, at 10:59 AM, Inchallah Yarab wrote:
  
   hi,
   
   i want to use the function table to build a table not of frequence 
 (number 
  of time the vareable is repeated in a list or a data frame!!) but in 
 function of classes
  [[elided Yahoo spam]]
   
   example
   
   x      y        z
   1    0      100
   5    1      1500
   6    1      1200
   2    2      500
   1    1      3500
   5    2    2000
   8    5    4500
   
   i want to do a table summerizing the number of variable where z is 
in
  [0-1000],],[1000-3000], [ 3000]
   
   thank you very much for your help
  
  
  See ?cut, which bins a continuous variable.
  
   DF
   x y    z
  1 1 0  100
  2 5 1 1500
  3 6 1 1200
  4 2 2  500
  5 1 1 3500
  6 5 2 2000
  7 8 5 4500
  
  
   table(cut(DF$z, breaks = c(-Inf, 1000, 3000, Inf),
             labels = c(0 - 1000, 1000 - 3000, 
 3000)))
  
     0 - 1000 1000 - 3000        3000
           2            3        
     2
  
  HTH,
  
  Marc Schwartz
  
  
  
     [[alternative HTML version deleted]]
  
  __
  R-help@r-project.org mailing list
  

Re: [R] error in creating gantt chart.

2009-08-25 Thread Jim Lemon

rajclinasia wrote:

hi every one,
i have a excel sheet like this

   labels   starts ends
1  first task 1-Jan-04 3-Mar-04
2 second task 2-Feb-04 5-May-04
3  third task 3-Mar-04 6-Jun-04
4 fourth task 4-Apr-04 8-Aug-04
5  fifth task 5-May-04 9-Sep-04

now i converted this excel sheet into csv file and i read the csv file into
R with the below code.

my.gantt.info-read.csv(C:/Documents and
Settings/balakrishna/Desktop/one.csv).

and for create gantt chart i used below code.

 gantt.chart(my.gantt.info).

if i run this above code i am getting the error like this 


Error in x$starts : $ operator is invalid for atomic vectors.

 can anybody help in this aspect it would be very appreciable.
  

Hi Raj,
My apologies for not testing the solution I sent. The dates in the 
spreadsheet were converted to character strings, then factors in the 
input stage. If you reconvert them as follows:


my.gantt.info$starts-as.POSIXct(strptime(my.gantt.info$starts,%d-%b-%y))
my.gantt.info$ends-as.POSIXct(strptime(my.gantt.info$ends,%d-%b-%y))

things should work properly.

Jim

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


Re: [R] image plot

2009-08-25 Thread Jim Lemon

ogbos okike wrote:

Hi,
I am trying to use the image function to do a color plot. My matrix columns
are labeled y and x. I tried image(y, x) but I had error message (Error in
image.default(y, x) : increasing 'x' and 'y' values expected).
Could anybody please tell me how to add these increasing 'x' and 'y' values.
  

Hi Ogbos,
I think you may be passing the values that you want displayed rather 
than the positions of those values on a 2D grid. Try sending your matrix 
to color2D.matplot in the plotrix package. That just converts the values 
into colors and may be more like what you want.


Jim

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


Re: [R] table, sum, cat function

2009-08-25 Thread Richard . Cotton

   the second step in my exercice is to calculate the sum of the amout for each
   class et not the frequency
   i have this vector
   x   y
   1  100
   2  1500
   3  3250
   4  6250
   5  2000
   6   450
   i want to use the function table and cat to calculate the sum of the amount
   in each class [0-1000], [1000-3000],[ 3000]
   You want to use cut, not cat.  Take a look at the examples on the cut help
   page - they will help you.
   Regards,
   Richie.
   Mathematical Sciences Unit
   [1]HSL
 _

   ATTENTION:



   This message contains privileged and confidential information intended for
   the addressee(s) only. If this message was sent to you in error, you must
   not disseminate, copy or take any action in reliance on it and we request
   that you notify the sender immediately by return email.



   Opinions expressed in this message and any attachments are not necessarily
   those held by the [2]Health and Safety Laboratory or any person connected
   with the organisation, save those by whom the opinions were expressed.



   Please note that any messages sent or received by the [3]Health and Safety
   Laboratory  email system may be monitored and stored in an information
   retrieval system.
 _

   Think before you print - do you really need to print this email?
 _
 _

   Scanned by MailMarshal - Marshal's comprehensive email content security
   solution. Download a free evaluation of MailMarshal at [4]www.marshal.com
 _

References

   1. http://www.hsl.gov.uk/contact-us.htm
   2. http://www.hsl.gov.uk/
   3. http://www.hsl.gov.uk/
   4. http://www.marshal.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] Passing a list object to lapply

2009-08-25 Thread Uwe Ligges



Fowler, Mark wrote:

Hello,

I'm having difficulty passing an object name to a lapply function. Can
somebody tell me the trick to make this work?


lapply() works on objects rather than names of objects, hence you need 
get(paste(...)).


Uwe Ligges






#Works
T13702 - TRACKDATA[[13702.xls]][[data]]
min(unlist(lapply(list(T13702), function(x) mdy.date(x[1, 2], x[1, 1],
x[1, 3]
16553

#Works
d-2
assign(paste(T,substr(names(TRACKDATA)[d],1,(nchar(names(TRACKDATA)[d]
)-4)),sep=),TRACKDATA[[d]][[data]],pos=1)
min(unlist(lapply(list(T13702), function(x) mdy.date(x[1, 2], x[1, 1],
x[1, 3]
16553

#Fails.
d-2
assign(paste(T,substr(names(TRACKDATA)[d],1,(nchar(names(TRACKDATA)[d]
)-4)),sep=),TRACKDATA[[d]][[data]],pos=1)
min(unlist(lapply(list(paste(T,substr(names(TRACKDATA)[d],1,(nchar(nam
es(TRACKDATA)[d])-4)),sep=)), function(x) mdy.date(x[1, 2], x[1, 1],
x[1, 3]
Error in x[1, 2] : incorrect number of dimensions

traceback()

4: mdy.date(x[1, 2], x[1, 1], x[1, 3])
3: FUN(X[[1L]], ...)
2: lapply(list(paste(T, substr(names(TRACKDATA)[d], 1,
(nchar(names(TRACKDATA)[d]) - 
   4)), sep = )), function(x) mdy.date(x[1, 2], x[1, 1], x[1, 
   3]))
1: unlist(lapply(list(paste(T, substr(names(TRACKDATA)[d], 1, 
   (nchar(names(TRACKDATA)[d]) - 4)), sep = )), function(x)
mdy.date(x[1, 
   2], x[1, 1], x[1, 3])))


#Fails (trying noquote).
min(unlist(lapply(list(noquote(paste(T,substr(names(TRACKDATA)[d],1,(n
char(names(TRACKDATA)[d])-4)),sep=))), function(x) mdy.date(x[1, 2],
x[1, 1], x[1, 3]
Error in unclass(x)[...] : incorrect number of dimensions

traceback()

6: `[.noquote`(x, 1, 2)
5: x[1, 2]
4: mdy.date(x[1, 2], x[1, 1], x[1, 3])
3: FUN(X[[1L]], ...)
2: lapply(list(noquote(paste(T, substr(names(TRACKDATA)[d], 1, 
   (nchar(names(TRACKDATA)[d]) - 4)), sep = ))), function(x)
mdy.date(x[1, 
   2], x[1, 1], x[1, 3]))
1: unlist(lapply(list(noquote(paste(T, substr(names(TRACKDATA)[d], 
   1, (nchar(names(TRACKDATA)[d]) - 4)), sep = ))), function(x)
mdy.date(x[1, 
   2], x[1, 1], x[1, 3])))



Mark Fowler

Population Ecology Division

Bedford Inst of Oceanography
Dept Fisheries  Oceans
Dartmouth NS Canada

B2Y 4A2
Tel. (902) 426-3529
Fax (902) 426-9710
Email fowl...@mar.dfo-mpo.gc.ca
Home Tel. (902) 461-0708
Home Email mark.fow...@ns.sympatico.ca



[[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] latitude and longitude distribution

2009-08-25 Thread milton ruser
Hi there,

How about you send a minimum reproducible code as suggested on posting guide
:-)

bests

milton

On Tue, Aug 25, 2009 at 5:48 AM, ogbos okike ogbos.ok...@gmail.com wrote:

 Good day to you all,
 I have lightning data containing date, time, latitude and longitude. I hope
 that distribution of latitude and longitude will give number of lightning
 occurrence in a region. I have used factor function to sum up the number of
 events on latitude and longitude axis and saved as x and y. But when I
 tried
 to plot the two, I had and error message ( Error in image.default(x, y, z)
 :
 increasing 'x' and 'y' values expected). Every other effort I made failed
 to
 be successful - please I am a new user of R. Part of the data I am using
 is:

 latlon
 -5.1821 147.4462
 -5.1826 147.3733
 -5.1680 147.3855
 31.4489 -63.2175
 28.3199 -62.1831
 -18.2495 -44.6471
 -11.3654 -42.8249
 -2.6652 -73.2344
 -13.3543 -56.5338
 27.9594 -157.9413
 29.4454 -62.0620
 -5.1953 116.0678
 31.7057 -62.7211
 -15.6194 124.6710
 -7.1434 -72.2230
 -19.1066 -45.6655
 I would be extremely grateful should anyone be king enough as to guide me
 on
 how to handle this plot.
 Thank you for any help.
 Ogbos

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] How to create a random matrix

2009-08-25 Thread milton ruser
Like tris:

NCols=5
NRows=7

myMat-matrix(runif(NCols*NRows), ncol=NCols)
myMat

bests

milton



On Mon, Aug 24, 2009 at 6:17 PM, Peng Yu pengyu...@gmail.com wrote:

 Hi,

 I did a search but I was able to find how to generate a random matrix.
 Can somebody let me know how to do it?

 Regards,
 Peng

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


[[alternative HTML version deleted]]

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


Re: [R] [] for R

2009-08-25 Thread Liviu Andronic
On 8/24/09, kfcnhl zhengchenj...@hotmail.com wrote:
  I am assuming the variable out is the output parameter.
  However, I don't understand what is  out[1+xi*xx0]?
  Can someone explain this to me?

http://www.statmethods.net/management/subset.html

Liviu

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


Re: [R] Horisontal line in xtable

2009-08-25 Thread Liviu Andronic
Late answer, but still..

On 6/17/09, christiaan pauw cjp...@gmail.com wrote:
  I want a horisontal line that separates the results from the  sample
  information i.e. a horisontal line on the bottom of the line second from
  last

?print.xtable
hline.after: When 'type=latex', a vector of numbers between -1 and
  'nrow(x)', inclusive, indicating the rows after which a
  horizontal line should appear.  If 'NULL' is used no lines
  are produced. Default value is 'c(-1,0,nrow(x))' which means
  draw a line before and after the columns names and at the end
  of the table. Repeated values are allowed.


Liviu

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


Re: [R] problem with BRugs

2009-08-25 Thread Vitalie S.
On Tue, 25 Aug 2009 12:13:21 +0200, Uwe Ligges  
lig...@statistik.tu-dortmund.de wrote:





Vitalie S. wrote:

Hello Uwe,
 Just a related question, OpenBugs is using C and T for Censoring and  
Truncation. But this does not seem to work with BRugs.
 I am using this document  
http://mathstat.helsinki.fi/openbugs/Manuals/ModelSpecification.html#TheBUGSLanguageStochasticNodes



What's the problem? Error message? Reproducible code?



Oh, sorry,I justs assumed it would be an easy answer, like not  
implemented yet.


Here is the code:


fModel- function()
{
beta ~ dnorm(0,1) %_% T(0, 1)
}
writeModel(fModel,Model.txt);
modelCheck(Model.txt);

#ERROR: this density cannot be truncated error pos 33 (error on line 3)

Note that C and I work fine in the code above.

My info:


sessionInfo(BRugs)

R version 2.9.0 (2009-04-17)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United  
States.1252;LC_MONETARY=English_United  
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252


attached base packages:
character(0)

other attached packages:
[1] BRugs_0.5-1

Vitalie.



Specifying, e.g.

model - function()
 x ~ dnorm(mu, tau)%_%T(lower, upper)
writeModel(model)

works for me.

Best,
Uwe





Thanks,
Vitalie.
 On Tue, 25 Aug 2009 10:00:44 +0200, Uwe Ligges  
lig...@statistik.tu-dortmund.de wrote:





R Heberto Ghezzo, Dr wrote:
Hello, I am sorry, I have this problem before and Uwe send me the  
answer but I misplaced it


Oh dear! But it is not lost, since the answer to the second part of  
your problem was: Please read the documentation!




and can not find it.

  writing a model for BRugs



library(BRugs)

Loading required package: coda
Loading required package: lattice
Welcome to BRugs running on OpenBUGS version 3.0.3

setwd(c:/tmp)

Error in setwd(c:/tmp) : cannot change working directory



So c:/tmp does not exist or you don't have permissions there?



mo - function(){

+   for (k in 1:p){
+ delta[1,k] ~ dnorm(0,0.1)I(,delta[2,k])
Error: unexpected symbol in:


The answer was: Please read the documentation!

?writeModel (which you want to use on this function) tells you:

As a difference, BUGS syntax allows truncation specification like  
this: dnorm(...) I(...) but this is illegal in R. To overcome this  
incompatibility, use %_% before I(...): dnorm(...) %_% I(...). The  
dummy operator %_% will be removed before the BUGS code is saved. 




  for (k in 1:p){
delta[1,k] ~ dnorm(0,0.1)I

delta[2,k] ~ dnorm(0,0.1)I(delta[1,k],delta[3,k])

Error: unexpected symbol in delta[2,k] ~ dnorm(0,0.1)I

delta[3,k] ~ dnorm(0,0.1)I(delta[2,k],)}

Error: unexpected symbol in delta[3,k] ~ dnorm(0,0.1)I

}

Error: unexpected '}' in }
 so R parser does not like the I(,) construct


which is *not* the problem, see above.


Best wishes,
Uwe



, What is the alternative way of propgramming the
constrain I(lower,upper)
Thanks
Heberto Ghezzo
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide  
http://www.R-project.org/posting-guide.html

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


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

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





--

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


Re: [R] problem with BRugs

2009-08-25 Thread Uwe Ligges



Vitalie S. wrote:
On Tue, 25 Aug 2009 12:13:21 +0200, Uwe Ligges 
lig...@statistik.tu-dortmund.de wrote:





Vitalie S. wrote:

Hello Uwe,
 Just a related question, OpenBugs is using C and T for Censoring and 
Truncation. But this does not seem to work with BRugs.
 I am using this document 
http://mathstat.helsinki.fi/openbugs/Manuals/ModelSpecification.html#TheBUGSLanguageStochasticNodes 




What's the problem? Error message? Reproducible code?



Oh, sorry,I justs assumed it would be an easy answer, like not 
implemented yet.


Here is the code:


fModel- function()
{
beta ~ dnorm(0,1) %_% T(0, 1)
}
writeModel(fModel,Model.txt);
modelCheck(Model.txt);

#ERROR: this density cannot be truncated error pos 33 (error on line 3)



This is a BUGS error message that indeed tells you that BUGS cannot 
truncate that density - not related to R at all.


Best,
Uwe Ligges




Note that C and I work fine in the code above.

My info:


sessionInfo(BRugs)

R version 2.9.0 (2009-04-17)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252


attached base packages:
character(0)

other attached packages:
[1] BRugs_0.5-1

Vitalie.



Specifying, e.g.

model - function()
 x ~ dnorm(mu, tau)%_%T(lower, upper)
writeModel(model)

works for me.

Best,
Uwe





Thanks,
Vitalie.
 On Tue, 25 Aug 2009 10:00:44 +0200, Uwe Ligges 
lig...@statistik.tu-dortmund.de wrote:





R Heberto Ghezzo, Dr wrote:
Hello, I am sorry, I have this problem before and Uwe send me the 
answer but I misplaced it


Oh dear! But it is not lost, since the answer to the second part of 
your problem was: Please read the documentation!




and can not find it.

  writing a model for BRugs



library(BRugs)

Loading required package: coda
Loading required package: lattice
Welcome to BRugs running on OpenBUGS version 3.0.3

setwd(c:/tmp)

Error in setwd(c:/tmp) : cannot change working directory



So c:/tmp does not exist or you don't have permissions there?



mo - function(){

+   for (k in 1:p){
+ delta[1,k] ~ dnorm(0,0.1)I(,delta[2,k])
Error: unexpected symbol in:


The answer was: Please read the documentation!

?writeModel (which you want to use on this function) tells you:

As a difference, BUGS syntax allows truncation specification like 
this: dnorm(...) I(...) but this is illegal in R. To overcome this 
incompatibility, use %_% before I(...): dnorm(...) %_% I(...). The 
dummy operator %_% will be removed before the BUGS code is saved. 




  for (k in 1:p){
delta[1,k] ~ dnorm(0,0.1)I

delta[2,k] ~ dnorm(0,0.1)I(delta[1,k],delta[3,k])

Error: unexpected symbol in delta[2,k] ~ dnorm(0,0.1)I

delta[3,k] ~ dnorm(0,0.1)I(delta[2,k],)}

Error: unexpected symbol in delta[3,k] ~ dnorm(0,0.1)I

}

Error: unexpected '}' in }
 so R parser does not like the I(,) construct


which is *not* the problem, see above.


Best wishes,
Uwe



, What is the alternative way of propgramming the
constrain I(lower,upper)
Thanks
Heberto Ghezzo
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

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


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

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







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


[R] xtable longtable with caption on top

2009-08-25 Thread Liviu Andronic
Dear all
I would like to export a matrix to a LaTeX longtable environment
that would have its caption on top of the table. However xtable()
seems to bar me from doing this:
 print(xtable(mtcars[1:10,c(1,2)], caption=CARS),
+ tabular.environment=longtable, caption.placement=top
+ , floating=F)
% latex table generated in R 2.9.1 by xtable 1.5-5 package
% Tue Aug 25 13:48:01 2009
\begin{longtable}{rrr}
  \hline
  mpg  cyl \\
  \hline
Mazda RX4  21.00  6.00 \\
  Mazda RX4 Wag  21.00  6.00 \\
  Datsun 710  22.80  4.00 \\
  Hornet 4 Drive  21.40  6.00 \\
  Hornet Sportabout  18.70  8.00 \\
  Valiant  18.10  6.00 \\
  Duster 360  14.30  8.00 \\
  Merc 240D  24.40  4.00 \\
  Merc 230  22.80  4.00 \\
  Merc 280  19.20  6.00 \\
   \hline
\hline
\caption{CARS}
\end{longtable}
Warning message:
In print.xtable(xtable(mtcars[1:10, c(1, 2)], caption = CARS),  :
  Attempt to use longtable with caption.placement=top. Changing to bottom.


The error seems strange since I would assume that longtable tables
would naturally have the caption at the beginning of the table,
especially if it streches over multiple pages. There is no such error
when caption.placement=bottom. Would this be a bug in xtable()?
Thank you
Liviu




-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

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

2009-08-25 Thread Jim Lemon

ogbos okike wrote:

Good day to you all,
I have lightning data containing date, time, latitude and longitude. I hope
that distribution of latitude and longitude will give number of lightning
occurrence in a region. I have used factor function to sum up the number of
events on latitude and longitude axis and saved as x and y. But when I tried
to plot the two, I had and error message ( Error in image.default(x, y, z) :
increasing 'x' and 'y' values expected). Every other effort I made failed to
be successful - please I am a new user of R. Part of the data I am using is:
  

Hi Ogbos,
That's better. What may be more to your liking is this:

library(maps)
data(worldMapEnv)
map(world)
points(lightning$lon,lightning$lat,col=red)

Jim

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


[R] Partykit Document

2009-08-25 Thread indranil basu
Hi All,
 I'm a newcomer to the R community, just started learning R. I need
to use partykit for developing CART. But I'm not getting any document/help
for using partykit/rpart.
http://www.agrocampus-ouest.fr/math/useR-2009/slides/Hothorn+Zeileis.pdfgives
some example, but it doesn't tell how my own data should be formatted
so that it can be accepted by partykit.

Example,
data(GlaucomaM, package = ipred) is accepted. Now instead of GlaucomaM,
I need to give my own data. But the data format for GlaucomaM is not given.
So how can I know that?

Please help me in this.

Thanks and Regards.
- Indranil Basu,
Bangalore,
India

[[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] Filling matrix secondary diagonal

2009-08-25 Thread Henrique Dallazuanna
Try this:

m - matrix(sample(9), 3)
diag(m)
diag(m[-1,])
diag(m[,-1])




On Mon, Aug 24, 2009 at 4:03 PM, Vaupo m-va...@web.de wrote:


 Hi,

 how do i fill the secondary diagonals of a matrix?
 Is there an funktion like the diag funktion in matlab, where i can
 specify
 the diagonal i´d like to fill?

 --
 View this message in context:
 http://www.nabble.com/Filling-matrix-secondary-diagonal-tp25121745p25121745.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.




-- 
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] Odp: table, sum, cat function

2009-08-25 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 25.08.2009 12:07:11:

 Hi,
 
 the second step in my exercice is to calculate the sum of the amout for 
each 
 class et not the frequency 
 
 i have this vector
 
 x   y
 1  100
 2  1500 
 3  3250
 4  6250
 5  2000
 6   450
 
 
 i want to use the function table and cat to calculate the sum of the 
amount in
 each class [0-1000], [1000-3000],[ 3000]

It starts to look like some kind of homework. If yes you shall seek the 
help from your tutor.

If you want to do it yourself than tapply, by, aggregate or package doBy 
could be good starting point.

Regards
Petr


 
 Thank you for your help??
 
 inchallah
 
 
 
[[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] FW: Pec Function in R - syntax

2009-08-25 Thread K F Pearce
 
Hello everyone - sorry, I forgot to add the syntax for my program in the last 
message:

My syntax is as follows:

library(Hmisc)
 library(survival)
 library(pec)
 AL-read.table(PredErr2.txt,header=TRUE)

 Models-list(Kaplan.Meier=survfit(Surv(OVS,dead)~1,data=AL),EBMT+SN
 Pgroup=coxph(Surv(OVS,dead)~GroupMod,method=efron,data=AL),EBMTgro
 up=coxph(Surv(OVS,dead)~GroupGrat,
 method=efron,data=AL),EBMToriginal=coxph(Surv(OVS,dead)~Gratwohl,
 method=efron,data=AL),EBMT+SNPoriginal=
 coxph(Surv(OVS,dead)~Gratwohl+PIL1rAnyC+PIL4AnyT,
 method=efron,data=AL))

 PredError.632plus-pec(object=Models,formula=Surv(OVS,dead)~1,data=AL,
 exact=TRUE,cens.model=marginal,replan=boot632plus,B=100,verbose=TR
 UE)

Thankyou so much.
Kim


Dr Kim Pearce CStat
Industrial Statistics Research Unit (ISRU) School of Mathematics and Statistics 
Herschel Building University of Newcastle Newcastle upon Tyne United Kingdom
NE1 7RU

Tel.   0044 (0)191 222 6244 (direct)
Fax.   0044 (0)191 222 8020
Email: k.f.pea...@ncl.ac.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.


[R] mixed normal distriburtion

2009-08-25 Thread mahdiyeh
I'm trying to draw the density function of a mixed normal distribution
in the form of:
.6*N(.4,.1)+ .4*N(.8,.1)
At first I generate a random sample with size 200 by the below code:
means = c(.4,.8)
sds = sqrt(c(.1,.1))
ind = sample(1:2, n, replace=TRUE, prob=c(.6,.4))
x=rnorm(n,mean=means[ind],sd=sds[ind])

Then I use the below code for drawing the graph:
plot(density(x))

The plot doesn't seem to be belonging to the desired distribution,
because there is just one mode in it (I've seen the real graph of this
mixed normal in a paper, it has two clear distinct modes). Even the
hist() doesn't draw a plot similar to the real graph. I think the
generation code isn't correct. Is it? (I've asked the generation code
here!)

--
Free e-mail accounts at http://zworg.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] Pec function in R

2009-08-25 Thread K F Pearce
Hello everyone,

These are some questions about the 'pec' function in R.  These questions deal 
with prediction error curves and their derivation.  Prediction error curves are 
documented in, for example, Efron-type measures of prediction error for 
survival analysis by Gerds and Schumacher.

I have detailed some syntax that I have used at the bottom of this email.  The 
associated data is available upon request.

In the 'pec' function I have

formula=Surv(OVS,dead)~1

...apparently for right censored data, the RH side of the formula is used to 
specify conditional censoring models when there are no covariates (as in 
our case)...I understand that we are assuming that censoring occurs totally at 
random (for all models). 

Say we have a data set containing potential predictor variables X1,X2Xp.  
Our survival time variable (time) is measured in months and our status 
variable (status) has 0=alive and 1=dead.

Firstly, I would like to ask about how to derive conditional censoring models. 
From past conversations it seems that to establish the form of our censoring 
model(s), we would use status=event=alive =1  and status=event=death=0.  Is 
this correct?.. 

Now, say we are assuming that the model for censoring is of the cox regression 
type, do we assess the model for censoring using the usual variable selection 
procedures where candidate variables for variable selection are X1,X2Xp and 
we code *alive=1 and dead=0*?

Say we found that X1 and X5 should be included in our cox regression model for 
censoring, then we would enter:

formula=Surv(time,status)~X1+X5 and cens.model=cox  in function pec.

Am I thinking about this correctly? I think it could be more difficult than 
this, so I'd appreciate some guidance.

Replan is the method for estimating prediction error curves. I understand that 
replan=none would be used when we don't cross validate i.e. we would create a 
model using a specific bootstrap sample and then evaluate its performance on 
the same sample. 

If we are looking at bootstrap crossvalidation (OutOfBag) method...say we 
have 500 patients.it says in the paper - Gerds and Schumacher - that 
bootstrap samples Q*_1Q*_B each of size n are drawn with replacement from 
the original data (we have chosen 100 bootstrap samples  i.e. B=100 in our 
work).  

So here I assume that n is equal to the total number of patients i.e. 500 in 
this example?

When we decide to sample with replacement, as here,...I am assuming that, for 
each of the bootstrap samples, there are 500 patients but some of these 
patients could occur in this bootstrap sample more than once.

The documentation says M is the size of the bootstrap samples for sampling 
*without* replacement.

Hence am I correct in thinking that for sampling *with* replacement, M is equal 
to n ?  i.e. M=n by default.  However, if we choose Mn  then each of our 
bootstrap samples will have 'sampling without replacement' i.e. the training 
set would be comprised of n-M patients.  Am I correct?

[Each of the bootstrap samples acts as a 'training data set' to generate a 
modelthe model is then validated using the patients which weren't in the 
bootstrap sample. ]

In a study I did using a 286 case data set, I noticed that my prediction error 
curves seem to terminate at around 35 months when the actual last survival time 
was 248 months.  I checked the survival times and corresponding alive/dead 
for this data set and noticed that the number of 'deaths' gets very sparse 
after month 35but I'm still a bit puzzled as to why the curves end at 
around 35 months.  Perhaps the small number of cases in the original data set 
leads to small training data sets and hence to a termination of the curves at 
low times?  Has anybody else encountered this?

In our study, we wanted to develop a model on a specific bootstrap sample  and 
then test it out using observations which aren't in the bootstrap sample (this 
would be repeated B times)...we chose the 0.632+ bootstrap estimator.   There 
are many types of  estimators for prediction error curves.  How should we 
decide which is 'best'?

Thanks for any advice on these questions,
Kindest Regards,
Kim

Dr Kim Pearce CStat
Industrial Statistics Research Unit (ISRU)
School of Mathematics and Statistics
Herschel Building
University of Newcastle
Newcastle upon Tyne
United Kingdom
NE1 7RU

Tel.   0044 (0)191 222 6244 (direct)
Fax.   0044 (0)191 222 8020
Email: k.f.pea...@ncl.ac.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] problem with BRugs

2009-08-25 Thread Vitalie S.




This is a BUGS error message that indeed tells you that BUGS cannot  
truncate that density - not related to R at all.


Best,
Uwe Ligges



Yes, indeed, that does not work in OpenBugs as well. Means that  
documentation of Open bugs is  incorrect (they are using dnorm there).  
Also I works and T does not work for any distribution I've tried.


The problem is that BRugs documentation is not mentioning T and C  
operators.
OpenBugs tels about T and C but not I. And obviously nothing about what  
T does not work and I should be used instead!


If I didn't know from previous versions about I operator I would have  
been stuck with BRugs code.


So I believe this is also a problem of BRugs' documentation. T and C  
should be mentioned there along side with I.


The guys at OpenBugs obviously now the problem - just new users are  
utterly confused, that's all.


Sorry for taking your time.
And thanks for the port; indeed, great tool.

Vitalie.

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

2009-08-25 Thread Michael Cho
Hi,

Trying to do something fairly simple.  I'm trying to get a legend that
combines superscripts with a sequence, like this:
r^2 = 1
r^2 = 2
r^2 = 3
...
Except that r^2 is properly formatted as a superscript.

I've been playing with substitute and expression and can get an
individual line to appear, but I can't seem to get the syntax correct
so that I can get several of these to appear using  legend.
this works:
i-1
substitute(r^2==k,list(k=i))

but not this
i-seq(1,10)
substitute(r^2==k,list(k=i))

Can anyone help?

Thanks

Michael

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

2009-08-25 Thread maram salem
Dear All,
I have a matrix m of the form
 m
    [,1] [,2]
  [1,]  9072.302 0.0004462366
  [2,]  9086.811 0.0005628169
  [3,]  9101.320 0.0007126347
  [4,]  9115.830 0.0008986976
  [5,]  9130.339 0.001126
  [6,]  9144.848 0.0014018405
  [7,]  9159.357 0.0017344229
  [8,]  9173.866 0.0021363563
  [9,]  9188.375 0.0026389996
 [10,]  9202.884 0.0032406678
 
where the first col is my variable x and the second is f(x). I've obtained this 
from the result of a kernel density estimate so I don't know the explict form 
of f(x) .
For some reason i want to integerate f(x) over a certain range using integrate( 
). So i want R to consider the above matrix as a function where the first col 
is the argument x and the second is the realization f(x).
I've tried as.function and vectorize but it didn't work out.
Could u help me do it?
Thanks 
Maram



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

2009-08-25 Thread rajclinasia

Hi every one,

what do you mean by %d-%b-%y. is it reading format or writing format.

Thanks in Advance.
-- 
View this message in context: 
http://www.nabble.com/formats-tp25133503p25133503.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] multiple expressions in a legend

2009-08-25 Thread Gabor Grothendieck
Try this:

plot(0)
ix - as.double(1:3)
legend(top,  as.expression(lapply(ix, function(i) bquote(r^.(i)

On Tue, Aug 25, 2009 at 8:45 AM, Michael Chore...@channing.harvard.edu wrote:
 Hi,

 Trying to do something fairly simple.  I'm trying to get a legend that
 combines superscripts with a sequence, like this:
 r^2 = 1
 r^2 = 2
 r^2 = 3
 ...
 Except that r^2 is properly formatted as a superscript.

 I've been playing with substitute and expression and can get an
 individual line to appear, but I can't seem to get the syntax correct
 so that I can get several of these to appear using  legend.
 this works:
 i-1
 substitute(r^2==k,list(k=i))

 but not this
 i-seq(1,10)
 substitute(r^2==k,list(k=i))

 Can anyone help?

 Thanks

 Michael

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

2009-08-25 Thread Richard . Cotton
 I'm trying to draw the density function of a mixed normal distribution
 in the form of:
 .6*N(.4,.1)+ .4*N(.8,.1)
 At first I generate a random sample with size 200 by the below code:
 means = c(.4,.8)
 sds = sqrt(c(.1,.1))
 ind = sample(1:2, n, replace=TRUE, prob=c(.6,.4))
 x=rnorm(n,mean=means[ind],sd=sds[ind])
 
 Then I use the below code for drawing the graph:
 plot(density(x))
 
 The plot doesn't seem to be belonging to the desired distribution,
 because there is just one mode in it (I've seen the real graph of this
 mixed normal in a paper, it has two clear distinct modes). Even the
 hist() doesn't draw a plot similar to the real graph. I think the
 generation code isn't correct. Is it? (I've asked the generation code
 here!)

The code is fine - the reason you can't see two peaks is that the two 
distributions overlap a lot.  Set 
means - c(.4, 10) 
to see double peaks more clearly.

Regards,
Richie.

Mathematical Sciences Unit
HSL




ATTENTION:

This message contains privileged and confidential inform...{{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.


[R] Elastic net in R (enet package)

2009-08-25 Thread Alex Roy
Dear R users,
I am using enet package in R for applying elastic
net method. In elastic net, two penalities are applied one is lambda1 for
LASSO and lambda2 for ridge ( zou, 2005) penalty. But while running the
analysis, I realised tht, I  optimised only one lambda. ( even when I
looked at the example in R, they used only one penality)  So, I am wandering
which penalty they are referring to? Is it a combination of penalties or one
of them. I read the paper of zou and hastie but still in doubt.

Thanks in advance

Alex

[[alternative HTML version deleted]]

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


Re: [R] formats

2009-08-25 Thread Richard . Cotton
 what do you mean by %d-%b-%y. is it reading format or writing format.

%d-%b-%y is a date format - see the help page for strptime.

Example usage:
strptime(01-Jan-84, %d-%b-%y)
strftime(Sys.time(), %d-%b-%y)

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{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.


Re: [R] problem with BRugs

2009-08-25 Thread Uwe Ligges



Vitalie S. wrote:




This is a BUGS error message that indeed tells you that BUGS cannot 
truncate that density - not related to R at all.


Best,
Uwe Ligges



Yes, indeed, that does not work in OpenBugs as well. Means that 
documentation of Open bugs is  incorrect (they are using dnorm there). 
Also I works and T does not work for any distribution I've tried.


The problem is that BRugs documentation is not mentioning T and C 
operators.
OpenBugs tels about T and C but not I. And obviously nothing about 
what T does not work and I should be used instead!


If I didn't know from previous versions about I operator I would have 
been stuck with BRugs code.


So I believe this is also a problem of BRugs' documentation. T and C 
should be mentioned there along side with I.


The guys at OpenBugs obviously now the problem - just new users are 
utterly confused, that's all.



Please report OpenBUGS documentation issues at the OpenBUGS list. I do 
not have write access there.


Thank you very much,
Uwe



Sorry for taking your time.
And thanks for the port; indeed, great tool.

Vitalie.


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


Re: [R] Re : Odp: Re : Odp: Re : table function

2009-08-25 Thread David Winsemius


On Aug 25, 2009, at 6:25 AM, Inchallah Yarab wrote:


Thank you very much Peter it works!!

the second step is to calculate the sum of variable in each class!!!

how can i do this!!!


?table
?xtab



De : Petr PIKAL petr.pi...@precheza.cz

Cc : r-help@r-project.org
Envoyé le : Mardi, 25 Août 2009, 11h53mn 21s
Objet : Odp: [R] Re : Odp: Re : table function

Hi

r-help-boun...@r-project.org napsal dne 25.08.2009 11:28:31:


Â
Thank you Peter,
in my vector Z i have missing value NA and i want to count its  
number

in the vector
i had did alla this i know the difference between a numeirc and a  
factor



OK. If you know difference between factor and numeric you probably  
have

seen
?factor
where is note about how to make NA an extra level

#Here is z
z-c(10,100, 1000, 1200, 2000, 2200, 3000, 3200, 5000, 6000)
#let's put some NA values into it
z[c(2,5)] -NA
#let's make a cut
z.c-cut(z, breaks = c(-Inf, 1000, 3000, Inf), labels = c(0 - 1000,
1000 - 3000, 3000))
#as you see there are NA values but they are not extra level
z.c
[1] 0 - 1000NA0 - 10001000 - 3000 NA
[6] 1000 - 3000 1000 - 3000 300030003000
Levels: 0 - 1000 1000 - 3000 3000
is.na(z.c)
[1] FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE

# so let's try what help page says

factor(z.c, exclude=NULL)

[1] 0 - 1000NA0 - 10001000 - 3000 NA
[6] 1000 - 3000 1000 - 3000 300030003000
Levels: 0 - 1000 1000 - 3000 3000 NA
# wow we have NA as extra level, let's do table
table(factor(z.c, exclude=NULL))

0 - 1000 1000 - 30003000NA
  2332

Regards
Petr



the goal of this exercice that to count the number of missing value,

number

betwwen 0-1000 , 1000-3000, 3000.

Thank you again for your help





De : Petr PIKAL petr.pi...@precheza.cz

Cc : r-help@r-project.org
Envoyé le : Mardi, 25 Août 2009, 11h15mn 23s
Objet : Odp: [R] Re : table function

Hi

r-help-boun...@r-project.org napsal dne 25.08.2009 10:08:36:


Hi Mark,


Thank you for your answer !! it works but if i have NA in the  
vector

z

what

i shoud do to count its number in Z?


You do not have NA in z, you manage to convert it somehow to factor.
Please try to read about data types and its behaviour. Start with  
this

chapter
2.8 Other types of objects
in R intro manual which I suppose you have in doc folder of R program
directory. You possibly can convert it back to numeric by

e.g.

DF$z - as.numeric(as.character(DF$z))

but I presume you need to check your original data maybe by

str(your.data) what mode they are and why they are factor if you  
expect

them numeric.

Regards
Petr


x      y        z

1Â  Â  0Â  Â  Â  100
5Â  Â  1Â  Â  Â  1500
6Â  Â  1Â  Â  Â  NA
2Â  Â  2Â  Â  Â  500
1Â  Â  1Â  Â  Â  NA
5Â  Â  2Â  Â  2000
8Â  Â  5Â  Â  4500



i did the same but it gives me this error  message:
  [0 - 1000] [1000 - 3000]        3000
            0            0         
    0

Warning message:
In inherits(x, factor) : NAs introduced by coercion


Thank you



De : Marc Schwartz marc_schwa...@me.com

Cc : r-help@r-project.org
Envoyé le : Lundi, 24 Aoűt 2009, 18h33mn 52s
Objet : Re: [R] table function

On Aug 24, 2009, at 10:59 AM, Inchallah Yarab wrote:


hi,

i want to use the function table to build a table not of frequence

(number

of time the vareable is repeated in a list or a data frame!!) but in

function of classes

[[elided Yahoo spam]]


example

x      y        z
1Â  Â  0Â  Â  Â  100
5Â  Â  1Â  Â  Â  1500
6Â  Â  1Â  Â  Â  1200
2Â  Â  2Â  Â  Â  500
1Â  Â  1Â  Â  Â  3500
5Â  Â  2Â  Â  2000
8Â  Â  5Â  Â  4500

i want to do a table summerizing the number of variable where z is

in

[0-1000],],[1000-3000], [ 3000]


thank you very much for your help



See ?cut, which bins a continuous variable.


DF

  x y    z
1 1 0Â  100
2 5 1 1500
3 6 1 1200
4 2 2Â  500
5 1 1 3500
6 5 2 2000
7 8 5 4500



table(cut(DF$z, breaks = c(-Inf, 1000, 3000, Inf),
            labels = c(0 - 1000, 1000 - 3000,  
3000)))


    0 - 1000 1000 - 3000        3000
          2            3           
  2


HTH,

Marc Schwartz



    [[alternative HTML version deleted]]

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

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

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




[[alternative HTML version deleted]]

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

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

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




[[alternative HTML version deleted]]


Re: [R] Help on comparing two matrices

2009-08-25 Thread Gabor Grothendieck
They can be regarded as incidence matrices rather than adjacency
matrices and in that case it follows:

library(igraph)

# incidence matrix to canonical edge list
inc2canel - function(m) {
g - graph.incidence(m)
cp - canonical.permutation(g)
can - permute.vertices(g, cp$labeling)
el - get.edgelist(can)
el[ order(el[,1], el[,2]), ]
}

# test it out

m1 - matrix(c(0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1,
0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0,
0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1), 7)
m2 - m1[7:1, 8:1]
m3 - m2; m3[1, ] - 1

identical(inc2canel(m1), inc2canel(m2)) # TRUE
identical(inc2canel(m1), inc2canel(m3)) # FALSE



On Sun, Aug 23, 2009 at 6:09 PM, Steve
Lianogloumailinglist.honey...@gmail.com wrote:
 Hi,

 On Sun, Aug 23, 2009 at 4:14 PM, Michael Koganmichael.ko...@gmx.net wrote:
 Thanks for all the replies!

 Steve: I don't know whether my suggestion is a good one. I'm quite new to
 programming, have absolutely no experience and this was the only one I could
 think of. :-) I'm not sure whether I'm able to put your tips into practice,
 unfortunately I had no time for much reading today but I'll dive into it
 tomorrow.

 Ok, yeah. I'm not sure what the best way to do this myself, I would at
 first see if one could reduce these matrices by some principled manner
 and then do a comparison, which might jump to:

 Ted: Wow, that's heavy reading. In fact the matrices that I need to compare
 are incidence matrices so I suppose it's exactly the thing I need, but I
 don't know if I have the basics knowledge to understand this paper within
 the next months.

 Ted's sol'n. I haven't read the paper, but its title gives me an idea.
 Perhaps you can assume the two matrices you are comparing are
 adjacency matrices for a graph then use the igraph library to do a
 graph isomorphism test between the two graphs represented by your
 adjacency matrices and see if they are the same.

 This is probably not the most efficient (computationally) way to do
 it, but it might be the quickest way out coding-wise.

 I see your original example isn't using square matrices, and an
 adjacency matrix has to be square. Maybe you can pad your matrices
 with zero rows or columns (depending on what's deficient) as an easy
 way out.

 Just an idea.

 Of course, if David's solution is what you need, then no need to
 bother with any of this.

 -steve

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

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


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


Re: [R] Help on comparing two matrices

2009-08-25 Thread Steve Lianoglou

Hi,

It looks like you're getting more good stuff, but just to follow up:

On Aug 24, 2009, at 4:01 PM, Michael Kogan wrote:
Steve: The two matrices I want to compare really are graph matrices,  
just not adjacency but incidence matrices. There should be a way to  
get an adjacency matrix of a graph out of its incidence matrix but I  
don't know it...


If you're working with graph data, do yourself a favor and install  
igraph (no matter what solution you end up using for this particular  
problem).


http://cran.r-project.org/web/packages/igraph/
http://igraph.sourceforge.net/

In there, you'll find the `graph.incidence` function which creates a  
graph from its incidence matrix. You can then test if the two graphs  
are isomorphic.


That would look like so:

library(igraph)
g1 - graph.incidence(matrix.1)
g2 - graph.incidence(matrix.2)
is.iso - graph.isomorphic(g1, g2)
# Or, using the (somehow fast) vf2 algorithm
is.iso - graph.isomorphic.vf2(g1, g2)

HTH,
-steve

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

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


Re: [R] Help on comparing two matrices

2009-08-25 Thread Michael Kogan
Gabor: Wow, that seems to be exactly what I need! Does it matter that 
my incidence matrices represent neighborhood relations between 
vertices and faces rather than between vertices and edges?


Steve: Yep, I realize that this package is exactly what I'm searching 
for. :)


Gabor Grothendieck schrieb:

They can be regarded as incidence matrices rather than adjacency
matrices and in that case it follows:

library(igraph)

# incidence matrix to canonical edge list
inc2canel - function(m) {
g - graph.incidence(m)
cp - canonical.permutation(g)
can - permute.vertices(g, cp$labeling)
el - get.edgelist(can)
el[ order(el[,1], el[,2]), ]
}

# test it out

m1 - matrix(c(0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1,
0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0,
0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1), 7)
m2 - m1[7:1, 8:1]
m3 - m2; m3[1, ] - 1

identical(inc2canel(m1), inc2canel(m2)) # TRUE
identical(inc2canel(m1), inc2canel(m3)) # FALSE



On Sun, Aug 23, 2009 at 6:09 PM, Steve
Lianogloumailinglist.honey...@gmail.com wrote:
  

Hi,

On Sun, Aug 23, 2009 at 4:14 PM, Michael Koganmichael.ko...@gmx.net wrote:


Thanks for all the replies!

Steve: I don't know whether my suggestion is a good one. I'm quite new to
programming, have absolutely no experience and this was the only one I could
think of. :-) I'm not sure whether I'm able to put your tips into practice,
unfortunately I had no time for much reading today but I'll dive into it
tomorrow.
  

Ok, yeah. I'm not sure what the best way to do this myself, I would at
first see if one could reduce these matrices by some principled manner
and then do a comparison, which might jump to:



Ted: Wow, that's heavy reading. In fact the matrices that I need to compare
are incidence matrices so I suppose it's exactly the thing I need, but I
don't know if I have the basics knowledge to understand this paper within
the next months.
  

Ted's sol'n. I haven't read the paper, but its title gives me an idea.
Perhaps you can assume the two matrices you are comparing are
adjacency matrices for a graph then use the igraph library to do a
graph isomorphism test between the two graphs represented by your
adjacency matrices and see if they are the same.

This is probably not the most efficient (computationally) way to do
it, but it might be the quickest way out coding-wise.

I see your original example isn't using square matrices, and an
adjacency matrix has to be square. Maybe you can pad your matrices
with zero rows or columns (depending on what's deficient) as an easy
way out.

Just an idea.

Of course, if David's solution is what you need, then no need to
bother with any of this.

-steve

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

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







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

2009-08-25 Thread Wallis, David
To: silwood-r
Subject: Removing lattice graph gridlines and editing label box colour

Hi,

Is it possible to remove the background gridlines from a lattice graph (ie 
graph made up of multiple individual graphs with annoying blue grid in the 
backgroun)?

Also, Is it possible to change the colour of the individual graph label boxes? 
- ie the default pink boxes above the individual graphs

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] Lattice graph tweaking

2009-08-25 Thread Sundar Dorai-Raj
A reproducible example would be nice.

Try grid = FALSE for the first question, though I'm unaware which
lattice plot you are using where the default is TRUE. So I can't
guarantee that will even work.

For your second question, add

par.settings = list(strip.background = list(col = white))

to your call (e.g. xyplot(..., par.settings = ...)).

To see what other parameters you can set in par.settings, try:

str(trellis.par.get())

HTH,

--sundar

On Tue, Aug 25, 2009 at 6:14 AM, Wallis,
Daviddavid.walli...@imperial.ac.uk wrote:
 To: silwood-r
 Subject: Removing lattice graph gridlines and editing label box colour

 Hi,

 Is it possible to remove the background gridlines from a lattice graph (ie 
 graph made up of multiple individual graphs with annoying blue grid in the 
 backgroun)?

 Also, Is it possible to change the colour of the individual graph label 
 boxes? - ie the default pink boxes above the individual graphs

 Thanks

        [[alternative HTML version deleted]]

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


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


[R] Plotting the Log-Likelihood

2009-08-25 Thread enrico.fosco...@libero.it
Dear Users,

I would like to plot the log-likelihood (depending on two 
parameters).

I wrote the following code:





library(mvtnorm)


sigma-
matrix(c(4,2,2,3),ncol=2)

x-rmvnorm(n=500,mean=c(1,2),sigma=sigma)


likel-
function(param,data){


pos1-which(data[,1]0)

pos2-which(data[,1]=0)



#density


dens-rep(0,nrow(data))

dens[pos1]-dmvnorm(data[pos1,])
*param[1]

dens[pos2]-dmvnorm(data[pos2,])*param[2]


#return log-
likelihood


sum(log(dens))


}


#plotting the log-likelihood

param1-
seq(from=0,to=1,length=200)

param2-seq(from=0,to=1,length=200)

combin-
as.matrix(expand.grid(param1,param2,KEEP.OUT.ATTRS=FALSE))

likel.values-
apply(combin,1,likel,data=x)

matr.likel.values-matrix(likel.values,200,200)


persp(param1,param2,matr.likel.values,

xlab=param1,ylab=param2,


zlab=Likelihood,

theta=5,phi=20,expand=0.5,

col=lightblue,
ltheta=120,shade=0.75,ticktype=detailed)




It is all ok, but I am searching 
for a new lighting way in order to earn time.

I need an alternative function 
for apply(), when I calculate the log-likelihood for every single couple of 
values (param1,param2).

Do you have any ideas?

Thank you in advance,




Enrico Foscolo

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

2009-08-25 Thread Jo Etzel
I am trying to understand what the lda function in the MASS package calculates 
when there are more dimensions than examples. It is my understanding that the 
Fisher Linear Discriminant is not applicable in this case, because the inverse 
of the covariance matrix cannot be calculated. 

My question is how the output is calculated when the lda function is sent a 
dataset with more dimensions than examples. I had expected it to fail. Is a 
pseudoinverse (or some other technique) used internally to allow computation of 
the lda in this case?

Thank you in advance for your assistance.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Problems with loading 'wordnet' in a standalone pc

2009-08-25 Thread Kelvin Lam

Thanks Uwe.  The wordnet is working now.  My previous configuration that
causes the error was:

R - version 2.9.1
wordnet - version 0.1-4
rJava 0.6-2

After updating rJava to version 0.7-0 everything works now.



Uwe Ligges-3 wrote:
 
 Looks like nobody answered so far:
 
 
 Kelvin Lam wrote:
 Hi group,
 
 I have the following error code after submitting library(wordnet) in a
 standalone pc.  rJava is already in place.
 
 Please read the posting guide and tell us:
 
 
 - Which version of R?
 - Which version of wordnet?
 - Which version of rJava?
 - Which version of Java?
 
 If anywhere not the most recent one: Please upgrade and report again.
 
 
 Error in .jpackage(pkgname,lib.loc=libname)
 unused argument(s) (lib.loc=libname)
 Error: .onLoad failed in 'loadNamespace' for 'wordnet'
 Error: package/namespace load failed for 'wordnet'
 
 My guess is I miss something from the namespace but unfortunately I can't
 get to the internet.  Does anyone know what I'm missing (from the
 namespace?).  Thank you very much!
 
 No, probably nothing is missing from the namespace, but probably too old 
 versions or strange libraries in use.
 
 Best,
 Uwe Ligges
 
 
 Kelvin
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Problems-with-loading-%27wordnet%27-in-a-standalone-pc-tp25062412p25136409.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] Removing objects from workspace

2009-08-25 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Ronggui Huang
 Sent: Monday, August 24, 2009 9:26 PM
 To: Steven Kang
 Cc: r-help@r-project.org
 Subject: Re: [R] Removing objects from workspace
 
 It depends.
 
 If there are patterns in the names, you can make use of pattern
 argument of ls(). For example,
  x1=a;x2=b;x3=c
  ls(pattern=x[1-2])
 [1] x1 x2
  ls(pattern=x[^1-2])
 [1] x3
 # to remove x1-x3
 rm(list=ls(pattern=x[1-2]))
 
 More generally, if you want to remove all butx,xx,xxx,
 you can use
 rm(list=ls()[! ls() %in% c(x,xx,xxx)])

You need to quote the x, xx, and xxx.  Also,
ls()[ ! ls() %in% c(x,xx,xxx) ]
is the same as the more direct
setdiff( ls(), c(x,xx,xxx) )

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com  

 
 
 Hope this helps.
 
 
 2009/8/25 Steven Kang stochastick...@gmail.com:
  Hi all,
 
  I am currently woking with hundreds of objects in workspace 
 and whenever I
  invoke ls() to observe the names of the objects, there are 
 too much of
  unnecessary variables.
 
  For example, if I only require say 3 or 4 objects from 
 hundreds of objects
  in workspace, are there any methods that may do the job?
 
  I have tried rm(-c(x,xx,xxx)), but no luck..
 
  Your feedback in this problem would be highly appreciated.
 
 
 
 
 
  Steve
 
         [[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.
 
 
 
 
 -- 
 HUANG Ronggui, Wincent
 PhD Candidate
 Dept of Public and Social Administration
 City University of Hong Kong
 Home page: http://asrr.r-forge.r-project.org/rghuang.html
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


[R] Help in plotting a legend

2009-08-25 Thread Ashutosh Nandeshwar
Hello, List,

 

I am a new user of the R project, and I need some help in plotting a legend.
I am using the PBSmapping library to plot map of Ohio and heat color it with
the count of employees in each county. As a guide, I am using Data Mashups
in R. I am able to plot the map with the colors; however, I would like to
put a legend with a single box full of these colors, but only show the max
and the min value on the left corner and the right corner respectively. 

 

Here's a  part of the code I am using:

#empdata has the employee data with the latitude and longitude for each
employee

library(PBSmapping)

addressEvents-as.EventData(empdataRC,projection=NA)

#myShapeFile is a shape file of Ohio imported using importShapefile

addressPolys-findPolys(addressEvents,myShapeFile) 

 

myTrtFC-
table(factor(addressPolys$PID,levels=levels(as.factor(myShapeFile$PID 

log(myTrtFC)-lTrt

mapColors-heat.colors(max(lTrt)+1,alpha=.6)[max(lTrt)-lTrt+1] 

mapColors[ is.na(mapColors) ] - white

pdf(RC-Employees.pdf,version=1.4)

plotPolys(myShapeFile,axes=FALSE,bg=white,main= Employees
,xlab=,ylab=,col=mapColors) 

#here is the current legend, but as you can see, the colors and the box
count doesn't match

#i would like to see only one box with the gradients of the colors that I
used, and the max and the min value on top. I even tried a rectangle but I
could not plot it

legend(topleft,legend=seq(max(myTrtFC), 0, length.out=5),
fill=heat.colors(max(myTrtFC)+1,alpha=.6),title=Headcount,
horiz=TRUE,cex=.5,bty=n)

 

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] Help in building new function

2009-08-25 Thread Ana Paula Mora
It worked perfectly.

Thanks a lot.

On Mon, Aug 24, 2009 at 4:16 AM, Gabor Grothendieck ggrothendi...@gmail.com
 wrote:

 1. Just enter
  arima
 at the R console to see its source code (without comments).  The source
 tar.gz for R is found by googling for R, clicking on CRAN in left column
 and choosing mirror.  Or to view it online or get it via svn:
  https://svn.r-project.org/R/

 2. You want myarima's free variables to be found in the stats package so
 set the environment of myarima like this:

 environment(myarima) - asNamespace(stats)


 On Mon, Aug 24, 2009 at 2:18 AM, Ana Paula Moraanamor...@gmail.com
 wrote:
  Hi:
 
  I've installed the precompiled binary for Windows. I need to use an
 existing
  function, but I want to introduce some slight changes to it.
 
  1. Is there a way for me to find the source files through windows
 explorer?
  I know I can see it using edit(object name) but I want to know if I can
 see
  it via explorer in some location under the R directory.
 
  2. I don´t want to modify the code of that function until I'm sure that
 my
  changes are not causing any harm. So, I got the R-2.9.1.tar.gz file and
 open
  the arima.R file. I change the name of the function to myarima, the name
 of
  the file to myarima.R, save it and the loaded it using the source
 command.
  So far, so good. When I try to execute my function I get the error
 message
  Error in Delta %+% c(1, -1) : object 'R_TSconv' not found. So far, the
  only change I made is add a Hello world in the first line, so my change
 is
  not the source of the problem. Looks like my function (although it is
  exactly the same) is not being able to see this object.
 
  Can someone help me out? Am I missing something?
 
  Thanks a lot in advance.
 
  Regards,
 
  Ana
 
 [[alternative HTML version deleted]]
 
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 


[[alternative HTML version deleted]]

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


[R] seeking tutor on statistical learning and data-mining

2009-08-25 Thread Luna Laurent
(posting for my friend)

Hi all,

We are looking for a tutor who could teach me statistical learning and
data-mining using the book:

The Elements of Statistical Learning: Data Mining, Inference, and Prediction

Please drop me a line if you are interested. Thank you!

[[alternative HTML version deleted]]

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


Re: [R] Lattice graph tweaking

2009-08-25 Thread Wallis, David
Sorry,

That worked.

However, is it possible to single out specific boxes and change their colour? I 
want the four graph headers in 
the top right of the trellice to be different colour to the rest.

Thanks very much

From: Sundar Dorai-Raj [sdorai...@gmail.com]
Sent: Tuesday, August 25, 2009 3:19 PM
To: Wallis, David
Cc: silwood-r; r-help@r-project.org
Subject: Re: [R] Lattice graph tweaking

A reproducible example would be nice.

Try grid = FALSE for the first question, though I'm unaware which
lattice plot you are using where the default is TRUE. So I can't
guarantee that will even work.

For your second question, add

par.settings = list(strip.background = list(col = white))

to your call (e.g. xyplot(..., par.settings = ...)).

To see what other parameters you can set in par.settings, try:

str(trellis.par.get())

HTH,

--sundar

On Tue, Aug 25, 2009 at 6:14 AM, Wallis,
Daviddavid.walli...@imperial.ac.uk wrote:
 To: silwood-r
 Subject: Removing lattice graph gridlines and editing label box colour

 Hi,

 Is it possible to remove the background gridlines from a lattice graph (ie 
 graph made up of multiple individual graphs with annoying blue grid in the 
 backgroun)?

 Also, Is it possible to change the colour of the individual graph label 
 boxes? - ie the default pink boxes above the individual graphs

 Thanks

[[alternative HTML version deleted]]

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Appending strings at the beginning of a text file

2009-08-25 Thread Paul Smith
Dear All,

I have a piece of text that I want to append to a text file at the
beginning of the text file.

I have thought about using cat() with the option 'append=T', but the
appending, in this case, is done at the bottom of the text file. Any
ideas?

Thanks in advance,

Paul

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


[R] Covariates in NLS (Multiple nonlinear regression)

2009-08-25 Thread Lindsay Banin
Dear R-users,

I am trying to create a model using the NLS function, such that:

Y = f(X) + q + e

Where f is a nonlinear (Weibull: a*(1-exp(-b*X^c)) function of X and q is a 
covariate (continous variable) and e is an error term. I know that you can 
create multiple nonlinear regressions where x is polynomial for example, but is 
it possible to do this kind of thing when x is a function with unknown 
coefficients (a,b,c)? Ultimately, I am expecting the output to give individual 
regression models for each coefficient (a,b,c) with q as a covariate.

I have tried the following code, and get the resultant error messages:
 weib.nls - nls(Y ~ (a*(1-exp(-b*X^c)))|q,
 + data=DATA,
 + start=c(a=75,b=0.05,c=0.7))
 Error in nlsModel(formula, mf, start, wts) : 
   singular gradient matrix at initial parameter estimates
  summary(weib.nls)

  weib.nls2 - nls(Y~ (a*(1-exp(-b*X^c)))+q,
 + data=DATA,
 + start=c(a=75,b=0.05,c=0.7))
 Error in numericDeriv(form[[3L]], names(ind), env) : 
   Missing value or an infinity produced when evaluating the model
 

Many thanks in advance!
Lindsay

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

2009-08-25 Thread David Winsemius


On Aug 25, 2009, at 8:45 AM, maram salem wrote:


Dear All,
I have a matrix m of the form
 m
[,1] [,2]
  [1,]  9072.302 0.0004462366
  [2,]  9086.811 0.0005628169
  [3,]  9101.320 0.0007126347
  [4,]  9115.830 0.0008986976
  [5,]  9130.339 0.001126
  [6,]  9144.848 0.0014018405
  [7,]  9159.357 0.0017344229
  [8,]  9173.866 0.0021363563
  [9,]  9188.375 0.0026389996
 [10,]  9202.884 0.0032406678

where the first col is my variable x and the second is f(x). I've  
obtained this from the result of a kernel density estimate so I  
don't know the explict form of f(x) .
For some reason i want to integerate f(x) over a certain range using  
integrate( ). So i want R to consider the above matrix as a function  
where the first col is the argument x and the second is the  
realization f(x).

I've tried as.function and vectorize but it didn't work out.
Could u help me do it?
Thanks
Maram



http://finzi.psych.upenn.edu/Rhelp08/2008-July/169121.html






[[alternative HTML version deleted]]

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Appending strings at the beginning of a text file

2009-08-25 Thread Henrique Dallazuanna
Try this;

fConn - file('test.txt', 'r+')
Lines - readLines(fConn)
writeLines(paste(Text at beginning of file, Lines, sep = \n),
   con = fConn)

On Tue, Aug 25, 2009 at 12:54 PM, Paul Smith phh...@gmail.com wrote:

 Dear All,

 I have a piece of text that I want to append to a text file at the
 beginning of the text file.

 I have thought about using cat() with the option 'append=T', but the
 appending, in this case, is done at the bottom of the text file. Any
 ideas?

 Thanks in advance,

 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.




-- 
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] Help with nls and error messages singular gradient

2009-08-25 Thread Michael Pearmain
Hi All,

I'm trying to run nls on the data from the study by Marske (Biochemical
Oxygen Demand Interpretation Using Sum of Squares Surface. M.S. thesis,
University of Wisconsin, Madison, 1967) and was reported in Bates and Watts
(1988).

Data is as follows, (stored as mydata)

  time  bod
11 0.47
22 0.74
33 1.17
44 1.42
55 1.60
67 1.84
79 2.19
8   11 2.17

I then run the following;
#Plot initial curve
plot(mydata$time, mydata$bod,xlab=Time (in days),ylab=biochemical oxygen
demand (mg/l) )

model - nls(bod ~ beta1/(1 - exp(beta2*time)), data =
mydata, start=list(beta1 = 3, beta2 = -0.1),trace=T)

The start values are recommended, (I have used these values in SPSS without
any problems, SPSS returns values of Beta1 = 2.4979 and Beta2 = -2.02 456)

but return the error message,
Error in nls(bod ~ beta1/(1 - exp(beta2 * time)), data = mydata, start =
list(beta1 = 3,  : singular gradient

Can anyone offer any advice?

Thanks in advance

Mike









-- 
Michael Pearmain
Senior Analytics Research Specialist

“Statistics are like women; mirrors of purest virtue and truth, or like
whores to use as one pleases”

Google UK Ltd
Belgrave House
76 Buckingham Palace Road
London SW1W 9TQ
United Kingdom
t +44 (0) 2032191684
mpearm...@google.com

If you received this communication by mistake, please don't forward it to
anyone else (it may contain confidential or privileged information), please
erase all copies of it, including all attachments, and please let the sender
know it went to the wrong person. 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] lme, lmer, gls, and spatial autocorrelation

2009-08-25 Thread Timothy_Handley
Manuel,

Thanks for the reference. I printed it out and read through it this
morning.

I think I'm going to take a gls approach. I've spent the last couple weeks
reading about spatial autocorrelation, and found that the world of SAC is
large, complex, and requires more time than I currently have. Using gls
seems a reasonable compromise between statistical rigour, and the
unfortunate but real constraint of my limited time to work on this project.
According to Dorman et al, in their (admittedly limited) tests, GLS worked
reasonably well with Poisson distributed synthetic data.

Also, I've come to think that the ability to do model comparison would be
useful. While I would like to be able to confidently choose a model for
spatial autocorrelation a priori, based on biological knowledge, I don't
have enough information to do this. Even after some data exploration, using
variograms and plots of Moran's I, it still seems like there's insufficient
information. Using a fitness score such as AIC, I could compare a small
number of reasonable models to find the most appropriate error structure.
Additionally, I could compare the SAC-informed and SAC-ignorant models to
get a holistic assessment of the importance of SAC in my data.


Tim Handley
Fire Effects Monitor
Santa Monica Mountains National Recreation Area
401 W. Hillcrest Dr.
Thousand Oaks, CA 91360
805-370-2347


   
 Manuel Morales
 Manuel.A.Morales 
 @williams.edu To 
   timothy_hand...@nps.gov 
 08/24/2009 05:31   cc 
 PMBert Gunter 
   gunter.ber...@gene.com,   
   r-help@r-project.org
   Subject 
   Re: [R] lme, lmer, gls, and spatial 
   autocorrelation 
   
   
   
   
   
   




Hi Tim,

I don't believe there is a satisfactory solution in R - at least yet -
for non-normal models. Ultimately, this should be possible using lmer()
but not in the near-term. One possibility is to use glmPQL as described
in:

Dormann, F. C., McPherson, J. M., Araújo, M. B., Bivand, R., Bolliger,
J., Carl, G., Davies, R. G., Hirzel, A., Jetz, W., Kissling, W. D.,
Kühn, I., Ohlemüller, R., Peres-Neto, P. R., Reineking, B., Schröder,
B., Schurr, F. M. and Wilson, R. 2007. Methods to account for spatial
autocorrelation in the analysis of species distributional data: a
review. – Ecography 30: 609–628.

However, note the caution:

This is an inofficial abuse of a Generalized Linear Mixed Model
function (glmmPQL {MASS}), which is a wrapper function for lme {nlme},
which in turn internally calls gls {nlme}.

If all you need are parameter estimates, fine. If you want to do model
comparison, though, no luck.

Manuel

On Mon, 2009-08-24 at 12:10 -0700, timothy_hand...@nps.gov wrote:
 Bert -

  I took a look at that page just now, and I'd classify my problem as
 spatial regression. Unfortunately, I don't think the spdep library fits
my
 needs. Or at least, I can't figure out how to use it for this problem.
The
 examples I have seen all use spdep with networks. They build a graph,
 connecting each location to something like the nearest N neighbors,
attach
 some set of weights, and then do an analysis. The plots in my data have a
 very irregular, semi-random, yet somewhat clumped (several isolated
 islands), spatial distribution. Honestly, it's quite weird looking. I
don't
 know how to cleanly turn this into a network, and even if I did, I don't
 know that I ought to. To me (and please feel free to disagree) it seems
 more natural to use a matrix of distances and associated correlations,
 which is what the gls function appears to do.

 In the ecological analysis section, it looks like both 'ade4' and 'vegan'
 may have helpful tools. I'll explore that some more. However, I still
think
 that one of lme or gls already has the functionality I need, and I just
 need to learn how to use them properly.

 Tim Handley
 Fire Effects Monitor
 Santa Monica Mountains National Recreation Area
 401 W. Hillcrest Dr.
 Thousand Oaks, CA 

[R] draw n-1 lines with n X and n Y

2009-08-25 Thread mirko86

I want to draw lines using a matrix with the X-axe on the first column, and
the the Y-axe on the second column.
These lines have to link the n points of a graph, so they are n-1, but the
resout using  these two commands:
X - matrix(scan(MaxInterEdges.R,0), ncol=2);
lines(X[,1], X[,2], type = l, col = red);

is wrong, becose the lines are many more.

What can I do? 
-- 
View this message in context: 
http://www.nabble.com/draw-n-1-lines-with-n-X-and-n-Y-tp25137514p25137514.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] scatterplot3d bug??

2009-08-25 Thread Uwe Ligges

I finally found some time to look at it:

Yes, it does not work properly for angles  180 degrees. Will try to 
find a fix and make a new release soon.


Best wishes,
Uwe Ligges


Vivek Ayer wrote:

Hey guys,

Not sure if I encountered a bug with the scatterplot3d function.
Here's the calls I made:

s3d1 - 
scatterplot3d(TotLogDisttenp,TotDifftenp,TotMeasuredRSLtenp,pch=16,highlight.3d=TRUE,angle=40,type=h,main=MRSL
~ LogDist + Diff);
s3d1$plane3d(fitols);
s3d1 - 
scatterplot3d(TotLogDisttenp,TotDifftenp,TotMeasuredRSLtenp,pch=16,highlight.3d=TRUE,angle=130,type=h,main=MRSL
~ LogDist + Diff);
s3d1$plane3d(fitols);
s3d1 - 
scatterplot3d(TotLogDisttenp,TotDifftenp,TotMeasuredRSLtenp,pch=16,highlight.3d=TRUE,angle=210,type=h,main=MRSL
~ LogDist + Diff);
s3d1$plane3d(fitols);
s3d1 - 
scatterplot3d(TotLogDisttenp,TotDifftenp,TotMeasuredRSLtenp,pch=16,highlight.3d=TRUE,angle=310,type=h,main=MRSL
~ LogDist + Diff);
s3d1$plane3d(fitols);

Essentially four plots showing the data from different angles. This
includes the fit plane. The first two graphs make sense, but for the
latter two, the fit plane is not making sense.

Take a look at the attached png.

Is it a bug?

Thanks,
Vivek







__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Covariates in NLS (Multiple nonlinear regression)

2009-08-25 Thread Bert Gunter
I think you need to consult a local statistician, as you appear to be so far
out of your depth statistically that even the best-intentioned help from
this list may not suffice. For example, if I were that local statistician, I
would ask: what is the context? -- what is the underlying scientific issue
that led to this model? -- what are the data? -- etc. etc. before I would
even hazard advice on the statistical details(Please do not answer these
questions either publicly or privately, as they are just fyi's).

Bert Gunter
Genentech Nonclinical Biostatisics

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Lindsay Banin
Sent: Tuesday, August 25, 2009 9:02 AM
To: 'r-help@r-project.org'
Subject: [R] Covariates in NLS (Multiple nonlinear regression)

Dear R-users,

I am trying to create a model using the NLS function, such that:

Y = f(X) + q + e

Where f is a nonlinear (Weibull: a*(1-exp(-b*X^c)) function of X and q is a
covariate (continous variable) and e is an error term. I know that you can
create multiple nonlinear regressions where x is polynomial for example, but
is it possible to do this kind of thing when x is a function with unknown
coefficients (a,b,c)? Ultimately, I am expecting the output to give
individual regression models for each coefficient (a,b,c) with q as a
covariate.

I have tried the following code, and get the resultant error messages:
 weib.nls - nls(Y ~ (a*(1-exp(-b*X^c)))|q,
 + data=DATA,
 + start=c(a=75,b=0.05,c=0.7))
 Error in nlsModel(formula, mf, start, wts) : 
   singular gradient matrix at initial parameter estimates
  summary(weib.nls)

  weib.nls2 - nls(Y~ (a*(1-exp(-b*X^c)))+q,
 + data=DATA,
 + start=c(a=75,b=0.05,c=0.7))
 Error in numericDeriv(form[[3L]], names(ind), env) : 
   Missing value or an infinity produced when evaluating the model
 

Many thanks in advance!
Lindsay

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Decision boundaries for lda function?

2009-08-25 Thread Thomas Larsen

I got hold of 'Modern Applied Statistics with S' by Venables and Ripley (p.
335-336) and I was able to answer my own question:

###
AA-read.table(http://www.natursyn.dk/online/fingerprinting.txt,header=T)

aa.grp - factor(c(rep('f',13),rep('b',10),rep('p',10)))

aa.lda-lda(as.matrix(AA[3:9]),AA$group) 
aa.ld-predict(aa.lda,dimen=2)$x 
eqscplot(aa.ld,type=n,xlab=LD1, ylab=LD2,tol=0.25, las=1) 
text(aa.ld,labels = as.character(aa.grp))

aa.lda2 - lda(aa.ld, aa.grp)
x - seq(-7, 5.5, 0.25)
y - seq(-4.5, 6.5, 0.25)
Xcon - matrix(c(rep(x,length(y)),
   rep(y, rep(length(x), length(y,,2)

aa.pr1 - predict(aa.lda2, Xcon)$post[, c(f,b)] %*% c(1,1)
contour(x, y, matrix(aa.pr1, length(x), length(y)),
   levels=0.5, add=T, lty=3,method=simple)
aa.pr2 - predict(aa.lda2, Xcon)$post[, c(p,b)] %*% c(1,1)
contour(x, y, matrix(aa.pr2, length(x), length(y)),
   levels=0.5, add=T, lty=3,method=simple)
aa.pr3 - predict(aa.lda2, Xcon)$post[, c(f,p)] %*% c(1,1)
contour(x, y, matrix(aa.pr3, length(x), length(y)),
   levels=0.5, add=T, lty=3,drawlabels=F)
###


Thomas Larsen wrote:
 
 Hi,
 
 I am using the lda function from the MASS library. I would to find the
 decision boundaries of each class and subsequently plot them. I wonder if
 anybody can offer any help on this topic? 
 
 Below I applied the lda function on a small dataset of mine. 
 
 Any help will be much appreciated.
 
 library(MASS)
 
 AA-read.table(http://www.natursyn.dk/online/fingerprinting.txt,header=T)
 
 aa.lda-lda(as.matrix[3:9],AA$group) 
 aa.ld-predict(aa.lda,dimen=2)$x 
 eqscplot(aa.ld,type=n,xlab=LD1, ylab=LD2,las=1) 
 text(aa.ld,c(rep('f',13),rep('b',10),rep('p',10)))
 
 aa.mean-lda(aa.ld,AA$group)$means 
 points(aa.mean,pch=3) 
 
 Best,
 Thomas Larsen
 
 Leibniz-Laboratory for Stable Isotope Research
 Max-Eyth-Str. 11-13, 24118 Kiel, Germany
 Work: +49-431-880-3896
 

-- 
View this message in context: 
http://www.nabble.com/Decision-boundaries-for-lda-function--tp24823213p25137633.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] how to pass user input to a function?

2009-08-25 Thread Ista Zahn
Hi everyone,
I'm building a website (http://yourpsyche.org) using  Jeffrey Horner's
awesome Rapache module. I want to take user input, and pass it to an R
script. At first I was simply using if else statements, but after a
while I had so many nested if else's in my code that my head was
spinning. So then I started using cat() and source() to write
temporary files and read them back in (see example below). I've
searched around, and I think there might be a better way to do it with
substitute(), but I can't seem to figure it out (see attempt below).

 Here is a minimal example:

 ###set up simple example###
 GET - list(pass.var=b)
 a - 1:10
 b - 11:20

 ###using if else works but becomes confusing when I have a lot of variables 
 to pass###
 if(GET$pass.var==a)
+   {
+ mean(a)
+   } else if(GET$pass.var==b)
+   {
+ mean(b)
+   }
[1] 15.5

 ###writing to a temporary file works but feels like a hack and results in 
 many temp
files###
 cat('print(mean(', GET$pass.var,'))', file=tmp.R,sep=)
 source(tmp.R)
[1] 15.5

 ###this seems promising but I can't figure it out###
 substitute(mean(x), list(x=GET$pass.var))
mean(b)

 ###is there a better way?###


Thanks!
-- 
Ista Zahn
Graduate student
University of Rochester

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

2009-08-25 Thread Vivek Ayer
Great! Thanks again!

Vivek

2009/8/25 Uwe Ligges lig...@statistik.tu-dortmund.de:
 I finally found some time to look at it:

 Yes, it does not work properly for angles  180 degrees. Will try to find a
 fix and make a new release soon.

 Best wishes,
 Uwe Ligges


 Vivek Ayer wrote:

 Hey guys,

 Not sure if I encountered a bug with the scatterplot3d function.
 Here's the calls I made:

 s3d1 -
 scatterplot3d(TotLogDisttenp,TotDifftenp,TotMeasuredRSLtenp,pch=16,highlight.3d=TRUE,angle=40,type=h,main=MRSL
 ~ LogDist + Diff);
 s3d1$plane3d(fitols);
 s3d1 -
 scatterplot3d(TotLogDisttenp,TotDifftenp,TotMeasuredRSLtenp,pch=16,highlight.3d=TRUE,angle=130,type=h,main=MRSL
 ~ LogDist + Diff);
 s3d1$plane3d(fitols);
 s3d1 -
 scatterplot3d(TotLogDisttenp,TotDifftenp,TotMeasuredRSLtenp,pch=16,highlight.3d=TRUE,angle=210,type=h,main=MRSL
 ~ LogDist + Diff);
 s3d1$plane3d(fitols);
 s3d1 -
 scatterplot3d(TotLogDisttenp,TotDifftenp,TotMeasuredRSLtenp,pch=16,highlight.3d=TRUE,angle=310,type=h,main=MRSL
 ~ LogDist + Diff);
 s3d1$plane3d(fitols);

 Essentially four plots showing the data from different angles. This
 includes the fit plane. The first two graphs make sense, but for the
 latter two, the fit plane is not making sense.

 Take a look at the attached png.

 Is it a bug?

 Thanks,
 Vivek


 


 

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


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


Re: [R] how to pass user input to a function?

2009-08-25 Thread Michael E. Driscoll
Hi Ista -

I've had success using the do.call function with RApache

 do.call(func, arglst)

where 'func' is the function you desire to use, 'arglst' is a list of arguments.

You may need to do some cleanup of the arguments using evalq()
function (so that numbers are treated as numbers, for example).

HTH,

Mike
-- 
p: 415.860.4347
b: www.dataspora.com/blog
t: www.twitter.com/dataspora

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