Re: [R] Function to locate points in 3d octants or points on two axes

2011-02-02 Thread Petr Savicky
On Tue, Feb 01, 2011 at 08:30:22PM -0500, Bryan Hanson wrote:
 [Sorry, resending with a proper subject line!]
 
 Hi Guru's...
 
 I have a set of points that may lie along any of the x, y and z axes  
 in a Cartesian coordinate system.  I am hoping that a function exists  
 which will determine if any two selected points are on different axes,  
 i.e, if the one of the points is on x and the other on y or z, not  
 elsewhere on the x axis.  Put another way, I need to determine if the  
 triangle formed by the two points and the origin lies in the xy, xz or  
 yz planes.  This might be as simple as testing if any particular value  
 is zero, i.e. if the x coordinate is zero, then the points must be on  
 the z and y axes and the triangle in the yz plane.  But, I'm looking  
 for a fairly general solution, one that also returns the appropriate  
 plane as the answer.  Very closely related to this, I could use a  
 function that determines which of the 8 octants a point lies in. Seems  
 like the cross product might be part of this, but I'm a little rusty  
 on how to apply it.
 
 I hope this is clear enough, and someone has a suggestion to point me  
 in the right direction.  Before writing my own klunky version, I  
 thought I'd ask.

Hi.

I think that for suggesting an appropriate solution it may be needed
to know, which data structure is used for the input pairs of points. For
example, it may a single matrix n times 3 with points as rows and a pair
is represented by two indices of the points. Alternatively, the input
may be a single matrix n times 6, where rows are pairs of points.

In any case, the input may be simplified using sign() function. For example

  a - as.matrix(expand.grid(x=c(-1.1, 0, 1.1), y=c(0, 1.2), z=c(0, 1.3)))
  a

   x   y   z
   [1,] -1.1 0.0 0.0
   [2,]  0.0 0.0 0.0
   [3,]  1.1 0.0 0.0
   [4,] -1.1 1.2 0.0
   [5,]  0.0 1.2 0.0
   [6,]  1.1 1.2 0.0
   [7,] -1.1 0.0 1.3
   [8,]  0.0 0.0 1.3
   [9,]  1.1 0.0 1.3
  [10,] -1.1 1.2 1.3
  [11,]  0.0 1.2 1.3
  [12,]  1.1 1.2 1.3

  sign(a)

 x y z
   [1,] -1 0 0
   [2,]  0 0 0
   [3,]  1 0 0
   [4,] -1 1 0
   [5,]  0 1 0
   [6,]  1 1 0
   [7,] -1 0 1
   [8,]  0 0 1
   [9,]  1 0 1
  [10,] -1 1 1
  [11,]  0 1 1
  [12,]  1 1 1

This output represents a classification of the points into a finite
number of regions and keeps the information needed for any of the
tasks, which you mention.

Hope this helps.

Petr Savicky.

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


Re: [R] Hidden environment

2011-02-02 Thread Prof Brian Ripley

On Tue, 1 Feb 2011, Joel wrote:



Hi

I wondering if its possible to make a hidden environment for a package, so
the user cant see whats in it but the diffrent functions inside the package
can use the variables in the environment.


Up to a point:

1) See the manual about the concept of a name space.

2) A package can also have one or more private environments, using 
new.env() or local(): grDevices is an example.


However, R is Open Source so a determined user can find such 
environments: hence 'the user cant see whats in it' (is your ' key 
broken?) is not really achievable.



Hope you can understand what Im after.

Joel


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

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


[R] Finding the maximum in a particular group in a dataframe

2011-02-02 Thread Asan Ramzan
Hello

I am trying to find a way to find the max value, for only a subset of a
dataframe, depending on how the data is grouped for example,

How would I find the maxmium responce, for all the GPR119a condition below:

I've tried tapply

 tapply(GPR119data$responce, GPR119data$GPR119a, max)
Error in tapply(GPR119data$responce, GPR119data$GPR119a, max) : 
  arguments must have same length

responce,mouce,condition
0.105902,KO,con
0.232018561,KO,con
0.335008375,KO,con
0.387025433,KO,GPR119a
0.576769897,KO,GPR119a
0.645120419,KO,GPR119a
0.2538608,KO,GPR119b
0.183061952,KO,GPR119b
0.824035587,KO,GPR119b
0.399201597,KO,GPR119c
0.417006618,KO,GPR119c
0.572958834,KO,GPR119c
0.229467444,KO,GPR119d
0.294089745,KO,GPR119d
0.309964445,KO,GPR119d
0.30474325,KO,GPR119e
0.159374839,KO,GPR119e
0.467726848,KO,GPR119e
1.01841912,KO,GPR119f
0.423028621,KO,GPR119f
0.223588597,KO,GPR119f

