Re: [R] loop for a large database

2012-02-27 Thread Petr Savicky
On Sun, Feb 26, 2012 at 11:39:01AM -0800, mari681 wrote:
 SORRY!
 
 The data in MyTable are tagsets of photos,  like this:
 
   V1 V2   V3  V4  V5   V6V7   V8
 230green nailpolish   barrym   0   00 00
 231   ny  green brooklyn cleanup   clean  gowanus volunteer  gcc
 232green   saul  lecture   0   00 00
 233green colorscores  market colores marakesh   mercado malu
 234   ny  green brooklyn cleanup   clean  gowanus volunteer  gcc
 235green   saul  lecture   0   00 00
 236 portraitpetwhite   green catcanonsquare  eos
 
  V9   V10  V11  V12 V13 V14 V15
 230   0 000   0   0   0
 231 gowanuscanalconservancy 000   0   0   0
 232   0 000   0   0   0
 233   malugreen maroc souk marrocos   0   0   0
 234 gowanuscanalconservancy 000   0   0   0
 235   0 000   0   0   0
 236  is  eyes mark   taiwan  ii mk2  5d
 
 
 while data of MyVector is a list of tags (none of the columns in particular)
 whose frequency in MyTable has to be computed. Like this:
 
 [1] life  wood  pink  house green fall 

Hi.

Just to be sure, in all the previous solutions, malugreen is not an
occurence of green. Is this correct?

 MyTable has 21 millions rows and 15 columns, and the data is character,
 they are words.

Do you use the argument stringsAsFactors=FALSE, when reading the data
from a file? Otherwise, character data are converted to a factor.
The discussed solutions work in both cases, however, if we try to
prepare simplified data for testing efficiency, we should use the
same column class as in the real situation.

 When I tried the loop my computer crashed in the meaning that it freezed
 (froze?) and didn't allow me to do anything. The morning after I forced it
 off and rebooted.

This does not seem to be a consequence of a too long computation.
A possible cause can be too large memory requirements. How large memory
the R process uses after loading the data? Try gc() command after loading
the data and compare with the amount of memory available. On a Linux
machine, it is also possible to see the memory usage with top command
in the row, where R is reported.

Petr.

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

2012-02-27 Thread monkeylan
Dear R buddies,

Recently, I attempt to model the US/RMB Exchange rate log-return time series
with a *Hidden Markov model (first order Markov Chain  mixed Normal
distributions). *

I have applied the RHmm package to accomplish this task, but the results are
not so satisfying.
So, I would like to try a *Bayesian method *for the parameter estimation of
the Hidden Markov model.

Could anyone kindly tell me which R package can perform Bayesian estimation
of the model?

Many thanks for your help and time.

Best Regards,
James Allan 


--
View this message in context: 
http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4423946.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] What is the fastest way to combine all columns of a matrix to one column?

2012-02-27 Thread ali_protocol
Dear all,

Newbie: What is the fastest way to combine all columns of a matrix to one
column?

--
View this message in context: 
http://r.789695.n4.nabble.com/What-is-the-fastest-way-to-combine-all-columns-of-a-matrix-to-one-column-tp4423882p4423882.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] randomForest2Rules

2012-02-27 Thread saskay
Hi,
The work around this is to use printRandomForests function in Rattle
package. It outputs the forest in the form of rules.

For ex:
#Load libraries
library(rattle)
library(randomForest)

#Load sample data
data(iris)

#Build a forest
iris.rf - randomForest(Species ~ ., data=iris,
importance=TRUE,keep.forest=T, ntree=5, do.trace=T)
iris.rf

#send rules in above forest to a textfile
sink(file = rfrules.txt, append = FALSE, type = output)
printRandomForests(iris.rf)
sink()

After getting the rules in to a text file, and because the text is
structured, you can use the language of your choice to transform the rules
in to a format you need.

--
View this message in context: 
http://r.789695.n4.nabble.com/randomForest2Rules-tp3822530p4423956.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 advice on GLM

2012-02-27 Thread Christofer Bogaso
Dear all, I was trying to fit a GLM on the following data (this data was
taken from Agresti):

Dat - matrix(c(24, 1355, 35, 603, 21, 192, 30, 224), 4, byrow = TRUE)

Here the 1st column denotes the success and the second column is for
failure. We have 4 rows represeting the 4 states of some explanatory
variable, let say those states are:

Scores - c(0, 2, 4, 5)

My goal is to estimate the success probabilities for each state. Therefore,
I use a simple GLM:

p(x) = alpha + beta * x



*** My first approach

Here I break my sample into sample from Bernoulli distribution and fit glm:

YY - c(rep(1, 24), rep(0, 1355), rep(1, 35), rep(0, 603), rep(1, 21),
rep(0, 192), rep(1, 30), rep(0, 224))

XX - c(rep(0, 24 + 1355), rep(2, 35 + 603), rep(4, 21 + 192), rep(5, 30 +
224))

summary(glm(YY~XX, binomial(link = identity)))



*** My second approach

Here I work with the given sample as it is. Hence assuming Binomial
distribution as follows:

Proportion - apply(Dat, 1, function(x) return(x[1]/(x[1]+x[2])))

summary(glm(Proportion~c(0,2,4,5), binomial(link = identity)))

 Here I was expecting those 2 approaches should give exactly same result
(i.e. same estimates and same SE), which is not the case. Can somebody
point me what I am missing here?

Thanks and regards,

[[alternative HTML version deleted]]

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


Re: [R] loop for a large database

2012-02-27 Thread Petr PIKAL
Hi
 
 SORRY!
 
 The data in MyTable are tagsets of photos,  like this:
 
   V1 V2   V3  V4  V5   V6V7   V8
 230green nailpolish   barrym   0   00 00
 231   ny  green brooklyn cleanup   clean  gowanus volunteer  gcc
 232green   saul  lecture   0   00 00
 233green colorscores  market colores marakesh   mercado malu
 234   ny  green brooklyn cleanup   clean  gowanus volunteer  gcc
 235green   saul  lecture   0   00 00
 236 portraitpetwhite   green catcanonsquare  eos
 
  V9   V10  V11  V12 V13 V14 V15
 230   0 000   0   0   0
 231 gowanuscanalconservancy 000   0   0   0
 232   0 000   0   0   0
 233   malugreen maroc souk marrocos   0   0   0
 234 gowanuscanalconservancy 000   0   0   0
 235   0 000   0   0   0
 236  is  eyes mark   taiwan  ii mk2  5d
 
 
 while data of MyVector is a list of tags (none of the columns in 
particular)
 whose frequency in MyTable has to be computed. Like this:
 
 [1] life  wood  pink  house green fall 

What about changing your data frame to matrix and use table

set.seed(111)
x-sample(letters, 200, replace=T)
y-letters[3:6]
dim(x)-c(20,10)
dd-data.frame(x)
tt-table(as.matrix(dd))
tt[names(tt) %in% y]

 
 c  d  e  f 
13  5  8  3 

Regards
Petr 

 
 
 
 Thanks!!
 
 Marianna
 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/loop-for-a-
 large-database-tp4422052p4422776.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] What is the fastest way to combine all columns of a matrix to one column?

2012-02-27 Thread Petr PIKAL
Hi
 
 Dear all,
 
 Newbie: What is the fastest way to combine all columns of a matrix to 
one
 column?

If mm is your matrix use

dim(mm) -NULL

Regards
Petr


 
 --
 View this message in context: http://r.789695.n4.nabble.com/What-is-the-
 
fastest-way-to-combine-all-columns-of-a-matrix-to-one-column-tp4423882p4423882.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] tcl tk command function with arguments ??

2012-02-27 Thread Alexander
Hi Elai and Peter,

thanks a lot for your suggestions. I am still reading your answers, but I
didn't get at the begining the difference between

c-NULL
for (i in seq(3)) c[[i]]-i
c

and the exempel with the tcl tk buttons. Now I think, it is clear. Its due
to the interaction between R and tcl. The button created by R is executed
far later by tcltk and therefore, the button doesn't take the i during its
creation, but the last available i of its environment.
Do you know any manuals, articles, etc... which describe the interaction
between R and tcl. Now I learn only by examples which I find in the web.

Alexander

--
View this message in context: 
http://r.789695.n4.nabble.com/tcl-tk-command-function-with-arguments-tp4416470p4423969.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] Bayesian Hidden Markov Models

2012-02-27 Thread Oscar Rueda
Dear James, 
Although designed for the analysis of copy number CGH microarrays, RJaCGH
uses a Bayesian HMM model.

Cheers, 
Oscar


On 27/2/12 08:32, monkeylan lanjin...@yahoo.com.cn wrote:

 Dear R buddies,
 
 Recently, I attempt to model the US/RMB Exchange rate log-return time series
 with a *Hidden Markov model (first order Markov Chain  mixed Normal
 distributions). *
 
 I have applied the RHmm package to accomplish this task, but the results are
 not so satisfying.
 So, I would like to try a *Bayesian method *for the parameter estimation of
 the Hidden Markov model.
 
 Could anyone kindly tell me which R package can perform Bayesian estimation
 of the model?
 
 Many thanks for your help and time.
 
 Best Regards,
 James Allan
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4423946.
 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.

Oscar M. Rueda, PhD.
Postdoctoral Research Fellow, Breast Cancer Functional Genomics.
Cancer Research UK Cambridge Research Institute.
Li Ka Shing Centre, Robinson Way.
Cambridge CB2 0RE 
England 




NOTICE AND DISCLAIMER
This e-mail (including any attachments) is intended for ...{{dropped:16}}

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


Re: [R] tm_map help

2012-02-27 Thread Milan Bouchet-Valat
Le lundi 27 février 2012 à 10:47 +1100, Sachinthaka Abeywardana a
écrit :
 Hi all,
 
 I am trying to do some text mining with twitter and I am getting the error:
 
 Error in structure(names(sapply(possibleCompletions, [, 1)), names = x) :
   'names' attribute [1] must be the same length as the vector [0]
 
 
 When I use tm_map. Has anyone had/seen this error before? The code I
 have is shown below and this error only occurs with #qantas, hashtags
 like #asx, #obama work ok.
Please try to identify the document and the steps that trigger the
problem more precisely. You should come up with the simplest example
that reproduces the bug with #qantas, and then remove half the documents
of the corpus, retry, and do that until you find the culprit. Then it
will be easier to find the cause of the bug.


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] What is the fastest way to combine all columns of a matrix to one column?

2012-02-27 Thread Petr PIKAL
Hi
 Hi,
 
 Thank you. I actually wanted to reserve the rows, I dont know how to
 do this with
 dim(mm) -NULL

I do not understand. What does it mean reserve rows. Matrix is a vector 
with dimension so you can change dimensions freely with 

dim(mm) - any suitable combination

dim(mm) -NULL

gives you plain vector

dim(mm) - c(rows, columns)

gives you now matrix with specified number of rows and columns. You can 
put columns to 1 and in that case you will get one column matrix.

Please provide some toy example what do you really want.

Regards
Petr


 
 thanks again
 
 
 On 2/27/12, Petr PIKAL petr.pi...@precheza.cz wrote:
  Hi
 
  Dear all,
 
  Newbie: What is the fastest way to combine all columns of a matrix to
  one
  column?
 
  If mm is your matrix use
 
  dim(mm) -NULL
 
  Regards
  Petr
 
 
 
  --
  View this message in context: 
http://r.789695.n4.nabble.com/What-is-the-
 
  fastest-way-to-combine-all-columns-of-a-matrix-to-one-column-
 tp4423882p4423882.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] Military Time Comparison

2012-02-27 Thread Jim Holtman
what does 'str' of the object show?  are the columns factors/characters?  does 
the comparison have to consider the date?  
Sent from my iPad

On Feb 27, 2012, at 0:37, Edgar Alminar eaalmi...@ucsd.edu wrote:

 Oh, haha -- sorry for the vagueness:
 
 I was expecting to get the comparison to work. I also didn't mention that the 
 dataset is much larger; I just wanted to give the first few rows. 
 
 So, basically, I have a bunch of times in three columns, and I'm looking to 
 compare them in which the command works correctly. 
 
 Let's say, using the example below, that I want to get:
 
 match2 = subset(match2, AEONTIME  INFTIME.x)
 
 Well, with that exact syntax, it's not working because I'm getting back a 
 dataset in which some AEONTIMEs are actually  INFTIME.x.
 
 So, I feel like I'm just missing a piece of the syntax (i.e. as.date, 
 as.character, but what works for time?)
 
 I hope this helps. :-)
 
 Thanks!
 
 
 On Feb 26, 2012, at 9:32 PM, David Winsemius wrote:
 
 
 On Feb 26, 2012, at 10:31 PM, Edgar Alminar wrote:
 
 Hello All,
 I have this dataset:
 
  RID VISCODE  SCRNO RECNO AEWHEN   AEONDATE AEONTIME INFPOINT.x  
 INFDATE.x INFTIME.x INFPOINT.y  INFDATE.y INFTIME.y
 1   100 w00 IGI1480069 4  2 09/15/2009 1118  1 
 09/15/2009   947 14 -4  1117
 2   100 w00 IGI1480069 8  2 09/15/2009 1132  1 
 09/15/2009   947 14 -4  1117
 3   100 w00 IGI1480069 5  2 09/15/2009 1125  1 
 09/15/2009   947 14 -4  1117
 
 
 
 I have AEONTIME, INFTIME.x, and INFTIME.y, and they are all military times.
 I'm trying to do a comparison like this:
 
 match2 = subset(match2, AEONTIME  INFTIME.x)
 
 But it's not working correctly.
 
 Define what you expected. In the sample you offered none of those logical 
 comparisons would be true so you should get a dataframe with zero rows. (And 
 since you gave the result the same name, you have basically wiped out 
 match2.)
 
 
 How do I do this? :-)
 
 Do what?
 
 -- 
 
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT
 
 
 Edgar Alminar
 Clinical Operations
 Alzheimer's Disease Cooperative Study
 University of California, San Diego
 9500 Gilman Drive, MC-0949
 La Jolla, CA 92093-0949
 Tel: (858) 622-8798
 Fax: (858) 622-5876
 Email: eaalmi...@ucsd.edu
 
 Confidentiality Notice- This e-mail message from the Alz...{{dropped:11}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] best option for big 3D arrays?

2012-02-27 Thread Djordje Bajic
Steven, sorry for the delay in responding,

I have been investigating this also and here is the way I do it (though
probably not the best way):

# .. define a 3D array
 ngen = 904
 gratios - ff(NA, dim=rep(ngen,3), vmode=double)

# .. fill the array with standard R functions

 ffsave (gratios, file=mydir/myfile)# without extension
 finalizer(gratios) - delete

# ..

so, you firstly define the ff object, you put the data inside, and you
ffsave it. The ffsave function will generate two files, with extensions
ffdata and a Rdata. Then you set 'delete' to be the 'finalizer' of the
object; in this way you avoid ff to save it in some tmp dir and occupy disk
space forever. Then, you can access your object in the next R session:

 ffload(mydir/myfile)# also without extension

I hope this helped.

Cheers,

djordje



2012/2/23 steven mosher mosherste...@gmail.com

 Did you have to use a particular filename?  or extension.

 I created a similar file but then could not read it back in

 Steve

 On Mon, Feb 13, 2012 at 6:45 AM, Djordje Bajic je.li@gmail.comwrote:

 I've been investigating and I partially respond myself. I tried the
 packages 'bigmemory' and 'ff' and for me the latter did the work I need
 pretty straightforward. I create the array in filebacked form with the
 function ff, and it seems that the usual R indexing works well. I have yet
 to see the limitations, but I hope it helps.

 a foo example:

 myArr - ff(NA, dim=rep(904,3), filename=arr.ffd, vmode=double)
 myMat - matrix(1:904^2, ncol=904)
 for ( i in 1:904 ) {
myArr[,,i] - myMat
 }

 Thanks all,

 2012/2/11 Duncan Murdoch murdoch.dun...@gmail.com

  On 12-02-10 9:12 AM, Djordje Bajic wrote:
 
  Hi all,
 
  I am trying to fill a 904x904x904 array, but at some point of the loop
 R
  states that the 5.5Gb sized vector is too big to allocate. I have
 looked
  at
  packages such as bigmemory, but I need help to decide which is the
 best
  way to store such an object. It would be perfect to store it in this
  cube
  form (for indexing and computation purpouses). If not possible, maybe
 the
  best is to store the 904 matrices separately and read them individually
  when needed?
 
  Never dealed with such a big dataset, so any help will be appreciated
 
  (R+ESS, Debian 64bit, 4Gb RAM, 4core)
 
 
  I'd really recommend getting more RAM, so you can have the whole thing
  loaded in memory.  16 Gb would be nice, but even 8Gb should make a
  substantial difference.  It's going to be too big to store as an array
  since arrays have a limit of 2^31-1 entries, but you could store it as a
  list of matrices, e.g.
 
  x - vector(list, 904)
  for (i in 1:904)
   x[[i]] - matrix(0, 904,904)
 
  and then refer to entry i,j,k as x[[i]][j,k].
 
  Duncan Murdoch
 
 
 

