[R] displaying percentage in bar plot
Hi, I have a query regarding barplot I have a following data AIS LEvel 1 23 body regionA 10 15 20 B 15 25 15 Now I want to plot a barplot and in each bar (corresponding a body region), I need a percentage of AIS level 1 displayed in the plot. Is there an easy way to do this ? Thanks, Nataraju GM -- "No relationship is Static .. You either Step up or Step down" [[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] issue building my own package... moving from Apple OS to Windows
Hello, I have written my own very simple package. On an Apple, I was able to run through the "R CMD build" and "R CMD check" successfully. I have also installed the package, and successfully loaded the library on my Apple. This package is written entirely in R and requires no compilation. I am trying to move the package to a Windows machine. I (perhaps naively) thought, given that it contains no code requiring compilation, that I should just be able to take the .tar.gz file and directly install it in Windows. This didn't work. Nor did "translating' the contents of the .tar.gz file into a .zip file. I was about to provide the errors, but more googling on this issue suggests that maybe what I'm trying to do is impossible. Do I really have to "build" on a Windows box ... even when the package requires no compilation? Is there no simple translation tool available for this case? thank you, Daryl U. Washington Biostatistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error message in plm package
Dear R help, I use the package plm the function plm() to analyse a panel data and estimate a fixeffect model. I use the code as follow : fe <- plm(y~x+z, data, model = "within") But I had a error message Error in model.frame.default(form, ...) : object is not a matrix I don't what's wrong. Beacuse others use the same codes and data,the code can work. I consult the paper plm.pdf , but I can't find any answer. Thanks, I really would appreciate some suggestions. Helen Chen -- View this message in context: http://www.nabble.com/error-message-in-plm-package-tp23209223p23209223.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] Box-counting dimension and package 'fdim'
Dear R-helpers, I am looking for an implementation of the box-counting algorithm to estimate the box dimension of a cloud of points in 3D (aka fractal dimension, or similarity dimension). The package 'fdim' might be doing this, but the documentation is awful and I don't understand what is what there. Does anyone know of an implementation of this algorithm in R, or elsewhere, or uses the fdim package successfully and can help me out? thanks, Remko - Remko Duursma Post-Doctoral Fellow Centre for Plant and Food Science University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Generalized 2D list/array/whatever?
On Apr 24, 2009, at 12:16 AM, David Winsemius wrote: I cannot figure out what you are trying to do, but I'm reasonably sure that the construction: xxx[[index,index2]] ... is going to fail. If you want to create a two dimensional structure, most people would use either a dataframe or a matrix rather than a list, although lists have the advantage that they do not need to be "pre-dimensioned". If you know what your dimension are in advance they are probably the way to go. If you want to access multiple "dimensions" of a list, do not use [[ , ]] but rather [[ idx ]] to get the desired first "dimension" and then [ idx2 ] to the right of the expression for the first "dimension" to get or change the second "dimension", although "level" or "depth" might be the better terminology. m <- list(sin, 1:3, letters[1:3], expression(a+b)) m[[2]][3] # ] # that "]" shouldn't be there m[[2]][3] <- 8 m m[[2]][3] You have a better chance of getting on target advice if you explain what you want to do rather than showing us code patterned on another language that obviously doesn't work in R. On Apr 23, 2009, at 10:29 PM, Toby wrote: I must be going about my idea really backwards. I have functions like so: Nasa_PART_Bounds <- rbind(Nasa_PART_Bounds, c("Nasa_PART_B1")) Nasa_PART_B1 <- function(l,u) { l[["Nasa_PART_B1", "CYCLOMATIC_COMPLEXITY"]] <- 8 u[["Nasa_PART_B1", "CYCLOMATIC_COMPLEXITY"]] <- 60 l[["Nasa_PART_B1", "LOC_TOTAL"]] <- 73 } Where I add the function names of each "bounds" function to a list, which later on get called with two variables. dispatch2 <- function(f, x, y) { eval(call(f, x, y)) } for (i in bounds) { bb <- eval(substitute(foo[,1], list(foo=as.name(i rr <- lapply(bb, dispatch2, lb, ub) } However, I don't know how to do this in a better "R" way. I think my C and pearl experience is showing through... :( -Toby. On Thu, Apr 23, 2009 at 8:20 PM, Gabor Grothendieck wrote: Matrix made from a list: m <- list(sin, 1:3, letters[1:3], expression(a+b)) dim(m) <- c(2, 2) dimnames(m) <- list(letters[1:2], LETTERS[1:2]) class(m) # matrix or M <- structure(list(sin, 1:3, letters[1:3], expression(a+b)), .Dim = c(2, 2), .Dimnames = list(c("a", "b"), c("A", "B"))) class(M) # matrix On Thu, Apr 23, 2009 at 10:03 PM, Toby wrote: I'm trying to figure out how I can get a generalized 2D list/array/matrix/whatever working. Seems I can't figure out how to make the variables the right type. I always seem to get some sort of error... out of bounds, wrong type, wrong dim, etc. Very confused... :) x[["some label", "some other index"]] <- 3 x[["some other label", "something else"]] <- 4 I don't know the indexes/label ahead of time... they get generated... Any thoughts? 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] Generalized 2D list/array/whatever?
I cannot figure out what you are trying to do, but I'm reasonably sure that the construction: xxx[[index,index2]] ... is going to fail. If you want to create a two dimensional structure, most people would use either a dataframe or a matrix rather than a list, although lists have the advantage that they do not need to be "pre-dimensioned". If you know what your dimension are in advance they are probably the way to go. If you want to access multiple "dimensions" of a list, do not use [[ , ]] but rather [[ idx ]] to get the desired first "dimension" and then [ idx2 ] to the right of the expression for the first "dimension" to get or change the second "dimension", although "level" or "depth" might be the better terminology. m <- list(sin, 1:3, letters[1:3], expression(a+b)) m[[2]][3] ] m[[2]][3] <- 8 m m[[2]][3] You have a better chance of getting on target advice if you explain what you want to do rather than showing us code patterned on another language that obviously doesn't work in R. On Apr 23, 2009, at 10:29 PM, Toby wrote: I must be going about my idea really backwards. I have functions like so: Nasa_PART_Bounds <- rbind(Nasa_PART_Bounds, c("Nasa_PART_B1")) Nasa_PART_B1 <- function(l,u) { l[["Nasa_PART_B1", "CYCLOMATIC_COMPLEXITY"]] <- 8 u[["Nasa_PART_B1", "CYCLOMATIC_COMPLEXITY"]] <- 60 l[["Nasa_PART_B1", "LOC_TOTAL"]] <- 73 } Where I add the function names of each "bounds" function to a list, which later on get called with two variables. dispatch2 <- function(f, x, y) { eval(call(f, x, y)) } for (i in bounds) { bb <- eval(substitute(foo[,1], list(foo=as.name(i rr <- lapply(bb, dispatch2, lb, ub) } However, I don't know how to do this in a better "R" way. I think my C and pearl experience is showing through... :( -Toby. On Thu, Apr 23, 2009 at 8:20 PM, Gabor Grothendieck wrote: Matrix made from a list: m <- list(sin, 1:3, letters[1:3], expression(a+b)) dim(m) <- c(2, 2) dimnames(m) <- list(letters[1:2], LETTERS[1:2]) class(m) # matrix or M <- structure(list(sin, 1:3, letters[1:3], expression(a+b)), .Dim = c(2, 2), .Dimnames = list(c("a", "b"), c("A", "B"))) class(M) # matrix On Thu, Apr 23, 2009 at 10:03 PM, Toby wrote: I'm trying to figure out how I can get a generalized 2D list/array/matrix/whatever working. Seems I can't figure out how to make the variables the right type. I always seem to get some sort of error... out of bounds, wrong type, wrong dim, etc. Very confused... :) x[["some label", "some other index"]] <- 3 x[["some other label", "something else"]] <- 4 I don't know the indexes/label ahead of time... they get generated... Any thoughts? 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] deleting rows provisionally
onyourmark wrote: > > I have an object. I think it is a matrix, called 'answer2' > str(answer2) > int [1:1537, 1:2] 1 399 653 2 3 600 4 5 271 870 ... > - attr(*, "dimnames")=List of 2 > ..$ : chr [1:1537] "a4.1" "hirschsprung.399" "peritoneal.653" > "abdomen.2" ... > ..$ : chr [1:2] "row" "col" > > > I want to delete rows that have the same entries. > > Your "for" loop didn't make any assignments. How about answer3 <- answer2[-(answer2[,1]==answer2[,2]),] or answer3 <- answer2[answer2[,1]!=answer2[,2],] (which will be much faster than a loop anyway) ? -- View this message in context: http://www.nabble.com/deleting-rows-provisionally-tp23209365p23209468.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] deleting rows provisionally
I have an object. I think it is a matrix, called 'answer2' str(answer2) int [1:1537, 1:2] 1 399 653 2 3 600 4 5 271 870 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:1537] "a4.1" "hirschsprung.399" "peritoneal.653" "abdomen.2" ... ..$ : chr [1:2] "row" "col" I want to delete rows that have the same entries. For example: > answer2[4,1] [1] 2 > answer2[4,2] [1] 2 > And so I would like to delete row 4. I tried the following but it does not work. I defined answer3 to hold the result by first: >answer3<-answer2 and then: > for(i in 1:1537){if(answer2[i,1]==answer2[i,2]){answer3[-i,]}} Why doesn't this work? Thanks. -- View this message in context: http://www.nabble.com/deleting-rows-provisionally-tp23209365p23209365.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] Error building package: LaTeX error when creating PDF version
Duncan suggested R CMD check was not finding pdflatex, because there is no .log file in the same directory as the .tex file. However, the first line of output from R CMD check says: > * checking for working pdflatex ... OK Indeed: pdu...@pdunnubuntu:~/DSdata/GLMsData.Rchecks$ R CMD pdflatex This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) %&-line parsing enabled. ** And it waits for input. So that doesn't seem to be the problem. Further suggestions? P. Peter Dunn: Biostatistician School of Health and Sport Science Faculty of Science, Health and Education ML-34 University of the Sunshine Coast, Locked Bag 4 Maroochydore DC Qld 4558 Tel: +61 7 5456 5085 Fax: +61 7 5430 2896 Email: pdu...@usc.edu.au www.usc.edu.au ( http://www.usc.edu.au/ ) >>> Duncan Murdoch 24/04/2009 10:40 am >>> On 23/04/2009 8:24 PM, Peter Dunn wrote: > Hi all > > I am trying to build an R package, which I have successfully done many times > before, but have an error I cannot trace. I hope someone can help me. > > Here's is some edited output (full output below if it is useful): > > pdu...@pdunnubuntu:~/DSdata$ R CMD build GLMsData > * checking for file 'GLMsData/DESCRIPTION' ... OK > * preparing 'GLMsData': > * checking DESCRIPTION meta-information ... OK > * removing junk files > * checking for LF line-endings in source and make files > * checking for empty or unneeded directories > * building 'GLMsData_0.7.tar.gz' > > pdu...@pdunnubuntu:~/DSdata$ R CMD check GLMsData > * checking for working pdflatex ... OK > * using log directory '/home/pdunn2/DSdata/GLMsData.Rcheck' > * using R version 2.9.0 (2009-04-17) > > > > * checking data for non-ASCII characters ... OK > * checking examples ... OK > * checking PDF version of manual ... WARNING > LaTeX errors when creating PDF version. > This typically indicates Rd problems. > * checking PDF version of manual without index ... ERROR > > > So there is an error making the PDf version of the package manual. That's > fine; I am happy to fix it. But first I need to find it. > > So I enter the directory GLMsData.Rcheck and find the corresponding tex file > for the manual, and run pdflatex on this tex file: > > pdu...@pdunnubuntu:~/DSdata$ cd GLMsData.Rcheck/ > pdu...@pdunnubuntu:~/DSdata/GLMsData.Rcheck$ pdflatex GLMsData-manual.tex > > > > Output written on GLMsData-manual.pdf (79 pages, 405091 bytes). > Transcript written on GLMsData-manual.log. > pdu...@pdunnubuntu:~/DSdata/GLMsData.Rcheck$ > > > So from what I gather: > * R CMD check finds an error when using pdflatex to make the PDF version > of the manual > * But when I manually run pdflatex on the tex file, it works OK. > > Obviously, I am missing something. Can someone tell me what it is? I can't > find enlightenment on the archives or the manuals. You should also have a .log file in the same directory as the .tex file. You probably have a new one now that pdflatex works; please move that one aside and run R CMD check again. If you get a .log file, it should list whatever the error was; you could compare it to the .log that worked if you can't spot it. If you don't get a new log, that means R CMD check couldn't run pdflatex. Duncan Murdoch > > Thanks everyone. > > P. > > > >> sessionInfo() > R version 2.9.0 (2009-04-17) > i486-pc-linux-gnu > > locale: > LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices utils datasets methodsbase > > > > > > FULL OUTPUT: > > pdu...@pdunnubuntu:~/DSdata$ R CMD build GLMsData > * checking for file 'GLMsData/DESCRIPTION' ... OK > * preparing 'GLMsData': > * checking DESCRIPTION meta-information ... OK > * removing junk files > * checking for LF line-endings in source and make files > * checking for empty or unneeded directories > * building 'GLMsData_0.7.tar.gz' > > pdu...@pdunnubuntu:~/DSdata$ R CMD check GLMsData > * checking for working pdflatex ... OK > * using log directory '/home/pdunn2/DSdata/GLMsData.Rcheck' > * using R version 2.9.0 (2009-04-17) > * using session charset: UTF-8 > * checking for file 'GLMsData/DESCRIPTION' ... OK > * checking extension type ... Package > * this is package 'GLMsData' version '0.7' > * checking package dependencies ... OK > * checking if this is a source package ... OK > * checking for executable files ... OK > * checking whether package 'GLMsData' can be installed ... OK > * checking package directory ... OK > * checking for portable file names ... OK > * checking for sufficient/correct file permissions ... OK > * checking DESCRIPTION meta-information ... OK > * checking top-level files ... OK > * checking index information ... OK > * checking package subdirectories ... OK > * checking whether the package can be loade
Re: [R] Generalized 2D list/array/whatever?
I must be going about my idea really backwards. I have functions like so: Nasa_PART_Bounds <- rbind(Nasa_PART_Bounds, c("Nasa_PART_B1")) Nasa_PART_B1 <- function(l,u) { l[["Nasa_PART_B1", "CYCLOMATIC_COMPLEXITY"]] <- 8 u[["Nasa_PART_B1", "CYCLOMATIC_COMPLEXITY"]] <- 60 l[["Nasa_PART_B1", "LOC_TOTAL"]] <- 73 } Where I add the function names of each "bounds" function to a list, which later on get called with two variables. dispatch2 <- function(f, x, y) { eval(call(f, x, y)) } for (i in bounds) { bb <- eval(substitute(foo[,1], list(foo=as.name(i rr <- lapply(bb, dispatch2, lb, ub) } However, I don't know how to do this in a better "R" way. I think my C and pearl experience is showing through... :( -Toby. On Thu, Apr 23, 2009 at 8:20 PM, Gabor Grothendieck wrote: > Matrix made from a list: > > m <- list(sin, 1:3, letters[1:3], expression(a+b)) > dim(m) <- c(2, 2) > dimnames(m) <- list(letters[1:2], LETTERS[1:2]) > class(m) # matrix > > or > > M <- structure(list(sin, 1:3, letters[1:3], expression(a+b)), .Dim = c(2, > 2), > .Dimnames = list(c("a", "b"), c("A", "B"))) > class(M) # matrix > > On Thu, Apr 23, 2009 at 10:03 PM, Toby > wrote: > > I'm trying to figure out how I can get a generalized 2D > > list/array/matrix/whatever > > working. Seems I can't figure out how to make the variables the right > > type. I > > always seem to get some sort of error... out of bounds, wrong type, wrong > > dim, etc. > > Very confused... :) > > > > x[["some label", "some other index"]] <- 3 > > x[["some other label", "something else"]] <- 4 > > > > I don't know the indexes/label ahead of time... they get generated... > Any > > thoughts? > > > > -Toby. > > > >[[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] joining multiple lists
I'm not sure that merge will do what you originally requested. At least look at rbind before deciding to go with merge. On Apr 23, 2009, at 9:30 PM, Daniel Bradley wrote: Merge()! Thanks! On Fri, Apr 24, 2009 at 11:26 AM, Daniel Bradley >wrote: Hi! I'm reading and cleaning data from multiple excel spreadsheets. All the data has the same column names and the natural next step is to join the lists of data together to make one list for reporting purposes. I had thought that c(file1data, file2data) would do the trick but that seems to append the new columns to the list so I end up with duplicate column names "col1" "col2" "col3" "col1" col2" "col3" rather than consolidated column data. It's obviously a straight forward operation, but damned if I can find a straight forward explanation on the web. Any assistance would be most appreciated! 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] Help with for/if loop
On Apr 23, 2009, at 8:07 PM, Giggles_Fairy wrote: I have a set of data that includes various data columns. One if the survival time and another if a continuous variable of ages. I want to put the ages into intervals so that I can then perform the Kalpan Meier test. I am trying to use the following code to build a column with the age group numbers in agecatagory<-c( ) for (i in 1:137) { { if(age[i]<=46) {agecat[i]<-1} if(age[i]>46 & age[i]<= 58) {agecat[i]<-2} if(age[i]>58) {agecat[i]<-3} } agecatagory<-c(agecatagory, agecat[i]) } My help with your loop will be to eliminate it. Try: # age= sample(20:120, 100, replace=T) # use your own data agecatagory<- cut(age, breaks=c(0, 46, 58, max(age) ) ) table(agecatagory) #agecatagory # (0,46] (46,58] (58,120] #agecatagory is now a factor # 319 60 age.n <- as.numeric(agecatagory) table(age.n) #age.n # 1 2 3 #31 9 60 so a one liner would be: agecatagory <- as.numeric( cut(age, breaks=c(0, 46, 58, max(age) ) ) ) I have been getting various errors for various things and have finally got it so that only one error comes up Error in if (age[i] <= 46) { : missing value where TRUE/FALSE needed Could anyone pleaseee shed some light on this for me and tell em where I am going wrong. I am sure it is just a minor thing but I cant for the life of me figure it out! 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] Help with for/if loop
or perhaps agec <- 0*age age[age<=46] <- 1 age[age>46 & age<=58 <- 2 age[age>58] <- 3 or perhaps a one liner cut(x = age, breaks= c(0,46, 58,Inf), labels = c(1,2,3)) On Apr 24, 11:24 am, Jorge Ivan Velez wrote: > Dear Hollie, > ifelse() is one alternative in this particular case: > > # Some data > age<- c(46,47,43,46,47,59,50,54,59,60) > > ifelse(age<=46, 1, > ifelse( age>46 & age<=58 , 2, 3) ) > [1] 1 2 1 1 2 3 2 2 3 3 > > See ?ifelse for more details. > > HTH, > > Jorge > > On Thu, Apr 23, 2009 at 8:07 PM, Giggles_Fairy > wrote: > > > > > > > I have a set of data that includes various data columns. One if the > > survival > > time and another if a continuous variable of ages. I want to put the ages > > into intervals so that I can then perform the Kalpan Meier test. I am > > trying > > to use the following code to build a column with the age group numbers in > > > agecatagory<-c( ) > > for (i in 1:137) > > { > > { > > if(age[i]<=46) {agecat[i]<-1} > > if(age[i]>46 & age[i]<= 58) {agecat[i]<-2} > > if(age[i]>58) {agecat[i]<-3} > > } > > agecatagory<-c(agecatagory, agecat[i]) > > } > > > I have been getting various errors for various things and have finally got > > it so that only one error comes up > > Error in if (age[i] <= 46) { : missing value where TRUE/FALSE needed > > > Could anyone pleaseee shed some light on this for me and tell em where > > I > > am going wrong. I am sure it is just a minor thing but I cant for the life > > of me figure it out! > > > Your replies will be very much appreciated! > > > Hollie > > -- > > View this message in context: > >http://www.nabble.com/Help-with-for-if-loop-tp23207428p23207428.html > > Sent from the R help mailing list archive at Nabble.com. > > > __ > > r-h...@r-project.org mailing list > >https://stat.ethz.ch/mailman/listinfo/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-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://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] Generalized 2D list/array/whatever?
Matrix made from a list: m <- list(sin, 1:3, letters[1:3], expression(a+b)) dim(m) <- c(2, 2) dimnames(m) <- list(letters[1:2], LETTERS[1:2]) class(m) # matrix or M <- structure(list(sin, 1:3, letters[1:3], expression(a+b)), .Dim = c(2, 2), .Dimnames = list(c("a", "b"), c("A", "B"))) class(M) # matrix On Thu, Apr 23, 2009 at 10:03 PM, Toby wrote: > I'm trying to figure out how I can get a generalized 2D > list/array/matrix/whatever > working. Seems I can't figure out how to make the variables the right > type. I > always seem to get some sort of error... out of bounds, wrong type, wrong > dim, etc. > Very confused... :) > > x[["some label", "some other index"]] <- 3 > x[["some other label", "something else"]] <- 4 > > I don't know the indexes/label ahead of time... they get generated... Any > thoughts? > > -Toby. > > [[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] Generalized 2D list/array/whatever?
I'm trying to figure out how I can get a generalized 2D list/array/matrix/whatever working. Seems I can't figure out how to make the variables the right type. I always seem to get some sort of error... out of bounds, wrong type, wrong dim, etc. Very confused... :) x[["some label", "some other index"]] <- 3 x[["some other label", "something else"]] <- 4 I don't know the indexes/label ahead of time... they get generated... Any thoughts? -Toby. [[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] joining multiple lists
Merge()! Thanks! On Fri, Apr 24, 2009 at 11:26 AM, Daniel Bradley wrote: > Hi! > > I'm reading and cleaning data from multiple excel spreadsheets. All the > data has the same column names and the natural next step is to join the > lists of data together to make one list for reporting purposes. I had > thought that c(file1data, file2data) would do the trick but that seems to > append the new columns to the list so I end up with duplicate column names > "col1" "col2" "col3" "col1" col2" "col3" rather than consolidated column > data. It's obviously a straight forward operation, but damned if I can find > a straight forward explanation on the web. Any assistance would be most > appreciated! > > Thanks! > Dan > [[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] joining multiple lists
Hi! I'm reading and cleaning data from multiple excel spreadsheets. All the data has the same column names and the natural next step is to join the lists of data together to make one list for reporting purposes. I had thought that c(file1data, file2data) would do the trick but that seems to append the new columns to the list so I end up with duplicate column names "col1" "col2" "col3" "col1" col2" "col3" rather than consolidated column data. It's obviously a straight forward operation, but damned if I can find a straight forward explanation on the web. Any assistance would be most appreciated! Thanks! Dan [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with for/if loop
Dear Hollie, ifelse() is one alternative in this particular case: # Some data age<- c(46,47,43,46,47,59,50,54,59,60) ifelse(age<=46, 1, ifelse( age>46 & age<=58 , 2, 3) ) [1] 1 2 1 1 2 3 2 2 3 3 See ?ifelse for more details. HTH, Jorge On Thu, Apr 23, 2009 at 8:07 PM, Giggles_Fairy wrote: > > I have a set of data that includes various data columns. One if the > survival > time and another if a continuous variable of ages. I want to put the ages > into intervals so that I can then perform the Kalpan Meier test. I am > trying > to use the following code to build a column with the age group numbers in > > agecatagory<-c( ) > for (i in 1:137) > { > { > if(age[i]<=46) {agecat[i]<-1} > if(age[i]>46 & age[i]<= 58) {agecat[i]<-2} > if(age[i]>58) {agecat[i]<-3} > } > agecatagory<-c(agecatagory, agecat[i]) > } > > I have been getting various errors for various things and have finally got > it so that only one error comes up > Error in if (age[i] <= 46) { : missing value where TRUE/FALSE needed > > Could anyone pleaseee shed some light on this for me and tell em where > I > am going wrong. I am sure it is just a minor thing but I cant for the life > of me figure it out! > > Your replies will be very much appreciated! > > Hollie > -- > View this message in context: > http://www.nabble.com/Help-with-for-if-loop-tp23207428p23207428.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Can't install package "glmnet"
Hi, I was trying to install package glmnet in R, but failed and it show such messages: * Installing *source* package glmnet ... This package has only been tested with gfortran. So some checks are needed. R_HOME is /home/username/R/R-2.9.0 Attempting to determine R_ARCH... R_ARCH is Attempting to detect how R was configured for Fortran 90 Unsupported Fortran 90 compiler or Fortran 90 compilers unavailable! Stop! ERROR: configuration failed for package glmnet * Removing /home/username/R/R-2.9.0/library/glmnet The downloaded packages are in /tmp/RtmpwsLWSc/downloaded_packages Updating HTML index of packages in '.Library' Warning message: In install.packages("glmnet") : installation of package 'glmnet' had non-zero exit status It seems that it needs fortran 90 complier. What can I do to solve this problem? (I am not the administrator, only a user in the linux system). Thank you very much! Liang [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with for/if loop
I have a set of data that includes various data columns. One if the survival time and another if a continuous variable of ages. I want to put the ages into intervals so that I can then perform the Kalpan Meier test. I am trying to use the following code to build a column with the age group numbers in agecatagory<-c( ) for (i in 1:137) { { if(age[i]<=46) {agecat[i]<-1} if(age[i]>46 & age[i]<= 58) {agecat[i]<-2} if(age[i]>58) {agecat[i]<-3} } agecatagory<-c(agecatagory, agecat[i]) } I have been getting various errors for various things and have finally got it so that only one error comes up Error in if (age[i] <= 46) { : missing value where TRUE/FALSE needed Could anyone pleaseee shed some light on this for me and tell em where I am going wrong. I am sure it is just a minor thing but I cant for the life of me figure it out! Your replies will be very much appreciated! Hollie -- View this message in context: http://www.nabble.com/Help-with-for-if-loop-tp23207428p23207428.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] Error building package: LaTeX error when creating PDF version
On 23/04/2009 8:24 PM, Peter Dunn wrote: Hi all I am trying to build an R package, which I have successfully done many times before, but have an error I cannot trace. I hope someone can help me. Here's is some edited output (full output below if it is useful): pdu...@pdunnubuntu:~/DSdata$ R CMD build GLMsData * checking for file 'GLMsData/DESCRIPTION' ... OK * preparing 'GLMsData': * checking DESCRIPTION meta-information ... OK * removing junk files * checking for LF line-endings in source and make files * checking for empty or unneeded directories * building 'GLMsData_0.7.tar.gz' pdu...@pdunnubuntu:~/DSdata$ R CMD check GLMsData * checking for working pdflatex ... OK * using log directory '/home/pdunn2/DSdata/GLMsData.Rcheck' * using R version 2.9.0 (2009-04-17) * checking data for non-ASCII characters ... OK * checking examples ... OK * checking PDF version of manual ... WARNING LaTeX errors when creating PDF version. This typically indicates Rd problems. * checking PDF version of manual without index ... ERROR So there is an error making the PDf version of the package manual. That's fine; I am happy to fix it. But first I need to find it. So I enter the directory GLMsData.Rcheck and find the corresponding tex file for the manual, and run pdflatex on this tex file: pdu...@pdunnubuntu:~/DSdata$ cd GLMsData.Rcheck/ pdu...@pdunnubuntu:~/DSdata/GLMsData.Rcheck$ pdflatex GLMsData-manual.tex Output written on GLMsData-manual.pdf (79 pages, 405091 bytes). Transcript written on GLMsData-manual.log. pdu...@pdunnubuntu:~/DSdata/GLMsData.Rcheck$ So from what I gather: * R CMD check finds an error when using pdflatex to make the PDF version of the manual * But when I manually run pdflatex on the tex file, it works OK. Obviously, I am missing something. Can someone tell me what it is? I can't find enlightenment on the archives or the manuals. You should also have a .log file in the same directory as the .tex file. You probably have a new one now that pdflatex works; please move that one aside and run R CMD check again. If you get a .log file, it should list whatever the error was; you could compare it to the .log that worked if you can't spot it. If you don't get a new log, that means R CMD check couldn't run pdflatex. Duncan Murdoch Thanks everyone. P. sessionInfo() R version 2.9.0 (2009-04-17) i486-pc-linux-gnu locale: LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methodsbase FULL OUTPUT: pdu...@pdunnubuntu:~/DSdata$ R CMD build GLMsData * checking for file 'GLMsData/DESCRIPTION' ... OK * preparing 'GLMsData': * checking DESCRIPTION meta-information ... OK * removing junk files * checking for LF line-endings in source and make files * checking for empty or unneeded directories * building 'GLMsData_0.7.tar.gz' pdu...@pdunnubuntu:~/DSdata$ R CMD check GLMsData * checking for working pdflatex ... OK * using log directory '/home/pdunn2/DSdata/GLMsData.Rcheck' * using R version 2.9.0 (2009-04-17) * using session charset: UTF-8 * checking for file 'GLMsData/DESCRIPTION' ... OK * checking extension type ... Package * this is package 'GLMsData' version '0.7' * checking package dependencies ... OK * checking if this is a source package ... OK * checking for executable files ... OK * checking whether package 'GLMsData' can be installed ... OK * checking package directory ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking Rd files ... OK * checking Rd files against version 2 parser ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking data for non-ASCII characters ... OK * checking examples ... OK * checking PDF version of manual ... WARNING LaTeX errors when creating PDF version. This typically indicates Rd problems. * checking PDF version of manual without index ... ERROR pdu...@pdunnubuntu:~/DSdata$ cd GLMsData.Rcheck/ pdu...@pdunnubuntu:~/DSdata/GLMsData.Rcheck$ pdflatex GLMsData-manual.tex This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) %&-line parsing enabled. entering extended mode (./GLMsData-manual.tex LaTeX2e <2005/12/01> Babel and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, ukenglish, loaded. (/usr/share/texmf-texlive/tex/latex/base/book.cls Docume
[R] Error building package: LaTeX error when creating PDF version
Hi all I am trying to build an R package, which I have successfully done many times before, but have an error I cannot trace. I hope someone can help me. Here's is some edited output (full output below if it is useful): pdu...@pdunnubuntu:~/DSdata$ R CMD build GLMsData * checking for file 'GLMsData/DESCRIPTION' ... OK * preparing 'GLMsData': * checking DESCRIPTION meta-information ... OK * removing junk files * checking for LF line-endings in source and make files * checking for empty or unneeded directories * building 'GLMsData_0.7.tar.gz' pdu...@pdunnubuntu:~/DSdata$ R CMD check GLMsData * checking for working pdflatex ... OK * using log directory '/home/pdunn2/DSdata/GLMsData.Rcheck' * using R version 2.9.0 (2009-04-17) * checking data for non-ASCII characters ... OK * checking examples ... OK * checking PDF version of manual ... WARNING LaTeX errors when creating PDF version. This typically indicates Rd problems. * checking PDF version of manual without index ... ERROR So there is an error making the PDf version of the package manual. That's fine; I am happy to fix it. But first I need to find it. So I enter the directory GLMsData.Rcheck and find the corresponding tex file for the manual, and run pdflatex on this tex file: pdu...@pdunnubuntu:~/DSdata$ cd GLMsData.Rcheck/ pdu...@pdunnubuntu:~/DSdata/GLMsData.Rcheck$ pdflatex GLMsData-manual.tex Output written on GLMsData-manual.pdf (79 pages, 405091 bytes). Transcript written on GLMsData-manual.log. pdu...@pdunnubuntu:~/DSdata/GLMsData.Rcheck$ So from what I gather: * R CMD check finds an error when using pdflatex to make the PDF version of the manual * But when I manually run pdflatex on the tex file, it works OK. Obviously, I am missing something. Can someone tell me what it is? I can't find enlightenment on the archives or the manuals. Thanks everyone. P. > sessionInfo() R version 2.9.0 (2009-04-17) i486-pc-linux-gnu locale: LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methodsbase FULL OUTPUT: pdu...@pdunnubuntu:~/DSdata$ R CMD build GLMsData * checking for file 'GLMsData/DESCRIPTION' ... OK * preparing 'GLMsData': * checking DESCRIPTION meta-information ... OK * removing junk files * checking for LF line-endings in source and make files * checking for empty or unneeded directories * building 'GLMsData_0.7.tar.gz' pdu...@pdunnubuntu:~/DSdata$ R CMD check GLMsData * checking for working pdflatex ... OK * using log directory '/home/pdunn2/DSdata/GLMsData.Rcheck' * using R version 2.9.0 (2009-04-17) * using session charset: UTF-8 * checking for file 'GLMsData/DESCRIPTION' ... OK * checking extension type ... Package * this is package 'GLMsData' version '0.7' * checking package dependencies ... OK * checking if this is a source package ... OK * checking for executable files ... OK * checking whether package 'GLMsData' can be installed ... OK * checking package directory ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking Rd files ... OK * checking Rd files against version 2 parser ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking data for non-ASCII characters ... OK * checking examples ... OK * checking PDF version of manual ... WARNING LaTeX errors when creating PDF version. This typically indicates Rd problems. * checking PDF version of manual without index ... ERROR pdu...@pdunnubuntu:~/DSdata$ cd GLMsData.Rcheck/ pdu...@pdunnubuntu:~/DSdata/GLMsData.Rcheck$ pdflatex GLMsData-manual.tex This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) %&-line parsing enabled. entering extended mode (./GLMsData-manual.tex LaTeX2e <2005/12/01> Babel and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, ukenglish, loaded. (/usr/share/texmf-texlive/tex/latex/base/book.cls Document Class: book 2005/09/16 v1.4f Standard LaTeX document class (/usr/share/texmf-texlive/tex/latex/base/bk10.clo)) (/usr/share/texmf/tex/latex/R/Rd.sty (/usr/share/texmf-texlive/tex/latex/base/ifthen.sty) (/usr/share/texmf-texlive/tex/latex/tools/longtable.sty) (/usr/share/texmf-texlive/tex/latex/tools/bm.sty) (/usr/share/texmf-texlive/tex/latex/base/alltt.sty) (/usr/share/texmf-texlive/tex/latex/tools/verbatim.sty) (/usr/share/texmf-texlive/tex/latex/l
Re: [R] conditional grouping of variables: ave or tapply or by or???
Try this: > df$v4 <- ave(1:nrow(df), df$v1, FUN = function(i) with(df[i,], v2[!v3])) > df v1 v2 v3 v4 1 10 7 0 7 2 10 5 1 7 3 10 7 2 7 4 11 9 0 9 5 11 7 2 9 > # If as is the case here that 0 is always the first in each v1 group > # then it can be simplified further to: > df$v4 <- with(df, ave(v2, v1, FUN = function(x) x[1])) On Thu, Apr 23, 2009 at 6:11 PM, ozan bakis wrote: > Dear R Users, > I have the following data frame: > > v1 <- c(rep(10,3),rep(11,2)) > v2 <- sample(5:10, 5, replace = T) > v3 <- c(0,1,2,0,2) > df <- data.frame(v1,v2,v3) >> df > v1 v2 v3 > 1 10 9 0 > 2 10 5 1 > 3 10 6 2 > 4 11 7 0 > 5 11 5 2 > > I want to add a new column v4 such that its values are equal to the value > of v2 conditional on v3=0 for each subgroup of v1. In the above example, > the final result should be like > > df$v4 <- c(9,9,9,7,7) >> df > v1 v2 v3 v4 > 1 10 9 0 9 > 2 10 5 1 9 > 3 10 6 2 9 > 4 11 7 0 7 > 5 11 5 2 7 > > > I tried the following commands without success. > > df$v4 <- ave(df$v2, df$v1, FUN=function(x) x[df$v3==0]) > tapply(df$v2, df$v1, FUN=function(x) x[df$v3==0]) > by(df$v2, df$v1, FUN=function(x) x[df$v3==0]) > > Any help? Thanks in advance! > Ozan > > [[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] conditional grouping of variables: ave or tapply or by or???
On Thu, Apr 23, 2009 at 5:11 PM, ozan bakis wrote: > Dear R Users, > I have the following data frame: > > v1 <- c(rep(10,3),rep(11,2)) > v2 <- sample(5:10, 5, replace = T) > v3 <- c(0,1,2,0,2) > df <- data.frame(v1,v2,v3) >> df > v1 v2 v3 > 1 10 9 0 > 2 10 5 1 > 3 10 6 2 > 4 11 7 0 > 5 11 5 2 > > I want to add a new column v4 such that its values are equal to the value > of v2 conditional on v3=0 for each subgroup of v1. In the above example, > the final result should be like > > df$v4 <- c(9,9,9,7,7) >> df > v1 v2 v3 v4 > 1 10 9 0 9 > 2 10 5 1 9 > 3 10 6 2 9 > 4 11 7 0 7 > 5 11 5 2 7 > > > I tried the following commands without success. > > df$v4 <- ave(df$v2, df$v1, FUN=function(x) x[df$v3==0]) > tapply(df$v2, df$v1, FUN=function(x) x[df$v3==0]) > by(df$v2, df$v1, FUN=function(x) x[df$v3==0]) > > Any help? Thanks in advance! Here's one approach with the plyr package, http://had.co.nz/plyr library(plyr) ddply(df, .(v1), transform, v4 = v2[v3 == 0]) Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] suppress output from step function
Dear Pierre, See argument trace in ?step. Setting up trace=FALSE in your code should hide the steps: step(linear_model, trace=FALSE) HTH, Jorge On Thu, Apr 23, 2009 at 6:34 PM, Pierre Moffard wrote: > Dear all, > > Is there a way of using the step function on a linear model such that all > the steps are not printed out? > > Say I have a matrix X of 50 explanatory variables and a binary response Y. > > linear_model<-glm(Y~X, data=my_data, family="binomial") > SS<-step(linear_model) > > This last step produces all the output that would have been produced even > if I hadn't named the result SS. > > SS<-step(linear_model,print=FALSE) - this doesnt work either. > > Does anyone have any ideas? > > Thank you all in advance. > > Best, > Pierre > > > > >[[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] suppress output from step function
Dear all, Is there a way of using the step function on a linear model such that all the steps are not printed out? Say I have a matrix X of 50 explanatory variables and a binary response Y. linear_model<-glm(Y~X, data=my_data, family="binomial") SS<-step(linear_model) This last step produces all the output that would have been produced even if I hadn't named the result SS. SS<-step(linear_model,print=FALSE) - this doesnt work either. Does anyone have any ideas? Thank you all in advance. Best, Pierre [[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] Parenthesis around date/time using chron?
Try this: > x <- as.chron(Sys.time()) > format(x, enclosed = c("", "")) [1] "04/23/09 22:26:23" On Thu, Apr 23, 2009 at 6:03 PM, Kenneth Takagi wrote: > Hi, > > > > I've been using the chron package to convert excel time into > month/day/year and h:m:s formats, specifically for use as axis labels. > I've come across something I don't quite understand. > > > > ### Here are some excel times: > > dat = c(39083, 39083.00694, 39083.01389, 39083.02083, 39083.02778, > > 39083.03472, 39083.04167, 39083.04861, 39083.05556, 39083.0625 > > ) > > > > ### I create date/time vectors from excel times: > > orig =chron("01/01/1900"); > > # month/day/year h:m:s format > > date.time = orig + dat-2; > > # h:m:s format > > time= date.time - floor(date.time); > > # month/day/year format > > date = orig + floor(dat)-2; > > > > #I can easily recreate the date.time vector without the parenthesis (as > characters though): > > paste(date, time) > > > > But, I don't see why the values in the ORIGINAL date.time vector have > parenthesis around them? Is there as specific reason? > > > > Thanks! > > > > ken > > > > kat...@psu.edu > > > > > [[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] Stuck using constrOptim
My bad. It skipped my mind that constrOptim requires that you specify the gradient function for using BFGS. I have writtten a constrOPtim function that computes the gradient numerically and also can incorporate non-linear inequality constraints. I will send it to you, if you are interested. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of dre968 Sent: Thursday, April 23, 2009 5:23 PM To: r-help@r-project.org Subject: Re: [R] Stuck using constrOptim if i run the same program with constrOptim(p0,minsquare,keys=keys,benKeys=benKeys,NULL,ui=A,ci=B,method="BF GS") i get the following error: Error in dR(theta, theta.old, ...) : could not find function "grad" i'm not very mathematically inclined, i dont even know what a gradient is. any suggestions? dre968 wrote: > > Trying to use constrOptim to minimize the sum of squared deviations. > I put the objective function in as: sum((x %*% Y - Z)^2) so i'm trying > to get values for x to minimize the sum of the squared deviations > between the product of x and Y and Z. > > Anyways i have no problem using this when x is a 3x1 test variable. > it works great with the constraints and everything. when i actually > use it on my data x is 3x900 or so and it wont optimize it just gives > me back my initial guessthis is the output i'm getting: > > $value > [1] 22.7438 > > $counts > function gradient > 906 NA > > $convergence > [1] 1 > > $message > NULL > > $outer.iterations > [1] 1 > > $barrier.value > [1] 1.381551e-06 > > this is definitely not the right answer and it is just spitting back > my initial guess back. > > Any ideas? are there limits as to how big the variables can be for > this function? > -- View this message in context: http://www.nabble.com/Stuck-using-constrOptim-tp23197912p23203595.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] conditional grouping of variables: ave or tapply or by or???
Dear R Users, I have the following data frame: v1 <- c(rep(10,3),rep(11,2)) v2 <- sample(5:10, 5, replace = T) v3 <- c(0,1,2,0,2) df <- data.frame(v1,v2,v3) > df v1 v2 v3 1 10 9 0 2 10 5 1 3 10 6 2 4 11 7 0 5 11 5 2 I want to add a new column v4 such that its values are equal to the value of v2 conditional on v3=0 for each subgroup of v1. In the above example, the final result should be like df$v4 <- c(9,9,9,7,7) > df v1 v2 v3 v4 1 10 9 0 9 2 10 5 1 9 3 10 6 2 9 4 11 7 0 7 5 11 5 2 7 I tried the following commands without success. df$v4 <- ave(df$v2, df$v1, FUN=function(x) x[df$v3==0]) tapply(df$v2, df$v1, FUN=function(x) x[df$v3==0]) by(df$v2, df$v1, FUN=function(x) x[df$v3==0]) Any help? Thanks in advance! Ozan [[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] My surprising experience in trying out REvolution's R
We've taken a look at this in a bit more detail; it's a very interesting example. Although the code uses several functions that exploit the parallel processing in REvolution R (notably %*% and chol), this was one of those situations where the overheads of threading pretty much balanced any performance gains: the individual matrices for the operations were too small. For some examples where the performance gains do show, see: http://www.revolution-computing.com/products/r-performance.php A more promising avenue for speeding up this code lies in parallelizing the outer for(i in 1:200) loop... # David Smith On Tue, Apr 21, 2009 at 9:26 AM, Jason Liao wrote: > I care a lot about R's speed. So I decided to give REvolution's R > (http://revolution-computing.com/) a try, which bills itself as an > optimized R. Note that I used the free version. > > My machine is a Intel core 2 duo under Windows XP professional. The code > I run is in the end of this post. > > First, the regular R 1.9. It takes 2 minutes and 6 seconds, CPU usage > 50% > > Next, REvolution's R. It takes 2 minutes and 10 seconds, CPU usage 100%. > > > In other words, REvolution's R consumes double the CPU with slightly > less speed. > > The above has been replicated a few times (as a statistician of course). > > > Anyone has any insight on this? Anyway, my high hope was dashed. -- David M Smith Director of Community, REvolution Computing www.revolution-computing.com Tel: +1 (206) 577-4778 x3203 (San Francisco, USA) Check out our upcoming events schedule at www.revolution-computing.com/events __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Parenthesis around date/time using chron?
Hi, I've been using the chron package to convert excel time into month/day/year and h:m:s formats, specifically for use as axis labels. I've come across something I don't quite understand. ### Here are some excel times: dat = c(39083, 39083.00694, 39083.01389, 39083.02083, 39083.02778, 39083.03472, 39083.04167, 39083.04861, 39083.05556, 39083.0625 ) ### I create date/time vectors from excel times: orig =chron("01/01/1900"); # month/day/year h:m:s format date.time = orig + dat-2; # h:m:s format time= date.time - floor(date.time); # month/day/year format date = orig + floor(dat)-2; #I can easily recreate the date.time vector without the parenthesis (as characters though): paste(date, time) But, I don't see why the values in the ORIGINAL date.time vector have parenthesis around them? Is there as specific reason? Thanks! ken kat...@psu.edu [[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] Interpreting the results of Friedman test
Hello, I have problems interpreting the results of a Friedman test. It seems to me that the p-value resulting from a Friedman test and with it the "significance" has to be interpreted in another way than the p-value resulting from e.g. ANOVA? Let me describe the problem with some detail: I'm testing a lot of different hypotheses in my observer study and only for some the premises for performing an ANOVA are fulfilled (tested with Shapiro Wilk and Bartlett). For the others I perform a Friedman test. To my surprise, the p-value of the Friedman test is < 0.05 for all my tested hypotheses. Thus, I tried to "compare" the results with the results of an ANOVA by performing both test methods (Friedman, ANOVA) to a given set of data. While ANOVA results in p = 0.34445 (--> no significant difference between the groups), the Friedman test results in p = 1.913e-06 (--> significant difference between the groups?). How can this be? Or am I doing something wrong? I have three measured values for each condition. For ANOVA I use them all, for the Friedman test I calculated the geometric mean of the three values, since this test does not work with replicated values. Is this a crude mistake? Thanks in advance for any help. Doerte __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Stuck using constrOptim
so i set gr=Null: > constrOptim(p0,minsquare,Y=Y,Z=Z,NULL,gr=NULL,ui=A,ci=B,method="BFGS") and i recieved the following error: Error in optim(theta.old, fun, gradient, control = control, method = method, : objective function in optim evaluates to length 0 not 1 -- View this message in context: http://www.nabble.com/Stuck-using-constrOptim-tp23197912p23204289.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] R 2.8.1 change user input color of R scrpt too
The short answer is to upgrade to R version 2.9.0 where you have more control over the colors in the different types of windows. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of matildet > Sent: Thursday, April 23, 2009 11:25 AM > To: r-help@r-project.org > Subject: [R] R 2.8.1 change user input color of R scrpt too > > > Hello R community > > I'm using R 2.8.1 version and would like to change the color of user > input > for script pages. Once I have changed the color of console background > and > user input (by means of Interface Preferences menu), the color of > script > background has been automatically changed but the color of user input > has > not. > > Has someone any useful advice for my (little) problem? > > Thanks in advance > > Matilde > -- > View this message in context: http://www.nabble.com/R-2.8.1-change- > user-input-color-of-R-scrpt-too-tp23197473p23197473.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] Stuck using constrOptim
if i run the same program with constrOptim(p0,minsquare,keys=keys,benKeys=benKeys,NULL,ui=A,ci=B,method="BFGS") i get the following error: Error in dR(theta, theta.old, ...) : could not find function "grad" i'm not very mathematically inclined, i dont even know what a gradient is. any suggestions? dre968 wrote: > > Trying to use constrOptim to minimize the sum of squared deviations. I > put the objective function in as: sum((x %*% Y - Z)^2) so i'm trying to > get values for x to minimize the sum of the squared deviations between the > product of x and Y and Z. > > Anyways i have no problem using this when x is a 3x1 test variable. it > works great with the constraints and everything. when i actually use it > on my data x is 3x900 or so and it wont optimize it just gives me back my > initial guessthis is the output i'm getting: > > $value > [1] 22.7438 > > $counts > function gradient > 906 NA > > $convergence > [1] 1 > > $message > NULL > > $outer.iterations > [1] 1 > > $barrier.value > [1] 1.381551e-06 > > this is definitely not the right answer and it is just spitting back my > initial guess back. > > Any ideas? are there limits as to how big the variables can be for this > function? > -- View this message in context: http://www.nabble.com/Stuck-using-constrOptim-tp23197912p23203595.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] simple for loop question - how do you exit?
To "break" out of a loop early, use the "break" command (or rethink your logic and use a different type of loop, often if you will be commonly leaving the loop, a while loop may make more sense than a for loop). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of dre968 > Sent: Thursday, April 23, 2009 12:29 PM > To: r-help@r-project.org > Subject: [R] simple for loop question - how do you exit? > > > I have a loop and an if statement in the loop. once the if statement > is true > for 1 value in the loop i'd like to exit the loop. is there a command > to do > this? i know its going to be something like exit and i feel stupid > asking > this question > -- > View this message in context: http://www.nabble.com/simple-for-loop- > question---how-do-you-exit--tp23197504p23197504.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] Stuck using constrOptim
Hi, The constrOptim function used "Nelder-Mead" for the inner iterations, when gradient is not specified. Nelder-Mead is not good when you have a non-small number of parameters. I would sugest that you specify method = "BFGS" in the call to constrOptim. This might help. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of dre968 Sent: Thursday, April 23, 2009 4:22 PM To: r-help@r-project.org Subject: Re: [R] Stuck using constrOptim Sorry for the not enough info. the code seems to work for 10 or so variables but stops optimizing if i give it anymore than that. #Load data Data <- read.table..csv',head=TRUE,sep=",",stringsAsFactors = FALSE) #Load goal variables. this is what i'm trying to minimize to Z<-read.tablecsv',head=TRUE,sep=",",stringsAsFactors = FALSE) #set array Y<-array(0,dim=c(nrow(Data),15)) #load applicable values into array for(j in 1:15){ for(k in 1:nrow(Data)){ Y[k,j] = Data[k,3+j] } } #set constraint A <- array(0,dim=c(2+nrow(Y),nrow(Y))) B <- array(0,dim=c(2+nrow(Y),1)) # Constraint for total = 100% for(w in 1:nrow(Data)){ A[1,w] = 1 A[2,w] = -1 } #each value in x must be greater than 0 for(i in 1:nrow(Data)){ A[i+2,i] = 1 B[i+2] = -.1 } B[1,1] = .999 B[2,1] = -1.001 #initial guess p0<- array(0,dim=c(nrow(Data))) p0[1] = .5 p0[2] = .501 #objective function minsquare<-function(x,Y,Z){sum((x %*% Y - Z)^2)} #Optimization with constraints constrOptim(p0,minsquare,Y=Y,Z=Z,NULL,ui=A,ci=B) here is the code. -- View this message in context: http://www.nabble.com/Stuck-using-constrOptim-tp23197912p23200221.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] function output with for loop and if statement
tmp.out.sort <- tmp.out[, order(names(tmp.out))] tmp.out.sort <- tmp.out[, order(names(tmp.out)), drop=FALSE] >From your description of misbehavior with a single column, I think the drop=FALSE argument will provide the protection you need. Then you will not need the if clause. See ?`[.data.frame` for the story and examples. Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Stuck using constrOptim
Sorry for the not enough info. the code seems to work for 10 or so variables but stops optimizing if i give it anymore than that. #Load data Data <- read.table..csv',head=TRUE,sep=",",stringsAsFactors = FALSE) #Load goal variables. this is what i'm trying to minimize to Z<-read.tablecsv',head=TRUE,sep=",",stringsAsFactors = FALSE) #set array Y<-array(0,dim=c(nrow(Data),15)) #load applicable values into array for(j in 1:15){ for(k in 1:nrow(Data)){ Y[k,j] = Data[k,3+j] } } #set constraint A <- array(0,dim=c(2+nrow(Y),nrow(Y))) B <- array(0,dim=c(2+nrow(Y),1)) # Constraint for total = 100% for(w in 1:nrow(Data)){ A[1,w] = 1 A[2,w] = -1 } #each value in x must be greater than 0 for(i in 1:nrow(Data)){ A[i+2,i] = 1 B[i+2] = -.1 } B[1,1] = .999 B[2,1] = -1.001 #initial guess p0<- array(0,dim=c(nrow(Data))) p0[1] = .5 p0[2] = .501 #objective function minsquare<-function(x,Y,Z){sum((x %*% Y - Z)^2)} #Optimization with constraints constrOptim(p0,minsquare,Y=Y,Z=Z,NULL,ui=A,ci=B) here is the code. -- View this message in context: http://www.nabble.com/Stuck-using-constrOptim-tp23197912p23200221.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] function output with for loop and if statement
Gavin, thank you for the suggestions. Unfortunately the function is still not working correctly. Below are the dummy datasets that you requested. In the function dummy.vegdata = vegetation; and dummy.spplist = specieslist. A little clarification on why the if statement is in the function. I am using the apply function to sum columns of data that correspond with different lifeforms in order to derive a total cover value for each lifeform in each plot (plt). When only one species occurs in a lifeform the apply function doesn't work since there is only one column of data. So, the if statement is an attempt to include the column of data from the dummy.vegdata into the output when there is only one species in a given lifeform. Examples of this condition in the dummy.vegdata include water (Bare_Ground) and popbal (Deciduous_Tree). Aaron > dummy.vegdata plt water salarb salpul popbal leddec picgla picmar arcuva zygele epiang calpur poaarc pelaph flacuc tomnit hylspl carvag caraqu calcan carsax T1 0 0 10.00.0 200.0 35 00.00.0 0 0.05.00.0 20 550.0 15.0 0 T2 0 00.00.0 30.0 62 00.00.0 0 0.08.02.0 5 650.0 03.0 0 T3 0 00.00.0 00.0 1 802.00.0 4 0.00.00.0 0 00.0 00.0 0 T4 0 10.0 30.0 00.1 0 00.00.0 0 0.00.00.0 0 00.0 00.0 0 T5 0 00.00.0 00.0 0 00.00.0 0 0.00.00.0 0 00.0 00.0 0 T6 0 00.00.0 0 20.0 0 00.01.0 0 0.02.00.1 0 200.0 00.0 0 T7 0 00.00.0 50.0 40 00.00.0 0 0.05.00.0 0 850.0 00.0 0 T8 0 03.00.0 400.0 5 00.00.0 0 0.00.00.0 1 00.0 20.0 0 T9 0 01.00.0 200.0 10 00.00.0 0 0.00.10.0 0 30.0 10.0 0 T10 0 00.0 65.0 02.0 0 00.00.0 0 0.00.00.0 0 00.0 05.0 0 T11 0 11.00.0 300.0 45 00.00.0 0 0.11.00.0 0 101.0 00.0 0 T12 0 57.00.1 03.0 5 00.00.0 0 0.00.00.0 0 51.0 02.0 5 T13 0 0 20.00.0 52.0 5 00.00.0 0 0.00.00.0 25 02.0 23.0 15 T14 0 0 35.00.0 00.0 0 00.00.0 0 0.00.00.0 0 00.1 03.0 2 T15 0 00.01.0 0 20.0 0 50.10.0 0 0.00.00.0 0 100.0 00.0 0 T16 0 00.00.0 1 80.0 0 00.00.1 0 0.01.00.0 0 500.0 00.1 0 T17 100 00.00.0 00.0 0 00.00.0 0 0.00.00.0 0 00.0 00.0 0 T18 0 00.00.0 0 15.0 0 50.02.0 0 0.01.00.0 0 200.0 01.0 0 T19 0 00.0 10.0 0 50.0 0 00.00.0 0 0.00.10.0 0 550.0 0 20.0 0 T20 0 00.00.0 450.0 15 00.00.0 0 0.01.00.0 0 500.0 00.0 0 T21 0 00.00.0 00.0 0 00.00.0 0 0.00.00.0 0 00.0 0 35.0 0 T22 100 00.00.0 00.0 0 00.00.0 0 0.00.00.0 0 00.0 00.0 0 T23 0 00.00.0 0 15.0 0 10.00.0 0 0.00.00.0 0 20.0 00.0 0 T24 0 00.10.0 00.0 0 00.00.0 0 0.00.00.0 0 00.0 0 25.0 0 T25 0 00.00.0 0 25.0 0 00.01.0 0 0.00.00.0 0 150.0 02.0 0 > dummy.spplist code SciName LifeFormClass water Water Bare_GroundOther salarbSalix_arbusculoides Deciduous_Shrubs Vascular salpul Salix_planifolia_pulchra Deciduous_Shrubs Vascular popbalPopulus_balsamifera Deciduous_Tree Vascular leddecLed
[R] iteration limit error in gamm and notExp2
hi, I am trying to run a mixed effect gam using gamm (mgcv) and I get the following error: "Error in lme.formula(y ~ X - 1, random = rand, data = strip.offset(mf), : nlminb problem, convergence error code = 1 message = iteration limit reached without convergence (9)" I've read all about 'notExp2' but since I am not an expert I didn't understand that much. I was wondering if anyone has an example of the use of notExp2, or another suggestion on solving this problem. many thanks Isidora [[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] latex(Hmisc): cgroup + rownames shifts column names
I have submitted this as a bug (http://biostat.mc.vanderbilt.edu/trac/Hmisc/ticket/29) but I am wondering if anyone else has seen it or perhaps developed a workaround. I could certainly fix the LaTeX by hand, but I am using this inside Sweave, so it is a bit cumbersome. The exact same code used to work fine, but something changed underneath it. Even so, perhaps I am using the latex() command incorrectly. When I do a latex table with rownames but without cgroup, everything is fine, but when I use cgroup (as in the second case), the rownames column gets the first column's name and subsequent column names are shifted. This worked fine for me a year ago, so something has changed in my setup or in Hmisc. I have another machine with Hmisc_3.4-3 installed, and its cgroup()-ed table was correct as well. I included the output from sessionInfo() at the bottom. test.df <- data.frame(row.names=letters[1:4], col1=1:4, col2=4:1, col3=4:7) latex(test.df, file="", table.env=FALSE, center="none") % latex.default(test.df, file = "", table.env = FALSE, center = "none") % \begin{tabular}{lrrr} \hline\hline %% Comment added by ME -- this next line is the one that is fine without cgroup \multicolumn{1}{l}{test.df}& \multicolumn{1}{c}{col1}& \multicolumn{1}{c}{col2}& \multicolumn{1}{c}{col3} \tabularnewline \hline a&$1$&$4$&$4$\tabularnewline b&$2$&$3$&$5$\tabularnewline c&$3$&$2$&$6$\tabularnewline d&$4$&$1$&$7$\tabularnewline \hline \end{tabular} latex(test.df, file="", n.cgroup=c(1,2), cgroup=c("","95\\% Conf. Limits"), table.env=FALSE, center="none") % latex.default(test.df, file = "", n.cgroup = c(1, 2), cgroup = c("", "95\\% Conf. Limits"), table.env = FALSE, center = "none") % \begin{tabular}{lrcrr} \hline\hline \multicolumn{1}{l}{\bfseries test.df}& \multicolumn{1}{c}{\bfseries }& \multicolumn{1}{c}{\bfseries }& \multicolumn{2}{c}{\bfseries 95\% Conf. Limits} \tabularnewline \cline{4-5} %% Comment added by ME -- this next line is the one that is broken with cgroup \multicolumn{1}{l}{col1}& \multicolumn{1}{c}{}& \multicolumn{1}{c}{col2}& \multicolumn{1}{c}{col3}& \multicolumn{1}{c}{col1} \tabularnewline \hline a&$1$&&$4$&$4$\tabularnewline b&$2$&&$3$&$5$\tabularnewline c&$3$&&$2$&$6$\tabularnewline d&$4$&&$1$&$7$\tabularnewline \hline \end{tabular} I am attaching a .pdf of the two tables. (I hope it goes through.) sessionInfo() R version 2.8.1 (2008-12-22) i486-pc-linux-gnu locale: LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=en_US;LC_MONETARY=C;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Hmisc_3.5-2 loaded via a namespace (and not attached): [1] cluster_1.11.13 grid_2.9.0 lattice_0.17-22 tcltk_2.9.0 [5] tools_2.9.0 I hope this is enough information to make the problem clear and that I haven't missed something obvious. Finally, I will subscribe to the help list (I usually just search the archives), but I would appreciate replies sent directly to me as well! Thanks! Michael x.pdf Description: Adobe PDF document __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Stuck using constrOptim
The information you have provided is not enough. Please read the posting guide on how ask for help. Provide a reproducible example so we can help you. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of dre968 Sent: Thursday, April 23, 2009 3:20 PM To: r-help@r-project.org Subject: [R] Stuck using constrOptim Trying to use constrOptim to minimize the sum of squared deviations. I put the objective function in as: sum((x %*% Y - Z)^2) so i'm trying to get values for x to minimize the sum of the squared deviations between the product of x and Y and Z. Anyways i have no problem using this when x is a 3x1 test variable. it works great with the constraints and everything. when i actually use it on my data x is 3x900 or so and it wont optimize it just gives me back my initial guessthis is the output i'm getting: $value [1] 22.7438 $counts function gradient 906 NA $convergence [1] 1 $message NULL $outer.iterations [1] 1 $barrier.value [1] 1.381551e-06 this is definitely not the right answer and it is just spitting back my initial guess back. Any ideas? are there limits as to how big the variables can be for this function? -- View this message in context: http://www.nabble.com/Stuck-using-constrOptim-tp23197912p23197912.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] Loess over split data
Dear R users, I am having trouble devising an efficient way to run a loess() function on all columns of a data.frame (with the x factor remaining the same for all columns) and I was hoping that someone here could help me fix my code so that I won't have to resort to using a for loop. (You'll find the upcoming lines of code in a single block near the end of the message.) Here's a small sample of my data : my.data=data.frame(birth.vec=c(274, 259, 288, 284, 276, 274, 284, 288, 273, 278), final.weight= c(2609.328, 2955.701, 4159.837, 4591.258, 5144.559, 2877.159, 4384.498, 3348.454, 3323.391, 2918.055)) ; "birth.vec" is in days and "final.weight" is in grams. Now, what I'm trying to do is to output smoothed curves for the 10th, 50th and 90th percentiles over completed weeks. In other words, I transform "birth.vec" into a factor vector of completed weeks with completed.weeks = as.factor(floor(my.data$birth.vec/7)) ; I use these factors to get weight quantiles by completed weeks with quan.list = tapply(my.data$final.weight,INDEX = completed.weeks,FUN=quantile,probs=c(0.1,0.5,0.9)) ; I then collapse the list into a data.frame with quan.frame = data.frame(do.call(rbind,quan.list)) ; Now comes the time to apply the loess() function to each percentile curve (i.e. to each column in quan.frame). Note that the x values for all percentile columns (i.e. X10., X50., X90.) x.values = as.numeric(rownames(quan.frame)) ; Once again, using tapply() (and transposing beforehand): t.quan.frame = t(quan.frame) ; ## The following command doesn't work smooth.result = tapply(t.quan.frame,INDEX=as.factor(rep(1:nrow(t.quan.frame),each=ncol(t.quan.frame))),FUN=loess) ; The "formula" argument of loess() is of course missing, since I have no idea how I could specify it in a way that the function could understand it. Now, for your convenience, here's the code patched together: my.data=data.frame(birth.vec=c(274, 259, 288, 284, 276, 274, 284, 288, 273, 278), final.weight= c(2609.328, 2955.701, 4159.837, 4591.258, 5144.559, 2877.159, 4384.498, 3348.454, 3323.391, 2918.055)) ; completed.weeks = as.factor(floor(my.data$birth.vec/7)) ; quan.list = tapply(my.data$final.weight,INDEX = completed.weeks,FUN=quantile,probs=c(0.1,0.5,0.9)) ; quan.frame = data.frame(do.call(rbind,quan.list)) ; x.values = as.numeric(rownames(quan.frame)) ; t.quan.frame = t(quan.frame) ; ## The following command doesn't work smooth.result = tapply(t.quan.frame,INDEX=as.factor(rep(1:nrow(t.quan.frame),each=ncol(t.quan.frame))),FUN=loess) ; ### So, is there a way to modify this code so that I'll get smoothed percentile curves? Any suggestion as to how it could be improved is also welcome. Although the forum archive is fairly comprehensive, phrasing search queries in a way that will yield the desired result is sometimes hard, hence this request for help that to some of you will most likely seem redundant. I thank you sincerely for your time, Luc __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] SAGE: was large factorials
Albyn Jones wrote: > On Wed, Apr 22, 2009 at 08:26:51PM -0700, Ben Bolker wrote: > > >> ??? octave is a Matlab clone, not a Mathematica clone (I would be >> interested in an open source Mathematica clone ...) ??? >> >> > > You might take a look at Sage. It is not a mathematica clone, but > open source mathematical software which has a development community > similar to that of R. > > ... except for that ws has quite a different attitude than bdr. vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R 2.9 binaries for redhat entreprise 4 / X86_64
On Thursday 23 April 2009 15:08:26 Marc Schwartz wrote: > I can't speak to the timeline for the CRAN RPMs, but you might also > want to keep an eye on the EPEL repos, which provide add-on RPMs for > RHEL. > > More info here: > >http://fedoraproject.org/wiki/EPEL > > and the specific link for R for RHEL 4/x84_64 is: > >http://download.fedora.redhat.com/pub/epel/4/x86_64/repoview/R.html > > Not there yet either. The package is already built and it will be out with the next batch of packages. EPEL has a regular schedule for these pushes. > HTH, > > Marc Schwartz -- José Abílio __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Stuck using constrOptim
Sorry i Mean 900x1 not 3x900 below dre968 wrote: > > Trying to use constrOptim to minimize the sum of squared deviations. I > put the objective function in as: sum((x %*% Y - Z)^2) so i'm trying to > get values for x to minimize the sum of the squared deviations between the > product of x and Y and Z. > > Anyways i have no problem using this when x is a 3x1 test variable. it > works great with the constraints and everything. when i actually use it > on my data x is 3x900 or so and it wont optimize it just gives me back my > initial guessthis is the output i'm getting: > > $value > [1] 22.7438 > > $counts > function gradient > 906 NA > > $convergence > [1] 1 > > $message > NULL > > $outer.iterations > [1] 1 > > $barrier.value > [1] 1.381551e-06 > > this is definitely not the right answer and it is just spitting back my > initial guess back. > > Any ideas? are there limits as to how big the variables can be for this > function? > -- View this message in context: http://www.nabble.com/Stuck-using-constrOptim-tp23197912p23198151.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] Stuck using constrOptim
Trying to use constrOptim to minimize the sum of squared deviations. I put the objective function in as: sum((x %*% Y - Z)^2) so i'm trying to get values for x to minimize the sum of the squared deviations between the product of x and Y and Z. Anyways i have no problem using this when x is a 3x1 test variable. it works great with the constraints and everything. when i actually use it on my data x is 3x900 or so and it wont optimize it just gives me back my initial guessthis is the output i'm getting: $value [1] 22.7438 $counts function gradient 906 NA $convergence [1] 1 $message NULL $outer.iterations [1] 1 $barrier.value [1] 1.381551e-06 this is definitely not the right answer and it is just spitting back my initial guess back. Any ideas? are there limits as to how big the variables can be for this function? -- View this message in context: http://www.nabble.com/Stuck-using-constrOptim-tp23197912p23197912.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] qqnorm.lme & pairs.lme
The model has multiple levels of random effects, so you need to tell qqnorm.lme which one you're interested in. e.g. qqnorm(m1, ~ranef(., level=1)) hth, Kingsford Jones On Thu, Apr 23, 2009 at 11:03 AM, Patrick Zimmerman wrote: > Hello, > > I am trying to do some plotting to check random effect assumptions for a > model I fit using lme. > > I want to use qqnorm and pairs (similarly to examples given in Pinheiro & > Bates p. 188), but it's not working. Here's some relevant code and the > error message: > > library(nlme) > data(Machines) > m1 <- lme(fixed=score~Machine,random=~1|Worker/Machine, data=Machines) > qqnorm(m1, ~ranef(.)) > > Error in rep(names(fData), rep(nr, nc)) : invalid 'times' argument > In addition: Warning message: > In data.frame(Worker = list("(Intercept)" = c(-7.51429457896346, : > row names were found from a short variable and have been discarded > > I also tried changing the last line to qqnorm(m1, form=~ranef(.)) > > Any advice? > > Thanks, > Pat Zimmerman > > [[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] surface interpolating 3d
There are a variety of interplation tools to choose from (kriging, splines, inverse-distance-weighting, ...), and a variety of ways to do each of these in R. For example, have a look at the help page and examples for krige in package gstat, krige.conv in geoR, or Krig in package fields. hth, Kingsford Jones On Thu, Apr 23, 2009 at 7:15 AM, calpeda wrote: > > Hi all, > > When you want to draw a surface with a mathematics program you need of two > vectors x and y and a matrix z. Then you plot the surface. > For example: > x=[1 2 3]; > y=[5 6 7]; > z=[1 2 3 > 4 5 6 > 7 8 9]; > > For my applications I have a 3 vectors x, y, z, that are the coordinates x, > y, and z of points in the space. I would find the surface that interpolate > this point. How can I do? > For example: > x=[1 2 3]; > y=[5 6 7]; > z=[6 9 8]; > > Thank you very much > -- > View this message in context: > http://www.nabble.com/surface-interpolating-3d-tp23196713p23196713.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] simple for loop question - how do you exit?
Nevermind i got it dre968 wrote: > > I have a loop and an if statement in the loop. once the if statement is > true for 1 value in the loop i'd like to exit the loop. is there a > command to do this? i know its going to be something like exit and i feel > stupid asking this question > -- View this message in context: http://www.nabble.com/simple-for-loop-question---how-do-you-exit--tp23197504p23197518.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] simple for loop question - how do you exit?
On 4/23/2009 2:29 PM, dre968 wrote: > I have a loop and an if statement in the loop. once the if statement is true > for 1 value in the loop i'd like to exit the loop. is there a command to do > this? i know its going to be something like exit and i feel stupid asking > this question Type ?"if" at the R prompt, which should load the help page for "Control Flow". -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] simple for loop question - how do you exit?
On 4/23/2009 2:29 PM, dre968 wrote: I have a loop and an if statement in the loop. once the if statement is true for 1 value in the loop i'd like to exit the loop. is there a command to do this? i know its going to be something like exit and i feel stupid asking this question You want "break". To see the help on this, you need the quotes around it: ?"break", but you don't use them in code, of course. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] simple for loop question - how do you exit?
I have a loop and an if statement in the loop. once the if statement is true for 1 value in the loop i'd like to exit the loop. is there a command to do this? i know its going to be something like exit and i feel stupid asking this question -- View this message in context: http://www.nabble.com/simple-for-loop-question---how-do-you-exit--tp23197504p23197504.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] suffix convention?
Hi, Is there some convention for choosing 'RData' or 'rda' for binary files written by save() or save.image()? The docs treat these interchangeably. Thanks. Cheers, -- Seb __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 construct confidence bands from a gls fit?
Dear R-list, I would like to show the implications of estimating a linear trend to time series, which contain significant serial correlation. I want to demonstrate this, comparing lm() and an gls() fits, using the LakeHuron data set, available in R. Now in my particular case I would like to draw confidence bands on the plot and show that there are differences. Unfortunately, I do not know how to construct those bands for the gls fit object. Does anyone know how to do that? Here is the code: library(nlme) library(car) lm.hu <- lm(LakeHuron~time(LakeHuron)) ## use durbin-watson test to estimate the AR(p) model durbin.watson(lm.hu,max.lag=7) # I decided to use a AR(2) model gls.hu <- gls(LakeHuron ~ time(LakeHuron), correlation=corARMA(p=2), method="ML") plot(LakeHuron, main="Lake level time series (Lake Huron)") lines(as.numeric(time(LakeHuron)),predict(lm.hu,interval=c("conf"))[,1],lty=1,col=2) lines(as.numeric(time(LakeHuron)),predict(lm.hu,interval=c("conf"))[,2],lty=2,col=2) lines(as.numeric(time(LakeHuron)),predict(lm.hu,interval=c("conf"))[,3],lty=2,col=2) ## predict of the gls class does not contain confidence intervals lines(as.numeric(time(LakeHuron)),predict(gls.hu,interval=c("conf")),lty=1,col=4) Thank you, Maik -- Maik Renner Institut für Hydrologie und Meteorologie Technische Universität Dresden __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 2.8.1 change user input color of R scrpt too
Hello R community I'm using R 2.8.1 version and would like to change the color of user input for script pages. Once I have changed the color of console background and user input (by means of Interface Preferences menu), the color of script background has been automatically changed but the color of user input has not. Has someone any useful advice for my (little) problem? Thanks in advance Matilde -- View this message in context: http://www.nabble.com/R-2.8.1-change-user-input-color-of-R-scrpt-too-tp23197473p23197473.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] qqnorm.lme & pairs.lme
Hello, I am trying to do some plotting to check random effect assumptions for a model I fit using lme. I want to use qqnorm and pairs (similarly to examples given in Pinheiro & Bates p. 188), but it's not working. Here's some relevant code and the error message: library(nlme) data(Machines) m1 <- lme(fixed=score~Machine,random=~1|Worker/Machine, data=Machines) qqnorm(m1, ~ranef(.)) Error in rep(names(fData), rep(nr, nc)) : invalid 'times' argument In addition: Warning message: In data.frame(Worker = list("(Intercept)" = c(-7.51429457896346, : row names were found from a short variable and have been discarded I also tried changing the last line to qqnorm(m1, form=~ranef(.)) Any advice? Thanks, Pat Zimmerman [[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] Load a data from oracle database to R
On Apr 23, 2009, at 12:18 PM, Gagan Pabla wrote: Hello, I am have trying to load data in R by connecting R to the database the following way: library(RODBC) channel<-odbcConnect("gagan") now after I connect to the server by putting pwd. I want to load table from the database named "temp" in to R so that I can do some descriptive statistics with it. now when I try to do "data(temp)" it gives error saying "In data(temp) : data set 'temp' not found". So, how do I load the table to R. Your help will be greatly appreciated. Thanks, Gagan Once you have established the connection to the Oracle server, you then need to perform a query against the database to get the data into R. So something like the following: temp <- sqlQuery(channel, "select * from temp") close(channel) Now you will have a data frame in R called temp. See ?sqlQuery after loading RODBC. BTW, there is a r-sig-db list. More info here: https://stat.ethz.ch/mailman/listinfo/r-sig-db HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] SAGE: was large factorials
On Wed, Apr 22, 2009 at 08:26:51PM -0700, Ben Bolker wrote: > > ??? octave is a Matlab clone, not a Mathematica clone (I would be > interested in an open source Mathematica clone ...) ??? > You might take a look at Sage. It is not a mathematica clone, but open source mathematical software which has a development community similar to that of R. http://www.sagemath.org/ albyn __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Load a data from oracle database to R
Hello, I am have trying to load data in R by connecting R to the database the following way: > library(RODBC) > channel<-odbcConnect("gagan") now after I connect to the server by putting pwd. I want to load table from the database named "temp" in to R so that I can do some descriptive statistics with it. now when I try to do "data(temp)" it gives error saying "In data(temp) : data set 'temp' not found". So, how do I load the table to R. Your help will be greatly appreciated. Thanks, Gagan [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] fitting assimptotic decaing with - and + on X
Hi Christian, Thank you very much for the help. Now I can run. But my main interest is on the region of x[-200 to +200] and as you can see this logistic regression not fit very well. You think that using other package / function I can get better fit of these data? Best wishes, miltinho brazil-toronto sp.coredep.attr<-read.table(stdin(), head=T, sep=",") species,dst,preference,probdye coredep,-7500,1,0.001 coredep,-1000,0.95,0.002 coredep,-500,0.9,0.003 coredep,-250,0.8,0.005 coredep,-120,0.7,0.01 coredep,-100,0.5,0.02 coredep,-90,0.3,0.03 coredep,-60,0.2,0.05 coredep,-30,0.15,0.065 coredep,0,0.1,0.08 coredep,30,0.09,0.1 coredep,60,0.08,0.15 coredep,90,0.07,0.2 coredep,120,0.06,0.3 coredep,240,0.05,0.4 coredep,500,0.04,0.5 coredep,1000,0.02,0.6 coredep,7500,0.01,0.7 plot(preference~as.factor(dst), data=sp.coredep.attr, type="n", cex=0.001, col="transparent", xlab="Distance (m)", main="CORE Dependent") lines(sp.coredep.attr$preference, type="b", lwd=2, col="blue") abline(v=10, col="blue", lty=3) text(10, 1, "EDGE", cex=1.5) text(7, 1, "CORE", cex=1.5, col="green") text(13, 1, "MATRIX", cex=1.5, col="red") text(4,0.65, "Preference", col="blue") text(16,0.65, "Prob.Die", col="red") lines(sp.coredep.attr$probdye, type="b", lwd=2, col="red", lty=2) require(drc) sp.coredep.attr.m1 <- drm(preference~dst, data=sp.coredep.attr, fct=L.4()) x11() plot(sp.coredep.attr.m1, log = "") x11() plot(sp.coredep.attr.m1, log = "", xlim = c(-500, 500), ylim = c(0, 1)) summary(sp.coredep.attr.m1) On Thu, Apr 23, 2009 at 1:41 AM, Christian Ritz wrote: > Hi Milton, > > you're right that most of the functions in the package "drc" are suited for > sigmoidal/s-shaped curves defined on the positive axis. > > However, there is one exception: the logistic model: > > library(drc) > > sp.coredep.attr.m1 <- drm(preference~dst, data=sp.coredep.attr, fct=L.4()) > > plot(sp.coredep.attr.m1, log = "") > plot(sp.coredep.attr.m1, log = "", xlim = c(-500, 500), ylim = c(0, 1)) > > summary(sp.coredep.attr.m1) > > > The fit isn't very good, possibly because the curve you've observed seems > to have a kind > of bent at or close to 0. > > Christian > > [[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] Floating simulation error
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Brendan Morse > Sent: Thursday, April 23, 2009 9:12 AM > To: r-help@r-project.org > Subject: [R] Floating simulation error > > > Hi all, I am running a simulation and a curious error keeps coming up > that stops the whole process. The error is a subscript out of bounds > error, and it seems to happen at different points (floating around) > throughout the looping simulation. Say, for example, it crashes on > sample 1 - iteration 200. I can force it to start again on iteration > 202 with all of the same settings, and it is fine. I can also force it > to start again on iteration 201 if I modify the starting seed value > and it goes on its merry way. What I think is happening is that > certain seed values are disrupting something and causing the subscript > error. > > My seeds are set as follows: The simulation has x number of > conditions. The starting seeds are set to equal the condition number > (1 to x). The program runs 500 iterations within each condition, and > the seed values for each iteration are set as x+iteration number. So, > for condition 1, iteration 1, the starting seed value would be 2, then > 3 etc. etc. At some point, I will get the subscript error but it seems > unpredictable. > > Has anyone had a similar problem or an idea as to what might be > happening? > > - Brendan > > Brendan, This is one of those situations where a self-contained, reproducible example would be really helpful. In the absence of that, seeing your actual code is absolutely necessary. I can't imagine anyone being able to provide any useful help here otherwise. Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Floating simulation error
Cosmic rays, perhaps? :) http://blog.revolution-computing.com/2009/04/blame-it-on-cosmic-rays.html Seriously though, my guess is that the simulation data from your 201st iteration is tickling some subtle bug in your code. This has happened to me before where I generate a random matrix that happens to be non-invertible, for example. I'd suggest grabbing the data from your 201st iteration (a simple way would be to run your RNG 200 times at the start of your code) and debug from there. # David Smith On Thu, Apr 23, 2009 at 11:12 AM, Brendan Morse wrote: > > Hi all, I am running a simulation and a curious error keeps coming up > that stops the whole process. The error is a subscript out of bounds > error, and it seems to happen at different points (floating around) > throughout the looping simulation. Say, for example, it crashes on > sample 1 - iteration 200. I can force it to start again on iteration > 202 with all of the same settings, and it is fine. I can also force it > to start again on iteration 201 if I modify the starting seed value > and it goes on its merry way. What I think is happening is that > certain seed values are disrupting something and causing the subscript > error. > > My seeds are set as follows: The simulation has x number of > conditions. The starting seeds are set to equal the condition number > (1 to x). The program runs 500 iterations within each condition, and > the seed values for each iteration are set as x+iteration number. So, > for condition 1, iteration 1, the starting seed value would be 2, then > 3 etc. etc. At some point, I will get the subscript error but it seems > unpredictable. > > Has anyone had a similar problem or an idea as to what might be > happening? > > - Brendan > > > Brendan Morse, M.S. > Industrial/Organizational Psychology > Ohio University > Office: 335 Porter Hall > Website: http://oak.cats.ohiou.edu/~bm123504 > > > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- David M Smith Director of Community, REvolution Computing www.revolution-computing.com Tel: +1 (206) 577-4778 x3203 (San Francisco, USA) Check out our upcoming events schedule at www.revolution-computing.com/events __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Floating simulation error
?traceback options("error") ( ?options) ?debug ?try ?tryCatch R has facilities to help you with such problems. Please use them -- and then repost with more specific info if you still cannot solve it. -- Bert Gunter -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Brendan Morse Sent: Thursday, April 23, 2009 9:12 AM To: r-help@r-project.org Subject: [R] Floating simulation error Hi all, I am running a simulation and a curious error keeps coming up that stops the whole process. The error is a subscript out of bounds error, and it seems to happen at different points (floating around) throughout the looping simulation. Say, for example, it crashes on sample 1 - iteration 200. I can force it to start again on iteration 202 with all of the same settings, and it is fine. I can also force it to start again on iteration 201 if I modify the starting seed value and it goes on its merry way. What I think is happening is that certain seed values are disrupting something and causing the subscript error. My seeds are set as follows: The simulation has x number of conditions. The starting seeds are set to equal the condition number (1 to x). The program runs 500 iterations within each condition, and the seed values for each iteration are set as x+iteration number. So, for condition 1, iteration 1, the starting seed value would be 2, then 3 etc. etc. At some point, I will get the subscript error but it seems unpredictable. Has anyone had a similar problem or an idea as to what might be happening? - Brendan Brendan Morse, M.S. Industrial/Organizational Psychology Ohio University Office: 335 Porter Hall Website: http://oak.cats.ohiou.edu/~bm123504 [[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] power.t.test formula
Usuario R wrote: > Hi, > > Does anyone of you knows a reference for the formula used in power.t.test > function? And also why it uses the Student's distribution instead of Normal. > (I know both of them can be used but don't see whether choose one or the > other) It is a straightforward first-principles calculation. The t distribution calculation is exact for normally distributed data with the same unknown variance in both groups. Formulas based on the normal distribution assumes the variance to be known, which overestimates small n. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] update.packages(checkBuilt=TRUE) returns Error: invalid version specification NA in 2.9.0
I installed R-2.9.0 yesterday, and followed the instructions in the R for Windows FAQ, 2.8 What's the best way to upgrade? It reads "run update.packages(checkBuilt=TRUE, ask=FALSE) in the new R and then delete anything left of the old installation." I did this but it returned an error. It's the checkBuilt=TRUE which causes it, though I don't know why: leaving it out or changing it to checkBuilt=FALSE do not return errors. > update.packages(checkBuilt=TRUE, ask=FALSE) --- Please select a CRAN mirror for use in this session --- Error: invalid version specification NA > update.packages(checkBuilt=TRUE) Error: invalid version specification NA Peter Keller Wildlife Biologist Tetlin National Wildlife Refuge [[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] Floating simulation error
Hi all, I am running a simulation and a curious error keeps coming up that stops the whole process. The error is a subscript out of bounds error, and it seems to happen at different points (floating around) throughout the looping simulation. Say, for example, it crashes on sample 1 - iteration 200. I can force it to start again on iteration 202 with all of the same settings, and it is fine. I can also force it to start again on iteration 201 if I modify the starting seed value and it goes on its merry way. What I think is happening is that certain seed values are disrupting something and causing the subscript error. My seeds are set as follows: The simulation has x number of conditions. The starting seeds are set to equal the condition number (1 to x). The program runs 500 iterations within each condition, and the seed values for each iteration are set as x+iteration number. So, for condition 1, iteration 1, the starting seed value would be 2, then 3 etc. etc. At some point, I will get the subscript error but it seems unpredictable. Has anyone had a similar problem or an idea as to what might be happening? - Brendan Brendan Morse, M.S. Industrial/Organizational Psychology Ohio University Office: 335 Porter Hall Website: http://oak.cats.ohiou.edu/~bm123504 [[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] power.t.test formula
Hi, Does anyone of you knows a reference for the formula used in power.t.test function? And also why it uses the Student's distribution instead of Normal. (I know both of them can be used but don't see whether choose one or the other) Thank you. 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] boxplot of two variables
Check out ggplot2: http://had.co.nz/ggplot2 especially: http://had.co.nz/ggplot2/geom_boxplot.html But you are strongly advised to read the book: http://had.co.nz/ggplot2/book/ On Thu, Apr 23, 2009 at 12:13 PM, Gabriel R. Rodriguez wrote: > Hello ! > > > > I have a dataframe with 6 variables (A1,A2,B1,B2,C1,C2) and 1 factor (F). > > > > I would like to produce a graph consisting of 3 boxplots sets, one for every > two variables (i.e A1 &A2) by the factor (F). > > I was looking around and I cannot figure it out, any suggestions? > > > > Best Regards, > > Gabriel > > > > > [[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. > -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tr.im/mikes_public_calendar ~ Certainty is folly... I think. ~ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Course announcement: R for Financial Data Analysis in New York (July 16-18th)
Dear userRs, Mango Solutions are pleased to announce that we will deliver a 3-day introductory R course focused on financial analysis in New York on the 16-18th of July. The course topics are as follows: * Introduction * The R Environment * Data Objects * Functions * Important R Functions * Traditional Graphics * Basic R Statistical and Mathematical Functions used in the Finance Industry * Time Series Analysis, Manipulation and Visualization * Performance and Risk Measurement As with all our courses, attendees are provided with comprehensive training manuals complete with detailed examples and laminated tip sheets for future reference. The cost of this course is $1800 for commercial attendees and $1000 for academic attendees. Should you wish to book a place on this course or have any questions please contact us at train...@mango-solutions.com. Further information is available on our web-site at http://www.mango-solutions.com/services/rtraining/r_finance.html Kind regards, Francisco mango solutions S & R Consulting and Training +44 (0)1249 767 700 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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-User groups in North America (SF, LA, NYC, Ottawa)
Folks, Here is the correct URL for the NYC R Users group: New York City http://www.meetup.com/nyhackr (61 members) Organized by Joshua Reich (Thanks to Johnathan Boysielal for pointing out this error, and Curt for the OSU correction as well). On Wed, Apr 22, 2009 at 12:01 PM, Michael E. Driscoll wrote: > Los Angeles > http://www.meetup.com/LAarea-R-usergroup/ (79 members) > May 7th Event: "Four case studies of using R" at 7pm, Boelter Hall, UCLA > Presenters: J. Leeuw, R. Gould, & B. Brett-Esborn (UCLA), S. Pafka (Epoch) > Organized by Szilard Pafka > > San Francisco / Bay Area > http://www.meetup.com/R-Users (228 members) > May 13th Event: Parallel Computing with R using ParallelR at Microsoft SF HQ > Presenter: David M Smith (Revolutions Computing) > Organized by Jim Porzak and yours truly > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] boxplot of two variables
Hello ! I have a dataframe with 6 variables (A1,A2,B1,B2,C1,C2) and 1 factor (F). I would like to produce a graph consisting of 3 boxplots sets, one for every two variables (i.e A1 &A2) by the factor (F). I was looking around and I cannot figure it out, any suggestions? Best Regards, Gabriel [[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] R 2.9 binaries for redhat entreprise 4 / X86_64
Hi ! Thank you for the info. Is this a little bit stable ? Mathieu On 23 Apr 2009, at 16:01, R P Herrold wrote: On Thu, 23 Apr 2009, Mathieu Van der Haegen wrote: I'd like to ask if someone could tell me when the binaries for R 2.9 / redhat entreprise 4 / X86_64 will be available ? I don't need a precise date but some indication like 1 month, 6 month, never ? How about: Now, in Red Hat's RawHide archive? [herr...@centos-5 ~]$ uname -a ; rpm -q R Linux centos-5.first.lan 2.6.18-128.1.6.el5xen #1 SMP Wed Apr 1 09:53:14 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux R-2.9.0-1orc [herr...@centos-5 ~]$ I built it earlier this week from SRPM on CentOS (a rebuild of RHEL) -- Russ herrold __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Adobe FLEX interacting with R for rich visualization over the Web
Harsh wrote on 04/23/2009 09:49 AM: Hi R users, I am looking to create a rich internet application using R as the analytical back-end with a GUI written entirely in Adobe FLEX. I have come across this paper http://www.bioconductor.org/packages/2.3/bioc/vignettes/RWebServices/inst/doc/RelatedWork.pdf which provides relevant information. From what I understand, FLEX can read xml files. The StatDataML library in R creates xml files which can be read by FLEX. Since I would need to implement the GUI on a web server and the R server would be on a different system, I felt using StatDataML to write xml files would be the best approach. I have also heard of the RSOAP library which possibly can be another alternative to the above library. I am trying to create a way for users to be able to visualize the results of regressions and other statistical functions in an interactive manner over the web. If anyone has worked with the above tools or related scenarios, I would greatly appreciate your feedback. You will be interested in the following links then: http://blog.revolution-computing.com/2009/04/find-a-safer-place-in-the-bay-area.html http://blog.revolution-computing.com/2009/04/comparing-baseball-pitcher-styles-with-lattice-graphics.html They provide examples of building web dashboards with R, which probably falls in the category of rich internet applications. Best, Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] large factorials
One more improvement. Perhaps it would be best just to return a numeric so sum1 inputs and outputs numerics: library(rSymPy) # define factorial to return a Sym object factorial.Sym <- function(n) Sym("factorial(", n, ")") sum1 <- function(l,u,t,i,n,w) { v <- 0 for (m in 0 :w) { v1 <- ((u^(1/2))*(l^(1/2))*t)^(i-n+2*m) v2 <- (factorial.Sym(i-n+m))*(factorial.Sym(m)) v3 <- v1/v2 v <- v+v3 } as.numeric(sympy(v)) # send it to SymPy, make result a Sym obj } s <- sum1(1,2,10,80,3,80) s # numeric On Thu, Apr 23, 2009 at 10:44 AM, Gabor Grothendieck wrote: > The code in my prior post works (except one comment was wrong) > but try this instead. The only change is the last line of the sum1 > function. This way it produces a Sym object rather than a character > string. > > library(rSymPy) > > # define factorial to return a Sym object > factorial.Sym <- function(n) Sym("factorial(", n, ")") > > sum1 <- function(l,u,t,i,n,w) { > v <- 0 > for (m in 0 :w) { > v1 <- ((u^(1/2))*(l^(1/2))*t)^(i-n+2*m) > v2 <- (factorial.Sym(i-n+m))*(factorial.Sym(m)) > v3 <- v1/v2 > v <- v+v3 > } > Sym(sympy(v)) # send it to SymPy, make result a Sym obj > } > > s <- sum1(1,2,10,80,3,80) > s # Sym > as.numeric(s) # numeric > > > On Thu, Apr 23, 2009 at 10:37 AM, Gabor Grothendieck > wrote: >> sympy() returns a character string, not an R numeric -- it shouldn't >> automatically return an R numeric since R can't represent all >> the numbers that sympy can. >> >> The development version of rSymPy has a second class which >> produces objects of class c("Sym", "character") and those >> can be manipulated with +, -, *, / producing other Sym >> objects so try this: >> >> >> library(rSymPy) >> >> # next line pulls in code to handle Sym objects >> source("http://rsympy.googlecode.com/svn/trunk/R/Sym.R";) >> >> # define factorial to return a Sym object >> factorial.Sym <- function(n) Sym("factorial(", n, ")") >> >> sum1 <- function(l,u,t,i,n,w) { >> v <- 0 >> for (m in 0 :w) { >> v1 <- ((u^(1/2))*(l^(1/2))*t)^(i-n+2*m) >> v2 <- (factorial.Sym(i-n+m))*(factorial.Sym(m)) >> v3 <- v1/v2 >> v <- v+v3 >> } >> sympy(v) >> } >> >> s <- sum1(1,2,10,80,3,80) >> s # Sym object >> as.numeric(s) # numeric >> >> >> On Thu, Apr 23, 2009 at 10:00 AM, molinar wrote: >>> >>> Here is what I did: >>> library(rSymPy) >>> factorial.sympy <- function(n) sympy(paste("factorial(", n, ")")) >>> factorial.sympy(171) >>> [1] >>> "124101807021766782342484052410310399261660557750169318538895180361199607522169175299275197812048758557646495950167038705280988985869071076733124203221848436431047357788996854827829075454156196485215346831804429323959817369689965723590394761615227855818006117636510842880" >>> Which work perfectly. >>> >>> Here is one of my summation functions: >>> >>> sum1 <- function(l,u,t,i,n,w) { >>> + v <- 0 >>> + for (m in 0 :w) { >>> + v1 <- ((u^(1/2))*(l^(1/2))*t)^(i-n+2*m) >>> + v2 <- (factorial.sympy(i-n+m))*(factorial.sympy(m)) >>> + v3 <- v1/v2 >>> + v <- v+v3 >>> + } >>> + return(v) >>> + } >>> >>> sum1(1,2,10,80,3,80) >>> Error in (factorial.sympy(i - n + m)) * (factorial.sympy(m)) : >>> non-numeric argument to binary operator >>> >>> I'm not sure why it works when I do the factorial normally but when I call >>> my function it doesn't work? >>> >>> >>> >>> >>> >>> >>> >>> molinar wrote: Thank you everyone all of your posts were very helpful. I tried each one and I think I have about 10 new packages installed. The formula I need to calculate did not involve any logarithms but infinite summations of factorials, I'm sorry for not specifying. I read some things about using logarithms but I thought in my case I would have to do an e to the log and by doing that R still gave me the same problems with numbers over 170. But I was able to get it to work by using the last post about the rsympy packages. I tried downloading bc but I didn't know how to connect it to R, so R said "could not find function bc". Thanks again for all of your help. Samantha Gabor Grothendieck wrote: > > Also the R sympy package can handle this: > >> library(rSymPy) > Loading required package: rJava > >> factorial.sympy <- function(n) sympy(paste("factorial(", n, ")")) > >> # note that first time sympy is called it loads java, jython and sympy >> # but on subsequent calls its faster. So make a dummy call first. >> factorial.sympy(10) > [1] "3628800" > >> # code from earlier post defining factorial.bc to be inserted here > >> benchmark(replications=10, columns=c('test', 'elapsed'), > + bc=factorial.bc(500), > + sympy = factorial.sympy(500)) > test elapsed > 1 bc 2.17 > 2 sympy 0.09 > > See the rSymPy
Re: [R] Plots - several pages per pdf - quality/size issue
> I hope that question will not be too redundant (sorry if it is) but > i don't seem able to find the answer i need in the archives... > > I try to create a file which would have 1.several pages and 2. > several plots by page. I know how to make a pdf file this way, but > my problem is that the pdf size gets way too big and cannot be open. > > So my question is: > - is there a way to diminish the pdf size/quality? > - does any other file format exists that would be of smaller quality > but still be able to print plots on several pages for the same file? You could try postscript instead. e.g. p1 <- xyplot(runif(1)~rnorm(1)|sample(letters[1:3], 1, replace=TRUE), layout=c(1,1)) pdf("test.pdf") print(p1) dev.off() # File size 623kb postscript("test.ps") print(p1) dev.off() # File size 257kb The other alternative is to print to a raster format, e.g. png. this creates different files for different pages, but you could always find a way to view multiple plot files at once. Some possibilities: 1. Use, e.g., Picasa to browse your plot files. 2. Create a simple webpage containing each image # R code png("test%d.png") print(p1) dev.off() # Web page code http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> http://www.w3.org/1999/xhtml";> # File sizes 3*13kb + 1kb Open and save this file in a word processor of your choice, and you can probably drop the file size even further. Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] transposing a matrix - row by row?
Thank you very much, Thierry! Really amazing, the magic melt from reshape. And, in fact, a bit dangerous - it just do what I need without any efforts on my part! Dimitri On Thu, Apr 23, 2009 at 10:40 AM, ONKELINX, Thierry wrote: > Dear Dimitri, > > Have a look at melt() from the reshape package. > > X<-matrix(c(10,20,30,40,50,60),2,3) > dimnames(X)<-list(c("1","2"),c("1","2","3")) > library(reshape) > melt(X) > > HTH, > > Thierry > > > > > ir. Thierry Onkelinx > Instituut voor natuur- en bosonderzoek / Research Institute for Nature > and Forest > Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, > methodology and quality assurance > Gaverstraat 4 > 9500 Geraardsbergen > Belgium > tel. + 32 54/436 185 > thierry.onkel...@inbo.be > www.inbo.be > > To call in the statistician after the experiment is done may be no more > than asking him to perform a post-mortem examination: he may be able to > say what the experiment died of. > ~ Sir Ronald Aylmer Fisher > > The plural of anecdote is not data. > ~ Roger Brinner > > The combination of some data and an aching desire for an answer does not > ensure that a reasonable answer can be extracted from a given body of > data. > ~ John Tukey > > -Oorspronkelijk bericht- > Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > Namens Dimitri Liakhovitski > Verzonden: donderdag 23 april 2009 16:31 > Aan: R-Help List > Onderwerp: [R] transposing a matrix - row by row? > > Hello, > I have a matrix that is a product of tapply on a larger data set. > Let's assume it looks like this: > > X<-matrix(c(10,20,30,40,50,60),2,3) > dimnames(X)<-list(c("1","2"),c("1","2","3")) > (X) > > 1 2 3 > 1 10 30 50 > 2 20 40 60 > > Is there an efficient way of transforming this matrix into the following > matrix: > > rows columns entries > 1 1 10 > 1 2 30 > 1 3 50 > 2 1 20 > 2 2 40 > 2 3 60 > > > Thank you very much! > -- > Dimitri Liakhovitski > MarketTools, Inc. > dimitri.liakhovit...@markettools.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. > > Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer > en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd > is > door een geldig ondertekend document. The views expressed in this message > and any annex are purely those of the writer and may not be regarded as > stating > an official position of INBO, as long as the message is not confirmed by a > duly > signed document. > -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.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] Adobe FLEX interacting with R for rich visualization over the Web
Hi R users, I am looking to create a rich internet application using R as the analytical back-end with a GUI written entirely in Adobe FLEX. I have come across this paper http://www.bioconductor.org/packages/2.3/bioc/vignettes/RWebServices/inst/doc/RelatedWork.pdf which provides relevant information. >From what I understand, FLEX can read xml files. The StatDataML library in R creates xml files which can be read by FLEX. Since I would need to implement the GUI on a web server and the R server would be on a different system, I felt using StatDataML to write xml files would be the best approach. I have also heard of the RSOAP library which possibly can be another alternative to the above library. I am trying to create a way for users to be able to visualize the results of regressions and other statistical functions in an interactive manner over the web. If anyone has worked with the above tools or related scenarios, I would greatly appreciate your feedback. Thanks Harsh Singhal __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] transposing a matrix - row by row?
one way is the following: X <- matrix(c(10,20,30,40,50,60), 2, 3, dimnames = list(c("1","2"), c("1","2","3"))) tX <- t(X) cbind( rows = c(col(tX)), columns = c(row(tX)), entries = c(tX) ) I hope it helps. Best, Dimitris Dimitri Liakhovitski wrote: Hello, I have a matrix that is a product of tapply on a larger data set. Let's assume it looks like this: X<-matrix(c(10,20,30,40,50,60),2,3) dimnames(X)<-list(c("1","2"),c("1","2","3")) (X) 1 2 3 1 10 30 50 2 20 40 60 Is there an efficient way of transforming this matrix into the following matrix: rows columns entries 1 1 10 1 2 30 1 3 50 2 1 20 2 2 40 2 3 60 Thank you very much! -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] large factorials
The code in my prior post works (except one comment was wrong) but try this instead. The only change is the last line of the sum1 function. This way it produces a Sym object rather than a character string. library(rSymPy) # define factorial to return a Sym object factorial.Sym <- function(n) Sym("factorial(", n, ")") sum1 <- function(l,u,t,i,n,w) { v <- 0 for (m in 0 :w) { v1 <- ((u^(1/2))*(l^(1/2))*t)^(i-n+2*m) v2 <- (factorial.Sym(i-n+m))*(factorial.Sym(m)) v3 <- v1/v2 v <- v+v3 } Sym(sympy(v)) # send it to SymPy, make result a Sym obj } s <- sum1(1,2,10,80,3,80) s # Sym as.numeric(s) # numeric On Thu, Apr 23, 2009 at 10:37 AM, Gabor Grothendieck wrote: > sympy() returns a character string, not an R numeric -- it shouldn't > automatically return an R numeric since R can't represent all > the numbers that sympy can. > > The development version of rSymPy has a second class which > produces objects of class c("Sym", "character") and those > can be manipulated with +, -, *, / producing other Sym > objects so try this: > > > library(rSymPy) > > # next line pulls in code to handle Sym objects > source("http://rsympy.googlecode.com/svn/trunk/R/Sym.R";) > > # define factorial to return a Sym object > factorial.Sym <- function(n) Sym("factorial(", n, ")") > > sum1 <- function(l,u,t,i,n,w) { > v <- 0 > for (m in 0 :w) { > v1 <- ((u^(1/2))*(l^(1/2))*t)^(i-n+2*m) > v2 <- (factorial.Sym(i-n+m))*(factorial.Sym(m)) > v3 <- v1/v2 > v <- v+v3 > } > sympy(v) > } > > s <- sum1(1,2,10,80,3,80) > s # Sym object > as.numeric(s) # numeric > > > On Thu, Apr 23, 2009 at 10:00 AM, molinar wrote: >> >> Here is what I did: >> library(rSymPy) >> factorial.sympy <- function(n) sympy(paste("factorial(", n, ")")) >> factorial.sympy(171) >> [1] >> "124101807021766782342484052410310399261660557750169318538895180361199607522169175299275197812048758557646495950167038705280988985869071076733124203221848436431047357788996854827829075454156196485215346831804429323959817369689965723590394761615227855818006117636510842880" >>> >> Which work perfectly. >> >> Here is one of my summation functions: >> >> sum1 <- function(l,u,t,i,n,w) { >> + v <- 0 >> + for (m in 0 :w) { >> + v1 <- ((u^(1/2))*(l^(1/2))*t)^(i-n+2*m) >> + v2 <- (factorial.sympy(i-n+m))*(factorial.sympy(m)) >> + v3 <- v1/v2 >> + v <- v+v3 >> + } >> + return(v) >> + } >> >> sum1(1,2,10,80,3,80) >> Error in (factorial.sympy(i - n + m)) * (factorial.sympy(m)) : >> non-numeric argument to binary operator >> >> I'm not sure why it works when I do the factorial normally but when I call >> my function it doesn't work? >> >> >> >> >> >> >> >> molinar wrote: >>> >>> Thank you everyone all of your posts were very helpful. I tried each one >>> and I think I have about 10 new packages installed. The formula I need to >>> calculate did not involve any logarithms but infinite summations of >>> factorials, I'm sorry for not specifying. I read some things about using >>> logarithms but I thought in my case I would have to do an e to the log and >>> by doing that R still gave me the same problems with numbers over 170. >>> >>> But I was able to get it to work by using the last post about the rsympy >>> packages. >>> >>> I tried downloading bc but I didn't know how to connect it to R, so R said >>> "could not find function bc". >>> >>> Thanks again for all of your help. >>> Samantha >>> >>> >>> >>> >>> >>> Gabor Grothendieck wrote: Also the R sympy package can handle this: > library(rSymPy) Loading required package: rJava > factorial.sympy <- function(n) sympy(paste("factorial(", n, ")")) > # note that first time sympy is called it loads java, jython and sympy > # but on subsequent calls its faster. So make a dummy call first. > factorial.sympy(10) [1] "3628800" > # code from earlier post defining factorial.bc to be inserted here > benchmark(replications=10, columns=c('test', 'elapsed'), + bc=factorial.bc(500), + sympy = factorial.sympy(500)) test elapsed 1 bc 2.17 2 sympy 0.09 See the rSymPy, r-bc and rbenchmark home pages: http://rsympy.googlecode.com http://r-bc.googlecode.com http://rbenchmark.googlecode.com On Wed, Apr 22, 2009 at 3:21 PM, molinar wrote: > > I am working on a project that requires me to do very large factorial > evaluations. On R the built in factorial function and the one I created > both are not able to do factorials over 170. The first gives an error > and > mine return Inf. > > Is there a way to have R do these larger calculations (the calculator in > accessories can do 1 factorial and Maple can do even larger) > -- > View this message in context: > http://www.nabble.com/large-factorials-tp23175816p23175816.html > Sent from the R he
Re: [R] transposing a matrix - row by row?
Dear Dimitri, Have a look at melt() from the reshape package. X<-matrix(c(10,20,30,40,50,60),2,3) dimnames(X)<-list(c("1","2"),c("1","2","3")) library(reshape) melt(X) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Dimitri Liakhovitski Verzonden: donderdag 23 april 2009 16:31 Aan: R-Help List Onderwerp: [R] transposing a matrix - row by row? Hello, I have a matrix that is a product of tapply on a larger data set. Let's assume it looks like this: X<-matrix(c(10,20,30,40,50,60),2,3) dimnames(X)<-list(c("1","2"),c("1","2","3")) (X) 1 2 3 1 10 30 50 2 20 40 60 Is there an efficient way of transforming this matrix into the following matrix: rows columns entries 1 1 10 1 2 30 1 3 50 2 1 20 2 2 40 2 3 60 Thank you very much! -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] large factorials
sympy() returns a character string, not an R numeric -- it shouldn't automatically return an R numeric since R can't represent all the numbers that sympy can. The development version of rSymPy has a second class which produces objects of class c("Sym", "character") and those can be manipulated with +, -, *, / producing other Sym objects so try this: library(rSymPy) # next line pulls in code to handle Sym objects source("http://rsympy.googlecode.com/svn/trunk/R/Sym.R";) # define factorial to return a Sym object factorial.Sym <- function(n) Sym("factorial(", n, ")") sum1 <- function(l,u,t,i,n,w) { v <- 0 for (m in 0 :w) { v1 <- ((u^(1/2))*(l^(1/2))*t)^(i-n+2*m) v2 <- (factorial.Sym(i-n+m))*(factorial.Sym(m)) v3 <- v1/v2 v <- v+v3 } sympy(v) } s <- sum1(1,2,10,80,3,80) s # Sym object as.numeric(s) # numeric On Thu, Apr 23, 2009 at 10:00 AM, molinar wrote: > > Here is what I did: > library(rSymPy) > factorial.sympy <- function(n) sympy(paste("factorial(", n, ")")) > factorial.sympy(171) > [1] > "124101807021766782342484052410310399261660557750169318538895180361199607522169175299275197812048758557646495950167038705280988985869071076733124203221848436431047357788996854827829075454156196485215346831804429323959817369689965723590394761615227855818006117636510842880" >> > Which work perfectly. > > Here is one of my summation functions: > > sum1 <- function(l,u,t,i,n,w) { > + v <- 0 > + for (m in 0 :w) { > + v1 <- ((u^(1/2))*(l^(1/2))*t)^(i-n+2*m) > + v2 <- (factorial.sympy(i-n+m))*(factorial.sympy(m)) > + v3 <- v1/v2 > + v <- v+v3 > + } > + return(v) > + } > > sum1(1,2,10,80,3,80) > Error in (factorial.sympy(i - n + m)) * (factorial.sympy(m)) : > non-numeric argument to binary operator > > I'm not sure why it works when I do the factorial normally but when I call > my function it doesn't work? > > > > > > > > molinar wrote: >> >> Thank you everyone all of your posts were very helpful. I tried each one >> and I think I have about 10 new packages installed. The formula I need to >> calculate did not involve any logarithms but infinite summations of >> factorials, I'm sorry for not specifying. I read some things about using >> logarithms but I thought in my case I would have to do an e to the log and >> by doing that R still gave me the same problems with numbers over 170. >> >> But I was able to get it to work by using the last post about the rsympy >> packages. >> >> I tried downloading bc but I didn't know how to connect it to R, so R said >> "could not find function bc". >> >> Thanks again for all of your help. >> Samantha >> >> >> >> >> >> Gabor Grothendieck wrote: >>> >>> Also the R sympy package can handle this: >>> library(rSymPy) >>> Loading required package: rJava >>> factorial.sympy <- function(n) sympy(paste("factorial(", n, ")")) >>> # note that first time sympy is called it loads java, jython and sympy # but on subsequent calls its faster. So make a dummy call first. factorial.sympy(10) >>> [1] "3628800" >>> # code from earlier post defining factorial.bc to be inserted here >>> benchmark(replications=10, columns=c('test', 'elapsed'), >>> + bc=factorial.bc(500), >>> + sympy = factorial.sympy(500)) >>> test elapsed >>> 1 bc 2.17 >>> 2 sympy 0.09 >>> >>> See the rSymPy, r-bc and rbenchmark home pages: >>> http://rsympy.googlecode.com >>> http://r-bc.googlecode.com >>> http://rbenchmark.googlecode.com >>> >>> On Wed, Apr 22, 2009 at 3:21 PM, molinar wrote: I am working on a project that requires me to do very large factorial evaluations. On R the built in factorial function and the one I created both are not able to do factorials over 170. The first gives an error and mine return Inf. Is there a way to have R do these larger calculations (the calculator in accessories can do 1 factorial and Maple can do even larger) -- View this message in context: http://www.nabble.com/large-factorials-tp23175816p23175816.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. >>> >>> >> >> > > -- > View this message in context: > http://www.nabble.com/large-factorials-tp23175816p23197344.html > Sent from the R help mailing list archive at Nabble.com. > > _
[R] Plots - several pages per pdf - quality/size issue
Dear R-experts, I hope that question will not be too redundant (sorry if it is) but i don't seem able to find the answer i need in the archives... I try to create a file which would have 1.several pages and 2.several plots by page. I know how to make a pdf file this way, but my problem is that the pdf size gets way too big and cannot be open. So my question is: - is there a way to diminish the pdf size/quality? - does any other file format exists that would be of smaller quality but still be able to print plots on several pages for the same file? Thank you for your help! Sarah __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] transposing a matrix - row by row?
Hello, I have a matrix that is a product of tapply on a larger data set. Let's assume it looks like this: X<-matrix(c(10,20,30,40,50,60),2,3) dimnames(X)<-list(c("1","2"),c("1","2","3")) (X) 1 2 3 1 10 30 50 2 20 40 60 Is there an efficient way of transforming this matrix into the following matrix: rows columns entries 1 1 10 1 2 30 1 3 50 2 1 20 2 2 40 2 3 60 Thank you very much! -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.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] Problem to get a simple Analysis of Variance table with lmer()
Dear R users, Is someone know how to get a simple analysis of variance table using other random distribution than normal (ex: Poisson or Binomial)? When I try, I recieved this message: (See my R code below) - R response Erreur dans anova(fit.poisson) : single argument anova for GLMMs not yet implemented OR Erreur dans anova(fit.binomial) : single argument anova for GLMMs not yet implemented - Here is the code that I used for a quick simulation of my data and for a gaussian distribution I have no problem to get a simple table but not when I use poisson or binomial distribution... Is it possible that it is effectively not yet implemented in the lmer package? or did I make something wrong? - My R code - z1<-as.factor(rep(seq(1:2), each=48)) # first random factor with 2 levels z2<-as.factor(rep(seq(1:16), each=6)) # second random factor (= repetition) x1<-as.factor(rep(seq(1:3), 32)) # first fixed factor with three levels x2<-as.character(rep(rep(seq(c("O","N")), each=3), 16)) # second fixed factor with 2 levels y.integer<-as.integer(runif(96, 0, 25)) # response variable (integer) y.binary<-as.integer(rbinom(96, 1,0.5)) # response variable (binary) data.test<-as.data.frame(cbind(z1,z2,x1,x2,y)) data.test$y<-as.integer(data.test$y) The models that I have tested: fit.normal<-lmer(y.integer~x1*x2 + (1|z1/z2/x1), data=data.test, family=gaussian) anova(fit.normal) summary(fit.normal) fit.poisson<-lmer(y.integer~x1*x2 + (1|z1/z2/x1), data=data.test, family=poisson(link = "log")) anova(fit.poisson) summary(fit.poisson) fit.binomial<-lmer(y.binary~x1*x2 + (1|z1/z2/x1), data=data.test, family=binomial(link = "logit")) anova(fit.binomial) summary(fit.binomial) --- Thank's in advance for you amswer. Julien -- Julien Beguin Etudiant au doctorat Faculté de Foresterie et de Géomatique Université Laval, local 2113 2405 rue de la Terrasse, G1V 0A6 Québec (Qc) Tel: (418) 656-2131 poste 2620 http://www.cen.ulaval.ca/anticosti/jbeguin.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plots - several pages per pdf - quality/size issue
Dear R-experts, I hope that question will not be too redundant (sorry if it is) but i don't seem able to find the answer i need in the archives... I try to create a file which would have 1.several pages and 2.several plots by page. I know how to make a pdf file this way, but my problem is that the pdf size gets way too big and cannot be open. So my question is: - is there a way to diminish the pdf size/quality? - does any other file format exists that would be of smaller quality but still be able to print plots on several pages for the same file? Thank you for your help! Sarah [[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] R 2.9 binaries for redhat entreprise 4 / X86_64
On Apr 23, 2009, at 8:18 AM, Mathieu Van der Haegen wrote: Hi everybody. I'd like to ask if someone could tell me when the binaries for R 2.9 / redhat entreprise 4 / X86_64 will be available ? I don't need a precise date but some indication like 1 month, 6 month, never ? Thank you for any help. Mathieu I can't speak to the timeline for the CRAN RPMs, but you might also want to keep an eye on the EPEL repos, which provide add-on RPMs for RHEL. More info here: http://fedoraproject.org/wiki/EPEL and the specific link for R for RHEL 4/x84_64 is: http://download.fedora.redhat.com/pub/epel/4/x86_64/repoview/R.html Not there yet either. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Setting lattice par parameters
Sundar, Thank you very much. I see my mistake. Much appreciated. Steve Friedman Ph. D. 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 Sundar Dorai-Raj To steve_fried...@nps.gov 04/23/2009 06:56 cc AM MSTr-help Help Subject Re: [R] Setting lattice par parameters Because you're not calling trellis.par.set correctly. It should be: trellis.par.set(par.ylab.text = list(cex = 0.65), par.xlab.text = list(cex = 0.65)) However, I usually do things like this: my.theme <- list(par.ylab.text = list(cex = 0.65), par.xlab.text = list(cex = 0.65)) barchart(..., par.settings = my.theme) so the settings are only changed for the current plot and not globally. HTH, --sundar On Thu, Apr 23, 2009 at 6:25 AM, wrote: > > Hello > > I'm plotting a large suite of barcharts and need to modify the size of the > text for both the yaxis and xaxis labels. > > I've tried using the following: > >> trellis.par.set(list(par.ylab.text = list(cex = 0.65)), > trellis.par.set(list = par.xlab.text = list(cex = 0.65 > > On inspection, however after I invoke this line, > >> trellis.par.get("par.ylab.text") >> trellis.par.get("par.xlab.text") > > It looks like the parameters have not been modified. > > Do I need to do something different than this approach ? > > Thank you very much in advance. > > Steve > > Steve Friedman Ph. D. > 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. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] large factorials
Hi Samantha, It is quite likely that you are not doing something right when you are explicitly computing large factorials. There is probably a good asymptotic approximation that will simplify things for you. In my experience, there is seldom a need to explicitly compute factorials of integers. What is the real problem that you are trying to solve? Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of molinar Sent: Thursday, April 23, 2009 9:42 AM To: r-help@r-project.org Subject: Re: [R] large factorials Thank you everyone all of your posts were very helpful. I tried each one and I think I have about 10 new packages installed. The formula I need to calculate did not involve any logarithms but infinite summations of factorials, I'm sorry for not specifying. I read some things about using logarithms but I thought in my case I would have to do an e to the log and by doing that R still gave me the same problems with numbers over 170. But I was able to get it to work by using the last post about the rsympy packages. I tried downloading bc but I didn't know how to connect it to R, so R said "could not find function bc". Thanks again for all of your help. Samantha Gabor Grothendieck wrote: > > Also the R sympy package can handle this: > >> library(rSymPy) > Loading required package: rJava > >> factorial.sympy <- function(n) sympy(paste("factorial(", n, ")")) > >> # note that first time sympy is called it loads java, jython and >> sympy # but on subsequent calls its faster. So make a dummy call first. >> factorial.sympy(10) > [1] "3628800" > >> # code from earlier post defining factorial.bc to be inserted here > >>benchmark(replications=10, columns=c('test', 'elapsed'), > + bc=factorial.bc(500), > + sympy = factorial.sympy(500)) >test elapsed > 1bc2.17 > 2 sympy0.09 > > See the rSymPy, r-bc and rbenchmark home pages: > http://rsympy.googlecode.com > http://r-bc.googlecode.com > http://rbenchmark.googlecode.com > > On Wed, Apr 22, 2009 at 3:21 PM, molinar wrote: >> >> I am working on a project that requires me to do very large factorial >> evaluations. On R the built in factorial function and the one I >> created both are not able to do factorials over 170. The first gives >> an error and mine return Inf. >> >> Is there a way to have R do these larger calculations (the calculator >> in accessories can do 1 factorial and Maple can do even larger) >> -- >> View this message in context: >> http://www.nabble.com/large-factorials-tp23175816p23175816.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. > > -- View this message in context: http://www.nabble.com/large-factorials-tp23175816p23197201.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] R 2.9 binaries for redhat entreprise 4 / X86_64
On Thu, 23 Apr 2009, Mathieu Van der Haegen wrote: I'd like to ask if someone could tell me when the binaries for R 2.9 / redhat entreprise 4 / X86_64 will be available ? I don't need a precise date but some indication like 1 month, 6 month, never ? How about: Now, in Red Hat's RawHide archive? [herr...@centos-5 ~]$ uname -a ; rpm -q R Linux centos-5.first.lan 2.6.18-128.1.6.el5xen #1 SMP Wed Apr 1 09:53:14 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux R-2.9.0-1orc [herr...@centos-5 ~]$ I built it earlier this week from SRPM on CentOS (a rebuild of RHEL) -- Russ herrold __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] large factorials
Here is what I did: library(rSymPy) factorial.sympy <- function(n) sympy(paste("factorial(", n, ")")) factorial.sympy(171) [1] "124101807021766782342484052410310399261660557750169318538895180361199607522169175299275197812048758557646495950167038705280988985869071076733124203221848436431047357788996854827829075454156196485215346831804429323959817369689965723590394761615227855818006117636510842880" > Which work perfectly. Here is one of my summation functions: sum1 <- function(l,u,t,i,n,w) { + v <- 0 + for (m in 0 :w) { + v1 <- ((u^(1/2))*(l^(1/2))*t)^(i-n+2*m) + v2 <- (factorial.sympy(i-n+m))*(factorial.sympy(m)) + v3 <- v1/v2 + v <- v+v3 + } + return(v) + } sum1(1,2,10,80,3,80) Error in (factorial.sympy(i - n + m)) * (factorial.sympy(m)) : non-numeric argument to binary operator I'm not sure why it works when I do the factorial normally but when I call my function it doesn't work? molinar wrote: > > Thank you everyone all of your posts were very helpful. I tried each one > and I think I have about 10 new packages installed. The formula I need to > calculate did not involve any logarithms but infinite summations of > factorials, I'm sorry for not specifying. I read some things about using > logarithms but I thought in my case I would have to do an e to the log and > by doing that R still gave me the same problems with numbers over 170. > > But I was able to get it to work by using the last post about the rsympy > packages. > > I tried downloading bc but I didn't know how to connect it to R, so R said > "could not find function bc". > > Thanks again for all of your help. > Samantha > > > > > > Gabor Grothendieck wrote: >> >> Also the R sympy package can handle this: >> >>> library(rSymPy) >> Loading required package: rJava >> >>> factorial.sympy <- function(n) sympy(paste("factorial(", n, ")")) >> >>> # note that first time sympy is called it loads java, jython and sympy >>> # but on subsequent calls its faster. So make a dummy call first. >>> factorial.sympy(10) >> [1] "3628800" >> >>> # code from earlier post defining factorial.bc to be inserted here >> >>>benchmark(replications=10, columns=c('test', 'elapsed'), >> + bc=factorial.bc(500), >> + sympy = factorial.sympy(500)) >>test elapsed >> 1bc2.17 >> 2 sympy0.09 >> >> See the rSymPy, r-bc and rbenchmark home pages: >> http://rsympy.googlecode.com >> http://r-bc.googlecode.com >> http://rbenchmark.googlecode.com >> >> On Wed, Apr 22, 2009 at 3:21 PM, molinar wrote: >>> >>> I am working on a project that requires me to do very large factorial >>> evaluations. On R the built in factorial function and the one I created >>> both are not able to do factorials over 170. The first gives an error >>> and >>> mine return Inf. >>> >>> Is there a way to have R do these larger calculations (the calculator in >>> accessories can do 1 factorial and Maple can do even larger) >>> -- >>> View this message in context: >>> http://www.nabble.com/large-factorials-tp23175816p23175816.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. >> >> > > -- View this message in context: http://www.nabble.com/large-factorials-tp23175816p23197344.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] Setting lattice par parameters
Because you're not calling trellis.par.set correctly. It should be: trellis.par.set(par.ylab.text = list(cex = 0.65), par.xlab.text = list(cex = 0.65)) However, I usually do things like this: my.theme <- list(par.ylab.text = list(cex = 0.65), par.xlab.text = list(cex = 0.65)) barchart(..., par.settings = my.theme) so the settings are only changed for the current plot and not globally. HTH, --sundar On Thu, Apr 23, 2009 at 6:25 AM, wrote: > > Hello > > I'm plotting a large suite of barcharts and need to modify the size of the > text for both the yaxis and xaxis labels. > > I've tried using the following: > >> trellis.par.set(list(par.ylab.text = list(cex = 0.65)), > trellis.par.set(list = par.xlab.text = list(cex = 0.65 > > On inspection, however after I invoke this line, > >> trellis.par.get("par.ylab.text") >> trellis.par.get("par.xlab.text") > > It looks like the parameters have not been modified. > > Do I need to do something different than this approach ? > > Thank you very much in advance. > > Steve > > Steve Friedman Ph. D. > 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. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 2.9 for redhat entreprise 4 / X86_64
Hi everybody. I'd like to ask if someone could tell me when the binaries for R 2.9 / redhat entreprise 4 / X86_64 will be available ? I don't need a precise date but some indication like 1 month, 6 month, never ? Thank you for any help. Mathieu --- Mathieu Van der Haegen Machine Learning Group Université Libre de Bruxelles [[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] argument 'exclude' in xtabs
Dear all I was willing to use argument 'exclude' in function xtabs to remove some levels of factors (xtabs help page says '"exclude: a vector of values to be excluded when forming the set of levels of the classifying factors"). I tried: > mydata <- data.frame( + treatment = c("B", "A", "C", "C", "B", "B", "C", "A", "B", "B", NA, "C"), + surv = c("YES", "NO", "YES", "YES", "NO", "NO", "NO", "YES", "YES", "NO", "NO", NA) + ) > levels(mydata$treatment) [1] "A" "B" "C" > # try to remove level "B" in variable treatment > xtabs(formula = ~ treatment + surv, data = mydata, exclude = "B") surv treatment NO YES A 1 1 B 3 2 C 1 2 One alternative is to do: > xtabs(formula = ~ treatment + surv, data = mydata[mydata$treatment != "B", ], drop.unused.levels = TRUE) surv treatment NO YES A 1 1 C 1 2 But I don't understand why I cannot remove "B" directly with argument exclude. Any help is welcome Regards Matthieu My version on Windows XP platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 9.0 year 2009 month 04 day17 svn rev48333 language R version.string R version 2.9.0 (2009-04-17) -- Matthieu Lesnoff CIRAD BP 1813, Quartier Niaréla, Immeuble Kouma Bamako, Mali E-mail: matthieu.lesn...@cirad.fr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 2.9 binaries for redhat entreprise 4 / X86_64
Hi everybody. I'd like to ask if someone could tell me when the binaries for R 2.9 / redhat entreprise 4 / X86_64 will be available ? I don't need a precise date but some indication like 1 month, 6 month, never ? Thank you for any help. Mathieu --- Mathieu Van der Haegen Machine Learning Group Université Libre de Bruxelles [[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] surface interpolating 3d
Hi all, When you want to draw a surface with a mathematics program you need of two vectors x and y and a matrix z. Then you plot the surface. For example: x=[1 2 3]; y=[5 6 7]; z=[1 2 3 4 5 6 7 8 9]; For my applications I have a 3 vectors x, y, z, that are the coordinates x, y, and z of points in the space. I would find the surface that interpolate this point. How can I do? For example: x=[1 2 3]; y=[5 6 7]; z=[6 9 8]; Thank you very much -- View this message in context: http://www.nabble.com/surface-interpolating-3d-tp23196713p23196713.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] large factorials
Thank you everyone all of your posts were very helpful. I tried each one and I think I have about 10 new packages installed. The formula I need to calculate did not involve any logarithms but infinite summations of factorials, I'm sorry for not specifying. I read some things about using logarithms but I thought in my case I would have to do an e to the log and by doing that R still gave me the same problems with numbers over 170. But I was able to get it to work by using the last post about the rsympy packages. I tried downloading bc but I didn't know how to connect it to R, so R said "could not find function bc". Thanks again for all of your help. Samantha Gabor Grothendieck wrote: > > Also the R sympy package can handle this: > >> library(rSymPy) > Loading required package: rJava > >> factorial.sympy <- function(n) sympy(paste("factorial(", n, ")")) > >> # note that first time sympy is called it loads java, jython and sympy >> # but on subsequent calls its faster. So make a dummy call first. >> factorial.sympy(10) > [1] "3628800" > >> # code from earlier post defining factorial.bc to be inserted here > >>benchmark(replications=10, columns=c('test', 'elapsed'), > + bc=factorial.bc(500), > + sympy = factorial.sympy(500)) >test elapsed > 1bc2.17 > 2 sympy0.09 > > See the rSymPy, r-bc and rbenchmark home pages: > http://rsympy.googlecode.com > http://r-bc.googlecode.com > http://rbenchmark.googlecode.com > > On Wed, Apr 22, 2009 at 3:21 PM, molinar wrote: >> >> I am working on a project that requires me to do very large factorial >> evaluations. On R the built in factorial function and the one I created >> both are not able to do factorials over 170. The first gives an error >> and >> mine return Inf. >> >> Is there a way to have R do these larger calculations (the calculator in >> accessories can do 1 factorial and Maple can do even larger) >> -- >> View this message in context: >> http://www.nabble.com/large-factorials-tp23175816p23175816.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. > > -- View this message in context: http://www.nabble.com/large-factorials-tp23175816p23197201.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] Setting lattice par parameters
Hello I'm plotting a large suite of barcharts and need to modify the size of the text for both the yaxis and xaxis labels. I've tried using the following: > trellis.par.set(list(par.ylab.text = list(cex = 0.65)), trellis.par.set(list = par.xlab.text = list(cex = 0.65 On inspection, however after I invoke this line, > trellis.par.get("par.ylab.text") > trellis.par.get("par.xlab.text") It looks like the parameters have not been modified. Do I need to do something different than this approach ? Thank you very much in advance. Steve Steve Friedman Ph. D. 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] R: R: R: how to split and handle a big R program into multiple files
May I suggest you join R-forge when your package has taken shape? It'll allow you to easily check the building of the package on all platforms and you'll be able to submit to CRAN in one click when it's good enough. baptiste On 23 Apr 2009, at 13:58, mau...@alice.it wrote: > Submitting to CRAN is one of my goals. What we are implementing is > not done yet either in R or MatLab. > There exists some Fortran applications of the algorithms we are > implementing for general use. > it'll still take me some time before I get there. > Maura > > > > -Messaggio originale- > Da: Duncan Murdoch [mailto:murd...@stats.uwo.ca] > Inviato: gio 23/04/2009 14.21 > A: mau...@alice.it > Cc: baptiste auguie; r-help Help > Oggetto: Re: [R] R: R: how to split and handle a big R program into > multiple files > > On 4/23/2009 7:15 AM, mau...@alice.it wrote: > > I read the on-line documentation. > > What I am still missing is how I run my program after > encapsulating it in a package. > > I will have to load the package ... just guessing > > If I had a large program that I needed to run just once, e.g. an > analysis or simulations for a paper, here's how I would organize it: > > - Identify all the general purpose functions and put them in a > package. > - The one-off parts of the code don't really belong as functions > in a > package, though there's nothing to stop you from doing that. I'd > probably put them into a vignette, or just write the whole paper in > Sweave, which is almost the same thing. > > If your general purpose functions do something new that would be > useful > to others, you might want to polish up the package and send it to CRAN > (and perhaps submit it with a supporting paper to JSS). But that's > not > necessary: a package is a good way to organize code for your own > use too. > > Duncan Murdoch > > > > > Thank you > > maura > > > > -Messaggio originale- > > Da: baptiste auguie [mailto:ba...@exeter.ac.uk] > > Inviato: gio 23/04/2009 12.17 > > A: mau...@alice.it > > Cc: r-help Help > > Oggetto: Re: R: [R] how to split and handle a big R program into > multiple files > > > > It is an R command (package utils), see ?package.skeleton > > > > baptiste > > > > On 23 Apr 2009, at 10:51, mau...@alice.it wrote: > > > >> > >> Is that an R command ? > >> I browswd for the on-line hlp about such a command but could not > >> find it. > >> Thank you. > >> maura > >> > >> > >> -Messaggio originale- > >> Da: baptiste auguie [mailto:ba...@exeter.ac.uk] > >> Inviato: gio 23/04/2009 11.48 > >> A: mau...@alice.it > >> Cc: r-help Help > >> Oggetto: Re: [R] how to split and handle a big R program into > >> multiple files > >> > >> > >> If most of the functions are quite stable (you don't change them > too > >> often), you could also consider creating a R package with > >> package.skeleton. > >> > >> > >> baptiste > >> > >> > >> > >> On 23 Apr 2009, at 10:39, jgar...@ija.csic.es wrote: > >> > >> > source() and the use of functions > >> > ... > >> > Javier > >> > --- > >> > > >> >> I am working on a program totally written in R which is now > getting > >> >> bigger > >> >> and bigger so that editling the only file that contains all the > >> >> functions > >> >> is becoming more and more unmanageable. > >> >> I wonder whether it is possible to spread the R code, making > up the > >> >> same > >> >> program, in a number of smaller files and then call them all, in > >> >> the right > >> >> order, through a list of something like the C language > >> >> directive. > >> >> > >> >> Any other suggestion how to organize, handle, and maintain a > big R > >> >> program > >> >> is welcome. > >> >> > >> >> Thank you in advance, > >> >> Maura > >> >> > >> >> > >> >> tutti i telefonini TIM! > >> >> > >> >> > >> >> [[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. > >> > >> _ > >> > >> Baptiste Auguié > >> > >> School of Physics > >> University of Exeter > >> Stocker Road, > >> Exeter, Devon, > >> EX4 4QL, UK > >> > >> Phone: +44 1392 264187 > >> > >> http://newton.ex.ac.uk/research/emag > >> __ > >> > >> > >> > >> > >> Alice Messenger ;-) chatti anche con gli amici di Windows Live > >> Messenger e tutti i telefonini TIM! > > > > er > >> > > > > _ > > > > Bapt