[R] Why does sin(pi) not return 0?

2013-09-26 Thread Babak Bastan
Hi experts, If I test sin(pi) in r, it returns me 1.224606e-16 Why doesn't return me 0? [[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 htt

Re: [R] Why does sin(pi) not return 0?

2013-09-26 Thread Pascal Oettli
Hi, A part of the answer is: > format(sin(pi), scientific=FALSE, digits=20) and also R FAQ 7.31 On my machine, > sin(pi) [1] 1.224647e-16 Regards, Pascal 2013/9/26 Babak Bastan > Hi experts, > > If I test sin(pi) in r, it returns me 1.224606e-16 > > Why doesn't return me 0? > >

Re: [R] Why does sin(pi) not return 0?

2013-09-26 Thread Rolf Turner
On 09/26/13 19:31, Babak Bastan wrote: Hi experts, If I test sin(pi) in r, it returns me 1.224606e-16 Why doesn't return me 0? If you think that 1.224606e-16 is different from 0, you should probably not be using computers. See FAQ 7.31 (which is in a way about the inverse of your question, b

[R] error handling

2013-09-26 Thread Michael Meyer
Greetings,   Error handling does not seem to work as expected. When a handler for general conditions is provided in first position in the handler list it will be called regardless of what condition has been signalled.   See sample code, move  "condition = function(c){...}" to first position in h

Re: [R] Why does sin(pi) not return 0?

2013-09-26 Thread Ted Harding
On 26-Sep-2013 07:55:38 Rolf Turner wrote: > On 09/26/13 19:31, Babak Bastan wrote: >> Hi experts, >> >> If I test sin(pi) in r, it returns me 1.224606e-16 >> >> Why doesn't return me 0? > > If you think that 1.224606e-16 is different from 0, you should probably not > be using computers. Is that

Re: [R] Why does sin(pi) not return 0?

2013-09-26 Thread Rainer M Krug
(Ted Harding) writes: > On 26-Sep-2013 07:55:38 Rolf Turner wrote: >> On 09/26/13 19:31, Babak Bastan wrote: >>> Hi experts, >>> >>> If I test sin(pi) in r, it returns me 1.224606e-16 >>> >>> Why doesn't return me 0? >> I think this should be a Fortune: , | >> If you think that 1.224606e-16

[R] Cosine window in r

2013-09-26 Thread Bretschneider (R)
Dear Babak Bastan, Re: > > Can some one tell me, how can I implement Cosine window in r? Is there a > function for that? > The Hanning window is a cosine windowing function, to multiply sample signals with (before an FFT etc.). e.g. z = y*hanning(256) It resides in the 'signal' package. Ho

[R] Override default colour scheme of an effects plot

2013-09-26 Thread Melanie Zoelck
Dear R-Help Members, I have created a few effects plots using the effects package and I am wondering if there is an option to override the default colour scheme of these plots and so as to create the same plot but in greyscale, as this is much better for publication to avoid colour charges. Th

Re: [R] Why does sin(pi) not return 0?

2013-09-26 Thread John Kane
Definitely a Fortune. John Kane Kingston ON Canada > -Original Message- > From: rai...@krugs.de > Sent: Thu, 26 Sep 2013 11:30:27 +0200 > To: r-h...@stat.math.ethz.ch > Subject: Re: [R] Why does sin(pi) not return 0? > > (Ted Harding) writes: > >> On 26-Sep-2013 07:55:38 Rolf Turner w

Re: [R] request for help in R

2013-09-26 Thread John Kane
John Kane Kingston ON Canada -Original Message- From: atta_...@yahoo.com Sent: Wed, 25 Sep 2013 23:16:48 -0700 (PDT) To: jrkrid...@inbox.com Subject: Re: [R] request for help in R hi, i have data for 15 gauging stations of different rivers and for monthly maxmimum flows data, i want to

Re: [R] Why does sin(pi) not return 0?

2013-09-26 Thread Suzen, Mehmet
On 26 September 2013 11:30, Rainer M Krug wrote: Why doesn't return me 0? It isn't R question at all. You might want to read about representing real numbers in a computer using floating point http://en.wikipedia.org/wiki/Floating_point If you want more precision for some reason, you may wan

Re: [R] Why does sin(pi) not return 0?