[[alternative HTML version deleted]]

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




[[alternative HTML version deleted]]

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


[R] read.csv converts NA to missing values

2012-02-27 Thread nikhil abhyankar
Hello,

I have a CSV file with region codes listed in a column. E.g. 'AS' for Asia,
'AU' for Australia and 'NA' North America.

However, the data frame created using read.csv shows NA where the string
variable should have had the value 'NA'.

How can I input the value 'NA' present in a column in a CSV file without R
changing it to missing?

Thanks

Nikhil

[[alternative HTML version deleted]]

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


Re: [R] read.csv converts NA to missing values

2012-02-27 Thread R. Michael Weylandt
I believe read.csv(..., na.strings = ) will do it.

Michael

On Mon, Feb 27, 2012 at 8:15 AM, nikhil abhyankar nsabhyan...@gmail.com wrote:
 Hello,

 I have a CSV file with region codes listed in a column. E.g. 'AS' for Asia,
 'AU' for Australia and 'NA' North America.

 However, the data frame created using read.csv shows NA where the string
 variable should have had the value 'NA'.

 How can I input the value 'NA' present in a column in a CSV file without R
 changing it to missing?

 Thanks

 Nikhil

        [[alternative HTML version deleted]]

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

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


Re: [R] read.csv converts NA to missing values

2012-02-27 Thread peter dalgaard

On Feb 27, 2012, at 14:15 , nikhil abhyankar wrote:

 Hello,
 
 I have a CSV file with region codes listed in a column. E.g. 'AS' for Asia,
 'AU' for Australia and 'NA' North America.
 
 However, the data frame created using read.csv shows NA where the string
 variable should have had the value 'NA'.
 
 How can I input the value 'NA' present in a column in a CSV file without R
 changing it to missing?


I'd try na.strings= (or maybe NULL or character(0))

-pd

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

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


[R] identify and delete in table

2012-02-27 Thread Jonas Fransson
Dear all,

I want to delete the exact matches in a large dataset based on a smaller 
dataset. In other words I want to subtract the smaller dataset from the larger 
one. The smaller dataset is a part of the larger one. The datasets contains 
hundred of thousands of lines (1 column) and the content on each line differ in 
length. The data is extracted paths from web logs.

On an abstract level I want to subtract dataset2 from dataset1 to get dataset3:

dataset1: 
1 A
2 B
3 X
4 AA
5 A
6 D
7 XA
8 C

dataset2:
1 A
2 X
3 A

dataset3:
1 B
2 AA
3 D
4 XA
5 C

The final order in dataset3 is not important.

Thanks,

Jonas Fransson
Ph.D.stud.

IVA / Det Informationsvidenskabelige Akademi
Royal School of Library and Information Science
Birketinget 6
DK-2300 Copenhagen S
T +45 32 58 60 66
D +45 32 34 15 10
www.iva.dk/jf


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

2012-02-27 Thread Diogo Alagador

Dear all,

I am tryng to solve a nonlinear optimization probel using the solnp function.
I have different datasets. For the smaller I get full solutions, for  
the bigger I got an error message stating:



Iter: 1 fn: 101.8017 Pars:  0.21000 0.21000 0.21000 0.21000
0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000  
0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000  
0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000  
0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000  
0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000  
0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000  
0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000 0.21000  
0.21000 0.21000 0.21000 0.21000


solnp-- Solution not reliableProblem Inverting Hessian.
Warning messages:
1: In p0 * vscale[(neq + 2):(nc + np + 1)] :
   longer object length is not a multiple of shorter object length
2: In cbind(temp, funv) :
   number of rows of result is not a multiple of vector length (arg  
1) 



Anyone knows what may be the reason? Just remembering that the same  
problem runs OK for smaller datasets.


Thanks in advance,

Diogo André
Portugal

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Extract data point coordinates from kernel home range estimation

2012-02-27 Thread despina_tg
Hello,

I'm very new in working on R and maybe that's a simple thing I'm trying to
do, but I am really stuck.

I have  a data point set of animal tracking coordinates and I have
implemented a kernel utilization distribution analysis in order to find the
home range for 95% of the relocation data. I have used the ud.kde() and
hr.kde() functions of the wild1 package, so I have a number of polygons
(peaks of kernel density) as an object of the following class:

 class(homerange)
[1] Polygons
attr(,package)
[1] sp

My question is how can I extract the point coordinates within each
polygon-circle? Because, the home range coordinates are arbitrary points
contouring the real data points.

Hope it's clear,

Despina

--
View this message in context: 
http://r.789695.n4.nabble.com/Extract-data-point-coordinates-from-kernel-home-range-estimation-tp4424107p4424107.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] General question about GLMM and heterogeneity of variance

2012-02-27 Thread GibsonR
My data have heterogeneity of variance (in a categorical variable), do I need
to specify a variance structure accounting for this in my model or do GLMMs
by their nature account for such heterogeneity (as a result of using
deviances rather than variances)? And if I do need to do this, how do I do
it (e.g. using something like the VarIdent function in nlme) and in what
package?

This is my first post so apologies for any breach of etiquette!


--
View this message in context: 
http://r.789695.n4.nabble.com/General-question-about-GLMM-and-heterogeneity-of-variance-tp4424429p4424429.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] loop for a large database

2012-02-27 Thread mari681
2012/2/27 Petr Savicky [via R] ml-node+s789695n4423895...@n4.nabble.com

 On Sun, Feb 26, 2012 at 11:39:01AM -0800, mari681 wrote:

  SORRY!
 
  The data in MyTable are tagsets of photos,  like this:
 
V1 V2   V3  V4  V5   V6V7   V8
  230green nailpolish   barrym   0   00 00
  231   ny  green brooklyn cleanup   clean  gowanus volunteer  gcc
  232green   saul  lecture   0   00 00
  233green colorscores  market colores marakesh   mercado malu
  234   ny  green brooklyn cleanup   clean  gowanus volunteer  gcc
  235green   saul  lecture   0   00 00
  236 portraitpetwhite   green catcanonsquare  eos
 
   V9   V10  V11  V12 V13 V14 V15
  230   0 000   0   0   0
  231 gowanuscanalconservancy 000   0   0   0
  232   0 000   0   0   0
  233   malugreen maroc souk marrocos   0   0   0
  234 gowanuscanalconservancy 000   0   0   0
  235   0 000   0   0   0
  236  is  eyes mark   taiwan  ii mk2  5d
 
 
  while data of MyVector is a list of tags (none of the columns in
 particular)
  whose frequency in MyTable has to be computed. Like this:
 
  [1] life  wood  pink  house green fall

 Hi.

 Just to be sure, in all the previous solutions, malugreen is not an
 occurence of green. Is this correct?


correct!!


  MyTable has 21 millions rows and 15 columns, and the data is
 character,
  they are words.

 Do you use the argument stringsAsFactors=FALSE, when reading the data
 from a file? Otherwise, character data are converted to a factor.
 The discussed solutions work in both cases, however, if we try to
 prepare simplified data for testing efficiency, we should use the
 same column class as in the real situation.

 Ok. Thanks!


  When I tried the loop my computer crashed in the meaning that it freezed
  (froze?) and didn't allow me to do anything. The morning after I forced
 it
  off and rebooted.

 This does not seem to be a consequence of a too long computation.
 A possible cause can be too large memory requirements. How large memory
 the R process uses after loading the data? Try gc() command after loading
 the data and compare with the amount of memory available. On a Linux
 machine, it is also possible to see the memory usage with top command
 in the row, where R is reported.

 Petr.


I should have tried before with a sample of data, rather than with the
whole table. I'll try again with all your suggestions. Thanks!!!

marianna



 __
 [hidden email] http://user/SendEmail.jtp?type=nodenode=4423895i=0mailing 
 list
 https://stat.ethz.ch/mailman/listinfo/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/loop-for-a-large-database-tp4422052p4423895.html
  To unsubscribe from loop for a large database, click 
 herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4422052code=bWFyaWFubmEuYm9sb2duZXNpQGdtYWlsLmNvbXw0NDIyMDUyfDY2MTc1ODA1OA==
 .
 NAMLhttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml



--
View this message in context: 
http://r.789695.n4.nabble.com/loop-for-a-large-database-tp4422052p4424086.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] Loop

2012-02-27 Thread kerry1912
I've tried to create a loop for the following code but have failed miserably. 

This is what the code is:

pnorm((Normal.Team.LnAveragePPPConceded.LnAveragePPPScores.HA.pred[1,1]
-Normal.Team.LnAveragePPPConceded.LnAveragePPPScores.HA.pred[50,1])/
sqrt(prediction.SE[1]^2 + prediction.SE[50]^2))

I'd like a loop so that it is something like this:

for (i in 1:50) {
pnorm((Normal.Team.LnAveragePPPConceded.LnAveragePPPScores.HA.pred[i,1]
-Normal.Team.LnAveragePPPConceded.LnAveragePPPScores.HA.pred[i+49,1])/
sqrt(prediction.SE[i]^2 + prediction.SE[i+49]^2))
}

Many thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/Loop-tp4424128p4424128.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] goodness of fit for glms

2012-02-27 Thread kerry1912
We are working on trying to find how well glm models fit our set of sports
results. We want to consider the following two models and work out which one
fits the data better:

summary(Tries.Team.Ha.glm)

(Dispersion parameter for poisson family taken to be 1)

Null deviance: 321.46  on 269  degrees of freedom
Residual deviance: 274.15  on 257  degrees of freedom
AIC: 879.06

Number of Fisher Scoring iterations: 5


and
 summary(Tries.Team.Ha.Distance.glm)

(Dispersion parameter for poisson family taken to be 1)

Null deviance: 321.46  on 269  degrees of freedom
Residual deviance: 272.06  on 256  degrees of freedom
AIC: 878.97

Number of Fisher Scoring iterations: 5


Many thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/goodness-of-fit-for-glms-tp4424193p4424193.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] how to read file append at specified positon

2012-02-27 Thread sagarnikam123
i have one file as
 munnabhai-read.table(hyphen[1],skip=1)
 munnabhai
 V1 V2  V3 V4 V5   V6 V7
1 1 12AS_A   4  A0.0  157.8994119  2
2 2 12AS_A   5  Y  -41.61818  -56.8011795  1
3 3 12AS_A   6  I  -55.47021  -51.1328352  1
4 4 12AS_A   7  A  -54.43085  -58.3428366  1
5 5 12AS_A   8  K  -54.31525  -39.2709474  1
6 6 12AS_A   9  Q  -61.37700  -33.5304490  1
7 7 12AS_A  10  R  -86.14173  -32.3448242  1
8 8 12AS_A  11  Q  -52.88589  -57.2830246  1

want to read v7 vector  add V8,
 edit it as in the same file

 V1 V2  V3 V4 V5   V6 V7V8
1 1 12AS_A   4  A0.0  157.8994119  22.3  
2 2 12AS_A   5  Y  -41.61818  -56.8011795  145.5
3 3 12AS_A   6  I  -55.47021  -51.1328352  178.5
4 4 12AS_A   7  A  -54.43085  -58.3428366  17.3
5 5 12AS_A   8  K  -54.31525  -39.2709474  18.9
6 6 12AS_A   9  Q  -61.37700  -33.5304490  14.5 
7 7 12AS_A  10  R  -86.14173  -32.3448242  17.3 
8 8 12AS_A  11  Q  -52.88589  -57.2830246  11.0


--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-read-file-append-at-specified-positon-tp4424227p4424227.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] strange behaviour of POSIXlt POSIXt object

2012-02-27 Thread ikuzar
Hi, 

I do not know what part of my code should I post here (I use large size of
data, the loop for contains many lines). The situation is difficult to
post here, but I hope these lines would be useful for help:

hcEndDateTmp = userDateStart
  if((hcStartTime=23:59)  (hcEndTime = 00:00)){
hcEndDateTmp$mday = userDateStart$mday + 1
  }
  hcEndDate = strftime(hcEndDateTmp, %Y-%m-%d)
  hcStart = 
hcEnd = as.POSIXlt(paste(hcEndDate, hcEndTime))

for(rowNum in 1:nbJour){
...
hcStart = as.POSIXlt(ecs$startAt[[rowNum]])
ecsInterval2 =
datePower[(datePower$DateTime=hcStart)(datePower$DateTime=hcEnd), ]
...
   hcEnd$mday = hcEnd$mday + 1
  cat(DEBUG: rowNum=, rowNum, is.na(hcEnd)=, is.na(hcEnd), \n)
}

the two last lines are very important. It yields:

DEBUG: rowNum= 1 is.na(hcEnd)= FALSE 
DEBUG: rowNum= 2 is.na(hcEnd)= FALSE 
DEBUG: rowNum= 3 is.na(hcEnd)= FALSE 
DEBUG: rowNum= 4 is.na(hcEnd)= FALSE 
DEBUG: rowNum= 5 is.na(hcEnd)= FALSE 
DEBUG: rowNum= 6 is.na(hcEnd)= FALSE 
DEBUG: rowNum= 7 is.na(hcEnd)= TRUE 

Browse[1] hcEnd
[1] 2009-03-29 06:30:00
Browse[1] class(hcEnd)
[1] POSIXlt POSIXt 

So, At the end of 7th iteration, hcEnd becomes NA (I guess because of
hcEnd$mday = hcEnd$mday + 1 ?!?). But It remains strange because the class
of hcEnd is here POSIXlt POSIXt (it should be logical.!! Am I
wrong???)

Here is the version of R:
platform   i386-pc-mingw32  
arch   i386 
os mingw32  
system i386, mingw32
status  
major  2
minor  13.2 
year   2011 
month  09   
day30   
svn rev57111
language   R
version.string R version 2.13.2 (2011-09-30)

thanks for your help

--
View this message in context: 
http://r.789695.n4.nabble.com/strange-behaviour-of-POSIXlt-POSIXt-object-tp4418115p4424214.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] compare two data frames with same columns names but of different dimensions

2012-02-27 Thread Arnaud Gaboury
Dear List,

I want to compare and return the rows which are NOT in the two data frames. 
Classic methods don't work as the df have NOT the same dimensions.


Here are one example of my df:

reported -
structure(list(Product = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 
3L, 4L, 5L, 5L), .Label = c(Cocoa, Coffee C, GC, Sugar No 11, 
ZS), class = factor), Price = c(2331, 2356, 2440, 2450, 204.55, 
205.45, 17792, 24.81, 1273.5, 1276.25), Nbr.Lots = c(-61L, -61L, 
5L, 1L, 40L, 40L, -1L, -1L, -1L, 1L)), .Names = c(Product, 
Price, Nbr.Lots), row.names = c(1L, 2L, 3L, 4L, 6L, 7L, 5L, 
10L, 8L, 9L), class = data.frame)

exportfile -
structure(list(Product = c(Cocoa, Cocoa, Cocoa, Coffee C, 
Coffee C, GC, Sugar No 11, ZS, ZS), Price = c(2331, 
2356, 2440, 204.55, 205.45, 17792, 24.81, 1273.5, 1276.25), Nbr.Lots = c(-61, 
-61, 6, 40, 40, -1, -1, -1, 1)), .Names = c(Product, Price, 
Nbr.Lots), row.names = c(NA, 9L), class = data.frame)

As you can see, they have same column names. 
My idea was to merge these two df when passing as argument not to take into 
account duplicate rows, so I will get one df with rows which are not in both 
df.
Is it possible? How to do it?

TY for any help.


Arnaud Gaboury
 
A2CT2 Ltd.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Ubuntu jaunty - R can't be install