Thank



  
[[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] combining vectors into list

2011-02-02 Thread Lorenzo Cattarino
Hi R users 

 

I have these two vectors:

 

Row - sample(1:25, 10)

Col - sample(1:25, 10)

 

Is there a way to combine them into a list, whose first component is a
vector containing the first element of Row and the first element of Col,
the second component is a vector containing the second element of Row
and the second element of Col, and so on...

 

Thanks you 

Lorenzo


[[alternative HTML version deleted]]

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


[R] Why my package is not being generate?

2011-02-02 Thread Cristiano Strieder
Hi all,

I have commited a new release of my package and waited for more than one
day. After that install.packages(tests,repos=http://r-forge.r-projet.org;)
still returns package 'tests' is not available. I have done the local
build  check and the package seems ok. Also have mofified the Title in the
DESCRIPTION  file.

What can be wrong?

Is there any tool or recomendation to validade my package before submit it?


-- 
Cristiano Strieder
São José dos Campos - SP

[[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] error in scan(...

2011-02-02 Thread gked

I know it's a common error and there is a lot of help available but still
can't resolve the issue:
all i am trying to do is to read a csv file from my folder and this is what
i get:

Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, 
: 
  scan() expected 'a real', got
'1,m,a,F,165,240,26.5,31,0.738,0.704,1.095,0.606,0.847'

Can you help?

-- 
View this message in context: 
http://r.789695.n4.nabble.com/error-in-scan-tp3253487p3253487.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] reshape data, adding rows to dataframe

2011-02-02 Thread Lucia Rueda

Hello everyone,

I have a data set like this:

 head( fish_transect)
  ID_TRANSECT ID_PROJECT   DE_ZONE DE_LOCALITY DE_SECTOR MES
1  42 MB TarragonaCreixell Control I   9
2  42 MB TarragonaCreixell Control I   9
3  42 MB TarragonaCreixell Control I   9
4  42 MB TarragonaCreixell Control I   9
5  42 MB TarragonaCreixell Control I   9
6  42 MB TarragonaCreixell Control I   9
   ID_SPECIES WEIGHT  SIZE   NFAMILIA
1 Spondyliosoma cantharus15.64 10 1Sparidae
2  Symphodus melanocercus  11.21 10  1   Labridae
3   Diplodus vulgaris 30.20 10  2   Sparidae
4   Diplodus vulgaris 52.24 12  2   Sparidae
5 Diplodus sargus221.4114 5Sparidae
6  Diplodus annularis 3.47   6  1Sparidae

I have been trying to duplicate the rows where N 1, that is I want a row
for each animal. Right now as you can see I have for example 5 D. sargus
which are 14 cm length and so on. How can I get 1 row for each animal? I've
been trying the reshape function without success. I also tried in access but
couldn't do it either.

Thanks a lot,

Lucia



-- 
View this message in context: 
http://r.789695.n4.nabble.com/reshape-data-adding-rows-to-dataframe-tp3253640p3253640.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] Counter in a For Loop - Efficiency Issue

2011-02-02 Thread Leendert Punt
I have a 32000 x 14 matrix (M) where entry (x, y) corresponds to
person x at a discrete time y. I then have a matrix (M2) of 6 x 2
where each entry is a an event by a person that is in the above 32000
and at a time that is in the range of the discrete time points above.
I want to populate the another matrix (M3) such that (x, y) is the
number of events of person x between times y-1 and y. This is simple
to code, (I just put the discrete time points and the 32000 people in
their own vectors, V1 and V2):


for (i in 1:32000){
for (j in 1:6){

for (k in 2:14){

if (M2[1, j] == V2[i]  M2[2, j]   V1[k-1] M2[2, j] = V1[k])
M3[i, k] = M3[i, k]+1

}}}

This would work im sure, the problem is that it takes a very long
time. Any advice on helping it run faster would be greatly
appreciated.

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


Re: [R] Preparing dataset for glmnet: factors to dummies

2011-02-02 Thread Mark Difford

Hi Frank,

 I believe that glmnet scales variables by their standard deviations. 
 This would not be appropriate for categorical predictors.

That's an excellent point, which many are likely to forget (including me)
since one is using a model matrix. The default argument is to standardize
inputs, but there is an option to turn it off. (One could then standardize
continuous inputs on different scales oneself.)

Regards, Mark.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Preparing-dataset-for-glmnet-factors-to-dummies-tp3250791p3253538.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] error in density plot

2011-02-02 Thread Ramya

Hi,

I have the code for the density plot
j - 8 
plot(density(diff_in_sample[,1]), main = list.files()[j])
for(i in 1:25){
lines(density(diff_in_sample[,i]))
}

This gives me an error 
Error in density.default(diff_in_sample[, i]) : 
  'x' contains missing values

I am not quite sure what to do. I have the same code doing plots for
otherfiles but just one is not working. what xactly it means missing values
even if there is there how can i tell it to overlook those

any help would be  appreciated

Thanks
Ramya


-- 
View this message in context: 
http://r.789695.n4.nabble.com/error-in-density-plot-tp3253489p3253489.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 Plot Two Curves Into One Page

2011-02-02 Thread Edwin Groot
On Tue, 1 Feb 2011 14:20:51 +0900
 Gundala Viswanath gunda...@gmail.com wrote:
 I have a R script that contain these lines for plotting:
 
 plot(foo,lwd=2,lty=3,col=red, main=);
 plot(bar,lwd=2,lty=3,col=blue);
 legend(0.6,0.6,c('Default','Probabilistic'),
 col=c('red','blue'),lwd=3);
 
 
 But it generate 1 file (Rplot.pdf) with two pages. Each page for 1
 plot.
 Is there a way I can put them together in to one page?
 
 - G.V.
 

Hello Gundala,
If these are fairly simple plots (i.e. curve, points, bar, step) you
can arrange your data as columns in a matrix and use matplot().

matplot(vectorOfxValues, FooBarAsMatrix, lwd=2, lty=3, col=c(red,
blue))
legend(0.6,0.6,c('Default','Probabilistic'), col=c('red','blue'),lwd=3)

Regards,
Edwin
-- 
Dr. Edwin Groot, postdoctoral associate
AG Laux
Institut fuer Biologie III
Schaenzlestr. 1
79104 Freiburg, Deutschland
+49 761-2032945

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


[R] RMySQL, cant find MySQL

2011-02-02 Thread Joel

Hi

I'm having some trouble with getting RMySQL installed on my Ubuntu system.

As the apt-get install version of R is 2.10.x I've reinstalled 2.12 the old
fashion way by ./conf and make.

But now when I shall install RMySQL I get 

Configuration error:
  could not find the MySQL installation include and/or library
  directories.  Manually specify the location of the MySQL
  libraries and the header files and re-run R CMD INSTALL.

And in truth I cant find the headers or libraries anywhere on my comp, but I
have MySQL up and running.

I did install MySQL via apt-get so if anyone know where it put the different
files I would love to know :).

Thx for the help
Joel
-- 
View this message in context: 
http://r.789695.n4.nabble.com/RMySQL-cant-find-MySQL-tp3253689p3253689.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] help

2011-02-02 Thread Łukasz Ręcławowicz
We don't need a loop!

require(Rmpfr)
factorial(mpfr(1:500,3800))


2011/2/2 Waclaw Kusnierczyk w...@idi.ntnu.no


 library(bc)
 factorial = function(n) bc(sprintf('
define factorial(n) {
if (n  2) return (1)
f = 2
i = 2
while (i  n) f *= ++i
return (f) }
factorial(%d)', n))


-- 
Mi³ego dnia

[[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] combining vectors into list

2011-02-02 Thread Ivan Calandra

Hi,

Try this:
mapply(FUN=c, Row, Col, SIMPLIFY=FALSE)

HTH,
Ivan

Le 2/2/2011 08:55, Lorenzo Cattarino a écrit :

Hi R users



I have these two vectors:



Row- sample(1:25, 10)

Col- sample(1:25, 10)



Is there a way to combine them into a list, whose first component is a
vector containing the first element of Row and the first element of Col,
the second component is a vector containing the second element of Row
and the second element of Col, and so on...



Thanks you

Lorenzo


[[alternative HTML version deleted]]

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



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

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

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


Re: [R] reshape data, adding rows to dataframe

2011-02-02 Thread Ivan Calandra

Hi,

Not sure what you want to do, but take a look at ?duplicated, ?unique, 
and maybe ?aggregate; it might be what you're looking for.


HTH,
Ivan

Le 2/2/2011 10:13, Lucia Rueda a écrit :

Hello everyone,

I have a data set like this:


head( fish_transect)

   ID_TRANSECT ID_PROJECT   DE_ZONE DE_LOCALITY DE_SECTOR MES
1  42 MB TarragonaCreixell Control I   9
2  42 MB TarragonaCreixell Control I   9
3  42 MB TarragonaCreixell Control I   9
4  42 MB TarragonaCreixell Control I   9
5  42 MB TarragonaCreixell Control I   9
6  42 MB TarragonaCreixell Control I   9
ID_SPECIES WEIGHT  SIZE   NFAMILIA
1 Spondyliosoma cantharus15.64 10 1Sparidae
2  Symphodus melanocercus  11.21 10  1   Labridae
3   Diplodus vulgaris 30.20 10  2   Sparidae
4   Diplodus vulgaris 52.24 12  2   Sparidae
5 Diplodus sargus221.4114 5Sparidae
6  Diplodus annularis 3.47   6  1Sparidae

I have been trying to duplicate the rows where N  1, that is I want a row
for each animal. Right now as you can see I have for example 5 D. sargus
which are 14 cm length and so on. How can I get 1 row for each animal? I've
been trying the reshape function without success. I also tried in access but
couldn't do it either.

Thanks a lot,

Lucia





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

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

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


Re: [R] RMySQL, cant find MySQL

2011-02-02 Thread Prof Brian Ripley

On Wed, 2 Feb 2011, Joel wrote:



Hi

I'm having some trouble with getting RMySQL installed on my Ubuntu system.

As the apt-get install version of R is 2.10.x I've reinstalled 2.12 the old
fashion way by ./conf and make.

But now when I shall install RMySQL I get

Configuration error:
 could not find the MySQL installation include and/or library
 directories.  Manually specify the location of the MySQL
 libraries and the header files and re-run R CMD INSTALL.

And in truth I cant find the headers or libraries anywhere on my comp, but I
have MySQL up and running.

I did install MySQL via apt-get so if anyone know where it put the different
files I would love to know :).


Well, you should ask such questions on R-sig-debian or R-sig-db, but I 
presume you forgot that you would need MySQL-dev (or whatever it is 
called on Ubuntu), the development part of the MySQL installation.




Thx for the help
Joel
--
View this message in context: 
http://r.789695.n4.nabble.com/RMySQL-cant-find-MySQL-tp3253689p3253689.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


PLEASE do as we ask.

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

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


Re: [R] Help in getting info from a DataFrame

2011-02-02 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 31.01.2011 15:51:16:

 
 

snip


  
  
 
 Hi
 
 thanks. I am not sure if I have understood 100% but at least I know now 
that
 there's a diference.
 
 About this: 
 
 lapsales
  Store  Prod qtd
  5  Aveiro Lapiseira   3
  8 Coimbra Lapiseira   1
  9 Setubal Lapiseira   1
   lapsales[max(lapsales$qtd),Store]
  [1] Setubal
  Levels: Aveiro Coimbra Evora lx Setubal
 
  why Setubal and not Aveiro?
 
 
 Can you explain me the result?

Probably qtd is not what you think it is. I get

 dados- data.frame(Store = c 
(Setubal,lx,Aveiro,Coimbra,Aveiro,Evora,Aveiro,Coimbra,Setubal),Prod=c(BlocoDesenho,BlocoDesenho,Tinteiro,Régua,Lapiseira,Regua,Tinteiro,Lapiseira,Lapiseira),qtd=c(2,1,2,1,3,1,1,1,1))
 lapsales - dados[dados$Prod==Lapiseira,  ]
 lapsales[which.max(lapsales[ , qtd ]), Store]
[1] Aveiro
Levels: Aveiro Coimbra Evora lx Setubal
 

and

 str(lapsales)
'data.frame':   3 obs. of  3 variables:
 $ Store: Factor w/ 5 levels Aveiro,Coimbra,..: 1 2 5
 $ Prod : Factor w/ 5 levels BlocoDesenho,..: 2 2 2
 $ qtd  : num  3 1 1

Maybe you get something different.

Regards
Petr





 
 thanks
 AD
 -- 
 View this message in context: 
http://r.789695.n4.nabble.com/Help-in-getting-
 info-from-a-DataFrame-tp3247740p3248883.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Counter in a For Loop - Efficiency Issue

2011-02-02 Thread Petr Savicky
On Wed, Feb 02, 2011 at 09:35:28AM +0200, Leendert Punt wrote:
 I have a 32000 x 14 matrix (M) where entry (x, y) corresponds to
 person x at a discrete time y. I then have a matrix (M2) of 6 x 2
 where each entry is a an event by a person that is in the above 32000
 and at a time that is in the range of the discrete time points above.
 I want to populate the another matrix (M3) such that (x, y) is the
 number of events of person x between times y-1 and y. This is simple
 to code, (I just put the discrete time points and the 32000 people in
 their own vectors, V1 and V2):
 
 
 for (i in 1:32000){
 for (j in 1:6){
 
 for (k in 2:14){
 
 if (M2[1, j] == V2[i]  M2[2, j]   V1[k-1] M2[2, j] = V1[k])
 M3[i, k] = M3[i, k]+1
 
 }}}

Consider the following approach, which uses M2, V1 and V2 as
used in the code above.

  V1 - c(0, 10, 20, 30, 40)
  V2 - 1:3 # list of persons in the required order
  M2 - rbind(
  c(1, 2, 1, 1, 3, 1, 3, 1),
  c(11, 21, 21, 21, 11, 21, 11, 31))

  person - factor(M2[1, ], levels=V2)
  interval - cut(M2[2, ], breaks=V1)
  M3 - table(person, interval)

  M2

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]12113131
[2,]   11   21   21   21   11   21   11   31

  M3

interval
  person (0,10] (10,20] (20,30] (30,40]
   1  0   1   3   1
   2  0   0   1   0
   3  0   2   0   0

Does this approach work for your data?

Petr Savicky.

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


Re: [R] sum the values in a vector as a complete number

2011-02-02 Thread Petr PIKAL
Hi


r-help-boun...@r-project.org napsal dne 01.02.2011 07:02:50:

 Hi AD,
 
 You might try the following:
 
 # data
 a - c(2,3,5)
 b - c(8,7)   # you got this wrong ;)
 
 # option 1
 foo - function(x) as.numeric(paste(x, sep = , collapse = ))
 
 # examples
 foo(a)
 # [1] 235
 foo(b)
 # [1] 87
 foo(a) + foo(b)
 # [1] 322
 
 # option 2
 foo2 - function(x, y) foo(x) + foo(y)
 
 # example
 foo2(a, b)
 # [1] 322
 
 See ?paste and ?as.numeric for more information.
 
 HTH,
 Jorge

Above solutions are maybe quicker but here is one plain numeric.

fff-function(x) rev(10^(0:(length(x)-1)))
sum(a*fff(a))+sum(b*fff(b))
[1] 322

or you can put the whole operation inside a function

fff-function(x) sum(x*rev(10^(0:(length(x)-1
fff(a)+fff(b)

Regards
Petr



 
 On Mon, Jan 31, 2011 at 11:22 PM, ADias  wrote:
 
 
  Hi
 
  I am trying to create a function that is able to calculate this sum:
 
  a-c(2,3,5)
  b-(8,7)
 
  with a meaning 235 and b 87. So the result of this sum would be 
235 +
  87
  = 322.
 
  I've searched a function like strsplit but that worked for integers 
and in
  reverse - not spliting but combining.
 
  Can you give me a hand on this please?
 
  thanks
  AD
  --
  View this message in context:
  
http://r.789695.n4.nabble.com/sum-the-values-in-a-vector-as-a-complete-
 number-tp3250470p3250470.html
  Sent from the R help mailing list archive at Nabble.com.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] reshape data, adding rows to dataframe

2011-02-02 Thread Petr Savicky
On Wed, Feb 02, 2011 at 01:13:11AM -0800, Lucia Rueda wrote:
 
 Hello everyone,
 
 I have a data set like this:
 
  head( fish_transect)
   ID_TRANSECT ID_PROJECT   DE_ZONE DE_LOCALITY DE_SECTOR MES
 1  42 MB TarragonaCreixell Control I   9
 2  42 MB TarragonaCreixell Control I   9
 3  42 MB TarragonaCreixell Control I   9
 4  42 MB TarragonaCreixell Control I   9
 5  42 MB TarragonaCreixell Control I   9
 6  42 MB TarragonaCreixell Control I   9
ID_SPECIES WEIGHT  SIZE   NFAMILIA
 1 Spondyliosoma cantharus15.64 10 1Sparidae
 2  Symphodus melanocercus  11.21 10  1   Labridae
 3   Diplodus vulgaris 30.20 10  2   Sparidae
 4   Diplodus vulgaris 52.24 12  2   Sparidae
 5 Diplodus sargus221.4114 5Sparidae
 6  Diplodus annularis 3.47   6  1Sparidae
 
 I have been trying to duplicate the rows where N 1, that is I want a row
 for each animal. Right now as you can see I have for example 5 D. sargus
 which are 14 cm length and so on. How can I get 1 row for each animal? I've
 been trying the reshape function without success. I also tried in access but
 couldn't do it either.

Hello.

Let me use a simpler example for testing.

  dat - data.frame(animal=c(a, b, c), N=c(2, 1, 3))
  dat

animal N
  1  a 2
  2  b 1
  3  c 3

Is the following operation what you want in terms of this small example?

  expand - dat[rep(1:nrow(dat), times=dat$N), ]
  rownames(expand) - NULL
  expand

animal N
  1  a 2
  2  a 2
  3  b 1
  4  c 3
  5  c 3
  6  c 3

Hope this helps.

Petr Savicky.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 column names/row names are preserved in matrix calculation?

2011-02-02 Thread Bogaso Christofer
Can somebody tell me that, if I do some arithmetic calculation over 2
matrices then how the column names and row names are preserved? It seems
that, for multiplication, column names and row names of the 2nd matrix are
preserved and for additional, there seems not having any explicit rule:

 

 set.seed(1)

 dat1 - matrix(rnorm(25), 5); colnames(dat1) = rownames(dat1) =
paste(mat1, 1:5, sep=)

 dat2 - matrix(rnorm(25), 5); colnames(dat2) = rownames(dat2) =
paste(mat2, 1:5, sep=)

 dat3 - matrix(rnorm(25), 5); colnames(dat3) = rownames(dat3) =
paste(mat3, 1:5, sep=)

 dat1

   mat11  mat12  mat13   mat14   mat15

mat11 -0.6264538 -0.8204684  1.5117812 -0.04493361  0.91897737

mat12  0.1836433  0.4874291  0.3898432 -0.01619026  0.78213630

mat13 -0.8356286  0.7383247 -0.6212406  0.94383621  0.07456498

mat14  1.5952808  0.5757814 -2.2146999  0.82122120 -1.98935170

mat15  0.3295078 -0.3053884  1.1249309  0.59390132  0.61982575

 dat2

mat21   mat22  mat23  mat24  mat25

mat21 -0.05612874  1.35867955 -0.4149946 -0.1645236 -0.7074952

mat22 -0.15579551 -0.10278773 -0.3942900 -0.2533617  0.3645820

mat23 -1.47075238  0.38767161 -0.0593134  0.6969634  0.7685329

mat24 -0.47815006 -0.05380504  1.1000254  0.5566632 -0.1123462

mat25  0.41794156 -1.37705956  0.7631757 -0.6887557  0.8811077

 dat1 %*% dat2 + dat3

   mat21  mat22  mat23   mat24  mat25

mat11 -1.2567987  0.5365897  3.5473394  0.89542630  2.5962144

mat12 -0.9370075 -1.0928568  0.2483355 -2.23467503  0.3284073

mat13  0.7665543 -2.6496778  1.8774045  1.45703219  0.9533289

mat14  0.7245671  4.5147054 -1.3445549  0.02866729 -5.356

mat15 -0.2173109 -0.1053570  0.3000135  2.88350373 -0.2541405

 

Can somebody finalize me what is the **rule** for preserving column names
and row names for matrix arithmatics?

 

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 getting info from a DataFrame

2011-02-02 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 02.02.2011 11:14:18:

 Hi
 
 r-help-boun...@r-project.org napsal dne 31.01.2011 15:51:16:
 
  
  
 
 snip
 
 
   
   
  
  Hi
  
  thanks. I am not sure if I have understood 100% but at least I know 
now 
 that
  there's a diference.
  
  About this: 
  
  lapsales
   Store  Prod qtd
   5  Aveiro Lapiseira   3
   8 Coimbra Lapiseira   1
   9 Setubal Lapiseira   1
lapsales[max(lapsales$qtd),Store]
   [1] Setubal
   Levels: Aveiro Coimbra Evora lx Setubal
  
   why Setubal and not Aveiro?
  
  
  Can you explain me the result?

Sorry I did not look to your code and used the code I sent you as a 
solution

What do you expect max(lapsales$qtg) give you as a result?
If you changed the number qtd to 4 instead of 3 you will get

 lapsales[max(lapsales$qtd),Store]
[1] NA
Levels: Aveiro Coimbra Evora lx Setubal

So R give you what you ask for. You asked for third line and you got it.

If you asked for which position is the maximum number

lapsales[which.max(lapsales$qtd),Store]
[1] Aveiro
Levels: Aveiro Coimbra Evora lx Setubal

You will get desired result.

Regards
Petr



 
 Probably qtd is not what you think it is. I get
 
  dados- data.frame(Store = c 
 
(Setubal,lx,Aveiro,Coimbra,Aveiro,Evora,Aveiro,Coimbra,Setubal),Prod=c
 
(BlocoDesenho,BlocoDesenho,Tinteiro,Régua,Lapiseira,Regua,Tinteiro,Lapiseira,Lapiseira),qtd=c
 (2,1,2,1,3,1,1,1,1))
  lapsales - dados[dados$Prod==Lapiseira,  ]
  lapsales[which.max(lapsales[ , qtd ]), Store]
 [1] Aveiro
 Levels: Aveiro Coimbra Evora lx Setubal
  
 
 and
 
  str(lapsales)
 'data.frame':   3 obs. of  3 variables:
  $ Store: Factor w/ 5 levels Aveiro,Coimbra,..: 1 2 5
  $ Prod : Factor w/ 5 levels BlocoDesenho,..: 2 2 2
  $ qtd  : num  3 1 1
 
 Maybe you get something different.
 
 Regards
 Petr
 
 
 
 
 
  
  thanks
  AD
  -- 
  View this message in context: 
 http://r.789695.n4.nabble.com/Help-in-getting-
  info-from-a-DataFrame-tp3247740p3248883.html
  Sent from the R help mailing list archive at Nabble.com.
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] kmeans: number of cluster centres must lie between 1 and nrow(x)

2011-02-02 Thread Feng Li
Thank you for the suggestion and it is exactly as you said only one
observation in each cluster. I know I can avoid this anyway and I am just
out of curiosity of the error.

I am writing a special algorithm to cluster some datasets with different
numbers of observations. For some particular datasets, there is only one
observation(e.g. people died of a rare disease). kmeans() thus will not work
at this situation.


Feng

2011/2/2 Rafael Björk rafael.bj...@gmail.com

 If you change the algorithm, the function allow you to do this:

  kmeans(a, 20,algorithm=Lloyd)

 Maybe i'm missing something here, but why would you want to create as many
 clusters as there are observations? Won't the outcome just be one
 observation in each cluster?






-- 
Feng Li
Department of Statistics
Stockholm University
106 91 Stockholm, Sweden
http://feng.li/

[[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: Read a similarity matrix from excel

2011-02-02 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 01.02.2011 10:20:48:

 Good morning,
 
 I have an excel spreadsheet with similarities among objects. The format 
of
 the file is the following:
 
 1st row: empty cell,object-1-name,object-name-2,...,object-N
 2nd row: object-name-1,0,s1,2,s1,3,...,s1,N
 3rd row: object-name-2,s2,1,0,s2,3,...,s2,N
 
 The table is symmetrical and contains the similarities among the objects
 (sx,k stands for similarity among x and k). The first row contains the
 name of the objects (strings of characters) in the same order that these
 same names are contained in the first column. The cell 1,1 is empty.
 
 How can I read this in R so that after reading it I can perform a
 hierarchical clustering. The table is 78x78 so it is relatively easy to
 manually change something if it makes it easier to read.

Select your table in Excel
Press Ctrl-C
In R do
test-read.delim(clipboard)

you shall get something like that

 test
  X a  b c
1 a 1 23 3
2 b 4  5 6
3 c 7  8 9


you has to get rid of first column

 mat-as.matrix(test[,-1])

and if you want you can put row.names tou your matrix

 row.names(mat)-colnames(mat)
 mat
  a  b c
a 1 23 3
b 4  5 6
c 7  8 9
 row.names(mat)-test$X
 mat
  a  b c
a 1 23 3
b 4  5 6
c 7  8 9


Regards
Petr




 
 I found many articles about reading a data table with variables and then
 constructing the distance matrix from within R, but I have the 
similarity
 matrix instead. 
 
 Thank you for your help
 
 George
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] pass nrow(x) to dots in function(x){plot(x,...)}

2011-02-02 Thread Marianne Promberger
Dear Rers,

I have a function to barplot() a matrix, eg

myfun - function(x, ...) { barplot(x , ... )} 

(The real function is more complicated, it does things to the matrix first.)

So I can do:

m1 -  matrix(1:20,4)
myfun(m1)
myfun(m1, main=My title)

I'd like to be able to add the number of rows of the matrix passed to
the function to the ... argument, eg

myfun(m1, main=paste(n=,ns))

where 'ns' would be nrow(m1)

I've tried this but it doesn't work:

myfun - function(x, ...) { 
  ns - nrow(x)
  barplot(x , ... ) }

myfun(m1, main=paste(n = ,ns) )

ns is not found

So, basically, how do I assign an object inside a function that I can
then access in the dots when executing the function?

Many thanks

Marianne


-- 
Marianne Promberger PhD, King's College London
http://promberger.info
R version 2.12.0 (2010-10-15)
Ubuntu 9.04

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


Re: [R] Counter in a For Loop - Efficiency Issue

2011-02-02 Thread Bart Joosen

without a reproducible sample, it is hard to tell, but I will give it a shot.
Maybe it's possible to merge your M with M2: merge(M, M2)
If you only want to count times, you can use seq_along(x) in a by function
eg:
dat - data.frame(person=rep(c(1,2,3), each=5), time=rnorm(15))
by(dat$person, dat$person, function(x) seq_along(x))

Ofcourse you can use any of the other vectorisation functions (lapply,
apply, aggregate, )

HTH


Bart
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Counter-in-a-For-Loop-Efficiency-Issue-tp3253674p3253698.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] reshape data, adding rows to dataframe

2011-02-02 Thread Lucia Rueda

Hi Ivan,

Thanks for your reply. This is what I want to do:

Imagine my dataset looks like this:

Species N  Size
Coris julis 1   8
Coris julis 3   10
D.vulgaris  2   12

I have 1 C.julis of 8 cm, 3 C. julis of 10 cm and 2 D.vulgaris of 12 cm. I
want 1 row for each animal, something like this:

Species N   Size
Coris julis 1   8
Coris julis 1   10
Coris julis 1   10
Coris julis 1   10
D.vulgaris  1   12
D.vulgaris  1   12

I hope that helps. I tried reshape but couldn't do it and from what I've
seen I don't think that aggregate, unique or duplicated would do it... but
I'm not good with R so I can be wrong.

Cheers!

Lucia


-- 
View this message in context: 
http://r.789695.n4.nabble.com/reshape-data-adding-rows-to-dataframe-tp3253640p3253780.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] Manipulating XTS data

2011-02-02 Thread Greg Hanley
Hi,

I'm pulling in data for the past 30 days or so. I'm going to slice
each day into 5 minute time intervals, and I want to find the average
value across all days for the given slice of time. That is, I want to
know what the average value at 8:00 was for the 30 day period, the
average value at 8:05, and so on. Is there a quick and easy way to do
this with XTS. I figured i could skip loops somehow if I knew how to
better use this package.

Thanks!
-Greg

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

2011-02-02 Thread karuna m
Dear R-help,
I am doing clustering via finite mixture model. Please suggest some packages in 
R to find clusters via finite mixture model with continuous variables. And 
also I wish to verify the distributional properties of the mixture 
distributions 
by fitting the model with lognormal, gamma, exponentials etc,.
Thanks in advance,
 warm regards,Ms.Karunambigai M
PhD Scholar
Dept. of Biostatistics
NIMHANS
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] reshape data, adding rows to dataframe

2011-02-02 Thread Henrique Dallazuanna
Try this:

transform(fish[rep(seq(nrow(fish)), fish$N),], N = 1)

On Wed, Feb 2, 2011 at 8:58 AM, Lucia Rueda lucia.ru...@ba.ieo.es wrote:


 Hi Ivan,

 Thanks for your reply. This is what I want to do:

 Imagine my dataset looks like this:

 Species N  Size
 Coris julis 1   8
 Coris julis 3   10
 D.vulgaris  2   12

 I have 1 C.julis of 8 cm, 3 C. julis of 10 cm and 2 D.vulgaris of 12 cm. I
 want 1 row for each animal, something like this:

 Species N   Size
 Coris julis 1   8
 Coris julis 1   10
 Coris julis 1   10
 Coris julis 1   10
 D.vulgaris  1   12
 D.vulgaris  1   12

 I hope that helps. I tried reshape but couldn't do it and from what I've
 seen I don't think that aggregate, unique or duplicated would do it... but
 I'm not good with R so I can be wrong.

 Cheers!

 Lucia


 --
 View this message in context:
 http://r.789695.n4.nabble.com/reshape-data-adding-rows-to-dataframe-tp3253640p3253780.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.


Re: [R] reshape data, adding rows to dataframe

2011-02-02 Thread Lucia Rueda

Exactly!! Thanks a lot Petr. It worked!

Thansk to you as well Ivan!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/reshape-data-adding-rows-to-dataframe-tp3253640p3253793.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] Error of 'memory not mapped' in ff Package with VirtualBox

2011-02-02 Thread Wonsang You

Dear R Helpers,

I would like to report on an error in the ff package here.
The ff package is an R package which enables us to store large data on disk
systematically and have fast access to the database.
I used the package in Linux as a guest OS of VirtualBox, and executed the
following commands.

library(ff)
x-ff(1:5,length=5,update=TRUE,vmode=double,filename=header.ff,overwrite=TRUE)

Afterwards, I got the following error message.

*** caught segfault ***
address 0x, cause 'memory not mapped'

Traceback:
 1: .Call(get_vector, .ffmode[vmode], attr(x, physical), index,
nreturn, PACKAGE = ff)
 2: `[.ff`(ret, 1)
 3: ret[1]
 4: as.vector(ret[1])
 5: identical(as.vector(initdata[1]), as.vector(ret[1]))
 6: ff(1:5, length = 5, update = TRUE, vmode = double, filename =
header.ff, overwrite = TRUE)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:

Can anyone give an advice to solve the problem?

Best Regards,
Ryan

-
Wonsang You
Leibniz Institute for Neurobiology
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Error-of-memory-not-mapped-in-ff-Package-with-VirtualBox-tp3253856p3253856.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] multicore + xeon ?

2011-02-02 Thread kv

Is there any reason to expect a problem ?
i'm running this script on the cluster down the hall:

module load R/2.11.0
R
library(multicore) 
fxx-function(ll) runif(1)
mclapply(1:10,fxx)

i get:

Error in fork() : Unable to fork.

less /proc/cpuinfo

yields:

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model   : 15
model name  : Intel(R) Xeon(R) CPU   X5365  @ 3.00GHz
stepping: 11
cpu MHz : 2992.502
cache size  : 4096 KB
physical id : 0
siblings: 4
core id : 0
cpu cores   : 4
fpu : yes
fpu_exception   : yes
cpuid level : 10
wp  : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm
constant_tsc pni monito
r ds_cpl vmx est tm2 cx16 xtpr dca lahf_lm
bogomips: 5990.06
clflush size: 64
cache_alignment : 64
address sizes   : 38 bits physical, 48 bits virtual

-- 
View this message in context: 
http://r.789695.n4.nabble.com/multicore-xeon-tp3253882p3253882.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] help

2011-02-02 Thread Petr Savicky
On Tue, Feb 01, 2011 at 12:51:18PM -0800, Kiogou Lydie wrote:
 
 
 PLEASE HELP
 
 I actually want to do the following:
 
 a[j] = (1/(j!))*?? (i-1-d), j = 500, ?? means product i = 1 to
 j
 
 ??
 
 Yet, j! will stop at 170 and ?? (i-1-d) at 172; so, a[j] will
 not exceed 170.
 
 I would like to have at least 200 a[j]. 
 
 ??
 
 WHAT SHOULD I DO?

Computing factorial of 171 and larger numbers may be done using
extended arithmetic in Rmpfr as already suggested. Depending
on the purpose of computing factorial of large numbers, consider
also the function lfactorial(), which computes the logarithm
in the standard numeric type.

  lfactorial(1000)

  [1] 5912.128

Hope this helps.

Petr Savicky.

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

2011-02-02 Thread Romildo Martins
Hello,


How to convert x into y?

 x
[1] 15, 23, 2, 21, 11, 5

 y
 [,1] [,2]
[1,]   15   23
[2,]   232
[3,]221
[4,]   21   11
[5,]   115


Thanks a lot!

Romildo

[[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] String to Matrix

2011-02-02 Thread Henrique Dallazuanna
Try this:

embed(scan(textConnection(x), sep = ,), 2)

On Wed, Feb 2, 2011 at 10:12 AM, Romildo Martins
romildo.mart...@gmail.comwrote:

 Hello,


 How to convert x into y?

  x
 [1] 15, 23, 2, 21, 11, 5

  y
 [,1] [,2]
 [1,]   15   23
 [2,]   232
 [3,]221
 [4,]   21   11
 [5,]   115


 Thanks a lot!

 Romildo

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




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

[[alternative HTML version deleted]]

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


Re: [R] Strange result from sort: sort(c(aa, ff)) gives ff aa with R.2.12.1 on windows 7

2011-02-02 Thread Prof Brian Ripley
'Strange' to have no response on this.  Can a knowledgeable Danish 
writer please confirm that this is how the OSes are supposed to handle 
Danish collation?


On Mon, 24 Jan 2011, Prof Brian Ripley wrote:


On Mon, 24 Jan 2011, Søren Højsgaard wrote:


Dear list,

Please consider the following call of sort


sort(c(a,f))

[1] a f

sort(c(f,a))

[1] a f


sort(c(aa,ff))

[1] ff aa

sort(c(ff,aa))

[1] ff aa
The last two results look strange to me. Is that a bug???


It seems that you and your OS disagree about Danish, and I'm in no position 
to know which is correct.  But this is not an R issue: the sorting is done by 
OS services.



The result seems to come from calls to order:


order(c(a,f))

[1] 1 2

order(c(f,a))

[1] 2 1


order(c(aa,ff))

[1] 2 1

order(c(ff,aa))

[1] 1 2


I get the same results on R.2.12.1, R.2.11.1 and R.2.13.0 on Windows 7. 
However on Linux, I get the right answer (the answer I expected). From 
the help pages I get the impression that there might be an issue about 
locale, but I didn't understand the details.


Can anyone tell me what goes on here, please


I recall that 'aa' used to sort at the end of the alphabet in Danish 
telephone books, so it seems the sort used on Windows thinks so too. See 
?Comparison for some further details.  What I don't understand is that 
someone resident in Denmark finds this strange 


I get exactly the same in a Danish locale on Mac OS X, for example:


sort(c(aa,ff))

[1] ff aa

and also on my Linux box (Fedora 14 with LC_COLLATE=da_DK.utf8)


sort(c(aa,ff))

[1] ff aa

en_DK is not a Danish locale (in is English in Denmark).  If you want an 
English sort, try an English locale for LC_COLLATE (there may well be 
several, hence 'an').




Regards
Søren







sessionInfo()

R version 2.12.1 Patched (2010-12-27 r53883)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=Danish_Denmark.1252  LC_CTYPE=Danish_Denmark.1252
[3] LC_MONETARY=Danish_Denmark.1252 LC_NUMERIC=C
[5] LC_TIME=Danish_Denmark.1252
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base
other attached packages:
[1] SHDtools_1.0



sessionInfo()

R version 2.12.1 (2010-12-16)
Platform: i686-pc-linux-gnu (32-bit)
locale:
[1] LC_CTYPE=en_DK.utf8   LC_NUMERIC=C
[3] LC_TIME=en_DK.utf8LC_COLLATE=en_DK.utf8
[5] LC_MONETARY=C LC_MESSAGES=en_DK.utf8
[7] LC_PAPER=en_DK.utf8   LC_NAME=C
[9] LC_ADDRESS=C  LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_DK.utf8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

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

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



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


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error of 'memory not mapped' in ff Package with VirtualBox

2011-02-02 Thread Prof Brian Ripley
This is clearly a problem occuring in the C code of the ff package. 
Please report to the package maintainer, Cced here (with the 'at a 
minimum' information requested in the posting guide, most importantly 
the Linux architecture and the versions involved).


FWIW it works for me on


sessionInfo()

R version 2.12.1 (2010-12-16)
Platform: x86_64-unknown-linux-gnu (64-bit)
...
other attached packages:
[1] ff_2.2-1  bit_1.1-6

If possible, try running this under valgrind (see 'Writing R 
Extensions') to get more info on the cause: at least run under gdb to 
get more precise info on what was not mapped.


You don't say what the host OS of VirtualBox was.  We've found I/O 
under VirtualBox with a x86_64 Linux host to be slow, but R to run 
reliably.



On Wed, 2 Feb 2011, Wonsang You wrote:



Dear R Helpers,

I would like to report on an error in the ff package here.
The ff package is an R package which enables us to store large data on disk
systematically and have fast access to the database.
I used the package in Linux as a guest OS of VirtualBox, and executed the
following commands.

library(ff)
x-ff(1:5,length=5,update=TRUE,vmode=double,filename=header.ff,

overwrite=TRUE)


Afterwards, I got the following error message.

*** caught segfault ***
address 0x, cause 'memory not mapped'

Traceback:
1: .Call(get_vector, .ffmode[vmode], attr(x, physical), index,
nreturn, PACKAGE = ff)
2: `[.ff`(ret, 1)
3: ret[1]
4: as.vector(ret[1])
5: identical(as.vector(initdata[1]), as.vector(ret[1]))
6: ff(1:5, length = 5, update = TRUE, vmode = double, filename =
header.ff, overwrite = TRUE)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:

Can anyone give an advice to solve the problem?

Best Regards,
Ryan

-
Wonsang You
Leibniz Institute for Neurobiology
--
View this message in context: 
http://r.789695.n4.nabble.com/Error-of-memory-not-mapped-in-ff-Package-with-VirtualBox-tp3253856p3253856.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.



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

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


Re: [R] Strange result from sort: sort(c(aa, ff)) gives ff aa with R.2.12.1 on windows 7

2011-02-02 Thread Søren Højsgaard
Not sure if I qualify as being knowledgeable, but... 

You write

 I recall that 'aa' used to sort at the end of the alphabet in Danish 
 telephone books, so it seems the sort used on Windows thinks so too. See 
 ?Comparison for some further details.  What I don't understand is that 
 someone resident in Denmark finds this strange 

Yes, I can confirm that aa resides at the end of the Danish alphabet (as an 
old way of writing the letter which in modern writing is å).
But what should one then do if one wants aa to mean an a followed by another 
a and not aa (=å) when calling sort??

Regards
Søren Højsgaard

-Oprindelig meddelelse-
Fra: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] 
Sendt: 2. februar 2011 13:21
Til: Søren Højsgaard
Cc: r-h...@stat.math.ethz.ch
Emne: Re: [R] Strange result from sort: sort(c(aa, ff)) gives ff aa 
with R.2.12.1 on windows 7

'Strange' to have no response on this.  Can a knowledgeable Danish 
writer please confirm that this is how the OSes are supposed to handle 
Danish collation?

On Mon, 24 Jan 2011, Prof Brian Ripley wrote:

 On Mon, 24 Jan 2011, Søren Højsgaard wrote:

 Dear list,
 
 Please consider the following call of sort
 
 sort(c(a,f))
 [1] a f
 sort(c(f,a))
 [1] a f
 
 sort(c(aa,ff))
 [1] ff aa
 sort(c(ff,aa))
 [1] ff aa
 The last two results look strange to me. Is that a bug???

 It seems that you and your OS disagree about Danish, and I'm in no position 
 to know which is correct.  But this is not an R issue: the sorting is done by 
 OS services.

 The result seems to come from calls to order:
 
 order(c(a,f))
 [1] 1 2
 order(c(f,a))
 [1] 2 1
 
 order(c(aa,ff))
 [1] 2 1
 order(c(ff,aa))
 [1] 1 2

 I get the same results on R.2.12.1, R.2.11.1 and R.2.13.0 on Windows 7. 
 However on Linux, I get the right answer (the answer I expected). From 
 the help pages I get the impression that there might be an issue about 
 locale, but I didn't understand the details.
 
 Can anyone tell me what goes on here, please

 I recall that 'aa' used to sort at the end of the alphabet in Danish 
 telephone books, so it seems the sort used on Windows thinks so too. See 
 ?Comparison for some further details.  What I don't understand is that 
 someone resident in Denmark finds this strange 

 I get exactly the same in a Danish locale on Mac OS X, for example:

 sort(c(aa,ff))
 [1] ff aa

 and also on my Linux box (Fedora 14 with LC_COLLATE=da_DK.utf8)

 sort(c(aa,ff))
 [1] ff aa

 en_DK is not a Danish locale (in is English in Denmark).  If you want an 
 English sort, try an English locale for LC_COLLATE (there may well be 
 several, hence 'an').

 
 Regards
 Søren
 
 
 
 
 
 
 sessionInfo()
 R version 2.12.1 Patched (2010-12-27 r53883)
 Platform: i386-pc-mingw32/i386 (32-bit)
 locale:
 [1] LC_COLLATE=Danish_Denmark.1252  LC_CTYPE=Danish_Denmark.1252
 [3] LC_MONETARY=Danish_Denmark.1252 LC_NUMERIC=C
 [5] LC_TIME=Danish_Denmark.1252
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 other attached packages:
 [1] SHDtools_1.0
 
 
 sessionInfo()
 R version 2.12.1 (2010-12-16)
 Platform: i686-pc-linux-gnu (32-bit)
 locale:
 [1] LC_CTYPE=en_DK.utf8   LC_NUMERIC=C
 [3] LC_TIME=en_DK.utf8LC_COLLATE=en_DK.utf8
 [5] LC_MONETARY=C LC_MESSAGES=en_DK.utf8
 [7] LC_PAPER=en_DK.utf8   LC_NAME=C
 [9] LC_ADDRESS=C  LC_TELEPHONE=C
 [11] LC_MEASUREMENT=en_DK.utf8 LC_IDENTIFICATION=C
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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

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

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


[R] Problem with getFX function

2011-02-02 Thread Usuario R
Hi everyone,

Following this post:
http://r.789695.n4.nabble.com/currency-conversion-function-tt906056.html#a906061


I was trying to run the code:

foo - function(from, to, date){
  url - 
http://www.oanda.com/convert/classic?script=..%2Fconvert%2Fclassiclanguage=envalue=1

  params -
sprintf(%sdate=%sexch=%sexch2=margin_fixed=0expr=%sexpr2=SUBMIT=Convert+Nowlang=endate_fmt=us,
url, format(as.Date(date), %m/%d/%y), from, to)
Lines - readLines(params)
value - gsub(.*([0-9]\\.+[0-9]+).*, \\1, grep(nl, grep(from,
grep(to, Lines, value = TRUE), value = TRUE), value = TRUE))
as.numeric(value)
}

foo('BRL', 'USD', '2010-10-14')

But it gives me the following:

numeric(0)
Warning message:
In readLines(params) :
  incomplete final line found on '
http://www.oanda.com/convert/classic?script=..%2Fconvert%2Fclassiclanguage=envalue=1date=10/14/10exch=BRLexch2=margin_fixed=0expr=USDexpr2=SUBMIT=Convert+Nowlang=endate_fmt=us
'


Does anyone what the problem is about?

If I type simply:

 getFX(EUR/USD,from=2011-01-01)

Then I get similar error:

[1] EURUSD
Warning message:
In readLines(tmp) :
  incomplete final line found on
'xxx\AppData\Local\Temp\RtmpI1HUzb\file27f7532'


(I've hide the path)

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] error in scan(...

2011-02-02 Thread jim holtman
It is clear that you have letters in the data you are trying to
process; that is the cause of the erro.  What was the 'scan' statement
you were using?  Were you expecting all numerics in the string?  The
error message is consistent with your input.

On Wed, Feb 2, 2011 at 2:07 AM, gked grigoriy.lyuks...@gmail.com wrote:

 I know it's a common error and there is a lot of help available but still
 can't resolve the issue:
 all i am trying to do is to read a csv file from my folder and this is what
 i get:

 Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
 :
  scan() expected 'a real', got
 '1,m,a,F,165,240,26.5,31,0.738,0.704,1.095,0.606,0.847'

 Can you help?

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

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




-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

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


Re: [R] Strange result from sort: sort(c(aa, ff)) gives ff aa with R.2.12.1 on windows 7

2011-02-02 Thread Prof Brian Ripley

On Wed, 2 Feb 2011, Søren Højsgaard wrote:


Not sure if I qualify as being knowledgeable, but...

You write


I recall that 'aa' used to sort at the end of the alphabet in Danish
telephone books, so it seems the sort used on Windows thinks so too. See
?Comparison for some further details.  What I don't understand is that
someone resident in Denmark finds this strange 


Yes, I can confirm that aa resides at the end of the Danish 
alphabet (as an old way of writing the letter which in modern 
writing is å). But what should one then do if one wants aa to 
mean an a followed by another a and not aa (=å) when calling 
sort??


Set Sys.setlocale(LC_COLLATE, ) appropriately (sorry, that's very 
OS-specific but 'C' and 'en' or 'English' probably work on Windows). 
On platforms using ICU (most, but not Windows), see also 
?icuSetCollate for further ways to tweak collation: that has aarhus 
in its examples.




Regards
Søren Højsgaard

-Oprindelig meddelelse-
Fra: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
Sendt: 2. februar 2011 13:21
Til: Søren Højsgaard
Cc: r-h...@stat.math.ethz.ch
Emne: Re: [R] Strange result from sort: sort(c(aa, ff)) gives ff aa 
with R.2.12.1 on windows 7

'Strange' to have no response on this.  Can a knowledgeable Danish
writer please confirm that this is how the OSes are supposed to handle
Danish collation?

On Mon, 24 Jan 2011, Prof Brian Ripley wrote:


On Mon, 24 Jan 2011, Søren Højsgaard wrote:


Dear list,

Please consider the following call of sort


sort(c(a,f))

[1] a f

sort(c(f,a))

[1] a f


sort(c(aa,ff))

[1] ff aa

sort(c(ff,aa))

[1] ff aa
The last two results look strange to me. Is that a bug???


It seems that you and your OS disagree about Danish, and I'm in no position
to know which is correct.  But this is not an R issue: the sorting is done by
OS services.


The result seems to come from calls to order:


order(c(a,f))

[1] 1 2

order(c(f,a))

[1] 2 1


order(c(aa,ff))

[1] 2 1

order(c(ff,aa))

[1] 1 2



I get the same results on R.2.12.1, R.2.11.1 and R.2.13.0 on Windows 7.
However on Linux, I get the right answer (the answer I expected). From
the help pages I get the impression that there might be an issue about
locale, but I didn't understand the details.

Can anyone tell me what goes on here, please


I recall that 'aa' used to sort at the end of the alphabet in Danish
telephone books, so it seems the sort used on Windows thinks so too. See
?Comparison for some further details.  What I don't understand is that
someone resident in Denmark finds this strange 

I get exactly the same in a Danish locale on Mac OS X, for example:


sort(c(aa,ff))

[1] ff aa

and also on my Linux box (Fedora 14 with LC_COLLATE=da_DK.utf8)


sort(c(aa,ff))

[1] ff aa

en_DK is not a Danish locale (in is English in Denmark).  If you want an
English sort, try an English locale for LC_COLLATE (there may well be
several, hence 'an').



Regards
Søren







sessionInfo()

R version 2.12.1 Patched (2010-12-27 r53883)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=Danish_Denmark.1252  LC_CTYPE=Danish_Denmark.1252
[3] LC_MONETARY=Danish_Denmark.1252 LC_NUMERIC=C
[5] LC_TIME=Danish_Denmark.1252
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base
other attached packages:
[1] SHDtools_1.0



sessionInfo()

R version 2.12.1 (2010-12-16)
Platform: i686-pc-linux-gnu (32-bit)
locale:
[1] LC_CTYPE=en_DK.utf8   LC_NUMERIC=C
[3] LC_TIME=en_DK.utf8LC_COLLATE=en_DK.utf8
[5] LC_MONETARY=C LC_MESSAGES=en_DK.utf8
[7] LC_PAPER=en_DK.utf8   LC_NAME=C
[9] LC_ADDRESS=C  LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_DK.utf8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

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



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


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



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

Re: [R] error in density plot

2011-02-02 Thread Ben Bolker
Ramya ramya.victory at gmail.com writes:

 I have the code for the density plot
 j - 8 
 plot(density(diff_in_sample[,1]), main = list.files()[j])
 for(i in 1:25){
 lines(density(diff_in_sample[,i]))
 }
 
 This gives me an error 
 Error in density.default(diff_in_sample[, i]) : 
   'x' contains missing values

 [snip]

?NA

lines(na.omit(density(diff_in_sample[,i])))

Consider replacing the loop by apply() [no efficiency
gain, but more compact 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] Function to locate points in 3d octants or points on two axes

2011-02-02 Thread Bryan Hanson
Thanks Petr, the sign function will be of help.  I was not aware of  
it.  Bryan


On Feb 2, 2011, at 3:21 AM, Petr Savicky wrote:


On Tue, Feb 01, 2011 at 08:30:22PM -0500, Bryan Hanson wrote:

[Sorry, resending with a proper subject line!]

Hi Guru's...

I have a set of points that may lie along any of the x, y and z axes
in a Cartesian coordinate system.  I am hoping that a function exists
which will determine if any two selected points are on different  
axes,

i.e, if the one of the points is on x and the other on y or z, not
elsewhere on the x axis.  Put another way, I need to determine if the
triangle formed by the two points and the origin lies in the xy, xz  
or
yz planes.  This might be as simple as testing if any particular  
value

is zero, i.e. if the x coordinate is zero, then the points must be on
the z and y axes and the triangle in the yz plane.  But, I'm looking
for a fairly general solution, one that also returns the appropriate
plane as the answer.  Very closely related to this, I could use a
function that determines which of the 8 octants a point lies in.  
Seems

like the cross product might be part of this, but I'm a little rusty
on how to apply it.

I hope this is clear enough, and someone has a suggestion to point me
in the right direction.  Before writing my own klunky version, I
thought I'd ask.


Hi.

I think that for suggesting an appropriate solution it may be needed
to know, which data structure is used for the input pairs of points.  
For
example, it may a single matrix n times 3 with points as rows and a  
pair

is represented by two indices of the points. Alternatively, the input
may be a single matrix n times 6, where rows are pairs of points.

In any case, the input may be simplified using sign() function. For  
example


 a - as.matrix(expand.grid(x=c(-1.1, 0, 1.1), y=c(0, 1.2), z=c(0,  
1.3)))

 a

  x   y   z
  [1,] -1.1 0.0 0.0
  [2,]  0.0 0.0 0.0
  [3,]  1.1 0.0 0.0
  [4,] -1.1 1.2 0.0
  [5,]  0.0 1.2 0.0
  [6,]  1.1 1.2 0.0
  [7,] -1.1 0.0 1.3
  [8,]  0.0 0.0 1.3
  [9,]  1.1 0.0 1.3
 [10,] -1.1 1.2 1.3
 [11,]  0.0 1.2 1.3
 [12,]  1.1 1.2 1.3

 sign(a)

x y z
  [1,] -1 0 0
  [2,]  0 0 0
  [3,]  1 0 0
  [4,] -1 1 0
  [5,]  0 1 0
  [6,]  1 1 0
  [7,] -1 0 1
  [8,]  0 0 1
  [9,]  1 0 1
 [10,] -1 1 1
 [11,]  0 1 1
 [12,]  1 1 1

This output represents a classification of the points into a finite
number of regions and keeps the information needed for any of the
tasks, which you mention.

Hope this helps.

Petr Savicky.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Error of 'memory not mapped' in ff Package with VirtualBox

2011-02-02 Thread Wonsang You
Dear Prof. Brian Ripley,

Thank you for your kind advice. I have to report to you that I attempted to
save the ff file at  a shared directory between guest OS (Linux) and host OS
(Windows 7).

I tried to change the working directory as an unshared folder, and then I
tried the same commands. In this case, I had no problem as you did. In
conclusion, the ff package does not support to assign memory for shared
folders between guest OS and host OS.

For your reference, my experiments were done in the following environment.

R version 2.12.1 (2010-12-16)
Platform: i686-pc-linux-gnu (32-bit)

I appreciate you for your help.

Best Regards,
Ryan



2011/2/2 Prof Brian Ripley rip...@stats.ox.ac.uk

 This is clearly a problem occuring in the C code of the ff package. Please
 report to the package maintainer, Cced here (with the 'at a minimum'
 information requested in the posting guide, most importantly the Linux
 architecture and the versions involved).

 FWIW it works for me on

  sessionInfo()

 R version 2.12.1 (2010-12-16)
 Platform: x86_64-unknown-linux-gnu (64-bit)
 ...
 other attached packages:
 [1] ff_2.2-1  bit_1.1-6

 If possible, try running this under valgrind (see 'Writing R Extensions')
 to get more info on the cause: at least run under gdb to get more precise
 info on what was not mapped.

 You don't say what the host OS of VirtualBox was.  We've found I/O under
 VirtualBox with a x86_64 Linux host to be slow, but R to run reliably.


 On Wed, 2 Feb 2011, Wonsang You wrote:


 Dear R Helpers,

 I would like to report on an error in the ff package here.
 The ff package is an R package which enables us to store large data on
 disk
 systematically and have fast access to the database.
 I used the package in Linux as a guest OS of VirtualBox, and executed the
 following commands.

 library(ff)
 x-ff(1:5,length=5,update=TRUE,vmode=double,filename=header.ff,

overwrite=TRUE)


 Afterwards, I got the following error message.

 *** caught segfault ***
 address 0x, cause 'memory not mapped'

 Traceback:
 1: .Call(get_vector, .ffmode[vmode], attr(x, physical), index,
 nreturn, PACKAGE = ff)
 2: `[.ff`(ret, 1)
 3: ret[1]
 4: as.vector(ret[1])
 5: identical(as.vector(initdata[1]), as.vector(ret[1]))
 6: ff(1:5, length = 5, update = TRUE, vmode = double, filename =
 header.ff, overwrite = TRUE)

 Possible actions:
 1: abort (with core dump, if enabled)
 2: normal R exit
 3: exit R without saving workspace
 4: exit R saving workspace
 Selection:

 Can anyone give an advice to solve the problem?

 Best Regards,
 Ryan

 -
 Wonsang You
 Leibniz Institute for Neurobiology
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Error-of-memory-not-mapped-in-ff-Package-with-VirtualBox-tp3253856p3253856.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.


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


[[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] subset in a BIG matrix

2011-02-02 Thread alcesgabbo

I have a matrix with a lot of values inside..

when I execute the folowing command

matrix2=subset(martix, condition.)

it works...

but after the previous command I execute another subset

matrix3=subset(martix2, condition2.)

and appears the following error:

(subscript) logical subscript too long

How can I solve this???
I think the probles is the size of the matrix...
Thanks..
-- 
View this message in context: 
http://r.789695.n4.nabble.com/subset-in-a-BIG-matrix-tp3254115p3254115.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] Lattice nb/wlist help

2011-02-02 Thread Gary Nobles

Hi all,

I have a grid of points at regular intervals (taken from a raster). 

I want to create a listw matrix which opperates like this 

1 1 1 
1 1 1 
1 1 1 

and also like this 

1  1  1  1  1 
1  1  1  1  1 
1  1  1  1  1 
1  1  1  1  1 
1  1  1  1  1 

and so on 


I want it to work with localG from package spdep: 
localG(x, listw, zero.policy=NULL, spChk=NULL) 

Any help is much appreciated.

Thanks 

Gary  


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Lattice-nb-wlist-help-tp3253962p3253962.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] reshape data, adding rows to dataframe

2011-02-02 Thread Lucia Rueda

Thanks Henrique!

It solves the problem of having the column N with unreal number of
individuals since N=1

with Petr's example:

expand - transform(dat[rep(1:nrow(dat), times=dat$N), ] ,N=1)
rownames(expand) - NULL 
expand
 expand
  animal N
1  a 1
2  a 1
3  b 1
4  c 1
5  c 1
6  c 1

Cheers! 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/reshape-data-adding-rows-to-dataframe-tp3253640p3254038.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] Significant codes in mtable

2011-02-02 Thread Striessnig, Erich
Hi all,

Does anyone know a way to change the significant stars in mtable (package 
memisc)? The default is
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1,

however I need it to be

Signif. codes:  0 '***' 0.01 '**' 0.05 '*' 0.1 ' ' 1

Kind regards,
Erich

[[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] Finding the dominant factor in an unbalanced group

2011-02-02 Thread Sandy Small

Hi all.
This is perhaps more a statistics question but I'm hoping someone can
help me.

I have a group of patients for whom I'm looking at beat to beat RR
interval changes.
I have plotted the difference between one beat length and the next
against the difference between the previous beat length and the current one.
This gives me a plot with four quadrants: the bottom left corresponding
to successively shorter beats, the top right to succesively longer, the
top left to a shorter followed by a longer beat and the bottom right to
a longer by a shorter.

In theory if successive changes in beat length are random there should
be an approximately equal number of counts in each quadrant of my plot.

I have a dataframe which for each of my patients lists the number of
counts in each quadrant:
(dput data at the end of this mail)

I can determine whether the distribution is balanced or not with a Chi
Squared (chisq.test)

However what I would like to do is determine whether there is a dominant
quadrant (eg. CBP06118 in the example data), or a dominant pair of
quadrants  (eg CBP06036 in the example data) and if so which they are.
If my dataset were only 10 patients it probably wouldn't be a problem
(although I'm not certain what statistical check I could do beyond
re-applying chisquared tests with only the relevant quadrants which
sounds dodgy to me) the problem occurs because my data set is a couple
of orders of magnitude bigger,

Can anyone help?

dput data is:

structure(list(basestudy = structure(1:10, .Label = c(CBP06036,
CBP06095, CBP06098, CBP06100, CBP06112, CBP06118, CBP06127,
CBP06158, CBP06163, CBP06166), class = factor), tl = c(302L,
211L, 347L, 223L, 178L, 230L, 243L, 278L, 391L, 252L), tr = c(99L,
134L, 171L, 210L, 158L, 252L, 89L, 247L, 258L, 168L), br = c(305L,
212L, 346L, 223L, 178L, 231L, 244L, 277L, 388L, 254L), bl = c(142L,
288L, 284L, 191L, 144L, 360L, 147L, 184L, 164L, 186L)), .Names =
c(basestudy,
tl, tr, br, bl), row.names = c(NA, 10L), class = data.frame)

Many thanks

--

Sandy Small
Clinical Physicist
NHS Greater Glasgow and Clyde
and
NHS Forth Valley





This message may contain confidential information. If yo...{{dropped:21}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Error w tokenizer .jcall unless run as root

2011-02-02 Thread Nick Torenvliet
Hi all,

I've got an R script that loads the following libraries

library(rJava)
library(RWeka)
library(tm)

At some when I try to run the tm tokenizer as

MyTokenizer - function(x) NGramTokenizer(x, Weka_control(min = 1, max = 4))
ECONOMIST_TDM -
TermDocumentMatrix(ECONOMIST_CORPUS,control=list(tokenize=MyTokenizer))

I get the following error unless I'm running R as root...

Error in .jcall(RWekaInterfaces, [S, tokenize, .jcast(tokenizer,  :
  RcallMethod: cannot determine object class
 ECONOMIST_TDM -
TermDocumentMatrix(ECONOMIST_CORPUS,control=list(tokenize=MyTokenizer))
Error in .jcall(RWekaInterfaces, [S, tokenize, .jcast(tokenizer,  :
  RcallMethod: cannot determine object class

I first noticed this problem in the summer, and just left it thinking I
would stumble across a solution.
I do realize this means I need to set permissions somewhere properly -- but
I haven't stumbled across the affected file and even if I don't know what
the proper permisions/owner/group should be.

Does anyone know what I need to do?  I'm running R on Lucid Lynx.

Regards,

Nick

[[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] Acf of Frima

2011-02-02 Thread Chuse chuse
Hello,

I am trying to calculate the autocovariance matrix for any general
farima(p,d,q) with
p,q  1. Could anyone give an idea how to implement in R or if there
is any package for this?

thank you beforehand.

Jose.

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


Re: [R] Significant codes in mtable

2011-02-02 Thread Henrique Dallazuanna
Take a look on symnum function:

symnum(runif(30), cutpoints = c(0, 0.01, 0.05, 0.1, 1), symbols = c(***,
**, *, ))


On Wed, Feb 2, 2011 at 11:25 AM, Striessnig, Erich 
erich.striess...@wu.ac.at wrote:

 Hi all,

 Does anyone know a way to change the significant stars in mtable (package
 memisc)? The default is
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1,

 however I need it to be

 Signif. codes:  0 '***' 0.01 '**' 0.05 '*' 0.1 ' ' 1

 Kind regards,
 Erich

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




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

[[alternative HTML version deleted]]

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


Re: [R] Finding the maximum in a particular group in a dataframe

2011-02-02 Thread David Winsemius


On Feb 2, 2011, at 3:48 AM, Asan Ramzan wrote:


Hello

I am trying to find a way to find the max value, for only a subset  
of a

dataframe, depending on how the data is grouped for example,

How would I find the maxmium responce, for all the GPR119a condition  
below:


I've tried tapply


tapply(GPR119data$responce, GPR119data$GPR119a, max)

Error in tapply(GPR119data$responce, GPR119data$GPR119a, max) :
  arguments must have same length


You need to use tapply on the names of the columns , not on the values:

tapply(GPR119data$responce, GPR119data$condition, max)

 tapply(GPR119data$responce, GPR119data$condition, max)
  con   GPR119a   GPR119b   GPR119c   GPR119d   GPR119e   GPR119f
0.3350084 0.6451204 0.8240356 0.5729588 0.3099644 0.4677268 1.0184191

Then you can choose the GPR119a  value for further examination or  
display;


 tapply(GPR119data$responce, GPR119data$condition, max)[GPR119a]
  GPR119a
0.6451204


responce,mouce,condition


I'm guessing from this display that when you read this data in you  
used the default separator which is white-space and that does not  
include commas. In addition to the above, try adding sep=, in your  
read.table function.



0.105902,KO,con
0.232018561,KO,con
0.335008375,KO,con
0.387025433,KO,GPR119a
0.576769897,KO,GPR119a
0.645120419,KO,GPR119a
0.2538608,KO,GPR119b
0.183061952,KO,GPR119b
0.824035587,KO,GPR119b
0.399201597,KO,GPR119c
0.417006618,KO,GPR119c
0.572958834,KO,GPR119c
0.229467444,KO,GPR119d
0.294089745,KO,GPR119d
0.309964445,KO,GPR119d
0.30474325,KO,GPR119e
0.159374839,KO,GPR119e
0.467726848,KO,GPR119e
1.01841912,KO,GPR119f
0.423028621,KO,GPR119f
0.223588597,KO,GPR119f

Thank




[[alternative HTML version deleted]]

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


David Winsemius, MD
West Hartford, CT

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


[R] help

2011-02-02 Thread ghasem amini
hello
I have recently started using the LOCFIT package, together with Clive
Loader's book.  I need to implement some method for automatic (plug-in)
bandwidth selection in a multivariate kernel regression.  From the book, and
the LOCFIT documentation,  it is not clear whether this is possible.  As far
as I can see, the only time the various automated procedures, e.g., SJPI,
are used is in the kdeb function, which is for preparing a summary
comparison of various selection methods, and only for a *univariate kernel
density.  *Does anyone here know of a way to implement automatic (plug-in)
bandwidth selection for kernel regression, maybe with some R function that
calls LOCFIT?  Or can you suggest a good alternative package for this,
either in R/Matlab or a stand-alone?

Thanks a lot, and regards

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


Re: [R] clustering with finite mixture model

2011-02-02 Thread Matt Shotwell
There are quite a few packages that work with finite mixtures, as 
evidenced by the descriptions here:


http://cran.r-project.org/web/packages/index.html

These might be useful:

http://cran.r-project.org/web/packages/flexmix/index.html
http://cran.r-project.org/web/packages/mclust/index.html

-Matt

On 02/02/2011 04:28 AM, karuna m wrote:

Dear R-help,
I am doing clustering via finite mixture model. Please suggest some packages in
R to find clusters via finite mixture model with continuous variables. And
also I wish to verify the distributional properties of the mixture distributions
by fitting the model with lognormal, gamma, exponentials etc,.
Thanks in advance,
  warm regards,Ms.Karunambigai M
PhD Scholar
Dept. of Biostatistics
NIMHANS
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.



--
Matthew S Shotwell   Assistant Professor   School of Medicine
 Department of Biostatistics   Vanderbilt University

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


Re: [R] Help in getting info from a DataFrame

2011-02-02 Thread David Winsemius


On Jan 31, 2011, at 3:44 AM, ADias wrote:




David Winsemius wrote:



On Jan 30, 2011, at 5:27 PM, ADias wrote:


dados-
data
.frame
(Store
=
c
(Setubal
,lx
,Aveiro
,Coimbra
,Aveiro,Evora,Aveiro,Coimbra,Setubal),Prod=c(Bloco
Desenho,Bloco
Desenho
,Tinteiro
,Régua
,Lapiseira
,Regua
,Tinteiro,Lapiseira,Lapiseira),qtd=c(2,1,2,1,3,1,1,1,1))



See if this is a more useful approach:


lapsales - dados[dados$Prod==Lapiseira,  ]
lapsales[which.max(lapsales[ , qtd ]), Store]

[1] Aveiro
Levels: Aveiro Coimbra Evora lx Setubal

--  
David Winsemius, MD

West Hartford, CT

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



Hi,

thank you for the help.

Two questions I would like to make.

Suppose I have put your answer on an object like this:

r-lapsales[which.max(lapsales[ , qtd ]), Store]

so

r

[1] Aveiro
Levels: Aveiro Coimbra Evora lx Setubal

and suppoese I wish to add this year result to previous years results:

results-c(Lx,Setubal)
so I did:

results-c(results,r)

and what I get is:


results

[1] Lx  Setubal 1


Right. You appended a factor variable to a character variable and got  
the numeric representation for the Aveiro values which is 1 and it  
then got coerced into 1 because the firts element offered to the c()  
function was character.



why 1 and not Aveiro?

Second question is:


lapsales

   Store  Prod qtd
5  Aveiro Lapiseira   3
8 Coimbra Lapiseira   1
9 Setubal Lapiseira   1

lapsales[max(lapsales$qtd),Store]

[1] Setubal
Levels: Aveiro Coimbra Evora lx Setubal


The max of lapsales$qtd is 3 to it is looking up the third store  ==  
Setubal.


--
David.



why Setubal and not Aveiro?

many thanks
AD
--
View this message in context: 
http://r.789695.n4.nabble.com/Help-in-getting-info-from-a-DataFrame-tp3247740p3248276.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
West Hartford, CT

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


[R] Applying multiple functions to one object

2011-02-02 Thread Karl Ove Hufthammer
Dear list members,

I recall seeing a convenience function for applying multiple functions to 
one object (i.e., almost the opposite of 'mapply’) somewhere.
Example: If the function was named ’fun’ the output of

  fun(3.14, mode, typeof, class)

would be identical to the output of

  c(mode(3.14), typeof(3.14), class(3.14))

Is my memory failing me, or does such a function already exists in a 
package? Of course, it’s not difficult to define a summary function and 
apply this to the object, but writing, for example,

fun(x, mean, median, sd, mad)

to quickly show the relevant information is much more *convient*.


It would be even nicer with a function that could also handle vectors and 
lists of values, and output the result as data frames or matrices. Example: 

x = c(foo, bar, foobar)
fun(x, nchar, function(st) substr(st, 1 ,2) )

y = list(3, 3L, 3.14, factor(3))
fun(x, mode, typeof, class)

-- 
Karl Ove Hufthammer

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


Re: [R] Applying multiple functions to one object

2011-02-02 Thread Eik Vettorazzi
Hi Karl,
same to me. Much of the times when coding I think, 'damn it, I have seen
that before, but where...'

... and so the following is from scratch, not from memory.

fun-function(x,...){
 mthd-list(...)
 lapply(mthd,function(m) do.call(m,list(x)))
}
fun(3.14, mode, typeof, class)

there is no error-catching for non-existing functions, no naming of
results and so on, but it may be a start.

hth.



Am 02.02.2011 14:59, schrieb Karl Ove Hufthammer:
 Dear list members,
 
 I recall seeing a convenience function for applying multiple functions to 
 one object (i.e., almost the opposite of 'mapply’) somewhere.
 Example: If the function was named ’fun’ the output of
 
   fun(3.14, mode, typeof, class)
 
 would be identical to the output of
 
   c(mode(3.14), typeof(3.14), class(3.14))
 
 Is my memory failing me, or does such a function already exists in a 
 package? Of course, it’s not difficult to define a summary function and 
 apply this to the object, but writing, for example,
 
 fun(x, mean, median, sd, mad)
 
 to quickly show the relevant information is much more *convient*.
 
 
 It would be even nicer with a function that could also handle vectors and 
 lists of values, and output the result as data frames or matrices. Example: 
 
 x = c(foo, bar, foobar)
 fun(x, nchar, function(st) substr(st, 1 ,2) )
 
 y = list(3, 3L, 3.14, factor(3))
 fun(x, mode, typeof, class)
 


-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] General Solution to Drawing a Spline Curve in 3d?

2011-02-02 Thread Bryan Hanson

Hello Again...

I know that R has plenty of functions for drawing splines between two  
points in 2d, and plenty of ways to fit a spline curve among various  
points in 2d or 3d (I think), but, is there a function which can be  
used to draw a simple spline curve between any two points in 3d  
space?  Since such a spline curve would be fundamentally a 2d object,  
I imagine that if a 3d version exists it would have to have some sort  
of argument specifying where that 2d plane should be drawn (maybe in  
cylindrical coordinates?).


What I'm looking for would be the 3d analog of grid.curve or xspline.   
What I'm trying to do is related to the idea of great circles, as  
implemented in package geosphere, but the curves I'd like to draw are  
not on the surface of a sphere nor are they parts of a circle.


Thanks for any suggestions!  Bryan
***
Bryan Hanson
Professor of Chemistry  Biochemistry

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


Re: [R] error in density plot

2011-02-02 Thread David Winsemius


On Feb 2, 2011, at 8:22 AM, Ben Bolker wrote:


Ramya ramya.victory at gmail.com writes:


I have the code for the density plot
j - 8
plot(density(diff_in_sample[,1]), main = list.files()[j])
for(i in 1:25){
lines(density(diff_in_sample[,i]))
}

This gives me an error
Error in density.default(diff_in_sample[, i]) :
 'x' contains missing values


[snip]

?NA

lines(na.omit(density(diff_in_sample[,i])))


I don't know if that will work, but since Bolker wrtote it,  it's got  
a reasonable probability of being correct code. I generally use the  
na.rm argument inside the density function rather than na.omit wrapped  
around it.


lines(density(diff_in_sample[,i], na.rm=TRUE))

Although if there are a lot of NA's then the registration of the lines  
results are going to be way off from the original plot axis.


--
David.




Consider replacing the loop by apply() [no efficiency
gain, but more compact 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.


David Winsemius, MD
West Hartford, CT

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


[R] update not working

2011-02-02 Thread Luis Ridao
R-help,

I'm using the update command for a multiple regression model and it is
just not working:

 update(model1, . ~ . – temp:wind:rad,data=ozone.pollution)
Error: unexpected input in model2-update(model1, . ~ . –

 summary(model1)

Call:
lm(formula = ozone ~ temp * wind * rad + I(rad^2) + I(temp^2) +
I(wind^2), data = ozone.pollution)

Residuals:
Min  1Q  Median  3Q Max
-38.894 -11.205  -2.736   8.809  70.551

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept)5.683e+02  2.073e+02   2.741  0.00725 **
temp  -1.076e+01  4.303e+00  -2.501  0.01401 *
wind  -3.237e+01  1.173e+01  -2.760  0.00687 **
rad   -3.117e-01  5.585e-01  -0.558  0.57799
I(rad^2)  -3.619e-04  2.573e-04  -1.407  0.16265
I(temp^2)  5.833e-02  2.396e-02   2.435  0.01668 *
I(wind^2)  6.106e-01  1.469e-01   4.157 6.81e-05 ***
temp:wind  2.377e-01  1.367e-01   1.739  0.08519 .
temp:rad   8.403e-03  7.512e-03   1.119  0.26602
wind:rad   2.054e-02  4.892e-02   0.420  0.67552
temp:wind:rad -4.324e-04  6.595e-04  -0.656  0.51358
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 17.82 on 100 degrees of freedom
Multiple R-squared: 0.7394, Adjusted R-squared: 0.7133
F-statistic: 28.37 on 10 and 100 DF,  p-value:  2.2e-16



Can anyone help with this?

Thanks in advance

[[alternative HTML version deleted]]

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


Re: [R] Regression type 2, x measured with error

2011-02-02 Thread misil

Excellent!! thanks for all!
misil

2011/2/1 mbedward [via R]
ml-node+3253006-114577237-210...@n4.nabble.comml-node%2b3253006-114577237-210...@n4.nabble.com


 Another search term is geometric mean regression.

 For simple models you can try the lmodel2 package.

 Michael

 On 2 February 2011 04:31, David Winsemius [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3253006i=0
 wrote:

 
  On Feb 1, 2011, at 10:41 AM, misil wrote:
 
 
  I wanna to do a Regression type 2 or Regression with X measured with
  erroranybody knows how can i make it in R??
  thanks!
 
  There are several prior posts in the archives ... although perhaps not
 the
  Nabble archives since they start throwing away stuff after about a year.
  Search on orthogonal regression, total least sqaures regression or
  Deming regression.
 
  David Winsemius, MD
  West Hartford, CT
 
  __
  [hidden email] 
  http://user/SendEmail.jtp?type=nodenode=3253006i=1mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

 __
 [hidden email] http://user/SendEmail.jtp?type=nodenode=3253006i=2mailing 
 list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://r.789695.n4.nabble.com/Regression-type-2-x-measured-with-error-tp3251875p3253006.html
  To unsubscribe from Regression type 2, x measured with error, click 
 herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=3251875code=anVhcGluQGdtYWlsLmNvbXwzMjUxODc1fDE5NjM3ODYxNTY=.



-- 
View this message in context: 
http://r.789695.n4.nabble.com/Regression-type-2-x-measured-with-error-tp3251875p3254308.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


[R] matrix and a function - apply function

2011-02-02 Thread ADias

Hi

I have this function and this matrix:

function(x,y) x+y/x

m-matrix(c(1,2,4,2,10,8),3,2)

 m
 [,1] [,2]
[1,]12
[2,]2   10
[3,]48

each row represent a point (x,y) in a chart and I want via my fucntion to
calculate the image in order to get this results:

for point (1,2) I would get 1+2/1 = 3
for point (2,10) I would get 2+10/2 = 7
for point (4,8) I would get 4+8/4 = 6

I have tried using sapply here but I get this:

 sapply(m,function(x,y) x+y/x)
Error in y/x : 'y' is missing

what I am doing wrong?

thanks
ADias
-- 
View this message in context: 
http://r.789695.n4.nabble.com/matrix-and-a-function-apply-function-tp3254271p3254271.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Need help subsetting time series data

2011-02-02 Thread Nathaniel

Hi all,

I have multiple datasets of time series data taken from GPS collars.  The
collars are supposed to take a fix every hour on the half hour, i.e., 0:30,
1:30, 2:30...23:30, (because it sometimes takes longer for the collars to
acquire a location the minute of these locations vary from 30-34) but
because of a software glitch in the collars, at random times the collars
start taking multiple fixes between programmed fixes, i.e., 22:31, 23:31,
0:31, 1:26, 1:29, 1:30, 1:31, 1:32, 1:33, 1:35, 1:35, 1:35, 1:35, 1:36,
1:36, 1:36, 2:30.  These glitches occur approximately once a day throughout
the 24 hour and 60 minute cycle.  I want to remove all these extra locations
from my dataset, but am new to R and haven't figured out a way to do so. 
I've tried some inelegant solutions involving verbose code, but haven't been
able to come up with something that works correctly.

Some things I've tried:

#Subsetting out by minute value:
MR1001=read.csv(etc)
datetime-paste(MR1001$date,MR1001$time)
datetime-as.POSIXlt(strptime(as.character(datetime), tz=UTC, %m/%d%Y
%H:%M:%S))
MR1001$min-datetime$min
t1-subset(MR1001,min==30|min==31|min==32|min==33|min==34)

This works for most of the data, but when the unwanted fixes occur during
the 30-34 minute mark of an hour (see example above) they are kept, which I
don't want.  To deal with this I tried to incorporate the time between fixes
in an attempt to write an ifelse statement and subset the data that way:

MR1001=read.csv(etc)
MR1001=read.csv(etc)
datetime-paste(MR1001$date,MR1001$time)
datetime-as.POSIXlt(strptime(as.character(datetime), tz=UTC, %m/%d%Y
%H:%M:%S))
MR1001$min-datetime$min
t1-subset(MR1001,min==30|min==31|min==32|min==33|min==34)
datetime-paste(MR1001$date,MR1001$time)
datetime-as.POSIXct(strptime(as.character(datetime), tz=UTC, %m/%d%Y
%H:%M:%S))
datetime2-datetime[-1]
datetime2[length(datetime)]-datetime2[length(datetime)-1]+3600
datetime3-datetime2-datetime
datetime4-datetime3/60
datetime5-as.numeric(datetime4)
t1$diff-datetime5

This didn't work either though, because when an unwanted fix occurred after
a wanted fix the value in the diff column was small, and I couldn't figure
out how to subset the data in that format (I want to keep the 1st, 2nd, 3rd,
and last fix in the example columns below (23:31, 00:31, 01:30, 2:30)):

timediff
23:31 60
00:31 58.78
01:30 1.07
01:31 1.07
01:32 1.07
01:33 1.07
01:34 1.08
2:30   60

I hope this explanation is clear and that someone with more experience than
me can help with a solution.

Thanks very much in advance for your time and help!

Nathaniel
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-help-subsetting-time-series-data-tp3254236p3254236.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Help me apply mapply

2011-02-02 Thread Alaios
Hello all I would like to ask your help use mapply.

I have a function called findCell that takes two arguments(x,sr)
where x is a vector of size two (e.g x-c(2,3) and sr is a matrix.

I would like to call many times the findCell function (thus I need mapply) for 
different x inputs but always for the same sr.

as x is a vector of size two (two cells) I want to pass inside inside the 
following 2*10 matrix. 
-The first input is the two elements of the first row  cbin(test[1,1],test[1,2])
-the second input is cbind(test[2,1],test[2,2]
-the third input is cbind(test[3,1],test[3,2]

and so on

This is the str:
str(cbind(test[,1],test[,2]))
 num [1:30, 1:2] -1 -0.667 -0.333 0 0.333 ...

so I tried the following:
 mapply(findCell,x=cbind(test[,1],test[,2]),sr=sr)
Error in if (!is.finite(length.out) || length.out  0L) stop(length must be 
non-negative number) else if (length.out ==  : 
  missing value where TRUE/FALSE needed
Calls: mapply - .Call - Anonymous - seq - seq.default

I have spend time reading the ?mapply but I am not sure what is the problem 
here. Could you please help me understand what is missing?

Best Regards
Alex

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

2011-02-02 Thread Brian

Hi

I'm trying to predict using a model I fitted with SVM.

I constructed the model (called Svm) using a training set, and now I want to
use a test set (called BankTest) for prediction.

The response variable is in the first column of BankTest.

 SvmPred = predict(Svm, BankTest[,-1], probability=TRUE)
 SvmPredRes = table(Pred = SvmPred, True = BankTest[,1])

I get this error:
Error in table(Pred = SvmPred, True = BankTest) :  all arguments must have
the same length

 I checked the length of both BankTest[,1] and SvmPredict.
 length(SvmPred)
[1] 2282
 length(BankTest[,1])
[1] 2598

How are these two columns not the same size? Surely the prediction should
try to predict all the values of BankTest[,1]?

Any help would be much appreciated.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/SVM-Prediction-and-Plot-tp3254421p3254421.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] matrix and a function - apply function

2011-02-02 Thread David Winsemius


On Feb 2, 2011, at 9:12 AM, ADias wrote:



Hi

I have this function and this matrix:

function(x,y) x+y/x

m-matrix(c(1,2,4,2,10,8),3,2)


m

[,1] [,2]
[1,]12
[2,]2   10
[3,]48

each row represent a point (x,y) in a chart and I want via my  
fucntion to

calculate the image in order to get this results:

for point (1,2) I would get 1+2/1 = 3
for point (2,10) I would get 2+10/2 = 7
for point (4,8) I would get 4+8/4 = 6

I have tried using sapply here but I get this:


sapply(m,function(x,y) x+y/x)

Error in y/x : 'y' is missing


I'm not sure what sapply does with a matrix argument. I've only used t  
with vectors and lists.  I suspect that it would straighten out the  
argument to a length = 6 vector. (And then, of course, the y  
wouldn't be there.)





what I am doing wrong?


Two things: instead use apply() and realize that the argument is  
passed as a vector


apply(m, 1, function(x) x[1] +x[2]/x[1] )


--
David Winsemius, MD
West Hartford, CT

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


Re: [R] SVM Prediction and Plot

2011-02-02 Thread Steve Lianoglou
Hi,

On Wed, Feb 2, 2011 at 9:56 AM, Brian ctto...@hotmail.com wrote:

 Hi

 I'm trying to predict using a model I fitted with SVM.

 I constructed the model (called Svm) using a training set, and now I want to
 use a test set (called BankTest) for prediction.

 The response variable is in the first column of BankTest.

 SvmPred = predict(Svm, BankTest[,-1], probability=TRUE)
 SvmPredRes = table(Pred = SvmPred, True = BankTest[,1])

 I get this error:
 Error in table(Pred = SvmPred, True = BankTest) :  all arguments must have
 the same length

  I checked the length of both BankTest[,1] and SvmPredict.
 length(SvmPred)
 [1] 2282
 length(BankTest[,1])
 [1] 2598

 How are these two columns not the same size? Surely the prediction should
 try to predict all the values of BankTest[,1]?

What do you get when you type:

R head(SvmPred)

-- 
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] matrix and a function - apply function

2011-02-02 Thread Petr PIKAL
Hi


r-help-boun...@r-project.org napsal dne 02.02.2011 16:05:21:

 
 On Feb 2, 2011, at 9:12 AM, ADias wrote:
 
 
  Hi
 
  I have this function and this matrix:
 
  function(x,y) x+y/x
 
  m-matrix(c(1,2,4,2,10,8),3,2)
 
  m
  [,1] [,2]
  [1,]12
  [2,]2   10
  [3,]48
 
  each row represent a point (x,y) in a chart and I want via my 
  fucntion to
  calculate the image in order to get this results:
 
  for point (1,2) I would get 1+2/1 = 3
  for point (2,10) I would get 2+10/2 = 7
  for point (4,8) I would get 4+8/4 = 6
 
  I have tried using sapply here but I get this:
 
  sapply(m,function(x,y) x+y/x)
  Error in y/x : 'y' is missing
 
 I'm not sure what sapply does with a matrix argument. I've only used t 
 with vectors and lists.  I suspect that it would straighten out the 
 argument to a length = 6 vector. (And then, of course, the y 
 wouldn't be there.)
 
 
 
  what I am doing wrong?
 
 Two things: instead use apply() and realize that the argument is 
 passed as a vector
 
 apply(m, 1, function(x) x[1] +x[2]/x[1] )

Maybe apply is not necessary here

 m[,1]+m[,2]/m[,1]
[1] 3 7 6

Regards
Petr


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

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


Re: [R] matrix and a function - apply function

2011-02-02 Thread Eik Vettorazzi
there is no need for 'apply' here, because R can handle vectors.

ord-m[,1]+m[,2]/m[,1]



Am 02.02.2011 15:12, schrieb ADias:
 
 Hi
 
 I have this function and this matrix:
 
 function(x,y) x+y/x
 
 m-matrix(c(1,2,4,2,10,8),3,2)
 
 m
  [,1] [,2]
 [1,]12
 [2,]2   10
 [3,]48
 
 each row represent a point (x,y) in a chart and I want via my fucntion to
 calculate the image in order to get this results:
 
 for point (1,2) I would get 1+2/1 = 3
 for point (2,10) I would get 2+10/2 = 7
 for point (4,8) I would get 4+8/4 = 6
 
 I have tried using sapply here but I get this:
 
 sapply(m,function(x,y) x+y/x)
 Error in y/x : 'y' is missing
 
 what I am doing wrong?
 
 thanks
 ADias


-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

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

2011-02-02 Thread Sebastián Daza

Hi everyone,
Does anyone know how to get black and white theme (grey scale,, I 
would say) graphs using lattice or ggplot2, as it is shown in this 
webpage: http://lmdvr.r-forge.r-project.org/figures/figures.html?


I am using Sweave, and I cannot get that color configuration.
I have added the following option: trellis.device(color=FALSE) but I got 
a pdf file with color graphs.


Thank in advance.
--
Sebastián Daza
sebastian.d...@gmail.com

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


Re: [R] update not working

2011-02-02 Thread Ista Zahn
Hi Luis,
Well, when I copied your code I discovered that
On Wed, Feb 2, 2011 at 9:42 AM, Luis Ridao luri...@gmail.com wrote:
 R-help,

 I'm using the update command for a multiple regression model and it is
 just not working:

 update(model1, . ~ . – temp:wind:rad,data=ozone.pollution)
^
  this is not a minus sign!
Are you using a word processer to write your code?

update(ozone ~ temp * wind * rad + I(rad^2) + I(temp^2) + I(wind^2), .
~ . -temp:wind:rad)

works for me.

Best,
Ista

 Error: unexpected input in model2-update(model1, . ~ . –

 summary(model1)

 Call:
 lm(formula = ozone ~ temp * wind * rad + I(rad^2) + I(temp^2) +
    I(wind^2), data = ozone.pollution)

 Residuals:
    Min      1Q  Median      3Q     Max
 -38.894 -11.205  -2.736   8.809  70.551

 Coefficients:
                Estimate Std. Error t value Pr(|t|)
 (Intercept)    5.683e+02  2.073e+02   2.741  0.00725 **
 temp          -1.076e+01  4.303e+00  -2.501  0.01401 *
 wind          -3.237e+01  1.173e+01  -2.760  0.00687 **
 rad           -3.117e-01  5.585e-01  -0.558  0.57799
 I(rad^2)      -3.619e-04  2.573e-04  -1.407  0.16265
 I(temp^2)      5.833e-02  2.396e-02   2.435  0.01668 *
 I(wind^2)      6.106e-01  1.469e-01   4.157 6.81e-05 ***
 temp:wind      2.377e-01  1.367e-01   1.739  0.08519 .
 temp:rad       8.403e-03  7.512e-03   1.119  0.26602
 wind:rad       2.054e-02  4.892e-02   0.420  0.67552
 temp:wind:rad -4.324e-04  6.595e-04  -0.656  0.51358
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 Residual standard error: 17.82 on 100 degrees of freedom
 Multiple R-squared: 0.7394,     Adjusted R-squared: 0.7133
 F-statistic: 28.37 on 10 and 100 DF,  p-value:  2.2e-16



 Can anyone help with this?

 Thanks in advance

        [[alternative HTML version deleted]]


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





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

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


Re: [R] help

2011-02-02 Thread Wacek Kusnierczyk

On 2/2/11 3:59 AM, Łukasz Ręcławowicz wrote:

We don't need a loop!

require(Rmpfr)
factorial(mpfr(1:500,3800))


This is very good!  I get an unexpected warning, though:

Warning message:
In if (mpfr.is.integer(x)) round(r) else r :
  the condition has length  1 and only the first element will be used

vQ

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


Re: [R] grey scale graphs

2011-02-02 Thread Ista Zahn
Well, if you're using pdf, you could set the gray option there, e.g.,

pdf.options(colormodel=gray)

Or you could just use a gray theme. In ggplot2 use

+ theme_gray()

Not sure in lattice, but I think it also has a themeing system.

Best,
Ista
2011/2/2 Sebastián Daza sebastian.d...@gmail.com:
 Hi everyone,
 Does anyone know how to get black and white theme (grey scale,, I would
 say) graphs using lattice or ggplot2, as it is shown in this webpage:
 http://lmdvr.r-forge.r-project.org/figures/figures.html?

 I am using Sweave, and I cannot get that color configuration.
 I have added the following option: trellis.device(color=FALSE) but I got a
 pdf file with color graphs.

 Thank in advance.
 --
 Sebastián Daza
 sebastian.d...@gmail.com

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




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

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


[R] drawing from one cell to another using layout() - possible?

2011-02-02 Thread Mark Heckmann
Is it possible to cross the cell boundaries set by layout using base graphics?
I.e. I want to draw e.g. a line from one layout cell to another.
Is there a way to do that?

layout(matrix(c(1,2), byrow=TRUE, ncol=2))
plot.new()
text(0,0,paste(rep(a, 200), collapse=), xpd=T)

layout.show(2)

I would like the a's to not end at the layout borders of the left cell.

Thanks in advance,
Mark

PS. I need to use base not groid graphics, though it may be simpler...
-- 
Mark Heckmann (Dipl. Wirt.-Ing.)
phone +49 (0) 421/1614618

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

2011-02-02 Thread Eik Vettorazzi
Hi,
maybe you rethink your calculations. Just for curiosity, what's the purpose?

First of all, using
prod(1:j-1-.25)  #and
prod(1:j)

instead of a loop is much more efficent.
If you need all values for a[1] up to a[j] you can use cumprod

But this doesn't get you rid of numeric overflow

but 1/(1*2*3*4*..*j) * (-d)(1-d)(2-d)...(j-1-d)
is the same as
(-d)/1 * (1-d)/2 * (2-d)/3 ... * (j-1-d)/j

(multiplication is commutative)

j-1:500
a-cumprod((j-1-.25)/j)

or am I missing something?



Am 01.02.2011 21:51, schrieb Kiogou Lydie:
 
 
 PLEASE HELP
 
 I actually want to do the following:
 
 a[j] = (1/(j!))*Π (i-1-d), j = 500, Π means product i = 1 to
 j
 
  
 
 Yet, j! will stop at 170 and Π (i-1-d) at 172; so, a[j] will
 not exceed 170.
 
 I would like to have at least 200 a[j]. 
 
  
 
 WHAT SHOULD I DO?
 
  
 
 PLEASE SEE MY CODE FOR DETAIL!!
 
 
 
 R CODE:
 ###
 
 
 
 d = .25
 
 # generate j!
 v=j=1
 for (i in 1:200){
 v[i] = i
 for (i in 2:200){
 j[1]=1
 j[i] = j[i-1]*v[i]
 }
 }
 j
 
 # generate aj
 l=A=a=0
 for (k in 1:200){
 l[k] = (k-1-d)
   for (i in 2:200){
 A[1] = l[1]
 A[i] = A[i-1]*l[i]
  for ( i in 1:200){
   a[i]= (1/j[i])*A[i]
 }
   
 }
 }
 a
 
  END CODE ##
 #
 
 
 With GOD, everything is POSSIBLE.
 
 Avec DIEU, tout est POSSIBLE.
 
 
   
   [[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.


-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

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


Re: [R] Finding the maximum in a particular group in a dataframe

2011-02-02 Thread Dennis Murphy
Hi:

Using df as your data frame,

max(subset(df, condition == 'GPR119a', select = responce))
[1] 0.6451204

You asked this question yesterday with several correct responses. What was
wrong with them?

Dennis

On Wed, Feb 2, 2011 at 12:48 AM, Asan Ramzan asanram...@yahoo.com wrote:

 Hello

 I am trying to find a way to find the max value, for only a subset of a
 dataframe, depending on how the data is grouped for example,

 How would I find the maxmium responce, for all the GPR119a condition below:

 I've tried tapply

  tapply(GPR119data$responce, GPR119data$GPR119a, max)
 Error in tapply(GPR119data$responce, GPR119data$GPR119a, max) :
   arguments must have same length

 responce,mouce,condition
 0.105902,KO,con
 0.232018561,KO,con
 0.335008375,KO,con
 0.387025433,KO,GPR119a
 0.576769897,KO,GPR119a
 0.645120419,KO,GPR119a
 0.2538608,KO,GPR119b
 0.183061952,KO,GPR119b
 0.824035587,KO,GPR119b
 0.399201597,KO,GPR119c
 0.417006618,KO,GPR119c
 0.572958834,KO,GPR119c
 0.229467444,KO,GPR119d
 0.294089745,KO,GPR119d
 0.309964445,KO,GPR119d
 0.30474325,KO,GPR119e
 0.159374839,KO,GPR119e
 0.467726848,KO,GPR119e
 1.01841912,KO,GPR119f
 0.423028621,KO,GPR119f
 0.223588597,KO,GPR119f

 Thank




[[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] SMA and EMA in package TTR

2011-02-02 Thread Joshua Ulrich
Hi Anyi,

That's not currently possible.  You could use the rollmean function in
the development version of the zoo package (on R-forge) to calculate
the simple moving average as you described.

I would like to add this as an option to TTR functions, but it is not
high on my priority list.  I would appreciate patches.

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



On Sat, Jan 29, 2011 at 7:39 PM, Anyi Zhu anyi@gmail.com wrote:
 Hi,

 Just wondering for the SMA and EMA in package TTR, is it possible to me to
 code it so that, say if I need to calculate SMA (x, n=100), when the sample
 size is less than 100, it will give me the SMA (x, k) where k is the sample
 size of the data? Right now it only gives me an invalid n error.

 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.


Re: [R] Function to locate points in 3d octants or points on twoaxes

2011-02-02 Thread Daniel Nordlund
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Bryan Hanson
 Sent: Wednesday, February 02, 2011 5:23 AM
 To: Petr Savicky
 Cc: r-help@r-project.org
 Subject: Re: [R] Function to locate points in 3d octants or points on
 twoaxes
 
 Thanks Petr, the sign function will be of help.  I was not aware of
 it.  Bryan
 
 On Feb 2, 2011, at 3:21 AM, Petr Savicky wrote:
 
  On Tue, Feb 01, 2011 at 08:30:22PM -0500, Bryan Hanson wrote:
  [Sorry, resending with a proper subject line!]
 
  Hi Guru's...
 
  I have a set of points that may lie along any of the x, y and z axes
  in a Cartesian coordinate system.  I am hoping that a function exists
  which will determine if any two selected points are on different
  axes,
  i.e, if the one of the points is on x and the other on y or z, not
  elsewhere on the x axis.  Put another way, I need to determine if the
  triangle formed by the two points and the origin lies in the xy, xz
  or
  yz planes.  This might be as simple as testing if any particular
  value
  is zero, i.e. if the x coordinate is zero, then the points must be on
  the z and y axes and the triangle in the yz plane.  But, I'm looking
  for a fairly general solution, one that also returns the appropriate
  plane as the answer.  Very closely related to this, I could use a
  function that determines which of the 8 octants a point lies in.
  Seems
  like the cross product might be part of this, but I'm a little rusty
  on how to apply it.
 
  I hope this is clear enough, and someone has a suggestion to point me
  in the right direction.  Before writing my own klunky version, I
  thought I'd ask.
 

For a general solution you also need to consider how you want to deal with 
boundary conditions.  For example, if the x and y coordinates are zero for 
both points then the points lie in both the xz and yz planes.  And if one of 
the coordinates of a point is zero, then how do you decide which quadrant it is 
in?

Dan

Daniel Nordlund
Bothell, WA USA

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


Re: [R] Acf of Frima

2011-02-02 Thread Spencer Graves
What's farima?  functional arima or fractional arima?  If the former, 
the fda package includes a function cor.fd for correlation matrix 
from functional data object(s).  If the latter, I suggest you use sos 
as follows:



library(sos)
(fr - findFn('fractional arima'))


  findFn searches a database of help pages of contributed 
packages.  This particular call returned 13 links in 5 packages and 
opened the results in a table in a web browser with hot links , sorted 
to put first the package with the most matches.



  Hope this helps.
  Spencer


On 2/2/2011 5:43 AM, Chuse chuse wrote:

Hello,

I am trying to calculate the autocovariance matrix for any general
farima(p,d,q) with
p,q  1. Could anyone give an idea how to implement in R or if there
is any package for this?

thank you beforehand.

Jose.

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





--
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567

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


Re: [R] Function to locate points in 3d octants or points on twoaxes

2011-02-02 Thread Bryan Hanson
Thanks Dan for pointing that out.  My question really arose from the  
need to draw splines between arbitrary 3d pairs of points, so I posted  
a new question to the list addressing that more specifically.  While  
the issue of 3d splines must have been dealt with in graphics/ 
animation oriented programs/languages, I think I may have to grow my  
own and I'll need the suggestions offered by you and Petr.  Thanks,  
Bryan


On Feb 2, 2011, at 11:55 AM, Daniel Nordlund wrote:


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org 
]

On Behalf Of Bryan Hanson
Sent: Wednesday, February 02, 2011 5:23 AM
To: Petr Savicky
Cc: r-help@r-project.org
Subject: Re: [R] Function to locate points in 3d octants or points on
twoaxes

Thanks Petr, the sign function will be of help.  I was not aware of
it.  Bryan

On Feb 2, 2011, at 3:21 AM, Petr Savicky wrote:


On Tue, Feb 01, 2011 at 08:30:22PM -0500, Bryan Hanson wrote:

[Sorry, resending with a proper subject line!]

Hi Guru's...

I have a set of points that may lie along any of the x, y and z  
axes
in a Cartesian coordinate system.  I am hoping that a function  
exists

which will determine if any two selected points are on different
axes,
i.e, if the one of the points is on x and the other on y or z, not
elsewhere on the x axis.  Put another way, I need to determine if  
the

triangle formed by the two points and the origin lies in the xy, xz
or
yz planes.  This might be as simple as testing if any particular
value
is zero, i.e. if the x coordinate is zero, then the points must  
be on
the z and y axes and the triangle in the yz plane.  But, I'm  
looking
for a fairly general solution, one that also returns the  
appropriate

plane as the answer.  Very closely related to this, I could use a
function that determines which of the 8 octants a point lies in.
Seems
like the cross product might be part of this, but I'm a little  
rusty

on how to apply it.

I hope this is clear enough, and someone has a suggestion to  
point me

in the right direction.  Before writing my own klunky version, I
thought I'd ask.




For a general solution you also need to consider how you want to  
deal with boundary conditions.  For example, if the x and y  
coordinates are zero for both points then the points lie in both the  
xz and yz planes.  And if one of the coordinates of a point is zero,  
then how do you decide which quadrant it is in?


Dan

Daniel Nordlund
Bothell, WA USA

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

2011-02-02 Thread jim holtman
To solve it, a little more data would help.  At least provide exactly
the statements you are using and an 'str' of the objects; e.g.,

str(matrix2)
str(condition2)

error message might indicate that the length of condition2 is larger
than the subset of matrix2 that you want.

On Wed, Feb 2, 2011 at 8:30 AM, alcesgabbo alcesga...@hotmail.com wrote:

 I have a matrix with a lot of values inside..

 when I execute the folowing command

 matrix2=subset(martix, condition.)

 it works...

 but after the previous command I execute another subset

 matrix3=subset(martix2, condition2.)

 and appears the following error:

 (subscript) logical subscript too long

 How can I solve this???
 I think the probles is the size of the matrix...
 Thanks..
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/subset-in-a-BIG-matrix-tp3254115p3254115.html
 Sent from the R help mailing list archive at Nabble.com.

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




-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

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


Re: [R] subset in a BIG matrix

2011-02-02 Thread Steve Lianoglou
Hi,

On Wed, Feb 2, 2011 at 8:30 AM, alcesgabbo alcesga...@hotmail.com wrote:

 I have a matrix with a lot of values inside..

 when I execute the folowing command

 matrix2=subset(martix, condition.)

 it works...

 but after the previous command I execute another subset

 matrix3=subset(martix2, condition2.)

 and appears the following error:

 (subscript) logical subscript too long

 How can I solve this???
 I think the probles is the size of the matrix...

Without your actual code, it's hard to tell, but if I were to take a
guess, I think you're generating your `condition2` logic vector based
on your original `matrix` maybe?

If you aren't already doing so, put your subsetting logic into your
`subset` call, eg:

matrix3 - subset(matrix2, some.column = some.value) ## or whatever

-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] grey scale graphs

2011-02-02 Thread David Winsemius


On Feb 2, 2011, at 10:26 AM, Sebastián Daza wrote:


Hi everyone,
Does anyone know how to get black and white theme (grey scale,, I  
would say) graphs using lattice or ggplot2, as it is shown in this  
webpage: http://lmdvr.r-forge.r-project.org/figures/figures.html?


I am using Sweave, and I cannot get that color configuration.
I have added the following option: trellis.device(color=FALSE) but I  
got a pdf file with color graphs.


Maybe you should use postscript as a device for which the default is  
for color=FALSE.


?trellis.device



Thank in advance.
--
Sebastián Daza
sebastian.d...@gmail.com

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


David Winsemius, MD
West Hartford, CT

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


[R] Why my package is not being generated?

2011-02-02 Thread Cristiano Strieder
Hi all,

I have commited a new release of my package and waited for more than
one day. After that
install.packages(tests,repos=http://r-forge.r-projet.org;) still
returns package 'tests' is not available. I have done the local
build  check and the package seems ok. Also have mofified the Title
in the DESCRIPTION  file.

What can be wrong?

Is there any tool or recomendation to validade my package before submit it?

--
Cristiano Strieder
São José dos Campos - SP

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


Re: [R] SVM Prediction and Plot

2011-02-02 Thread Brian

Thanks for the reply.

When I run this:

 head(SvmPred)
3570 2361 5406 2041 3440 4123 
   NNYYYY 
Levels: N Y

-- 
View this message in context: 
http://r.789695.n4.nabble.com/SVM-Prediction-and-Plot-tp3254421p3254570.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] Efficient way to determine if a data frame has missing observations

2011-02-02 Thread H Roark

I have a data set covering a large number of cities with values for 
characteristics such as land area, population, and employment. The problem I 
have is that some cities lack observations for some of the characteristics and 
I'd like a quick way to determine which cities have missing data.  For example:

city-c(A,A,A,B,B,C) 
var-c(sqmi,pop,emp,pop,emp,pop)
value-c(10,100,40,30,10,20)
df-data.frame(city,var,value)

In this data frame, city A has complete data for the three variables, while 
city B is missing land area, and city C only has population data. In the full 
data frame, my approach to finding the missing observations has been to create 
a data frame with all combinations of 'city' and 'var', merge this onto the 
original data frame, and then extract the observations with missing data for 
'value':

city_unq-c(A,B,C)
var_unq-c(sqmi,pop,emp)
comb-expand.grid(city=city_unq,var=var_unq)

mrg-merge(comb,df,by=c(city,var),all=T)
missing-mrg[is.na(mrg$value),]

This works, but on a large dataset it gets slow and I'm looking for a a more 
efficient way to achieve this same result.  Any suggestions would be much 
appreciated.

Cheers
  
[[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] exact logistic regression

2011-02-02 Thread Den
Hello to R people
Does anybody know to calculate exact logistic regression in R?
Does such option exist anywhere?
Surprisingly, could not find it using search engine. It is hard to
believe, however, that such useful function is not implemented in R yet?
Could you help, please

Thank you
Denis

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

2011-02-02 Thread H Roark

I'm wondering about the behavior of the merge function when using factors as by 
variables. I know that when you combine two factors using c() the results can 
be odd, as in:

c(factor(1:5),factor(6:10))

which prints: [1] 1 2 3 4 5 1 2 3 4 5

I presume this is because factors are actually stored as integers, with 
6,7,8,9,10 stored internally as 1,2,3,4,5.

This concerns me somewhat, as I often merge data frames using factors as the by 
variables. From what I can tell, the merge function creates matches based on 
factor labels (i.e. the result of as.character(factor_var)) and not the 
internally stored integers, but I'm wondering if there are particular lurking 
problems that I should be aware of?  I'm especially curious as to how R 
recalculates the levels of the by variables in outer joins where not every 
observation is matched, as in:

df1-data.frame(a=factor(c(a,b)),b=1:2)
df2-data.frame(a=factor(c(b,c)),c=2:3)
df3-merge(df1,df2,by=a,all=T)

Many 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] Average of several line plots

2011-02-02 Thread mattnixon

Hi,

I have several data sets which are all approximately within the same values
as each other (both X and Y) and all of these data sets more or less overlap
each other when plotted on the same graph. However, although each data set
varies between approximately the same range, there are vastly different
numbers of data points within each data set (due to the nature of how these
values had to be measured).

Currently, I am trying to figure out a way to produce a graph showing all
these data sets and a line showing the average of all of the data sets.
Given the different number of data points, I can't think of an easy way to
do this.

Can anybody help?

Thanks!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Average-of-several-line-plots-tp3254850p3254850.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] Function to locate points in 3d octants or points on twoaxes

2011-02-02 Thread David Winsemius


On Feb 2, 2011, at 12:28 PM, Bryan Hanson wrote:

Thanks Dan for pointing that out.  My question really arose from the  
need to draw splines between arbitrary 3d pairs of points, so I  
posted a new question to the list addressing that more  
specifically.  While the issue of 3d splines must have been dealt  
with in graphics/animation oriented programs/languages, I think I  
may have to grow my own and I'll need the suggestions offered by  
you and Petr.  Thanks, Bryan


I fit crossed cubic regression splines using the rms package, which  
might provide this functionality. However, I get the idea you want an  
exact fit rather than a  fit that is constrained to a particular  
functional form with parameters determined by a minimization metric  
involving a large number of points.


--
David


On Feb 2, 2011, at 11:55 AM, Daniel Nordlund wrote:


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org 
]

On Behalf Of Bryan Hanson
Sent: Wednesday, February 02, 2011 5:23 AM
To: Petr Savicky
Cc: r-help@r-project.org
Subject: Re: [R] Function to locate points in 3d octants or points  
on

twoaxes

Thanks Petr, the sign function will be of help.  I was not aware of
it.  Bryan

On Feb 2, 2011, at 3:21 AM, Petr Savicky wrote:


On Tue, Feb 01, 2011 at 08:30:22PM -0500, Bryan Hanson wrote:

[Sorry, resending with a proper subject line!]

Hi Guru's...

I have a set of points that may lie along any of the x, y and z  
axes
in a Cartesian coordinate system.  I am hoping that a function  
exists

which will determine if any two selected points are on different
axes,
i.e, if the one of the points is on x and the other on y or z, not
elsewhere on the x axis.  Put another way, I need to determine  
if the
triangle formed by the two points and the origin lies in the xy,  
xz

or
yz planes.  This might be as simple as testing if any particular
value
is zero, i.e. if the x coordinate is zero, then the points must  
be on
the z and y axes and the triangle in the yz plane.  But, I'm  
looking
for a fairly general solution, one that also returns the  
appropriate

plane as the answer.  Very closely related to this, I could use a
function that determines which of the 8 octants a point lies in.
Seems
like the cross product might be part of this, but I'm a little  
rusty

on how to apply it.

I hope this is clear enough, and someone has a suggestion to  
point me

in the right direction.  Before writing my own klunky version, I
thought I'd ask.




For a general solution you also need to consider how you want to  
deal with boundary conditions.  For example, if the x and y  
coordinates are zero for both points then the points lie in both  
the xz and yz planes.  And if one of the coordinates of a point is  
zero, then how do you decide which quadrant it is in?


Dan

Daniel Nordlund
Bothell, WA USA

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] Merging by factor variables

2011-02-02 Thread Erik Iverson



H Roark wrote:

I'm wondering about the behavior of the merge function when using factors as by 
variables. I know that when you combine two factors using c() the results can 
be odd, as in:

c(factor(1:5),factor(6:10))

which prints: [1] 1 2 3 4 5 1 2 3 4 5

I presume this is because factors are actually stored as integers, with 
6,7,8,9,10 stored internally as 1,2,3,4,5.

This concerns me somewhat, as I often merge data frames using factors as the by 
variables. From what I can tell, the merge function creates matches based on 
factor labels (i.e. the result of as.character(factor_var)) and not the 
internally stored integers, but I'm wondering if there are particular lurking 
problems that I should be aware of?  I'm especially curious as to how R 
recalculates the levels of the by variables in outer joins where not every 
observation is matched, as in:

df1-data.frame(a=factor(c(a,b)),b=1:2)
df2-data.frame(a=factor(c(b,c)),c=2:3)
df3-merge(df1,df2,by=a,all=T)


As far as I know, there is no reason to be concerned when using merge
as you do.

The magic that ?merge is performing is actually being done in ?rbind,
and you should read the help for that, particularly under Data frame
methods. You can also study the code of base.rbind.data.frame to see
what it's actually doing.

--Erik

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


Re: [R] Efficient way to determine if a data frame has missing observations

2011-02-02 Thread Erik Iverson



H Roark wrote:

I have a data set covering a large number of cities with values for 
characteristics such as land area, population, and employment. The problem I 
have is that some cities lack observations for some of the characteristics and 
I'd like a quick way to determine which cities have missing data.  For example:

city-c(A,A,A,B,B,C) 
var-c(sqmi,pop,emp,pop,emp,pop)

value-c(10,100,40,30,10,20)
df-data.frame(city,var,value)

In this data frame, city A has complete data for the three variables, while 
city B is missing land area, and city C only has population data. In the full 
data frame, my approach to finding the missing observations has been to create 
a data frame with all combinations of 'city' and 'var', merge this onto the 
original data frame, and then extract the observations with missing data for 
'value':

city_unq-c(A,B,C)
var_unq-c(sqmi,pop,emp)
comb-expand.grid(city=city_unq,var=var_unq)

mrg-merge(comb,df,by=c(city,var),all=T)
missing-mrg[is.na(mrg$value),]


Perhaps the following, or a variation thereof?

subset(as.data.frame(table(city = df$city, var = df$var)), Freq == 0)

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


Re: [R] SVM Prediction and Plot

2011-02-02 Thread Steve Lianoglou
Hi,

On Wed, Feb 2, 2011 at 10:35 AM, Brian ctto...@hotmail.com wrote:

 Thanks for the reply.

 When I run this:

 head(SvmPred)
 3570 2361 5406 2041 3440 4123
   N    N    Y    Y    Y    Y
 Levels: N Y

Hmmm ... I think we'll need more info.

It looks like it should be working. By your output, your
`probabilites=TRUE` parameter in your call to `predict` isn't actually
doing anything. You need to train the svm and set `probability=TRUE`
if you're really after class probabilties.

Also, maybe there are some NA's in your data? Also, to be extra
careful, the second argument to predict should be a matrix, I guess it
already is, but ... what happens if you call predict like so:

R SvmPred = predict(Svm, as.matrix(BankTest[,-1]), na.omit=na.fail)

-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] Efficient way to determine if a data frame has missing observations

2011-02-02 Thread Henrique Dallazuanna
Try this:

subset(as.data.frame(xtabs( ~ city + var, df)), !Freq)


On Wed, Feb 2, 2011 at 1:49 PM, H Roark hrbuil...@hotmail.com wrote:


 I have a data set covering a large number of cities with values for
 characteristics such as land area, population, and employment. The problem I
 have is that some cities lack observations for some of the characteristics
 and I'd like a quick way to determine which cities have missing data.  For
 example:

 city-c(A,A,A,B,B,C)
 var-c(sqmi,pop,emp,pop,emp,pop)
 value-c(10,100,40,30,10,20)
 df-data.frame(city,var,value)

 In this data frame, city A has complete data for the three variables, while
 city B is missing land area, and city C only has population data. In the
 full data frame, my approach to finding the missing observations has been to
 create a data frame with all combinations of 'city' and 'var', merge this
 onto the original data frame, and then extract the observations with missing
 data for 'value':

 city_unq-c(A,B,C)
 var_unq-c(sqmi,pop,emp)
 comb-expand.grid(city=city_unq,var=var_unq)

 mrg-merge(comb,df,by=c(city,var),all=T)
 missing-mrg[is.na(mrg$value),]

 This works, but on a large dataset it gets slow and I'm looking for a a
 more efficient way to achieve this same result.  Any suggestions would be
 much appreciated.

 Cheers

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




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

[[alternative HTML version deleted]]

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


Re: [R] Average of several line plots

2011-02-02 Thread Peter Ehlers

On 2011-02-02 08:44, mattnixon wrote:


Hi,

I have several data sets which are all approximately within the same values
as each other (both X and Y) and all of these data sets more or less overlap
each other when plotted on the same graph. However, although each data set
varies between approximately the same range, there are vastly different
numbers of data points within each data set (due to the nature of how these
values had to be measured).

Currently, I am trying to figure out a way to produce a graph showing all
these data sets and a line showing the average of all of the data sets.
Given the different number of data points, I can't think of an easy way to
do this.


Have a look at ?approxfun

Peter Ehlers



Can anybody help?

Thanks!


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


[R] Indexing from two variables

2011-02-02 Thread dunner

Hello, thank you all for your patience and time

I am essentially trying to get disorganised data into long form for linear
modelling.

I have 2 dataframes rec and book

Each row in book needs to be pasted onto the end of several of the rows of
rec according to two variables in the row: MRN and COURSE which match.

I have tried the following and variations thereon to no avail:

/code
#for each line of the recovery dataframe #insert the one line of the book
dataset that corresponds to the MRN AND the course-of-treatment (COURSE)

#get the mrn and course from the first line of the recovery dataframe (rec)

i=1
newlist=list()
colnames(newlist)=colnames(book)
for ( i in 1:dim(rec)[1]) {

mrn=as.numeric(as.vector(rec$MRN[i]));
course=as.character(rec$COURSE[i]);

## find the corresponding row in the book dataframe ## by generating a
logical vector and using ## it to access book

get.vector-as.vector(((as.numeric(as.vector(book$MRN))==mrn) 
(as.character(book$COURSE)==course)))

#gives you a vector of logicals (works)

newlist[i]-book[get.vector,]  ### (doesn't work)

i=i+1;
}
/code

If anyone has any suggestions on 

1)getting this to work
2) making it more elegant (or perhaps just less clumsy)

If I have been unclear in any way I beg your pardons.

I do understand I haven't combined any data above, I think if I can generate
a long-format dataframe I can combine them all on my own. Apologies to
anybody who receives this twice, I had a bounced reply the first time, and
assumed it was unsuccessful.

Ross Dunne
MB MRCPsych
ross.du...@tcd.ie



-- 
View this message in context: 
http://r.789695.n4.nabble.com/Indexing-from-two-variables-tp3255405p3255405.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] Average of several line plots

2011-02-02 Thread Eduardo de Oliveira Horta
It is not clear from your message whether these data represent
functions or such. Could you perhaps bring up an example?

I'm guessing each data set contains evaluation points and function
values at those points, and that you would like to plot these
functions and the mean function all on the same graph, is that right?

If the points in the domain differ from each other, it's not as
immediate to build a mean function. A quick recipe would be to use
splinefun on each data set, generate a new grid for the domain,
evaluate each obtained spline on this grid to get new data sets and
build the mean function from there.

But without an example it's really just guessing. Hope this helps anyway.

?splinefun

Best regards,

Eduardo

On Wed, Feb 2, 2011 at 2:44 PM, mattnixon m.r.ni...@ex.ac.uk wrote:

 Hi,

 I have several data sets which are all approximately within the same values
 as each other (both X and Y) and all of these data sets more or less overlap
 each other when plotted on the same graph. However, although each data set
 varies between approximately the same range, there are vastly different
 numbers of data points within each data set (due to the nature of how these
 values had to be measured).

 Currently, I am trying to figure out a way to produce a graph showing all
 these data sets and a line showing the average of all of the data sets.
 Given the different number of data points, I can't think of an easy way to
 do this.

 Can anybody help?

 Thanks!
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Average-of-several-line-plots-tp3254850p3254850.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] Indexing from two variables

2011-02-02 Thread Ista Zahn
Hard to know exactly without seeing the structrure of rec and book,
but I would start with ?merge

Best,
Ista

On Wed, Feb 2, 2011 at 2:06 PM, dunner ross.du...@tcd.ie wrote:

 Hello, thank you all for your patience and time

 I am essentially trying to get disorganised data into long form for linear
 modelling.

 I have 2 dataframes rec and book

 Each row in book needs to be pasted onto the end of several of the rows of
 rec according to two variables in the row: MRN and COURSE which match.

 I have tried the following and variations thereon to no avail:

 /code
 #for each line of the recovery dataframe #insert the one line of the book
 dataset that corresponds to the MRN AND the course-of-treatment (COURSE)

 #get the mrn and course from the first line of the recovery dataframe (rec)

 i=1
 newlist=list()
 colnames(newlist)=colnames(book)
 for ( i in 1:dim(rec)[1]) {

        mrn=as.numeric(as.vector(rec$MRN[i]));
        course=as.character(rec$COURSE[i]);

 ## find the corresponding row in the book dataframe ## by generating a
 logical vector and using ## it to access book

 get.vector-as.vector(((as.numeric(as.vector(book$MRN))==mrn) 
 (as.character(book$COURSE)==course)))

 #gives you a vector of logicals (works)

 newlist[i]-book[get.vector,]  ### (doesn't work)

 i=i+1;
 }
 /code

 If anyone has any suggestions on

 1)getting this to work
 2) making it more elegant (or perhaps just less clumsy)

 If I have been unclear in any way I beg your pardons.

 I do understand I haven't combined any data above, I think if I can generate
 a long-format dataframe I can combine them all on my own. Apologies to
 anybody who receives this twice, I had a bounced reply the first time, and
 assumed it was unsuccessful.

 Ross Dunne
 MB MRCPsych
 ross.du...@tcd.ie



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Indexing-from-two-variables-tp3255405p3255405.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.




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

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


  1   2   >