2013-09-26 Thread Pierrick Bruneau
Just to add a small note, sin(pi) is below machine precision : > .Machine$double.eps [1] 2.220446e-16 (see ?.Machine for exact definition) -> if myval is bounded to be positive, one safe way of testing equality to 0 would then be "myval < .Machine$double.eps" On Thu, Sep 26, 2013 at 2:48 PM,

[R] moving a window over a matrix column

2013-09-26 Thread Babak Bastan
Greeting I want to move a window over a column in a Matrix. For example. I have a 8X1 Matrix and I want to read the data from 1 until 5, for the second time 2 until 6, third time 3 till 7 and... and do something on this values and show them in a diagramm: I wrote this code: #here I make an nX1 M

Re: [R] Why does sin(pi) not return 0?

2013-09-26 Thread David Winsemius
On Sep 26, 2013, at 8:06 AM, Pierrick Bruneau wrote: Just to add a small note, sin(pi) is below machine precision : .Machine$double.eps [1] 2.220446e-16 (see ?.Machine for exact definition) -> if myval is bounded to be positive, one safe way of testing equality to 0 would then be "myval

Re: [R] moving a window over a matrix column

2013-09-26 Thread Bert Gunter
Perhaps ?filter -- Bert On Thu, Sep 26, 2013 at 6:30 AM, Babak Bastan wrote: > Greeting > > I want to move a window over a column in a Matrix. For example. I have a > 8X1 Matrix and I want to read the data from 1 until 5, for the second time > 2 until 6, third time 3 till 7 and... and do some

Re: [R] table of contents link style in R's PDF docs

2013-09-26 Thread Ista Zahn
Hi Ben, On Wed, Sep 25, 2013 at 11:38 PM, Ben Harrison wrote: > Hello, > I am mildly annoyed each time I use a PDF doc of an R package that the table > of contents hyperlinks are *only* on the page numbers. To activate a > hyperlink, one must carefully scan sideways from the text item wanted to

Re: [R] moving a window over a matrix column

2013-09-26 Thread David Winsemius
On Sep 26, 2013, at 8:30 AM, Babak Bastan wrote: Greeting I want to move a window over a column in a Matrix. For example. I have a 8X1 Matrix and I want to read the data from 1 until 5, for the second time 2 until 6, third time 3 till 7 and... and do something on this values and show th

[R] Boxplot from statistics of original data

2013-09-26 Thread Rodrigo César da Silva
Hi, I have a data set that contains a set of universities and a number of statistics about the performance of students on an exam. A sample of the table follows: Institutions_Name Mean Median Minimum Maximum 1Quartile 3Quartile CENTRO UNIVERSITÁRIO LUTERANO DE MANAUS 58,5 57,5 0 98

[R] Installing Rcplex