2012-02-27 Thread Veyssière Marine

Dear helpers,
I would like to install R on a computer with Ubuntu Jaunty. 
Unfortunately, Jaunty  does not  appear in any CRAN mirror website I  
have tried (France, Canada, Italy, Germany).
Could you give me any mirror website  allowing installation on 
Jaunty?or  could you give me a procedure to passby this problem?


Thanks for your help,
Best regards,
Marine Veyssière

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


Re: [R] identify and delete in table

2012-02-27 Thread jim holtman
Is this what you want:

 ds1 - read.table(text = 1 A
+ 2 B
+ 3 X
+ 4 AA
+ 5 A
+ 6 D
+ 7 XA
+ 8 C, as.is = TRUE)

 ds2 - read.table(text = 1 A
+ 2 X
+ 3 A, as.is = TRUE)

 # find matches
 ds3 - ds1[!(ds1$V2 %in% ds2$V2), ]
 ds3
  V1 V2
2  2  B
4  4 AA
6  6  D
7  7 XA
8  8  C


On Mon, Feb 27, 2012 at 6:17 AM, Jonas Fransson j...@iva.dk wrote:
 Dear all,

 I want to delete the exact matches in a large dataset based on a smaller 
 dataset. In other words I want to subtract the smaller dataset from the 
 larger one. The smaller dataset is a part of the larger one. The datasets 
 contains hundred of thousands of lines (1 column) and the content on each 
 line differ in length. The data is extracted paths from web logs.

 On an abstract level I want to subtract dataset2 from dataset1 to get 
 dataset3:

 dataset1:
 1 A
 2 B
 3 X
 4 AA
 5 A
 6 D
 7 XA
 8 C

 dataset2:
 1 A
 2 X
 3 A

 dataset3:
 1 B
 2 AA
 3 D
 4 XA
 5 C

 The final order in dataset3 is not important.

 Thanks,

 Jonas Fransson
 Ph.D.stud.

 IVA / Det Informationsvidenskabelige Akademi
 Royal School of Library and Information Science
 Birketinget 6
 DK-2300 Copenhagen S
 T +45 32 58 60 66
 D +45 32 34 15 10
 www.iva.dk/jf


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



-- 
Jim Holtman
Data Munger Guru

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

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


Re: [R] Ubuntu jaunty - R can't be install

2012-02-27 Thread Arnaud Gaboury
I don't understand where is your problem. Are you looking for jaunty as a 
package on R Crans?? Are you looking to install R package on your Ubuntu box? 
As you know, Jaunty is no more supported by Ubuntu, so packets have been moved 
in Archives.

Arnaud Gaboury
 
A2CT2 Ltd.


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Veyssière Marine
Sent: lundi 27 février 2012 14:50
To: r-help@r-project.org
Subject: [R] Ubuntu jaunty - R can't be install

Dear helpers,
I would like to install R on a computer with Ubuntu Jaunty. 
Unfortunately, Jaunty  does not  appear in any CRAN mirror website I have tried 
(France, Canada, Italy, Germany).
Could you give me any mirror website  allowing installation on Jaunty?or  could 
you give me a procedure to passby this problem?

Thanks for your help,
Best regards,
Marine Veyssière

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

2012-02-27 Thread ilai
set.seed(1)
(DFid - data.frame(
x = sample(1:20,10),
y = sample(1:20,10),
IDs = sapply(1:10,function(i) paste(ID,i,sep=

require(spdep)
coordinates(DFid) - ~x+y
coords - coordinates(DFid)
dnn4 - dnearneigh(DFid,0,4)
 summary(dnn4)
 plot(DFid)
 plot(dnn4,coords,add=T,col=2)
 nb2mat(dnn4, zero.policy=TRUE)

This just one option from the multitude of spatial packages.

HTH


On Sun, Feb 26, 2012 at 4:55 PM, Ross Dwyer ross.dw...@uq.edu.au wrote:
 Dear List,

 I have been trying to extract associations from a matrix whereby individual 
 locations are within a certain distance threshold from one another.

 I have been able to extract those individuals where there is 'no interaction' 
 (i.e. where these individuals are not within a specified distance threshold 
 from another individual) and give these individuals a unique Group ID 
 containing that one individual.

 i.e.

   ID Group

 1 ID1     1

 2 ID3     2

 3 ID4     3

 4 ID5     4

 5 ID7     5

 6 ID8     6

 7 ID9     7


 What I need assistance with is allocating associations with a unique group id.
 i.e. If we have interactions between  ID2_ID6, ID6_ID2, ID6_ID10, 
 ID10_ID6 as in the example code...


   ID Group

 1 ID1     1

 2 ID3     2

 3 ID4     3

 4 ID5     4

 5 ID7     5

 6 ID8     6

 7 ID9     7

 ##
 8 ID2     8
 9 ID6     8
 10 ID10     8

 ##
 The code also needs to robust enough to recognize instances where we have an 
 interaction in a separate group...
 i.e. ID11_ID12 should be in a separate group (Group 9) as they don't 
 interact with IDs 2, 6, or 10 (not in below code!)
 11 ID11     9
 12 ID12     9


 I've been trying to figure this out but have drawn a blank. My example code 
 can be found below.

 Very best wishes,

 Ross

 Dr Ross Dwyer
 Postdoctoral Research Fellow
 University of Queensland



 ###
 require(stats)
 x - sample(1:20,10)
 y - sample(1:20,10)
 IDs - sapply(1:10,function(i) paste(ID,i,sep=))
 (DFid - data.frame(x,y))
    x  y
 1   7 20
 2   5  3
 3  12  5
 4   3 12
 5  18 19
 6   2  1
 7  19 15
 8  20 11
 9  13 14
 10  1  2


 (DMdist - dist(DFid, method = euclidean,
 +                diag = FALSE, upper = TRUE))
           1         2         3         4         5         6         7       
   8         9        10
 1            17.117243 15.811388  8.944272 11.045361 19.646883 13.00 
 15.811388  8.485281 18.973666
 2  17.117243            7.280110  9.219544 20.615528  3.605551 18.439089 
 17.00 13.601471  4.123106
 3  15.811388  7.280110           11.401754 15.231546 10.770330 12.206556 
 10.00  9.055385 11.401754
 4   8.944272  9.219544 11.401754           16.552945 11.045361 16.278821 
 17.029386 10.198039 10.198039
 5  11.045361 20.615528 15.231546 16.552945           24.083189  4.123106  
 8.246211  7.071068 24.041631
 6  19.646883  3.605551 10.770330 11.045361 24.083189           22.022716 
 20.591260 17.029386  1.414214
 7  13.00 18.439089 12.206556 16.278821  4.123106 22.022716            
 4.123106  6.082763 22.203603
 8  15.811388 17.00 10.00 17.029386  8.246211 20.591260  4.123106      
       7.615773 21.023796
 9   8.485281 13.601471  9.055385 10.198039  7.071068 17.029386  6.082763  
 7.615773           16.970563
 10 18.973666  4.123106 11.401754 10.198039 24.041631  1.414214 22.203603 
 21.023796 16.970563

 #Generate True/False matrix on those individuals  4 units apart
 DMTF - apply(as.matrix(DMdist), c(1,2), function(x) ifelse(x=4,T,F))
 diag(DMTF)- NA #replace diagonal with NA
 dimnames(DMTF) - list(IDs, IDs) #add individual's name to matrix

 DMTF
       ID1   ID2   ID3   ID4   ID5   ID6   ID7   ID8   ID9  ID10
 ID1     NA FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
 ID2  FALSE    NA FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
 ID3  FALSE FALSE    NA FALSE FALSE FALSE FALSE FALSE FALSE FALSE
 ID4  FALSE FALSE FALSE    NA FALSE FALSE FALSE FALSE FALSE FALSE
 ID5  FALSE FALSE FALSE FALSE    NA FALSE FALSE FALSE FALSE FALSE
 ID6  FALSE  TRUE FALSE FALSE FALSE    NA FALSE FALSE FALSE  TRUE
 ID7  FALSE FALSE FALSE FALSE FALSE FALSE    NA FALSE FALSE FALSE
 ID8  FALSE FALSE FALSE FALSE FALSE FALSE FALSE    NA FALSE FALSE
 ID9  FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE    NA FALSE
 ID10 FALSE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE    NA

 irow - as.character(gl(length(IDs),length(IDs),labels=IDs))
 icol -rep(IDs, length(IDs))

 AssocMatrix - matrix(data=paste(irow,_,icol,_,sep=),
 +                       nrow = length(IDs), ncol = length(IDs),
 +                       dimnames= list(IDs, IDs))

 AssocMatrix

     ID1         ID2         ID3         ID4         ID5         ID6         
 ID7         ID8         ID9         ID10

 ID1  ID1_ID1_  ID2_ID1_  ID3_ID1_  ID4_ID1_  ID5_ID1_  ID6_ID1_  
 ID7_ID1_  ID8_ID1_  ID9_ID1_  ID10_ID1_

 ID2  ID1_ID2_  ID2_ID2_  ID3_ID2_  ID4_ID2_  ID5_ID2_  ID6_ID2_  
 ID7_ID2_  ID8_ID2_  ID9_ID2_  ID10_ID2_

 ID3  ID1_ID3_  ID2_ID3_  ID3_ID3_  ID4_ID3_  ID5_ID3_  ID6_ID3_  
 ID7_ID3_  ID8_ID3_  ID9_ID3_  

Re: [R] strange behaviour of POSIXlt POSIXt object

2012-02-27 Thread William Dunlap
is.na(POSIXltObject) can behave oddly if you manipulate
the fields of the POSIXlt object directly so as to
cause illegal combinations of values.  E.g., the 35th
of February, 2009, is not considered an NA but the 36th
and above are:

   z - as.POSIXlt(2009-02-25 06:30:00)
   for(i in 1:20){ z$mday - z$mday + 1L ; cat(is.na(z), : );print(z)}
  FALSE : [1] 2009-02-26 06:30:00
  FALSE : [1] 2009-02-27 06:30:00
  FALSE : [1] 2009-02-28 06:30:00
  FALSE : [1] 2009-03-01 06:30:00
  FALSE : [1] 2009-03-02 06:30:00
  FALSE : [1] 2009-03-03 06:30:00
  FALSE : [1] 2009-03-04 06:30:00
  FALSE : [1] 2009-03-05 06:30:00
  FALSE : [1] 2009-03-06 06:30:00
  FALSE : [1] 2009-03-07 06:30:00
  TRUE : [1] 2009-03-08 06:30:00
  TRUE : [1] 2009-03-09 06:30:00
  TRUE : [1] 2009-03-10 06:30:00
  TRUE : [1] 2009-03-11 06:30:00
  TRUE : [1] 2009-03-12 06:30:00
  TRUE : [1] 2009-03-13 06:30:00
  TRUE : [1] 2009-03-14 06:30:00
  TRUE : [1] 2009-03-15 06:30:00
  TRUE : [1] 2009-03-16 06:30:00
  TRUE : [1] 2009-03-17 06:30:00

The print routine does not seem to consult is.na().

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of ikuzar
 Sent: Monday, February 27, 2012 2:41 AM
 To: r-help@r-project.org
 Subject: Re: [R] strange behaviour of POSIXlt POSIXt object
 
 Hi,
 
 I do not know what part of my code should I post here (I use large size of
 data, the loop for contains many lines). The situation is difficult to
 post here, but I hope these lines would be useful for help:
 
 hcEndDateTmp = userDateStart
   if((hcStartTime=23:59)  (hcEndTime = 00:00)){
 hcEndDateTmp$mday = userDateStart$mday + 1
   }
   hcEndDate = strftime(hcEndDateTmp, %Y-%m-%d)
   hcStart = 
 hcEnd = as.POSIXlt(paste(hcEndDate, hcEndTime))
 
 for(rowNum in 1:nbJour){
 ...
 hcStart = as.POSIXlt(ecs$startAt[[rowNum]])
 ecsInterval2 =
 datePower[(datePower$DateTime=hcStart)(datePower$DateTime=hcEnd), ]
 ...
hcEnd$mday = hcEnd$mday + 1
   cat(DEBUG: rowNum=, rowNum, is.na(hcEnd)=, is.na(hcEnd), \n)
 }
 
 the two last lines are very important. It yields:
 
 DEBUG: rowNum= 1 is.na(hcEnd)= FALSE
 DEBUG: rowNum= 2 is.na(hcEnd)= FALSE
 DEBUG: rowNum= 3 is.na(hcEnd)= FALSE
 DEBUG: rowNum= 4 is.na(hcEnd)= FALSE
 DEBUG: rowNum= 5 is.na(hcEnd)= FALSE
 DEBUG: rowNum= 6 is.na(hcEnd)= FALSE
 DEBUG: rowNum= 7 is.na(hcEnd)= TRUE
 
 Browse[1] hcEnd
 [1] 2009-03-29 06:30:00
 Browse[1] class(hcEnd)
 [1] POSIXlt POSIXt
 
 So, At the end of 7th iteration, hcEnd becomes NA (I guess because of
 hcEnd$mday = hcEnd$mday + 1 ?!?). But It remains strange because the class
 of hcEnd is here POSIXlt POSIXt (it should be logical.!! Am I
 wrong???)
 
 Here is the version of R:
 platform   i386-pc-mingw32
 arch   i386
 os mingw32
 system i386, mingw32
 status
 major  2
 minor  13.2
 year   2011
 month  09
 day30
 svn rev57111
 language   R
 version.string R version 2.13.2 (2011-09-30)
 
 thanks for your help
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/strange-behaviour-of-POSIXlt-POSIXt-
 object-tp4418115p4424214.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] strange behaviour of POSIXlt POSIXt object

2012-02-27 Thread ikuzar
So, how is the correct way to increment the day ?

--
View this message in context: 
http://r.789695.n4.nabble.com/strange-behaviour-of-POSIXlt-POSIXt-object-tp4418115p4425206.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] RStudio: how to change language from fr(french) to eng(english)

2012-02-27 Thread ikuzar
Hello, 

RStudio displays errors in french . I'd like to change it in english

Please help, 

Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/RStudio-how-to-change-language-from-fr-french-to-eng-english-tp4424972p4424972.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] set heatmap.2 color ranges

2012-02-27 Thread Wendy
Hi all, 

I have a matrix with values between 0 and 1. I want to plot this matrix on a
heat map so anything 0.05 is blue, anything =0.05 and 0.01 is yellow, and
anything else is grey. I am using the heatmap.2 function. I searched around
but did not find an efficient way to set colour ranges as I described. Could
anybody give some hints? Thank you in advance. 

Wendy

--
View this message in context: 
http://r.789695.n4.nabble.com/set-heatmap-2-color-ranges-tp4425166p4425166.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] RStudio: how to change language from fr(french) to eng(english)

2012-02-27 Thread Prof Brian Ripley

On 27/02/2012 15:29, ikuzar wrote:

Hello,

RStudio displays errors in french . I'd like to change it in english


See the 'R Installation and Administration' manual.  If that does not 
help, ask RStudio's help (it is not a product supported here).


Setting the LANGUAGE environment variable to 'en' should work unless 
RStudio is itself setting it.



Please help,

Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/RStudio-how-to-change-language-from-fr-french-to-eng-english-tp4424972p4424972.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.


PLEASE do: the 'at a minimum' information requested would have been 
helpful here.



--
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] RStudio: how to change language from fr(french) to eng(english)

2012-02-27 Thread Jeff Newmiller
Then why don't you ask about it on the RStudio support forum?
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

ikuzar raz...@hotmail.fr wrote:

Hello, 

RStudio displays errors in french . I'd like to change it in english

Please help, 

Thanks

--
View this message in context:
http://r.789695.n4.nabble.com/RStudio-how-to-change-language-from-fr-french-to-eng-english-tp4424972p4424972.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] best option for big 3D arrays?

2012-02-27 Thread steven mosher
Thanks,

 That helped. Maybe when I get a chance I will do some blog posts on  the
basics of ff
 I think some tutorials would be a good idea

Steve

On Mon, Feb 27, 2012 at 3:47 AM, Djordje Bajic je.li@gmail.com wrote:

 Steven, sorry for the delay in responding,

 I have been investigating this also and here is the way I do it (though
 probably not the best way):

 # .. define a 3D array
  ngen = 904
  gratios - ff(NA, dim=rep(ngen,3), vmode=double)

 # .. fill the array with standard R functions

  ffsave (gratios, file=mydir/myfile)# without extension
  finalizer(gratios) - delete

 # ..

 so, you firstly define the ff object, you put the data inside, and you
 ffsave it. The ffsave function will generate two files, with extensions
 ffdata and a Rdata. Then you set 'delete' to be the 'finalizer' of the
 object; in this way you avoid ff to save it in some tmp dir and occupy disk
 space forever. Then, you can access your object in the next R session:

  ffload(mydir/myfile)# also without extension

 I hope this helped.

 Cheers,

 djordje



 2012/2/23 steven mosher mosherste...@gmail.com

  Did you have to use a particular filename?  or extension.
 
  I created a similar file but then could not read it back in
 
  Steve
 
  On Mon, Feb 13, 2012 at 6:45 AM, Djordje Bajic je.li@gmail.com
 wrote:
 
  I've been investigating and I partially respond myself. I tried the
  packages 'bigmemory' and 'ff' and for me the latter did the work I need
  pretty straightforward. I create the array in filebacked form with the
  function ff, and it seems that the usual R indexing works well. I have
 yet
  to see the limitations, but I hope it helps.
 
  a foo example:
 
  myArr - ff(NA, dim=rep(904,3), filename=arr.ffd, vmode=double)
  myMat - matrix(1:904^2, ncol=904)
  for ( i in 1:904 ) {
 myArr[,,i] - myMat
  }
 
  Thanks all,
 
  2012/2/11 Duncan Murdoch murdoch.dun...@gmail.com
 
   On 12-02-10 9:12 AM, Djordje Bajic wrote:
  
   Hi all,
  
   I am trying to fill a 904x904x904 array, but at some point of the
 loop
  R
   states that the 5.5Gb sized vector is too big to allocate. I have
  looked
   at
   packages such as bigmemory, but I need help to decide which is the
  best
   way to store such an object. It would be perfect to store it in this
   cube
   form (for indexing and computation purpouses). If not possible, maybe
  the
   best is to store the 904 matrices separately and read them
 individually
   when needed?
  
   Never dealed with such a big dataset, so any help will be appreciated
  
   (R+ESS, Debian 64bit, 4Gb RAM, 4core)
  
  
   I'd really recommend getting more RAM, so you can have the whole thing
   loaded in memory.  16 Gb would be nice, but even 8Gb should make a
   substantial difference.  It's going to be too big to store as an array
   since arrays have a limit of 2^31-1 entries, but you could store it
 as a
   list of matrices, e.g.
  
   x - vector(list, 904)
   for (i in 1:904)
x[[i]] - matrix(0, 904,904)
  
   and then refer to entry i,j,k as x[[i]][j,k].
  
   Duncan Murdoch
  
  
  
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] Need advice on GLM

2012-02-27 Thread ilai
On Mon, Feb 27, 2012 at 1:44 AM, Christofer Bogaso
bogaso.christo...@gmail.com wrote:

  Here I was expecting those 2 approaches should give exactly same result
 (i.e. same estimates and same SE), which is not the case. Can somebody
 point me what I am missing here?


The vector of weights as described in ?glm which from your example is
clear you either didn't look at or completely misinterpreted.

summary(glm(YY~XX, binomial(link = identity)))
summary(glm(Dat~Scores, binomial(link = identity)))
summary(glm(Proportion~Scores, weights=rowSums(Dat),binomial(link =
identity)))




 Thanks and regards,

        [[alternative HTML version deleted]]

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

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


[R] compare two data frames of different dimensions and only keep unique rows

2012-02-27 Thread Arnaud Gaboury
Dear list,

I am still struggling with something that should be easy: I compare two data 
frames with a lot of common rows and want to keep only rows that are NOT in 
both data frames, unique.

Here are an example of these data frame.

reported -
structure(list(Product = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 3L, 4L, 5L, 5L), 
.Label = c(Cocoa, Coffee C, GC, Sugar No 11, ZS), class = factor), 
Price = c(2331, 2356, 2440, 2450, 204.55, 205.45, 17792, 24.81, 1273.5, 
1276.25), Nbr.Lots = c(-61L, -61L, 5L, 1L, 40L, 40L, -1L, -1L, -1L, 1L)), 
.Names = c(Product, Price, Nbr.Lots), row.names = c(1L, 2L, 3L, 4L, 6L, 
7L, 5L, 10L, 8L, 9L), class = data.frame)

exportfile -
structure(list(Product = c(Cocoa, Cocoa, Cocoa, Coffee C, Coffee C, 
GC, Sugar No 11, ZS, ZS), Price = c(2331, 2356, 2440, 204.55, 205.45, 
17792, 24.81, 1273.5, 1276.25), Nbr.Lots = c(-61, -61, 6, 40, 40, -1, -1, -1, 
1)), .Names = c(Product, Price, Nbr.Lots), row.names = c(NA, 9L), class = 
data.frame)

I can rbind() them, thus resulting in one data frame with duplicated row, but I 
have no idea how to delete duplicated rows. I have tried plyaing with unique(), 
duplicated with no success

v-rbind(exportfile,reported)
v -
structure(list(Product = c(Cocoa, Cocoa, Cocoa, Coffee C, 
Coffee C, GC, Sugar No 11, ZS, ZS, Cocoa, Cocoa, 
Cocoa, Cocoa, Coffee C, Coffee C, GC, Sugar No 11, 
ZS, ZS), Price = c(2331, 2356, 2440, 204.55, 205.45, 17792, 
24.81, 1273.5, 1276.25, 2331, 2356, 2440, 2450, 204.55, 205.45, 
17792, 24.81, 1273.5, 1276.25), Nbr.Lots = c(-61, -61, 6, 40, 
40, -1, -1, -1, 1, -61, -61, 5, 1, 40, 40, -1, -1, -1, 1)), .Names = 
c(Product, 
Price, Nbr.Lots), row.names = c(1, 2, 3, 4, 5, 
6, 7, 8, 9, 11, 21, 31, 41, 61, 71, 51, 
10, 81, 91), class = data.frame)


TY for your help

Arnaud Gaboury
 
A2CT2 Ltd.

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

2012-02-27 Thread Jannis

Dear list members,


does anyone have an idea why the following construction does not work 
but gives the following error message:


assign('test', array(1:10, dim=c(10,10)))
dimnames(get('test')) - list(1:10,1:10)


Error in dimnames(get(test)) - list(1:10, 1:10) :
  target of assignment expands to non-language object


What could be a way to get this to work?


thanks a lot
Jannis

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


Re: [R] compare two data frames of different dimensions and only keep unique rows

2012-02-27 Thread jim holtman
is this what you want:

 v - rbind(reported, exportfile)
 v[!duplicated(v), ]
   ProductPrice Nbr.Lots
1Cocoa  2331.00  -61
2Cocoa  2356.00  -61
3Cocoa  2440.005
4Cocoa  2450.001
6 Coffee C   204.55   40
7 Coffee C   205.45   40
5   GC 17792.00   -1
10 Sugar No 1124.81   -1
8   ZS  1273.50   -1
9   ZS  1276.251
13   Cocoa  2440.006



On Mon, Feb 27, 2012 at 12:36 PM, Arnaud Gaboury
arnaud.gabo...@a2ct2.com wrote:
 Dear list,

 I am still struggling with something that should be easy: I compare two data 
 frames with a lot of common rows and want to keep only rows that are NOT in 
 both data frames, unique.

 Here are an example of these data frame.

 reported -
 structure(list(Product = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 3L, 4L, 5L, 5L), 
 .Label = c(Cocoa, Coffee C, GC, Sugar No 11, ZS), class = 
 factor), Price = c(2331, 2356, 2440, 2450, 204.55, 205.45, 17792, 24.81, 
 1273.5, 1276.25), Nbr.Lots = c(-61L, -61L, 5L, 1L, 40L, 40L, -1L, -1L, -1L, 
 1L)), .Names = c(Product, Price, Nbr.Lots), row.names = c(1L, 2L, 3L, 
 4L, 6L, 7L, 5L, 10L, 8L, 9L), class = data.frame)

 exportfile -
 structure(list(Product = c(Cocoa, Cocoa, Cocoa, Coffee C, Coffee C, 
 GC, Sugar No 11, ZS, ZS), Price = c(2331, 2356, 2440, 204.55, 205.45, 
 17792, 24.81, 1273.5, 1276.25), Nbr.Lots = c(-61, -61, 6, 40, 40, -1, -1, -1, 
 1)), .Names = c(Product, Price, Nbr.Lots), row.names = c(NA, 9L), class 
 = data.frame)

 I can rbind() them, thus resulting in one data frame with duplicated row, but 
 I have no idea how to delete duplicated rows. I have tried plyaing with 
 unique(), duplicated with no success

 v-rbind(exportfile,reported)
 v -
 structure(list(Product = c(Cocoa, Cocoa, Cocoa, Coffee C,
 Coffee C, GC, Sugar No 11, ZS, ZS, Cocoa, Cocoa,
 Cocoa, Cocoa, Coffee C, Coffee C, GC, Sugar No 11,
 ZS, ZS), Price = c(2331, 2356, 2440, 204.55, 205.45, 17792,
 24.81, 1273.5, 1276.25, 2331, 2356, 2440, 2450, 204.55, 205.45,
 17792, 24.81, 1273.5, 1276.25), Nbr.Lots = c(-61, -61, 6, 40,
 40, -1, -1, -1, 1, -61, -61, 5, 1, 40, 40, -1, -1, -1, 1)), .Names = 
 c(Product,
 Price, Nbr.Lots), row.names = c(1, 2, 3, 4, 5,
 6, 7, 8, 9, 11, 21, 31, 41, 61, 71, 51,
 10, 81, 91), class = data.frame)


 TY for your help

 Arnaud Gaboury

 A2CT2 Ltd.

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



-- 
Jim Holtman
Data Munger Guru

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

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


Re: [R] problem with assign and get

2012-02-27 Thread Peter Langfelder
On Mon, Feb 27, 2012 at 9:41 AM, Jannis bt_jan...@yahoo.de wrote:
 Dear list members,


 does anyone have an idea why the following construction does not work but
 gives the following error message:

 assign('test', array(1:10, dim=c(10,10)))
 dimnames(get('test')) - list(1:10,1:10)


 Error in dimnames(get(test)) - list(1:10, 1:10) :
  target of assignment expands to non-language object


 What could be a way to get this to work?

dimnames(test) - list(1:10,1:10)

Peter

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


Re: [R] problem with assign and get

2012-02-27 Thread Sarah Goslee
Hi,

On Mon, Feb 27, 2012 at 12:41 PM, Jannis bt_jan...@yahoo.de wrote:
 Dear list members,


 does anyone have an idea why the following construction does not work but
 gives the following error message:

 assign('test', array(1:10, dim=c(10,10)))
 dimnames(get('test')) - list(1:10,1:10)


 Error in dimnames(get(test)) - list(1:10, 1:10) :
  target of assignment expands to non-language object

There's no object to assign dimnames to. Think about it
this way - what do you expect the dimnames of to be
changed? test has no dimnames; get(test) would
print the object named test, but how could you change
the dimnames of a displayed object?

If you want to change the dimnames of the object named
test, you first need to use get(test) to assign that object
to a new object, then change the dimnames, then assign
the changed object to the desired name.

myobject - get(test)
dimnames(myobject) - list(1:10, 1:10)
assign(test, myobject)

Note: I'm assuming your small reproducible example (thank
you!) is a surrogate for something more complex, so that
dimnames(test) - list(1:10, 1:10) is not an acceptable
solution. But frequently there are better options than the
use of get/assign for solving particular problems.

Sarah

-- 
Sarah Goslee
http://www.functionaldiversity.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] compare two data frames of different dimensions and only keep unique rows

2012-02-27 Thread Arnaud Gaboury
No, but I tried your way too.

In fact, the only three unique rows are these ones:

 Product Price Nbr.Lots
   Cocoa  24405
   Cocoa  24501
   Cocoa  24406

Here is a dirty working trick I found :

 df-merge(exportfile,reported,all.y=T)
 df1-merge(exportfile,reported)
 dff1-do.call(paste,df)
 dff-do.call(paste,df)
 dff1-do.call(paste,df1)
 df[!dff %in% dff1,]
  Product Price Nbr.Lots
3   Cocoa  24405
4   Cocoa  24501
 

My two problems are : I do think it is not so a clean code, then I won't know 
by advance which of my two df will have the greates dimension (I can add some 
lines to deal with it, but again, seems very heavy).

I hoped I could find a better solution.


A2CT2 Ltd.


-Original Message-
From: jim holtman [mailto:jholt...@gmail.com] 
Sent: lundi 27 février 2012 18:42
To: Arnaud Gaboury
Cc: r-help@r-project.org
Subject: Re: [R] compare two data frames of different dimensions and only keep 
unique rows

is this what you want:

 v - rbind(reported, exportfile)
 v[!duplicated(v), ]
   ProductPrice Nbr.Lots
1Cocoa  2331.00  -61
2Cocoa  2356.00  -61
3Cocoa  2440.005
4Cocoa  2450.001
6 Coffee C   204.55   40
7 Coffee C   205.45   40
5   GC 17792.00   -1
10 Sugar No 1124.81   -1
8   ZS  1273.50   -1
9   ZS  1276.251
13   Cocoa  2440.006



On Mon, Feb 27, 2012 at 12:36 PM, Arnaud Gaboury arnaud.gabo...@a2ct2.com 
wrote:
 Dear list,

 I am still struggling with something that should be easy: I compare two data 
 frames with a lot of common rows and want to keep only rows that are NOT in 
 both data frames, unique.

 Here are an example of these data frame.

 reported -
 structure(list(Product = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 3L, 4L, 
 5L, 5L), .Label = c(Cocoa, Coffee C, GC, Sugar No 11, ZS), 
 class = factor), Price = c(2331, 2356, 2440, 2450, 204.55, 205.45, 
 17792, 24.81, 1273.5, 1276.25), Nbr.Lots = c(-61L, -61L, 5L, 1L, 40L, 
 40L, -1L, -1L, -1L, 1L)), .Names = c(Product, Price, Nbr.Lots), 
 row.names = c(1L, 2L, 3L, 4L, 6L, 7L, 5L, 10L, 8L, 9L), class = 
 data.frame)

 exportfile -
 structure(list(Product = c(Cocoa, Cocoa, Cocoa, Coffee C, 
 Coffee C, GC, Sugar No 11, ZS, ZS), Price = c(2331, 2356, 
 2440, 204.55, 205.45, 17792, 24.81, 1273.5, 1276.25), Nbr.Lots = 
 c(-61, -61, 6, 40, 40, -1, -1, -1, 1)), .Names = c(Product, Price, 
 Nbr.Lots), row.names = c(NA, 9L), class = data.frame)

 I can rbind() them, thus resulting in one data frame with duplicated 
 row, but I have no idea how to delete duplicated rows. I have tried 
 plyaing with unique(), duplicated with no success

 v-rbind(exportfile,reported)
 v -
 structure(list(Product = c(Cocoa, Cocoa, Cocoa, Coffee C, 
 Coffee C, GC, Sugar No 11, ZS, ZS, Cocoa, Cocoa, 
 Cocoa, Cocoa, Coffee C, Coffee C, GC, Sugar No 11, ZS, 
 ZS), Price = c(2331, 2356, 2440, 204.55, 205.45, 17792, 24.81, 
 1273.5, 1276.25, 2331, 2356, 2440, 2450, 204.55, 205.45, 17792, 24.81, 
 1273.5, 1276.25), Nbr.Lots = c(-61, -61, 6, 40, 40, -1, -1, -1, 1, 
 -61, -61, 5, 1, 40, 40, -1, -1, -1, 1)), .Names = c(Product, 
 Price, Nbr.Lots), row.names = c(1, 2, 3, 4, 5, 6, 7, 
 8, 9, 11, 21, 31, 41, 61, 71, 51, 10, 81, 91), 
 class = data.frame)


 TY for your help

 Arnaud Gaboury

 A2CT2 Ltd.

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



--
Jim Holtman
Data Munger Guru

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

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


Re: [R] Virus Infection in colorspace_1.1-1.zip (R x64 2.14.1)

2012-02-27 Thread Duncan Murdoch