2013-09-26 Thread Davide Luciani
Hi, I have tried to install the R package Rcplex on windows xp without success. I have only cplex_studio124.win-x86-32 version. I have modified the makevars.win file as indicated in the installation guide ( http://cran.r-project.org/web/packages/Rcplex/INSTALL ), then I zipped the whole folder

[R] R hangs at NGramTokenizer

2013-09-26 Thread Neep Hazarika
Hi: I try to construct a Document-Term Meatrix from a corpus. The commands I used are: > library(parallel)> library(tm)> library(RWeka)> library(topicmodels)> > library(RTextTools)> cl=makeCluster(detectCores())> > invisible(clusterEvalQ(cl, library(tm)))> invisible(clusterEvalQ(cl, > library(R

Re: [R] Why does sin(pi) not return 0?

2013-09-26 Thread Martin Maechler
> Suzen, Mehmet > on Thu, 26 Sep 2013 14:48:52 +0200 writes: > On 26 September 2013 11:30, Rainer M Krug wrote: > Why doesn't return me 0? > It isn't R question at all. You might want to read about representing > real numbers in a computer using floating point

Re: [R] table of contents link style in R's PDF docs

2013-09-26 Thread Duncan Murdoch
On 25/09/2013 11:38 PM, Ben Harrison wrote: Hello, I am mildly annoyed each time I use a PDF doc of an R package that the table of contents hyperlinks are *only* on the page numbers. To activate a hyperlink, one must carefully scan sideways from the text item wanted to the far right of the page a

Re: [R] moving a window over a matrix column

2013-09-26 Thread Berend Hasselman
On 26-09-2013, at 15:30, Babak Bastan wrote: > Greeting > > I want to move a window over a column in a Matrix. For example. I have a > 8X1 Matrix and I want to read the data from 1 until 5, for the second time > 2 until 6, third time 3 till 7 and... and do something on this values and > show th

[R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Magnus Thor Torfason
Just ran these two statements: > min(NA,"bla") [1] NA > min("bla", NA) [1] "bla" And then reran with explicit na.rm=FALSE > min(NA,"bla", na.rm=FALSE) [1] NA > min("bla", NA, na.rm=FALSE) [1] "bla" That seems wrong. Would this be considered a bug or is there a way to explain these results

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread arun
Hi,  min(5,1) #[1] 1  min(c(1,5)) #[1] 1  min(c(1,5))==min(c(5,1)) #[1] TRUE   min(c(NA,"bla")) #[1] NA  min(c("bla",NA)) #[1] NA  min(c("bla",NA),na.rm=FALSE) #[1] NA  min(c("bla",NA),na.rm=TRUE) #[1] "bla" A.K. - Original Message - From: Magnus Thor Torfason To: "r-help@r-projec

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Ista Zahn
Hi A.K., On Thu, Sep 26, 2013 at 11:22 AM, arun wrote: > Hi, > min(5,1) > #[1] 1 > > > min(c(1,5)) > #[1] 1 > min(c(1,5))==min(c(5,1)) > #[1] TRUE > > > > min(c(NA,"bla")) > #[1] NA > min(c("bla",NA)) > #[1] NA > min(c("bla",NA),na.rm=FALSE) > #[1] NA > min(c("bla",NA),na.rm=TRUE) > #[1]

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Bert Gunter
Please update your R version (as requested by the posting guide) and repeat. On my version: > min(c(NA,"b")) [1] NA > min(c("b",NA)) [1] NA Note that ?min specifically states: "If na.rm is FALSE [the default - BG] an NA value in any of the arguments will cause a value of NA to be returned, othe

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread arun
min(c(NA,"bla"),na.rm=FALSE) [1] NA > min(c("bla",NA),na.rm=FALSE) [1] NA A.K. - Original Message - From: Ista Zahn To: arun Cc: Magnus Thor Torfason ; R help Sent: Thursday, September 26, 2013 11:36 AM Subject: Re: [R] min(NA,"bla") != min("bla", NA) Hi A.K., On Thu, Sep 26, 2013 a

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Bert Gunter
Hi again: After reading Ista's note I tried: > min("bla",NA) [1] "bla" So I stand corrected. This appears to be a bug. -- Bert On Thu, Sep 26, 2013 at 8:07 AM, Magnus Thor Torfason < zulutime@gmail.com> wrote: > Just ran these two statements: > > > min(NA,"bla") > [1] NA > > > min("bla"

[R] How to catch errors regarding the hessian in 'optim'

2013-09-26 Thread Michael Meyer
I am weighing in even though I know nothing. in tryCatch define an error handler error = function(e){ text <- print(e)    # surely there must be better ways # parse text for substring 'optim' or more strongly characteristic substrings # you have already seen to emerge from

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread William Dunlap
I'd say that is a bug. Furthermore, min(NA, "bla") returns an integer instead of a character and the results depend on whether the NA is of class "logical" or "character". > str(min(as.logical(NA), "bla")) # expect character NA int NA > str(min("bla", as.logical(NA))) # expect character NA

Re: [R] Installing Rcplex

2013-09-26 Thread Prof Brian Ripley
On 26/09/2013 09:06, Davide Luciani wrote: Hi, I have tried to install the R package Rcplex on windows xp without success. I have only cplex_studio124.win-x86-32 version. I have modified the makevars.win file as indicated in the installation guide ( http://cran.r-project.org/web/packages/Rcpl

Re: [R] How to catch errors regarding the hessian in 'optim'

2013-09-26 Thread William Dunlap
> in tryCatch define an error handler > > error = function(e){ > > text <- print(e)# surely there must be better ways > > # parse text for substring 'optim' or more strongly characteristic > substrings Note that print() should aways return its 'x' argument, so 'text' and 'e' wi

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Marc Schwartz
Arun, This additional example is still irrelevant. The difference occurs when the two values are passed as the "..." argument to min(), which is a list and is what Magnus was using, versus your examples, where the two values are passed as a single vector, which is coerced to character: > str(

[R] help generalizing the following non-symmetric "identity"-like matrix

2013-09-26 Thread Charlie Brown
Hi, I need help generalizing the following non-symmetric "identity"-like matrix In this case: p = 5 k=3 and I want this: I.kp <- cbind(diag(3), c(0, 0, 0), c(0, 0, 0)) How can I generalize this so that I don't have to add/subtract c(0, 0, ... , 0) when p and k changes? Hopefully that makes sen

Re: [R] help generalizing the following non-symmetric "identity"-like matrix

2013-09-26 Thread William Dunlap
> p <- 5 > k <- 3 > identical(cbind(diag(3), c(0, 0, 0), c(0, 0, 0)), diag(nrow=k, ncol=p)) [1] TRUE Look at help(diag). 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 >

[R] RODBC Package help ----binding issue

2013-09-26 Thread Singh, Mandeep - 2
Hi All, There's a function called setSqlTypeInfo(driver,value) in RODBC package http://cran.r-project.org/web/packages/RODBC/index.html Description Specify or retrieve a mapping of R types to DBMS datatypes. >From the package(RODBC) TypeInfo.r: setSqlTypeInfo <- function(driver, value) {

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Duncan Murdoch
On 26/09/2013 11:07 AM, Magnus Thor Torfason wrote: Just ran these two statements: > min(NA,"bla") [1] NA > min("bla", NA) [1] "bla" And then reran with explicit na.rm=FALSE > min(NA,"bla", na.rm=FALSE) [1] NA > min("bla", NA, na.rm=FALSE) [1] "bla" That seems wrong. Would this be

[R] plot multiple graphs in one graph and in multiple windows

2013-09-26 Thread Hui Du
Hi All, I have a question about plotting graphs. Supposedly, I want to plot 12 graphs. Putting 12 graphs to one window seems too crowded. Ideally, I want to put 4 pictures in one window and plot them in three separate window. For exmaple, my psuedo code is like par(mfrow = c(2, 2)) for( I i

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Duncan Murdoch
On 26/09/2013 11:07 AM, Magnus Thor Torfason wrote: Just ran these two statements: > min(NA,"bla") [1] NA > min("bla", NA) [1] "bla" And then reran with explicit na.rm=FALSE > min(NA,"bla", na.rm=FALSE) [1] NA > min("bla", NA, na.rm=FALSE) [1] "bla" This should be all fixed now (at

[R] R not ploting lines in the correct order

2013-09-26 Thread Shane Carey
Hi, I have a set of x, y points where x represents dates and y actual values. I am trying to plot a line graph of the data with points on top, but R is connecting the wrong points with lines. Does anyone know how I can rectify this. Please see sample below: x= 24/09/2009 09:13 16/10/2009 11:17

[R] Help with list

2013-09-26 Thread Sebastian Kruk
I have a list that gives me the number of occurrences of numbers 1, 2, 3 and 4. Sometimes a single in a casa just appears 0 and 1, in others only 2, and every combination you can think of. Eg > Caso [1:2] $ `9` 0 1 2 10 $ `13` 0 2 2 4 Can I turn it into a matrix consisting of 4 colum

Re: [R] R not ploting lines in the correct order

2013-09-26 Thread Sarah Goslee
Hi Shane, Please use dput() to provide your data, rather than pasting it in so that we can work from the same R object you are. Please also provide the code you're using to make the graph. Sarah On Thu, Sep 26, 2013 at 1:56 PM, Shane Carey wrote: > Hi, > > I have a set of x, y points where x re

Re: [R] Help with list

2013-09-26 Thread Gabor Grothendieck
On Thu, Sep 26, 2013 at 2:02 PM, Sebastian Kruk wrote: > I have a list that gives me the number of occurrences of numbers 1, 2, 3 and > 4. > > > Sometimes a single in a casa just appears 0 and 1, in others only 2, and every > combination you can think of. > > > Eg > > >> Caso [1:2] > $ `9` > > >

Re: [R] Help with list

2013-09-26 Thread arun
Hi, May be this help: Please dput() the example dataset: Caso<- structure(list(`9` = structure(c(2, 10), .Names = c("0", "1")),     `13` = structure(c(2, 4), .Names = c("0", "2"))), .Names = c("9", "13")) nm<-unique(unlist(lapply(Caso,names)))  vec1<- numeric(length(nm)) names(vec1)<- nm  do.ca

[R] Constructing a graph with ggplot2.

2013-09-26 Thread Caitlin
Hi all. I am attempting to graph data from three lab teams with milligrams of maltose shown on the y-axis and 5 pH values (5 to 9) on the x-axis as labels. Unfortunately, I can't seem to construct the graph in this manner using the following code: ph1 = c(5, 6, 7, 8, 9) ph2 = ph3 = ph1 e1 = c(0

[R] Read shortcuts of MS Excel files through R

2013-09-26 Thread Santosh
Dear Rxperts, Through Windows OS, I created shortcuts (paste as shortcut) to excel spreadsheets ( with "xlsx" as the file extension). I wasn't able to read the shortcuts through R and using "read" functions of "xlsx" package. exf <- "a1.xlsx.lnk" > read.xlsx(exf,1) Error in .jcall("RJavaTools",

[R] question regarding cast function in reshape package with mixture of numeric and character

2013-09-26 Thread Jack Luo
Hi, I am trying to process some data frame with cast function to unwind the stacked variables. I have no problem using cast when the values are all numeric based on the following format: cast(df,subject~v1+v2+v3,value = "value",fun.aggregate = mean, fill = "NA") However, I am getting some tr

Re: [R] Grouping Matrix by Columns; OHLC Data

2013-09-26 Thread arun
HI, May be this helps: set.seed(24)  mat1<- matrix(sample(1:60,30*24,replace=TRUE),ncol=24) colnames(mat1)<- rep(c("O","H","L","C"),6) indx<-seq_along(colnames(mat1)) n<- length(unique(colnames(mat1)))  res<- lapply(split(indx,(indx-1)%%n+1),function(i) mat1[,i]) lapply(res,head,2) #$`1` #  O 

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Rolf Turner
Just to add to the confusion, on my system I get NA --- which I understand to be the correct value --- from all of min(NA,"bla"), min("bla",NA), min(c(NA,"bla")), and min(c("bla",NA)). When I append the argument na.rm=TRUE to each of the calls, I get "bla" from each. So, no bug in my system

Re: [R] Constructing a graph with ggplot2.

2013-09-26 Thread Brian Diggs
On 9/26/2013 1:45 PM, Caitlin wrote: > Hi all. > > I am attempting to graph data from three lab teams with milligrams of > maltose shown on the y-axis and 5 pH values (5 to 9) on the x-axis as > labels. Unfortunately, I can't seem to construct the graph in this manner > using the following code: >

Re: [R] question regarding cast function in reshape package with mixture of numeric and character

2013-09-26 Thread Jeff Newmiller
I am baffled. Just what do you want it to do? In melted form the data are all in one column and so are necessarily of one type... there are no mixed types to cast. As usual, assistance here will be more useful when you follow the Posting Guide and post plain text only and give reproducible exam

[R] Sums based on values of other matrix

2013-09-26 Thread tobias schlager
Dear all, I have a big problem: - I got two matrices, A and B - A shows identifies the value of B, however the values of B must be summed - For instance, 1 1 2 2 2 2 1 1 gives matrix a 3 4 2 1 1 1 2 2 gives matrix b Now the result for the value 1 would be 7 4 which are the rowsums o

Re: [R] Boxplot from statistics of original data

2013-09-26 Thread Greg Snow
The boxplot function calls other functions, the boxplot.stats function calculates the stats, then the bxp function does the actual plotting. So just look at the structure of the object that is passed to bxp, reformat your data to that structure, and call bxp directly. On Thu, Sep 26, 2013 at 8:1

Re: [R] Sums based on values of other matrix

2013-09-26 Thread Sarah Goslee
Hi, You don't say what you want to do with the output, or whether you want to do it with more than one value, but here's one of the many possible ways to get your example: R> A <- matrix(c(1,1,2,2,2,2,1,1), nrow=2, byrow=TRUE) R> B <- matrix(c(3,4,2,1,1,1,2,2), nrow=2, byrow=TRUE) R> A [,1]

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Sarah Goslee
Sorry Rolf, but it's not just Windows (though I completely understand the urge to blame it): R> sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-redhat-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC

Re: [R] Read shortcuts of MS Excel files through R

2013-09-26 Thread Sarah Goslee
Hi, On Thu, Sep 26, 2013 at 4:54 PM, Santosh wrote: > Dear Rxperts, > > Through Windows OS, I created shortcuts (paste as shortcut) to excel > spreadsheets ( with "xlsx" as the file extension). I wasn't able to read > the shortcuts through R and using "read" functions of "xlsx" package. A shortc

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Don McKenzie
I had the same outcome as Sarah on mac OSX 10.8. R 3.0.1 On Sep 26, 2013, at 3:03 PM, Sarah Goslee wrote: > Sorry Rolf, but it's not just Windows (though I completely understand > the urge to blame it): > > R> sessionInfo() > R version 3.0.1 (2013-05-16) > Platform: x86_64-redhat-linux-gnu (64-

[R] Is it possible with two random effects in lme()?

2013-09-26 Thread Bettina Lado Lindner
Hello, I want two random effect in R. One is BLOQUE nested in REP and the other is TRAT. I don’t know how put TRAT independant of the other random effect. My model until this step is ok: data_2010_ECCI_ensayo$le1=groupedData(REND~ REP|BLOQUE, data=data_2010_ECCI_ensayo$le1) lmer_ECC2010_le1AR

[R] Unexpected input error

2013-09-26 Thread Alan Randolph
Hi, I am newbie to R so pardon me if this is not the forum for asking this question. I am getting the error "unexpected input in "evalq({‚" in the Boost Tutorial example section 13.3 of Graham William's, "Data Mining with Rattle and R. Below is the line as I have entered it and version i

[R] Re : Re: Re : Re: Re : Privacy rights of an old user of this list

2013-09-26 Thread John Gonzalez
Dear Uwe, - Message d'origine - De : Uwe Ligges Envoyés : 22.09.13 10:55 À : John Gonzalez Objet : Re: Re : Re: [R] Re : Privacy rights of an old user of this list >> On 21.09.2013 22:40, John Gonzalez wrote: >> As I said previously, I'm only concerned about what was published in the >> a

Re: [R] ConstrOptim Function (Related to Constraint Matrix/ui/ci error)

2013-09-26 Thread Munjal Patel
Hello All, I am stuck in the following problem. Cexpt=c(0,25,50,100,150,300,250,125,40) t=c(0,0.2,0.4,0.6,1,4,8,12,24) theta0= vector of 6 parms (My initial parameter) A=Constraint matrix (hopefully 6*6) B= Constraint vector of length 6) Cfit=function(t,theta){ J(t)=function(theta,t)

[R] ConstrOptim function Error

2013-09-26 Thread Munjal Patel
I am sorry for the previous email. I am getting such error while fitting in it. Am i missing something big in it ? Please guide me. Thanks a lot rm(list=ls()) >V=1 ;ke=0.5 t=c(0.00,0.20,0.50,1.00,2.00,4.00,6.00,8.00,12.00,18.00,24.00,30.00) A=identitty matrix of 6*6 ## Constraint Ma

Re: [R] plot multiple graphs in one graph and in multiple windows

2013-09-26 Thread Greg Snow
I think that you want: if (i %% 4 == 1 ) { dev.new() par(mfrow=c(2,2)) } or with the R 3.0.2 it looks like you will be able to do: if( par('page') ) { dev.new() par(mfrow=c(2,2)) } On Thu, Sep 26, 2013 at 10:47 AM, Hui Du wrote: > > Hi All, > > I have a question about plotting grap

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Duncan Murdoch
On 13-09-26 5:32 PM, Rolf Turner wrote: Just to add to the confusion, on my system I get NA --- which I understand to be the correct value --- from all of min(NA,"bla"), min("bla",NA), min(c(NA,"bla")), and min(c("bla",NA)). When I append the argument na.rm=TRUE to each of the calls, I get "bla

Re: [R] Sums based on values of other matrix

2013-09-26 Thread arun
Hi, Try: A<- structure(c(1, 2, 1, 2, 2, 1, 2, 1), .Dim = c(2L, 4L)) B<- structure(c(3, 1, 4, 1, 2, 2, 1, 2), .Dim = c(2L, 4L))  B1<- matrix(0,nrow(B),ncol(B)) B1[A==1]<-B[A==1]  rowSums(B1) #[1] 7 4 A.K. - Original Message - From: tobias schlager To: "r-help@r-project.org" Cc: Sent:

Re: [R] Grouping Matrix by Columns; OHLC Data

2013-09-26 Thread arun
Hi Jake. Sorry, I misunderstood about what you wanted. Instead of this: lapply(split(indx,(indx-1)%%n+1),function(i) mat1[,i]) If I use: res1<- lapply(split(indx,(indx-1)%/%n+1),function(i) mat1[,i]) #or lapply(split(indx, as.numeric(gl(ncol(mat1),n,ncol(mat1,function(i) mat1[,i])  lapp

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Duncan Murdoch
On 13-09-26 5:32 PM, Rolf Turner wrote: Just to add to the confusion, on my system I get NA --- which I understand to be the correct value --- from all of min(NA,"bla"), min("bla",NA), min(c(NA,"bla")), and min(c("bla",NA)). When I append the argument na.rm=TRUE to each of the calls, I get "bla

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Rolf Turner
On 09/27/13 10:34, Duncan Murdoch wrote: On 13-09-26 5:32 PM, Rolf Turner wrote: Just to add to the confusion, on my system I get NA --- which I understand to be the correct value --- from all of min(NA,"bla"), min("bla",NA), min(c(NA,"bla")), and min(c("bla",NA)). When I append the argument n

Re: [R] Is it possible with two random effects in lme()?

2013-09-26 Thread Ben Bolker
Bettina Lado Lindner hotmail.com> writes: > Hello, > I want two random effect in R. One is BLOQUE nested in REP > and the other is TRAT. I don’t know how put TRAT > independant of the other random effect. [snip] > I know that in lmer is easier but I use error correlation > so I need use l

Re: [R] Is it possible with two random effects in lme()?

2013-09-26 Thread Bert Gunter
I suggest you post this to the r-sig-mixed-models list instead. You are much more likely to get useful answers there. Cheers, Bert On Thu, Sep 26, 2013 at 11:25 AM, Bettina Lado Lindner wrote: > Hello, > I want two random effect in R. One is BLOQUE nested in REP and the other > is TRAT. I donâ

Re: [R] Sums based on values of other matrix

2013-09-26 Thread arun
Hi, If you have missing values:  set.seed(125)  A<- matrix(sample(c(NA,0:9),10*10,replace=TRUE),10,10)  set.seed(49)  B<- matrix(sample(c(NA,1:25),10*10,replace=TRUE),10,10) B1<- matrix(0,nrow=nrow(B),ncol=ncol(B))  B1[A==1 & !is.na(A)]<- B[A==1 & !is.na(A)]  rowSums(B1)  #[1]  0  0 38  7 16  0  0 

Re: [R] Sums based on values of other matrix

2013-09-26 Thread arun
Just to add: If you had missing values in both matrices, then some values in B matrix that are NA's could also replace the values in A that are 1. So, it is better to use: rowSums(B1,na.rm=TRUE) A.K. - Original Message - From: arun To: tobias schlager Cc: R help Sent: Thursday, Se

Re: [R] Read shortcuts of MS Excel files through R

2013-09-26 Thread Marc Schwartz
Hi, I am not on Windows so cannot test this, but a search reveals that in the R.utils CRAN package by Henrik Bengtsson, there is the readWindowsShortcut() function which may provide some assistance in getting the path to the actual file. Thus: install.package("R.utils", dependencies = TR

Re: [R] Boxplot from statistics of original data

2013-09-26 Thread Jim Lemon
On 09/27/2013 12:10 AM, Rodrigo César da Silva wrote: Hi, I have a data set that contains a set of universities and a number of statistics about the performance of students on an exam. A sample of the table follows: Institutions_Name Mean Median Minimum Maximum 1Quartile 3Quartile CEN

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Rolf Turner
On 09/27/13 11:07, Duncan Murdoch wrote: On 13-09-26 5:32 PM, Rolf Turner wrote: Just to add to the confusion, on my system I get NA --- which I understand to be the correct value --- from all of min(NA,"bla"), min("bla",NA), min(c(NA,"bla")), and min(c("bla",NA)). When I append the argument n

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Ista Zahn
On Thu, Sep 26, 2013 at 9:10 PM, Rolf Turner wrote: > On 09/27/13 11:07, Duncan Murdoch wrote: >> >> On 13-09-26 5:32 PM, Rolf Turner wrote: >>> >>> >>> Just to add to the confusion, on my system I get NA --- which I >>> understand to be >>> the correct value --- from all of min(NA,"bla"), min("bl

Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-26 Thread Duncan Murdoch
On 13-09-26 9:26 PM, Ista Zahn wrote: On Thu, Sep 26, 2013 at 9:10 PM, Rolf Turner wrote: On 09/27/13 11:07, Duncan Murdoch wrote: On 13-09-26 5:32 PM, Rolf Turner wrote: Just to add to the confusion, on my system I get NA --- which I understand to be the correct value --- from all of min(

[R] somewhat ineffective suppressing intercepts

2013-09-26 Thread Ross Boylan
Suppressing the intercept and contr.sum coding are not quite working as I expect: > mf <- data.frame(A=C(factor(c("a", "b", "c")), contr.sum)) > mm <- model.matrix(~0+A, data=mf) > mm Aa Ab Ac 1 1 0 0 2 0 1 0 3 0 0 1 What I expect (and want) is A1 A2 1 10 2 01 3 11 W

[R] snow::makeCluster on Windows hangs

2013-09-26 Thread Jeffrey Flint
The command which hangs: I'm hoping there is a simple explanation, but I searched on-line and nothing jumped out. > cl <- makeCluster(type="SOCK",c("localhost"),manual=TRUE) Manually start worker on localhost with C:/PROGRA~1/R/R-214~1.2/bin/Rscript.exe "C:/Program Files/R/R-2.14.2/library/sn

[R] Calculating euclidean distance in R

2013-09-26 Thread Debasish Sahu
Hello, I am quite new to R.(in fact for the first time I am using) So forgive me if I have asked a silly question. I have a table in.csv format with data for location of samples in X, Y, Z (column)format. Now I want to calculate the Euclidean distance for the total sample dataset. Can you please

Re: [R] Calculating euclidean distance in R

2013-09-26 Thread Bert Gunter
Have you read the Intoduction to R or other online tutorials to learn how R works before posting here? If not, please do so. -- Cheers, Bert On Thu, Sep 26, 2013 at 9:26 PM, Debasish Sahu wrote: > Hello, > I am quite new to R.(in fact for the first time I am using) > So forgive me if I have as

Re: [R] snow::makeCluster on Windows hangs

2013-09-26 Thread Prof Brian Ripley
You failed to mention this about contributed package 'snow' (and a long obsolete version of R: see the postin guide). That version of R has package 'parallel' which would be preferred. But it looks like you did not manually start the workers (and I am not sure why you would want to do that).

Re: [R] table of contents link style in R's PDF docs

2013-09-26 Thread Ben Harrison
On 27/09/13 00:03, Ista Zahn wrote: Hi Ben, On Wed, Sep 25, 2013 at 11:38 PM, Ben Harrison wrote: Hello, I agree that it would be nicer to have the whole TOC entry hyperlinked. But out of curiosity, why are you using the pdf documentation? I find the html much nicer. Best, Ista It's ju

Re: [R] table of contents link style in R's PDF docs

2013-09-26 Thread Ben Harrison
On 27/09/13 00:33, Duncan Murdoch wrote: On 25/09/2013 11:38 PM, Ben Harrison wrote: Hello, It's been the way it is for about 14 years, and I don't recall anyone else complaining, so I'd conclude it must have been set that way with you in mind. Ah-hah, I knew it! I *am* special. More ser

Re: [R] Read shortcuts of MS Excel files through R

2013-09-26 Thread Mark Lamias
Assuming you are trying to read the contents of the Excel files and not the shortcut itself, try something link this: #C:\users\mark\desktop\A1.xlsx.lnk is a shortcut I created on my desktop to an xlsx document in another directory #The windows type command, along with find gets the path to the