On 24/01/2012 7:44 PM, R. Michael Weylandt wrote:

I'm skeptical that CRAN would produce a bug, but it's not unheard of
for anti-viruses to not like its compiled code. Are you able to
compile locally? That might make it more comfortable -- if you do so,
you could also white list those files (since you made them)

Not a perfect workaround, but AV tends not to like OSS stuff for
whatever reason...


AVG contacted me about colorspace.dll.  They tracked down the false 
positive and have corrected it.   For future problems like this, they said:




In the future if any part of the R Project software is being detected 
by AVG Anti-Virus software,


please submit them to our Virus Labs at 
http://www.avg.com/us-en/whitelist.


Could you help me with forwarding this information to your public forums?


Duncan Murdoch

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


Re: [R] problem with assign and get

2012-02-27 Thread William Dunlap
Sarah Gosless said
 But frequently there are better options than the
 use of get/assign for solving particular problems.

I tend to be more extreme say recommend that you forget
you ever heard of the get and assign functions.

First, out-of-the-local-evaluation-environment assignments
make for confusing code.  You can usually do what you
need to do by having functions that return values.
Replacement functions, defined with
   `something-` - function(x, ..., value) { x$something-value; x }
and used as
   something(x) - newSomething
can be used to alter an existing object.

Second, if you decide that you need to do an assignment
outside of the current evironment, you ought to know which
environment you want to use.  It is often .GlobalEnv.
Then you can use
   yourEnvironment[[itemName]]
instead of
   get(itemName, envir=yourEnvironment)
and
   yourEnvironment[[itemName]] - itemValue
instead of
   assign(itemName, itemValue, envir=yourEnvironment)
The advantages of the [[ syntax are (a) it forces you
to decide where the data should be and (b) it lets you
use natural R syntax to modify objects.  E.g.,
   rownames(yourEnvironment[[itemName]]) - c(R1,R2)
will change the rownames of itemName in the environment
called yourEnvironment.

At somepoint you may decide to use a list instead of
an environment to hold your objects, in which case the
[[ syntax still works without any changes.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Sarah Goslee
 Sent: Monday, February 27, 2012 9:58 AM
 To: Jannis
 Cc: r-help@r-project.org
 Subject: Re: [R] problem with assign and get
 
 Hi,
 
 On Mon, Feb 27, 2012 at 12:41 PM, Jannis bt_jan...@yahoo.de wrote:
  Dear list members,
 
 
  does anyone have an idea why the following construction does not work but
  gives the following error message:
 
  assign('test', array(1:10, dim=c(10,10)))
  dimnames(get('test')) - list(1:10,1:10)
 
 
  Error in dimnames(get(test)) - list(1:10, 1:10) :
   target of assignment expands to non-language object
 
 There's no object to assign dimnames to. Think about it
 this way - what do you expect the dimnames of to be
 changed? test has no dimnames; get(test) would
 print the object named test, but how could you change
 the dimnames of a displayed object?
 
 If you want to change the dimnames of the object named
 test, you first need to use get(test) to assign that object
 to a new object, then change the dimnames, then assign
 the changed object to the desired name.
 
 myobject - get(test)
 dimnames(myobject) - list(1:10, 1:10)
 assign(test, myobject)
 
 Note: I'm assuming your small reproducible example (thank
 you!) is a surrogate for something more complex, so that
 dimnames(test) - list(1:10, 1:10) is not an acceptable
 solution. But frequently there are better options than the
 use of get/assign for solving particular problems.
 
 Sarah
 
 --
 Sarah Goslee
 http://www.functionaldiversity.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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] set heatmap.2 color ranges

2012-02-27 Thread David Winsemius


On Feb 27, 2012, at 11:26 AM, Wendy wrote:


0.05 is blue, anything =0.05 and 0.01 is yellow, and
anything else is grey



No data structures offered, but this may be a useful example:

col= c(grey,  yellow, blue)[findInterval(X, c(-.01, 0.01, 0.05,  
1.1))]


--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] How can the citation to be included in the manual for a package?

2012-02-27 Thread Matyas Sustik
Hi All,

I have a CITATION file in inst for my package, however I would like to have
our relevant paper to show up in the package documentation file as well.
I tried to put the paper in the Description field but that does not seem to
allow formatting (like a new line before the reference) it is a single
paragraph only

What is the R way of doing this?

Thanks!
-Matyas

[[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] Installing package QRMlib

2012-02-27 Thread DT54321
Hi, 
I am having real problems downloading the package 'QRMlib'. The tar.gz file
is shown here:

http://cran.r-project.org/src/contrib/Archive/QRMlib/

I have downloaded this to my local folder and entered the following command:

nstall.packages(myLocalFolder/QRMlib_1.4.5.1.tar.gz, repos = NULL)

but I am getting the following error message

Installing package(s) into ‘C:/Program Files/R/R-2.14.1/library’
(as ‘lib’ is unspecified)
Warning in install.packages :
  error 1 in extracting from zip file
Warning in install.packages :
  cannot open compressed file 'QRMlib_1.4.5.1.tar.gz/DESCRIPTION', probable
reason 'No such file or directory'
Error in install.packages : cannot open the connection

What am I doing wrong??

Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4425269.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] macro function

2012-02-27 Thread mrzung
hi,

I know how to use the for loop function like:

for(i in 1:ncol(mat)){
mat[i]-b[i,2]
}

but, in this case

r1-b[1,1]
r2-b[2,1]
r3-b[3,1]
r4-b[4,1]

*
*
*

r3002-b[3002,1]
r3003-b[3003,1]

- must make vectors

how should I make a efficient code for that?

Is there anything in R like SAS MACRO function?

Please help me.



--
View this message in context: 
http://r.789695.n4.nabble.com/macro-function-tp4425446p4425446.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] compare two data frames of different dimensions and only keep unique rows

2012-02-27 Thread Rui Barradas
Hello,

 
 In fact, the only three unique rows are these ones:
 
  Product Price Nbr.Lots
Cocoa  24405
Cocoa  24501
Cocoa  24406
 

The code below doesn't give the three in one step.

(ixmat - apply(reported, 1, function(x) apply(exportfile, 1, function(y)
any(x != y
reported[apply(ixmat, 2, all), ]
exportfile[apply(ixmat, 1, all), ]

But it does give all three.

Problem: it's inefficient. If n1 - nrow(reported) and  n2 -
nrow(exportfile),
to form the index matrix alone it will make ncol times n1*n2 comparisons.
And the matrix dims are n1, n2 ...

Anyway, I hope it gives ideas,

Rui Barradas




--
View this message in context: 
http://r.789695.n4.nabble.com/compare-two-data-frames-of-different-dimensions-and-only-keep-unique-rows-tp4425379p4425605.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] set heatmap.2 color ranges

2012-02-27 Thread David Winsemius


On Feb 27, 2012, at 1:32 PM, David Winsemius wrote:



On Feb 27, 2012, at 11:26 AM, Wendy wrote:


0.05 is blue, anything =0.05 and 0.01 is yellow, and
anything else is grey



No data structures offered, but this may be a useful example:

col= c(grey,  yellow, blue)[findInterval(X, c(-.01, 0.01,  
0.05, 1.1))]


Except you would want to have matching '''s

col= c(grey,  yellow, blue)[findInterval(X, c(-.01, 0.01, 0.05,  
1.1))]


Why are these things easier to see when they show in Received?



--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] macro function

2012-02-27 Thread Bert Gunter
On Mon, Feb 27, 2012 at 9:56 AM, mrzung mrzun...@gmail.com wrote:
 hi,

 I know how to use the for loop function like:

 for(i in 1:ncol(mat)){
 mat[i]-b[i,2]
 }

 but, in this case

 r1-b[1,1]
 r2-b[2,1]
 r3-b[3,1]
 r4-b[4,1]

 *
 *
 *

 r3002-b[3002,1]
 r3003-b[3003,1]

 - must make vectors

 how should I make a efficient code for that?

You shouldn't. There is no reason to do this.


 Is there anything in R like SAS MACRO function?

No! -- Thank goodness! R is a programming language to begin with. Have
you read An Intro to R?' If not, why not? There are numerous
resources available on CRAN to help you. Use them.

 Please help me.


Please first make an effort to help yourself.

-- Bert


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

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


Re: [R] compare two data frames of different dimensions and only keep unique rows

2012-02-27 Thread Petr Savicky
On Mon, Feb 27, 2012 at 07:10:57PM +0100, Arnaud Gaboury wrote:
 No, but I tried your way too.
 
 In fact, the only three unique rows are these ones:
 
  Product Price Nbr.Lots
Cocoa  24405
Cocoa  24501
Cocoa  24406
 
 Here is a dirty working trick I found :
 
  df-merge(exportfile,reported,all.y=T)
  df1-merge(exportfile,reported)
  dff1-do.call(paste,df)
  dff-do.call(paste,df)
  dff1-do.call(paste,df1)
  df[!dff %in% dff1,]
   Product Price Nbr.Lots
 3   Cocoa  24405
 4   Cocoa  24501
  
 
 My two problems are : I do think it is not so a clean code, then I won't know 
 by advance which of my two df will have the greates dimension (I can add some 
 lines to deal with it, but again, seems very heavy).

Hi.

Try the following.

  setdiffDF - function(A, B)
  {
  A[!duplicated(rbind(B, A))[nrow(B) + 1:nrow(A)], ]
  }

  df1 - setdiffDF(reported, exportfile)
  df2 - setdiffDF(exportfile, reported)
  rbind(df1, df2)

I obtained

 Product Price Nbr.Lots
  3Cocoa  24405
  4Cocoa  24501
  31   Cocoa  24406

Is this correct? I see the row

  Cocoa  2440.006

only in exportfile and not in reported.

The trick with paste() is not a bad idea. A variant of
it is used also in the base function duplicated.matrix(),
since it contains

  apply(x, MARGIN, function(x) paste(x, collapse = \r))

If speed is critical, then possibly the paste() trick
written for the whole columns, for example

  paste(df[[1]], df[[2]], df[[3]], sep=\r)

and then setdiff() can be better.

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] strange behaviour of POSIXlt POSIXt object

2012-02-27 Thread R. Michael Weylandt
Hadley's lubridate package might be of some help to you.

Michael

On Mon, Feb 27, 2012 at 11:40 AM, ikuzar raz...@hotmail.fr wrote:
 So, how is the correct way to increment the day ?

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/strange-behaviour-of-POSIXlt-POSIXt-object-tp4418115p4425206.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] Installing package QRMlib

2012-02-27 Thread R. Michael Weylandt
Do you perhaps need to add install.packages(...,  type=src)? Just a
(untested) guess...

Michael

On Mon, Feb 27, 2012 at 12:07 PM, DT54321 deepan.tailo...@gmail.com wrote:
 Hi,
 I am having real problems downloading the package 'QRMlib'. The tar.gz file
 is shown here:

 http://cran.r-project.org/src/contrib/Archive/QRMlib/

 I have downloaded this to my local folder and entered the following command:

 nstall.packages(myLocalFolder/QRMlib_1.4.5.1.tar.gz, repos = NULL)

 but I am getting the following error message

 Installing package(s) into ‘C:/Program Files/R/R-2.14.1/library’
 (as ‘lib’ is unspecified)
 Warning in install.packages :
  error 1 in extracting from zip file
 Warning in install.packages :
  cannot open compressed file 'QRMlib_1.4.5.1.tar.gz/DESCRIPTION', probable
 reason 'No such file or directory'
 Error in install.packages : cannot open the connection

 What am I doing wrong??

 Thanks

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4425269.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] Installing package QRMlib

2012-02-27 Thread Duncan Murdoch

On 27/02/2012 3:01 PM, R. Michael Weylandt wrote:

Do you perhaps need to add install.packages(...,  type=src)? Just a
(untested) guess...


That should be type=source, and that should solve the problem, 
assuming Deepan has the necessary tools installed.  If not, he can get 
them from CRAN in the bin/windows/Rtools directory.


Duncan Murdoch


Michael

On Mon, Feb 27, 2012 at 12:07 PM, DT54321deepan.tailo...@gmail.com  wrote:
  Hi,
  I am having real problems downloading the package 'QRMlib'. The tar.gz file
  is shown here:

  http://cran.r-project.org/src/contrib/Archive/QRMlib/

  I have downloaded this to my local folder and entered the following command:

  nstall.packages(myLocalFolder/QRMlib_1.4.5.1.tar.gz, repos = NULL)

  but I am getting the following error message

  Installing package(s) into ‘C:/Program Files/R/R-2.14.1/library’
  (as ‘lib’ is unspecified)
  Warning in install.packages :
error 1 in extracting from zip file
  Warning in install.packages :
cannot open compressed file 'QRMlib_1.4.5.1.tar.gz/DESCRIPTION', probable
  reason 'No such file or directory'
  Error in install.packages : cannot open the connection

  What am I doing wrong??

  Thanks

  --
  View this message in context: 
http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4425269.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.


[R] Principal Components for matrices with NA

2012-02-27 Thread Joyous Fisher
Hello,

I have a matrix with 267 columns, all rows of which have at least one
column missing (NA).
All three methods i've tried (pcs, princomp, and prcomp) fail with either

Error in svd(zsmall) : infinite or missing values in 'x' (latter two)

or

Error in cov.wt(z) : 'x' must contain finite values only

The last one happens because of the check

if (!all(is.finite(x)))

in cov.wt

Q: is there a way to do princomp or another method where every row has at
least one missing column?

I guess if missing values are thrown out, that leaves me with a zero row
matrix.
I could find the maximal set of columns such that there exists a subset of
rows with non NA values for every column in the set  - what is an efficient
way to do that?

Kind Regards
JS

[[alternative HTML version deleted]]

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


[R] How to incorporate interaction terms in MRM function of ecodist library?

2012-02-27 Thread Hossm_R
Hi,

I'm interested in incorporating some interaction terms between my
explanatory variables (distance matrices in this case) when I'm using the
function MRM of the package ecodist. The function is doing a multiple
regression on distance matrices. I can get the function to work perfectly on
my explanatory matrices by adding a (+) sign as known. However, when I try
to use the (*) sign or (:) between two terms that I'd like to check the
interaction for, I get same results as with just additive model. Is there
something that I do wrong?
Thanks,

*For example: *

 mrm.S10z_A- MRM(Adis ~ S10z.st+Distance.st, nperm=100)
 mrm.S10z_A
$coef
Adis pval
Int  0.553605282 0.06
S10z.st -0.002587542 0.86
Distance.st  0.028866573 0.07

$r.squared
 R2pval 
0.004180399 0.06000 

$F.test
   F   F.pval 
4.634535 0.06 

 mrm.S10z_A- MRM(Adis ~ S10z.st*Distance.st, nperm=100)
 mrm.S10z_A
$coef
Adis pval
Int  0.553605282 0.05
S10z.st -0.002587542 0.80
Distance.st  0.028866573 0.07

$r.squared
 R2pval 
0.004180399 0.05000 

$F.test
   F   F.pval 
4.634535 0.05 

 mrm.S10z_A- MRM(Adis ~ S10z.st:Distance.st, nperm=100)
 mrm.S10z_A
$coef
Adis pval
Int  0.553605282 0.05
S10z.st -0.002587542 0.81
Distance.st  0.028866573 0.11

$r.squared
 R2pval 
0.004180399 0.05000 

$F.test
   F   F.pval 
4.634535 0.05 


--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-incorporate-interaction-terms-in-MRM-function-of-ecodist-library-tp4425767p4425767.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 incorporate interaction terms in MRM function of ecodist library?

2012-02-27 Thread Sarah Goslee
Hi,

On Mon, Feb 27, 2012 at 2:28 PM, Hossm_R hossamesap...@gmail.com wrote:
 Hi,

 I'm interested in incorporating some interaction terms between my
 explanatory variables (distance matrices in this case) when I'm using the
 function MRM of the package ecodist. The function is doing a multiple
 regression on distance matrices.

MRM() will not process interaction terms.

You can use R's regular regression methods to get estimates of the
coefficients, but statistical significance from those methods is
unusable in this case.


I can get the function to work perfectly on
 my explanatory matrices by adding a (+) sign as known. However, when I try
 to use the (*) sign or (:) between two terms that I'd like to check the
 interaction for, I get same results as with just additive model. Is there
 something that I do wrong?
 Thanks,

 *For example: *

 mrm.S10z_A- MRM(Adis ~ S10z.st+Distance.st, nperm=100)
 mrm.S10z_A
 $coef
                    Adis pval
 Int          0.553605282 0.06
 S10z.st     -0.002587542 0.86
 Distance.st  0.028866573 0.07

 $r.squared
         R2        pval
 0.004180399 0.06000

 $F.test
       F   F.pval
 4.634535 0.06

 mrm.S10z_A- MRM(Adis ~ S10z.st*Distance.st, nperm=100)
 mrm.S10z_A
 $coef
                    Adis pval
 Int          0.553605282 0.05
 S10z.st     -0.002587542 0.80
 Distance.st  0.028866573 0.07

 $r.squared
         R2        pval
 0.004180399 0.05000

 $F.test
       F   F.pval
 4.634535 0.05

 mrm.S10z_A- MRM(Adis ~ S10z.st:Distance.st, nperm=100)
 mrm.S10z_A
 $coef
                    Adis pval
 Int          0.553605282 0.05
 S10z.st     -0.002587542 0.81
 Distance.st  0.028866573 0.11

 $r.squared
         R2        pval
 0.004180399 0.05000

 $F.test
       F   F.pval
 4.634535 0.05




-- 
Sarah Goslee
http://www.functionaldiversity.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] Help with rJava

2012-02-27 Thread Steve_Friedman

I am trying to invoke an in house developed java program from R and am
running into some confusing issues.


I've written this function:


DoNormalSkew - function() {
.jaddClassPath(U:/development/software/untilities/ELVeSkew/dist/ELVeSkew.jar)
.jpackage(U:/development/software/utilities/ELVeS/dist/ELVeSkew.jar)
.jcall(java/lang/System, V, method=Main.main(),
U:/development/software/utilities/ELVeSkew/test/csv,
   U:/development/software/utilities/ELVeSkew/test/out.csv
}

When I run this the function returns the following:

Error in .jcall(java/lang/System, V, method=Main.main(),
  U:/development/software/utilities/ELVeSkew/test/csv,  :
 could not find function Main.man


I have searched on line for examples and have not found any that can
explain this process clearly.
1.)  Do I need each of the statements for .jaddClassPath and .jpackage ?

2.)  Can  you help me understand the .jcall statement better, am I at least
on the right track?

3.) The java program arguments include an input file and output file, these
are given in the last 2 lines of the function.


I'm working on a Windows XP machine,  R version 2.14.1
packages updated today 2/27/2012


Your help is greatly appreciated.

Thanks
Steve



Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147

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


Re: [R] What is the fastest way to combine all columns of a matrix to one column?

2012-02-27 Thread Rolf Turner

On 27/02/12 20:57, ali_protocol wrote:

Dear all,

Newbie: What is the fastest way to combine all columns of a matrix to one
column?


What (on earth!) do you mean  by ``combine''?  *You* understand
what you mean; I doubt that anyone else does.  For Pete's sake, if
you are going to ask a question, make it clear what the expletive
deleted you are asking!

A self-contained reproducible example always helps.

cheers,

Rolf Turner

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


Re: [R] Bootstrapping

2012-02-27 Thread Jim Silverton
Hi,
I am doing some bootstrap. This the is the method I am procceding:
I select a value of sigma and set the sharp ratio = 4. From this I can
compute the mean mu.

For  a set sample size say n = 11, I generate 999 samples of size 11 with
the sigma and mean above.
This is a 11 x 999 matrix.  Now, I repeat this process  times.  so I
have a list of    (11 x 999) matrices.

For each of the  matrices, I compute the sharp ratio for each of the
999 columns. The means of these 999 srs are taken and put in a column.
These are the point estimates of the sharp ratios. I create a 0.025 and
0.975 quantile and store these in a matrix. SO I have a  x 2 matrix
with these confidence intrevcals.

I want to do the following:
(1) Compute the coverage probability
(2) The coverage error
(3) The length pf the interval
(4)The loeft bias
(5) The right bias
(6) The relative bias.

Any help with the code is greatly appreciated.

-- 
Thanks,
Jim.

[[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] Principal Components for matrices with NA

2012-02-27 Thread Rui Barradas
Hello,

 I could find the maximal set of columns such that there exists a subset of
 rows with non NA values for every column in the set  - what is an
 efficient
 way to do that?

Try 'na.exclude' on the transpose matrix.
Example:

set.seed(1)
x - matrix(1:200, ncol=25)

f - function(x){x[sample(length(x), 1)] - NA; x}
x - t(apply(x, 1, f))
x

x.without.NA - t(na.exclude(t(x)))

Hope this helps,

Rui Barradas



--
View this message in context: 
http://r.789695.n4.nabble.com/Principal-Components-for-matrices-with-NA-tp4425930p4426040.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] Non linear regression with complex equation

2012-02-27 Thread jeff_hawkes
Hi all,
Is it possible to model a function where the unknown parameter appears both
in the fitted equation AND in the determination of other parameters?  E.g.

y = a^2 + b/2 + k

where a = 2/k  and b = k^2 

and the model needs to determine k?  I know this is a very simple equation
(its just an example), the one I am modelling is much more complicated! 

k appears in the equation which the n.l.r model fits, but it also affects
other parameters in the equation.  Please let me know if you know a way of
achieving this.  I realise it is possible to set up a loop where the
modelled value for k is fed back in to a and b, and the model is run again -
but it seems like there should be a more elegant way within one run of the
model.

Thanks,
Jeff

--
View this message in context: 
http://r.789695.n4.nabble.com/Non-linear-regression-with-complex-equation-tp4425942p4425942.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] compare two data frames with same columns names but of different dimensions

2012-02-27 Thread Gaurav Sood
m - rbind(reported, exportfile)
m1 - m[duplicated(m),]
m[is.na(match(m$key, m1$key)),]

On Mon, Feb 27, 2012 at 9:46 AM, Arnaud Gaboury
arnaud.gabo...@a2ct2.com wrote:
 Dear List,

 I want to compare and return the rows which are NOT in the two data frames. 
 Classic methods don't work as the df have NOT the same dimensions.


 Here are one example of my df:

 reported -
 structure(list(Product = structure(c(1L, 1L, 1L, 1L, 2L, 2L,
 3L, 4L, 5L, 5L), .Label = c(Cocoa, Coffee C, GC, Sugar No 11,
 ZS), class = factor), Price = c(2331, 2356, 2440, 2450, 204.55,
 205.45, 17792, 24.81, 1273.5, 1276.25), Nbr.Lots = c(-61L, -61L,
 5L, 1L, 40L, 40L, -1L, -1L, -1L, 1L)), .Names = c(Product,
 Price, Nbr.Lots), row.names = c(1L, 2L, 3L, 4L, 6L, 7L, 5L,
 10L, 8L, 9L), class = data.frame)

 exportfile -
 structure(list(Product = c(Cocoa, Cocoa, Cocoa, Coffee C,
 Coffee C, GC, Sugar No 11, ZS, ZS), Price = c(2331,
 2356, 2440, 204.55, 205.45, 17792, 24.81, 1273.5, 1276.25), Nbr.Lots = c(-61,
 -61, 6, 40, 40, -1, -1, -1, 1)), .Names = c(Product, Price,
 Nbr.Lots), row.names = c(NA, 9L), class = data.frame)

 As you can see, they have same column names.
 My idea was to merge these two df when passing as argument not to take into 
 account duplicate rows, so I will get one df with rows which are not in both 
 df.
 Is it possible? How to do it?

 TY for any help.


 Arnaud Gaboury

 A2CT2 Ltd.

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

2012-02-27 Thread frauke
Hey, 

I have an array with the dimensions 200x6x200 and I want to save it in a
textfile. I want to be able to reload the text file to get the same array
again:   new.array-load(mytextfile.txt) or something similar. I was not
able to figure out a way to do that with write.table without having to save
200 text files. Is there another way?

Thank you!
Frauke





--
View this message in context: 
http://r.789695.n4.nabble.com/export-3D-array-to-txt-file-tp4426005p4426005.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] memory management

2012-02-27 Thread Sam Steingold
It appears that the intermediate data in functions is never GCed even
after the return from the function call.
R's RSS is 4 Gb (after a gc()) and

sum(unlist(lapply(lapply(ls(),get),object.size)))
[1] 1009496520

(less than 1 GB)

how do I figure out where the 3GB of uncollected garbage is hiding?

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://www.childpsy.net/ http://camera.org http://truepeace.org
http://www.PetitionOnline.com/tap12009/ http://thereligionofpeace.com
Modern man is the missing link between apes and human beings.

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

2012-02-27 Thread Luo, Ruijuan
Dear who may concern,
I am sending you this email to ask if I could have someone help me to write 
this script I am interested in.
I am requesting the script for performing variance-stabilizing normalizations 
on the R language. Could you please help me on that?
If I am asking a wrong person, could you please tell me the right email address 
I should contact?
Appreciated!
Thanks!

Regards

Ruijuan Luo


[[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] Note: no visible binding for global variable 'Dimnames'

2012-02-27 Thread Sam Steingold
I get this (twice):

Note: no visible binding for global variable 'Dimnames'
Note: no visible binding for global variable 'Dimnames'

on the __first__ invocation of a function which does this:

sm - sparseMatrix(i = ..., j = ..., x = ...)
for (i in 1:length(mynames))
  usr[[mynames[i]]] - sm[,i]

the Notes are printed when the usr-sm assignment is evaluated for i==1.
(but not for any subsequent i's of subsequent calls to the function).

I seem to be getting the right results, so I have been ignoring these
messages, but I was wondering if I was doing something wrong.

(needless to say that I do not have the word Dimnames anywhere in my code)

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://www.childpsy.net/ http://dhimmi.com http://americancensorship.org
http://iris.org.il http://www.memritv.org http://jihadwatch.org
Stupidity, like virtue, is its own reward.

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


Re: [R] export 3D array to .txt file

2012-02-27 Thread R. Michael Weylandt
You can save it directly as an R object with save() and load with
load() -- that's probably easiest. It should be portable between R
platforms and sesions, but won't be easily accessible to other
programs.

Michael

On Mon, Feb 27, 2012 at 3:45 PM, frauke fh...@andrew.cmu.edu wrote:
 Hey,

 I have an array with the dimensions 200x6x200 and I want to save it in a
 textfile. I want to be able to reload the text file to get the same array
 again:   new.array-load(mytextfile.txt) or something similar. I was not
 able to figure out a way to do that with write.table without having to save
 200 text files. Is there another way?

 Thank you!
 Frauke





 --
 View this message in context: 
 http://r.789695.n4.nabble.com/export-3D-array-to-txt-file-tp4426005p4426005.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] export 3D array to .txt file

2012-02-27 Thread Jim Holtman
why a text file?  are you going to pass it to another program?  'load'/'save' 
has already been suggested.  if you really want text, try 'dump'.

Sent from my iPad

On Feb 27, 2012, at 15:45, frauke fh...@andrew.cmu.edu wrote:

 Hey, 
 
 I have an array with the dimensions 200x6x200 and I want to save it in a
 textfile. I want to be able to reload the text file to get the same array
 again:   new.array-load(mytextfile.txt) or something similar. I was not
 able to figure out a way to do that with write.table without having to save
 200 text files. Is there another way?
 
 Thank you!
 Frauke
 
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/export-3D-array-to-txt-file-tp4426005p4426005.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] What is the fastest way to combine all columns of a matrix to one column?

2012-02-27 Thread Bert Gunter
Mod Rolf's question, the answer probably is: do nothing  -- it already
**is** a single column.

If you read the section on arrays and matrices in An Intro to R
*carefully* (this is part of every standard R distro) you will be
enlightened. Have you read it? If not, why not?

If mat is your matrix,

c(mat)

may also be enlightening.

-- Bert

On Mon, Feb 27, 2012 at 1:42 PM, Rolf Turner rolf.tur...@xtra.co.nz wrote:
 On 27/02/12 20:57, ali_protocol wrote:

 Dear all,

 Newbie: What is the fastest way to combine all columns of a matrix to one
 column?


 What (on earth!) do you mean  by ``combine''?  *You* understand
 what you mean; I doubt that anyone else does.  For Pete's sake, if
 you are going to ask a question, make it clear what the expletive
 deleted you are asking!

 A self-contained reproducible example always helps.

    cheers,

        Rolf Turner

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


[R] from data.frame to Venn diagram

2012-02-27 Thread Lara Poplarski
Hello All,

I have a data.frame with this structure:

m - matrix(sample(c(rep('yes', 10, replace = TRUE), rep('no', 10,
replace = TRUE), NA), 500, replace = TRUE), nrow = 100, ncol = 5)
colnames(m) - colnames(m, do.NULL = FALSE, prefix = col)
m - as.data.frame(m)

I need to generate a Venn diagram from this data.frame, displaying the
various intersections of 'yes' for the different columns. Ideally, the
circle for each column should be proportional to the number of non-NA
entries.

The package VennDiagram (described here:
http://www.biomedcentral.com/1471-2105/12/35) can do all this.
However, I have not been able to figure out how to transform the
data.frame into the required list format.

Any suggestions on how to do this?

Many thanks,
Lara

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


Re: [R] from data.frame to Venn diagram

2012-02-27 Thread Daniel Nordlund
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Lara Poplarski
 Sent: Monday, February 27, 2012 5:24 PM
 To: r-help@r-project.org
 Subject: [R] from data.frame to Venn diagram
 
 Hello All,
 
 I have a data.frame with this structure:
 
 m - matrix(sample(c(rep('yes', 10, replace = TRUE), rep('no', 10,
 replace = TRUE), NA), 500, replace = TRUE), nrow = 100, ncol = 5)
 colnames(m) - colnames(m, do.NULL = FALSE, prefix = col)
 m - as.data.frame(m)
 
 I need to generate a Venn diagram from this data.frame, displaying the
 various intersections of 'yes' for the different columns. Ideally, the
 circle for each column should be proportional to the number of non-NA
 entries.
 
 The package VennDiagram (described here:
 http://www.biomedcentral.com/1471-2105/12/35) can do all this.
 However, I have not been able to figure out how to transform the
 data.frame into the required list format.
 
 Any suggestions on how to do this?
 
 Many thanks,
 Lara
 

Lara,

I assume you wish to look at which people answered yes on col1 and which 
answered yes for col2 and the overlap.  So, something like this might help get 
you started

C1 - which(m$col1 == 'yes')
C2 - which(m$col2 == 'yes')
venn.diagram(list(C1=C1, C2=C2), c:/tmp/Venn_2set_simple.tiff)

If that is not what you want, then you will need to provide an example of what 
you want your output to be.

Hope this is helpful,

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] Non linear regression with complex equation

2012-02-27 Thread Rolf Turner


Your question is (completely) ill-posed.  What is your actual
model?  What you have said makes no sense at all as it stands.
(Minimal self-contained example .)

cheers,

Rolf Turner

On 28/02/12 09:25, jeff_hawkes wrote:

Hi all,
Is it possible to model a function where the unknown parameter appears both
in the fitted equation AND in the determination of other parameters?  E.g.

y = a^2 + b/2 + k

where a = 2/k  and b = k^2

and the model needs to determine k?  I know this is a very simple equation
(its just an example), the one I am modelling is much more complicated!

k appears in the equation which the n.l.r model fits, but it also affects
other parameters in the equation.  Please let me know if you know a way of
achieving this.  I realise it is possible to set up a loop where the
modelled value for k is fed back in to a and b, and the model is run again -
but it seems like there should be a more elegant way within one run of the
model.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Packages/functions for competing risk analysis

2012-02-27 Thread Jennifer Sabatier
Hi Rs,

I am analyzing a time to event dataset with several competing risks.

0 = Active by end of study
1 = Stopped treatment to start another treatment
2 = Lost
3 = Dead

My event of interest in Lost to Followup but starting a different treatment
and dying are competing risks.  All 1,2,3 events are events of exiting the
study, but it's only 2-LTFU that we are concerned with  (I know I am
repeating myself, sorry).

I can't seem to find a package or function that can handle 2 competing
risks for the main event.  I realize I may be using the well-known ones,
timereg and cmprisk, wrong.  And if I am, then I'd appreciate a correction.

Here's the model I tried (and it crashes)

comp.risk(Surv(futime, retention==2) ~ sex, data=dta, dta$retention,
causeS=c(1,3), resample.iid=1, n.sim=100)

I apologize, but I am cannot create the example dataset using code.  I am
not able.

The data, though is one to one.

ID   retention  sex  futime

1   0   1 524.3


etc.

Thank you, in advance, if you can help me.

Best,

Jen

[[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] General question about GLMM and heterogeneity of variance

2012-02-27 Thread Ben Bolker
GibsonR rachel.gibson at bristol.ac.uk writes:

 
 My data have heterogeneity of variance (in a categorical variable), do I need
 to specify a variance structure accounting for this in my model or do GLMMs
 by their nature account for such heterogeneity (as a result of using
 deviances rather than variances)? And if I do need to do this, how do I do
 it (e.g. using something like the VarIdent function in nlme) and in what
 package?

  We need a little more information.

  Also, it might be better to send follow-ups to r-sig-mixed-models at
r-project.org .

  Is your a categorical variable a predictor (independent) or
response (dependent) variable?  If it's a predictor, then the
details of its distribution are not important for the validity
of the analysis.  It it's a response, then you need to be doing
a multinomial or ordinal response model.  GLMs and GLMMs do account
for some forms of heterogeneity in variance.

  You probably need to tell us more about what you tried to do
and how you concluded that heteroscedasticity was a problem.

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


Re: [R] Principal Components for matrices with NA

2012-02-27 Thread Rui Barradas
Hello again,

 Q: is there a way to do princomp or another method where every row has at
 least one missing column?

See also package 'psych', function 'principal'. You can impute mean or
median to NAs.

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/Principal-Components-for-matrices-with-NA-tp4425930p4426284.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] row names of a heatmap on left hand side

2012-02-27 Thread 1Rnwb
Hello R Gurus,

I have a matrix for which I am doing a heatmap using heatmap.2. I want to
put the rownames on the lefthand side instead of the right side of the
heatmap. how can i put the rownames on left hand side: I have already tried
axis  but could not make it work

ccc-structure(c(1, 0.283300333755851, 0.237863231117007,
0.0148696794159253, 
-0.0780756406815149, -0.106161465097659, -0.0756387578559718, 
-0.0331407390639047, -0.0707492640028071, -0.0613323523367336, 
0.160614869977481, 0.163220169151304, -0.00799405273310068,
0.0702415660531524, 
-0.00269044770795431, 0.022118567043969, 0.0620175783757948, 
0.071884246401891, -0.0469804302975448, 0.0261500962333625,
0.126816435101853, 
0.135887180731395, 0.0110308674727327, 0.0805731314652419,
-0.147245436227401, 
NA, 1, 0.756696630102848, -0.0253573545151531, -0.0436449174849985, 
-0.0681193805838121, -0.125651668003682, -0.132100479190945, 
-0.0672954083207475, -0.230426861035276, -0.000418410746782722, 
0.0769862111911649, -0.0335582429785183, -0.0842411971843023, 
-0.122530783393992, -0.0649446178327085, -0.077787483725924, 
-0.0351869234224504, -0.083404295266297, -0.0381865040141299, 
0.106839122670871, 0.110275858855431, 0.0863464084194804, 0.153158957903198, 
-0.0240563780789799, NA, NA, 1, -0.0581824191662743, -0.0577752089674947, 
-0.0732098989298006, -0.128791472234673, -0.0988078828924034, 
-0.0679818896618525, -0.17312177564727, 0.012457362675565,
0.0592327855817399, 
-0.0666240794205135, -0.0715883024096398, -0.0922611542475004, 
-0.0690818250876944, -0.0580129934906561, -0.0172677939384777, 
-0.107766765710368, 0.00520294080324943, 0.0784863927912482, 
0.102062918116874, 0.0571392089924128, 0.122231446563675,
-0.037588761722365, 
NA, NA, NA, 1, 0.525472699159769, 0.514041356697963, 0.561064373161352, 
0.431210983834436, 0.452619063041757, 0.147444937649346, 0.0499871095691751, 
0.101711708044079, 0.313069848945963, 0.173478908711319, 0.234099595958429, 
0.442444172603688, 0.271047417517104, 0.271574694324702, 0.335146377247985, 
0.261796658619168, 0.20615917507402, 0.179710108054483, 0.00693091170071528, 
0.0572351824096096, 0.0421931015525606, NA, NA, NA, NA, 1,
0.500262732680092, 
0.575331145231366, 0.535966575237105, 0.588011751256699, 0.209316134244339, 
0.178306362315634, 0.144372963193607, 0.449164822440907, 0.311585643277039, 
0.373916415586687, 0.42342063290168, 0.257074092743689, 0.235277302551095, 
0.349938957503695, 0.330125591891904, 0.343804820698451, 0.273320029845419, 
-0.00571265033987237, 0.0226529101519386, 0.0133821821423264, 
NA, NA, NA, NA, NA, 1, 0.783943436792447, 0.738881212745611, 
0.74753358245511, 0.154011088987657, -0.0345413593712036,
0.0774290165561568, 
0.270530619110383, 0.197653878154696, 0.175622464937608, 0.494122861400667, 
0.205654982662595, 0.262435922111394, 0.336248481780927, 0.2457208720417, 
0.225645535832965, 0.166011304030232, -0.000628760762335414, 
-0.0498164098632905, 0.0504668500594617, NA, NA, NA, NA, NA, 
NA, 1, 0.694267683304991, 0.665025879567406, 0.202215608856743, 
0.0242420445336668, 0.115486719828318, 0.327074561287353, 0.232316609009873, 
0.252557073368415, 0.528071198751934, 0.271456859045674, 0.308461563380474, 
0.430695444971444, 0.343610015300747, 0.270906939265836, 0.233818502929012, 
0.0267752322720164, 0.0263022347486687, 0.0451312848263739, NA, 
NA, NA, NA, NA, NA, NA, 1, 0.776593952305343, 0.264441281328401, 
0.18148880771864, 0.123206249983537, 0.298515458147549, 0.325676094897333, 
0.269563532182944, 0.500437079037779, 0.315922872681825, 0.320594404612037, 
0.342087722381524, 0.234383707828859, 0.333287400951434, 0.218902122287433, 
0.0369772789625516, 0.0129942406701288, 0.0489108090105715, NA, 
NA, NA, NA, NA, NA, NA, NA, 1, 0.162583487686877, 0.195970937901678, 
0.120763943840432, 0.436732203917893, 0.466737746485222, 0.37904462705, 
0.512555709916608, 0.242432982203289, 0.253876944460396, 0.309350372966892, 
0.251258196675636, 0.230011894342281, 0.127848664881258,
-0.0115057022105185, 
-0.00311190058097034, 0.0549673967736474, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, 1, 0.245845410111639, 0.244681678373053, 0.345224517493842, 
0.231228340394969, 0.375331818652881, 0.279222931694161, 0.449497588453708, 
0.381759655904665, 0.125594966938876, 0.123732822791146, 0.242643089641339, 
0.213713940442987, -0.0464978734739873, -0.0530884098109049, 
0.00741507616587697, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
1, 0.257637258425107, 0.266404784079116, 0.418770493609101,
0.380954319800656, 
0.225911833064407, 0.239940125963318, 0.166185116079108, 0.0545692769866459, 
0.104587370234936, 0.157906865871569, 0.153607122076791,
-0.0654111656429167, 
-0.00340208731802426, -0.0629540855938132, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, 1, 0.302626240633324, 0.314160256475753, 
0.36659577440935, 0.283381437378777, 0.356824428698387, 0.458399544248849, 
0.0513918399545163, 0.175229426288891, 0.219315198173476, 0.379344376229316, 
0.0380837761734483, 0.052844098764557, 

[R] kmeans: how to retrieve clusters

2012-02-27 Thread ikuzar
Hello,

I'd like to classify data with kmeans algorithm. In my case, I should get  2
clusters in output. Here is my data

colCandInd   colCandMed
1   822950.5
2   83   1831.5
3   1192 2899.0 
4   1193 2103.5

The first cluster is the two first lines
the 2nd cluster is the two last lines

Here is the code:
x = colCandList$colCandInd
y = colCandList$colCandMed
m = matrix(c(x, y), nrow = length(colCandList$colCandInd), ncol=2)
kres = kmeans(m, 2)

Is there a way to retrieve both clusters in output of the algorithm in order
to process in each cluster ? (I am looking for smthing like kres$clustList
... where I can process each cluster)

kres$cluster did not yield what I expected ...

thanks for your help


--
View this message in context: 
http://r.789695.n4.nabble.com/kmeans-how-to-retrieve-clusters-tp4426427p4426427.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] memory management

2012-02-27 Thread Bert Gunter
This appears to be the sort of query that (with apologies to other R
gurus) only Brian Ripley or Luke Tierney could figure out. R generally
passes by value into function calls (but not *always*), so often
multiple copies of objects are made during the course of calls. I
would speculate that this is what might be going on below -- maybe
even that's what you meant.

Just a guess on my part, of course, so treat accordingly.

-- Bert

On Mon, Feb 27, 2012 at 1:03 PM, Sam Steingold s...@gnu.org wrote:
 It appears that the intermediate data in functions is never GCed even
 after the return from the function call.
 R's RSS is 4 Gb (after a gc()) and

 sum(unlist(lapply(lapply(ls(),get),object.size)))
 [1] 1009496520

 (less than 1 GB)

 how do I figure out where the 3GB of uncollected garbage is hiding?

 --
 Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 
 11.0.11004000
 http://www.childpsy.net/ http://camera.org http://truepeace.org
 http://www.PetitionOnline.com/tap12009/ http://thereligionofpeace.com
 Modern man is the missing link between apes and human beings.

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


Re: [R] Bayesian Hidden Markov Models

2012-02-27 Thread monkeylan
Dear Oscar,
 
I really appreciate your help for my problem. I have taken a look at the R 
package RJaCGH you mentioned roughly, but I am really a little confused by the 
CGH microarrays background of the package. Actually, I am a graduate student, 
majoring Mathematical Statistics. So, I know nothing about the CGH microarrays. 
 
Have you ever used the RJaCGH package before? If so, could you please briefly 
tell me how to use RJaCGH to implement a Bayesian Hidden Markov Models for my 
univariate time series? 
 
Thanks again for your patience and time.
 
Best Regards,
 
James Allan
 

--- 12年2月27日,周一, Oscar Rueda [via R] 
ml-node+s789695n4424152...@n4.nabble.com 写道:


发件人: Oscar Rueda [via R] ml-node+s789695n4424152...@n4.nabble.com
主题: Re: Bayesian Hidden Markov Models
收件人: monkeylan lanjin...@yahoo.com.cn
日期: 2012年2月27日,周一,下午6:05


Dear James, 
Although designed for the analysis of copy number CGH microarrays, RJaCGH 
uses a Bayesian HMM model. 

Cheers, 
Oscar 


On 27/2/12 08:32, monkeylan [hidden email] wrote: 


 Dear R buddies, 
 
 Recently, I attempt to model the US/RMB Exchange rate log-return time series 
 with a *Hidden Markov model (first order Markov Chain  mixed Normal 
 distributions). * 
 
 I have applied the RHmm package to accomplish this task, but the results are 
 not so satisfying. 
 So, I would like to try a *Bayesian method *for the parameter estimation of 
 the Hidden Markov model. 
 
 Could anyone kindly tell me which R package can perform Bayesian estimation 
 of the model? 
 
 Many thanks for your help and time. 
 
 Best Regards, 
 James Allan 
 
 
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4423946.
  
 html 
 Sent from the R help mailing list archive at Nabble.com. 
 
 __ 
 [hidden email] mailing list 
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 
Oscar M. Rueda, PhD. 
Postdoctoral Research Fellow, Breast Cancer Functional Genomics. 
Cancer Research UK Cambridge Research Institute. 
Li Ka Shing Centre, Robinson Way. 
Cambridge CB2 0RE 
England 




NOTICE AND DISCLAIMER 
This e-mail (including any attachments) is intended for ...{{dropped:16}} 

__ 
[hidden email] mailing list 
https://stat.ethz.ch/mailman/listinfo/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/Bayesian-Hidden-Markov-Models-tp4423946p4424152.html
 
To unsubscribe from Bayesian Hidden Markov Models, click here.
NAML

--
View this message in context: 
http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4426601.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] R for Mac - editor's pick on Download Typhoon

2012-02-27 Thread Download Typhoon
Dear R Development Core Team

R for Mac has been reviewed by Download Typhoon and got Editor's Pick award: 
http://www.downloadtyphoon.com/r-for-mac/infoyvnppyhf

Please publish Download Typhoon Editor's Pick award on your website by adding 
the following HTML code:

160 x 80:
a href=http://www.downloadtyphoon.com/; target=_blankimg 
src=http://www.downloadtyphoon.com/templates/downty/images/award_pick.gif; 
alt=Download Typhoon - Editor's Pick border=0//a

120 x 60:
a href=http://www.downloadtyphoon.com/; target=_blankimg 
src=http://www.downloadtyphoon.com/templates/downty/images/award_120x60_pick.gif;
 alt=Download Typhoon - Editor's Pick border=0//a

Text link:
a href=http://www.downloadtyphoon.com/; target=_blankEditor's Pick on 
Download Typhoon/a

Here are more images and options how link to us: 
http://www.downloadtyphoon.com/linktous.html

We're looking forward for further co-operation.

Best regards,
Download Typhoon

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


Re: [R] compare two data frames of different dimensions and only keep unique rows

2012-02-27 Thread Rui Barradas
Hello,

I've made Petr's solution a bit more general


Petr Savicky wrote
 
 On Mon, Feb 27, 2012 at 07:10:57PM +0100, Arnaud Gaboury wrote:
 No, but I tried your way too.
 
 In fact, the only three unique rows are these ones:
 
  Product Price Nbr.Lots
Cocoa  24405
Cocoa  24501
Cocoa  24406
 
 Here is a dirty working trick I found :
 
  df-merge(exportfile,reported,all.y=T)
  df1-merge(exportfile,reported)
  dff1-do.call(paste,df)
  dff-do.call(paste,df)
  dff1-do.call(paste,df1)
  df[!dff %in% dff1,]
   Product Price Nbr.Lots
 3   Cocoa  24405
 4   Cocoa  24501
  
 
 My two problems are : I do think it is not so a clean code, then I won't
 know by advance which of my two df will have the greates dimension (I can
 add some lines to deal with it, but again, seems very heavy).
 
 Hi.
 
 Try the following.
 
   setdiffDF - function(A, B)
   {
   A[!duplicated(rbind(B, A))[nrow(B) + 1:nrow(A)], ]
   }
 
   df1 - setdiffDF(reported, exportfile)
   df2 - setdiffDF(exportfile, reported)
   rbind(df1, df2)
 
 I obtained
 
  Product Price Nbr.Lots
   3Cocoa  24405
   4Cocoa  24501
   31   Cocoa  24406
 
 Is this correct? I see the row
 
   Cocoa  2440.006
 
 only in exportfile and not in reported.
 
 The trick with paste() is not a bad idea. A variant of
 it is used also in the base function duplicated.matrix(),
 since it contains
 
   apply(x, MARGIN, function(x) paste(x, collapse = \r))
 
 If speed is critical, then possibly the paste() trick
 written for the whole columns, for example
 
   paste(df[[1]], df[[2]], df[[3]], sep=\r)
 
 and then setdiff() can be better.
 
 Hope this helps.
 
 Petr Savicky.
 
 __
 R-help@ mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

It produces the symmetric difference for vectors, matrices, data.frames and
(so-so tested) lists.

#-
# First the set difference

`%-%` - function(x, y) UseMethod(%-%)
`%-%.default` - function(x, y){
f - function(A, B)
!duplicated(c(B, A))[length(B) + 1:length(A)]
ix - f(x, y)
x[ix]
}
`%-%.matrix` - `%-%.data.frame` - function(x, y){
f - function(A, B)
!duplicated(rbind(B, A))[nrow(B) + 1:nrow(A)]
ix - f(x, y)
x[ix, ]
}
`%-%.list` - function(x, y){
f - function(A, B)
if(class(A) == class(B)) A %-% B
lapply(y, function(Y) lapply(x, f, Y))
}

# Then the set symmetric difference
symdiff - function(x, y)  UseMethod(symdiff)
symdiff.default - function(x, y)
c(x %-% y, y %-% x)
symdiff.matrix - symdiff.data.frame - function(x, y){
xclass - class(x)
res - rbind(x %-% y, y %-% x)
class(res) - xclass
res
}
symdiff.list - function(x, y){
f - function(A, B)
if(class(A) == class(B)) symdiff(A, B)
lapply(y, function(Y) lapply(x, f, Y))
}

# Test it with data.frames first (the OP data)

reported %-% exportfile
exportfile %-% reported

symdiff(reported, exportfile)
symdiff(exportfile, reported)

#-
# And some other data types

x - 1:5
y - 3:8
x %-% y
y %-% x
symdiff(x, y)
symdiff(y, x)

X - list(a=x, rp=reported)
Y - list(b=y, ef=exportfile)
X %-% Y
Y %-% X
symdiff(X, Y)
symdiff(Y, X)

P.S. This question seems to pop-up repeatedly

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/compare-two-data-frames-of-different-dimensions-and-only-keep-unique-rows-tp4425379p4426607.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] Bayesian Hidden Markov Models

2012-02-27 Thread monkeylan
Dear Doctor Oscar,
 
Sorry for not noticing that you are the author of the RJaCGH package.

But I noticed that hidden Markov model in your package is with non-homogeneous 
transition probabilities. Here in my work, the HMM is just a first-order 
homogeneous Markov chain, i.e. the  transition  matrix is constant. 
 
So, Could you please tell me how can I adjust the R functions in your package 
to implement my analysis?
 
Best Regards,
 
James Allan


--- 12年2月27日,周一, Oscar Rueda [via R] 
ml-node+s789695n4424152...@n4.nabble.com 写道:


发件人: Oscar Rueda [via R] ml-node+s789695n4424152...@n4.nabble.com
主题: Re: Bayesian Hidden Markov Models
收件人: monkeylan lanjin...@yahoo.com.cn
日期: 2012年2月27日,周一,下午6:05


Dear James, 
Although designed for the analysis of copy number CGH microarrays, RJaCGH 
uses a Bayesian HMM model. 

Cheers, 
Oscar 


On 27/2/12 08:32, monkeylan [hidden email] wrote: 


 Dear R buddies, 
 
 Recently, I attempt to model the US/RMB Exchange rate log-return time series 
 with a *Hidden Markov model (first order Markov Chain  mixed Normal 
 distributions). * 
 
 I have applied the RHmm package to accomplish this task, but the results are 
 not so satisfying. 
 So, I would like to try a *Bayesian method *for the parameter estimation of 
 the Hidden Markov model. 
 
 Could anyone kindly tell me which R package can perform Bayesian estimation 
 of the model? 
 
 Many thanks for your help and time. 
 
 Best Regards, 
 James Allan 
 
 
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4423946.
  
 html 
 Sent from the R help mailing list archive at Nabble.com. 
 
 __ 
 [hidden email] mailing list 
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 
Oscar M. Rueda, PhD. 
Postdoctoral Research Fellow, Breast Cancer Functional Genomics. 
Cancer Research UK Cambridge Research Institute. 
Li Ka Shing Centre, Robinson Way. 
Cambridge CB2 0RE 
England 




NOTICE AND DISCLAIMER 
This e-mail (including any attachments) is intended for ...{{dropped:16}} 

__ 
[hidden email] mailing list 
https://stat.ethz.ch/mailman/listinfo/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/Bayesian-Hidden-Markov-Models-tp4423946p4424152.html
 
To unsubscribe from Bayesian Hidden Markov Models, click here.
NAML

--
View this message in context: 
http://r.789695.n4.nabble.com/Bayesian-Hidden-Markov-Models-tp4423946p4427000.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] aggregating specific parts in zoo index column to perform sliding average

2012-02-27 Thread knavero
Here's my code:

http://pastebin.com/0yRxEVtm

The important parts are uncommented and should be easy to find using the
link above. For the following line of code, I plan on looking for a way to
offset it up 7 rows so that the 15 minute timestamp would be considered the
median of the subset being averaged to find the mean: 

avgCool = aggregate(intCool, trunc(time(intCool), times(00:15:00)), mean)

Currently the issue is that, with the truncate function, it truncates but
really rounds down the time series values to the 15 minute time stamp
earlier in the series. For example, let's say we have one minute intervals
0:00, 0:01, 0:02,,0:37. It takes 0:00 - 0:14 and replaces that with
0:00. Then it sees 0:15, and changes values from 0:15 - 0:29 to 0:15. In
effect, aggregating the values and creating subsets. 

What I want to do here is change 0:00 - 0:07 to 0:00, change 0:08 - 0:22 to
0:15, and change 0:23 - 0:37 to 0:30 in which 0:15 and 0:30 are the medians
of each subset. Anyway, I hope that makes sense. Any ideas on which function
will make this an easy job? Much thanks in advance.



--
View this message in context: 
http://r.789695.n4.nabble.com/aggregating-specific-parts-in-zoo-index-column-to-perform-sliding-average-tp4426798p4426798.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] having this error below.

2012-02-27 Thread wilson_peter88
hi. can anybody help me to resolve this problem i am facing?


Warning in odbcDriverConnect(con, tabQuote = c([, ]), ...) :
  [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver
Manager] Data source name not found and no default driver specified
Warning in odbcDriverConnect(con, tabQuote = c([, ]), ...) :
  ODBC connection failed
Error in sqlTables(channel) : first argument is not an open RODBC channel


--
View this message in context: 
http://r.789695.n4.nabble.com/having-this-error-below-tp4427054p4427054.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] from data.frame to Venn diagram

2012-02-27 Thread Rui Barradas
Hello,


Lara Poplarski wrote
 
 Hello All,
 
 I have a data.frame with this structure:
 
 m - matrix(sample(c(rep('yes', 10, replace = TRUE), rep('no', 10,
 replace = TRUE), NA), 500, replace = TRUE), nrow = 100, ncol = 5)
 colnames(m) - colnames(m, do.NULL = FALSE, prefix = col)
 m - as.data.frame(m)
 
 I need to generate a Venn diagram from this data.frame, displaying the
 various intersections of 'yes' for the different columns. Ideally, the
 circle for each column should be proportional to the number of non-NA
 entries.
 
 The package VennDiagram (described here:
 http://www.biomedcentral.com/1471-2105/12/35) can do all this.
 However, I have not been able to figure out how to transform the
 data.frame into the required list format.
 
 Any suggestions on how to do this?
 
 Many thanks,
 Lara
 
 __
 R-help@ mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

Try this:

# First make a list of where there are 'yes' values in 'm'
mvenn - lapply(m, function(x) which(x == yes))
mvenn

venn.diagram(
x = mvenn[-5],  # exclude a list element (the 5th)
filename = vd_without_5th.tiff,
cex = 2.5,
cat.cex = 2.5,
cat.pos = 0
)

# Doesn't work or I'm missing something
venn.diagram(
x = mm,
filename=vd_all.tiff,
cex = 2.5,
cat.cex = 2.5,
cat.pos = 0
)
Error: Incorrect number of elements.

It seems to have a limit...

Hope this helps,

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/from-data-frame-to-Venn-diagram-tp4426642p4426853.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] having this error below.

2012-02-27 Thread Jeff Newmiller
Quite possibly, after you read the posting guide and provide a complete example 
of code that is causing the problem.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

wilson_peter88 weele...@hotmail.com wrote:

hi. can anybody help me to resolve this problem i am facing?


Warning in odbcDriverConnect(con, tabQuote = c([, ]), ...) :
  [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver
Manager] Data source name not found and no default driver specified
Warning in odbcDriverConnect(con, tabQuote = c([, ]), ...) :
  ODBC connection failed
Error in sqlTables(channel) : first argument is not an open RODBC
channel


--
View this message in context:
http://r.789695.n4.nabble.com/having-this-error-below-tp4427054p4427054.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] R for Mac - editor's pick on Download Typhoon

2012-02-27 Thread Steve Lianoglou
Thanks for taking the time to really kick the tires on R for mac and
providing a great service to the community.

The screen shots[1] you chose to use in order to really highlight R
for mac as well as ensuring that you are reviewing the latest and
greatest[2] really says volumes about the wonderfully thorough job you
folks are doing over there at downloadtyphoon.

Keep up the good work!

Also, nice ads!

-steve

[1] I see some X windows manager all the way down
[2] The version you are using is ~ 1 year old

On Mon, Feb 27, 2012 at 4:35 PM, Download Typhoon
awa...@downloadtyphoon.com wrote:
 Dear R Development Core Team

 R for Mac has been reviewed by Download Typhoon and got Editor's Pick 
 award: http://www.downloadtyphoon.com/r-for-mac/infoyvnppyhf

 Please publish Download Typhoon Editor's Pick award on your website by 
 adding the following HTML code:

 160 x 80:
 a href=http://www.downloadtyphoon.com/; target=_blankimg 
 src=http://www.downloadtyphoon.com/templates/downty/images/award_pick.gif; 
 alt=Download Typhoon - Editor's Pick border=0//a

 120 x 60:
 a href=http://www.downloadtyphoon.com/; target=_blankimg 
 src=http://www.downloadtyphoon.com/templates/downty/images/award_120x60_pick.gif;
  alt=Download Typhoon - Editor's Pick border=0//a

 Text link:
 a href=http://www.downloadtyphoon.com/; target=_blankEditor's Pick on 
 Download Typhoon/a

 Here are more images and options how link to us: 
 http://www.downloadtyphoon.com/linktous.html

 We're looking forward for further co-operation.

 Best regards,
 Download Typhoon

 http://www.downloadtyphoon.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.



-- 
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] To define a function which includes two functions as arguments such as plot and text

2012-02-27 Thread Yashwanth M.R
Hi  Mr. Uwe Ligges,

 

I really thankful for the reply.  I even tried the same,
means writing the new function. But the result is same as the last. Here is
the picture below,

 

 

Telco.Rpart.PLOT.TEXT.Functn -
function(Telco.Rpart.METHOD.CLASS)

{

Telco.Rpart.PLOT -
plot(Telco.Rpart.METHOD.CLASS,compress=FALSE,uniform=TRUE)

Telco.Rpart.TEXT -
text(Telco.Rpart.METHOD.CLASS,use.n = TRUE, cex = .75)

}

 

  Telco.Rpart.PLOT.TEXT -
Telco.Rpart.PLOT.TEXT.Functn(Telco.Rpart.METHOD.CLASS)

Telco.Rpart.PLOT.TEXT

 

 

Again if I solely run the command Telco.Rpart.PLOT.TEXT, the output it is
displaying as NULL. Please help me finding out the desired result ASAP.

 

 

Regards,

Yashwanth M.R

 

 

 

From: Uwe Ligges-3 [via R] [mailto:ml-node+s789695n4417618...@n4.nabble.com]

Sent: Friday, February 24, 2012 9:16 PM
To: Yashwanth M.R
Subject: Re: To define a function which includes two functions as arguments
such as plot and text

 



On 24.02.2012 12:22, Yashwanth M.R wrote: 


 Here is the two functions which I have used during my practice. 
 
 *plot(Telco.rpart.METHOD.CLASS,compress=FALSE,uniform=TRUE) 
 
 text(Telco.rpart.METHOD.CLASS,use.n = TRUE, cex = .75))* 
 
 Telco.rpart.METHOD.CLASS is my rpart object of the method class. 
 
 If I run this, 
 
 *Telco.Rpart.PLOT.TEXT- 
 c(plot(Telco.rpart.METHOD.CLASS,compress=FALSE,uniform=TRUE), 
 text(Telco.rpart.METHOD.CLASS,use.n = TRUE, cex = 
 .75)) 



c() concatenates the returned values of the two functions. If you want 
to define a sequence of function calls, define them within your own 
function, calling that new function will produce your desired results, 
as far as I understand. 

Uwe Ligges 


 
 http://r.789695.n4.nabble.com/file/n4416881/Rpart.gif
 
 the output is getting generated as shown in the figure. But if I solely
run 
 the same command Telco.Rpart.PLOT.TEXT right after the above, the output

 is as below, 
 
 /$x 
   [1]  4.035156  1.00  7.070312  3.015625  2.00  4.031250 
   [7]  3.00  5.062500  4.00  6.125000  5.00  7.25 
 [13]  6.50  6.00  7.00  8.00 11.125000 10.25 
 [19]  9.50  9.00 10.00 11.00 12.00 
 
 $y 
   [1] 1.125 1.000 1.000 0.875 0.750 0.750 0.625 0.625 0.500 0.500 0.375 
 [12] 0.375 0.250 0.125 0.125 0.250 0.875 0.750 0.625 0.500 0.500 0.625 
 [23] 0.750 
 / 
 
 
 Please help me in getting the output which is there is the Image.. 
 
 Regards, 
 Yashwanth M,R 
 
 -- 
 View this message in context:
http://r.789695.n4.nabble.com/To-define-a-function-which-includes-two-functi
ons-as-arguments-such-as-plot-and-text-tp4416881p4416881.html
 Sent from the R help mailing list archive at Nabble.com. 
 
 __ 
 [hidden email] mailing list 
 https://stat.ethz.ch/mailman/listinfo/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] mailing list 
https://stat.ethz.ch/mailman/listinfo/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/To-define-a-function-which-includes-two-functi
ons-as-arguments-such-as-plot-and-text-tp4416881p4417618.html 

To unsubscribe from To define a function which includes two functions as
arguments such as plot and text, click here
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by
_codenode=4416881code=eWFzaHdhbnRoQHByZWRpY3RpdmVhbmFseXRpY3MuaW58NDQxNjg4
MXwyOTE4OTgwMjc= .
 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_vieweri
d=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamesp
ace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNa
mespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%
21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml NAML 



--
View this message in context: 
http://r.789695.n4.nabble.com/To-define-a-function-which-includes-two-functions-as-arguments-such-as-plot-and-text-tp4416881p4427151.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] kmeans: how to retrieve clusters

2012-02-27 Thread Peter Langfelder
On Mon, Feb 27, 2012 at 3:18 PM, ikuzar raz...@hotmail.fr wrote:
 Hello,

 I'd like to classify data with kmeans algorithm. In my case, I should get  2
 clusters in output. Here is my data

 colCandInd       colCandMed
 1       82                2950.5
 2       83               1831.5
 3       1192     2899.0
 4       1193     2103.5

 The first cluster is the two first lines
 the 2nd cluster is the two last lines

 Here is the code:
 x = colCandList$colCandInd
 y = colCandList$colCandMed
 m = matrix(c(x, y), nrow = length(colCandList$colCandInd), ncol=2)
 kres = kmeans(m, 2)

 Is there a way to retrieve both clusters in output of the algorithm in order
 to process in each cluster ? (I am looking for smthing like kres$clustList
 ... where I can process each cluster)

 kres$cluster did not yield what I expected ...

Not sure what you mean by process each cluster and why kres$cluster
is not what you expected. kres$cluster will tell you which cluster
each point (row of your matrix) belongs to. The result depends on how
you initialize the kmeans since the inter-point distances are quite
similar to one another. For example, I get

  set.seed(10)
  kres = kmeans(m, 2)
 kres$cluster
[1] 2 2 1 1
 set.seed(1)
 kres = kmeans(m, 2)
 kres$cluster
[1] 1 1 2 2
 set.seed(200)
 kres = kmeans(m, 2)
 kres$cluster
[1] 2 2 1 1
 kres = kmeans(m, 2)
 kres$cluster
[1] 1 2 1 2

So 3 times out of 4 I get the result you expect, and once a different one.

If you need the result in a different format, that should be no problem.

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


[R] e1071 : class.weights

2012-02-27 Thread Yuliya Matveyeva
Dear R-society,

 I know this is probably a question to LibSVM, but I have not found a
LibSVM mailing list, so I would be really grateful if someone from this
list helped me.
 In the LibSVM documentation I have found a passage about dealing with
unbalanced sets, that says that in this case one sets two different
regularization parameters C^{-} and C^{+}. However I am not sure about how
this corresponds to the parameters in the svm function. There I find C and
class.weights. So am I right supposing that
 C^{-} = class.weights[1]*C and C^{+} = class.weights[2]*C ?

-- 
Sincerely yours,
Yulia Matveyeva,
Department of Statistical Modelling,
Faculty of Mathematics and Mechanics,
St Petersburg State University, Russia

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