Re: [R] Lost in POSIX
df$dt - as.Date(df$t) Thank you, David, but I need a *time* value. day was a confusing special case; how about min? -- View this message in context: http://r.789695.n4.nabble.com/Lost-in-POSIX-tp3052768p3053146.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] plot start at origin
On 22.11.2010 07:44, Roslina Zakaria wrote: Hi r-users, I would like my axes to intersect at (0,0). I tried xaxs=i,yaxs=i but it does not change anything. I hope anybody can help me with this problem. Here is my code. use par(xaxs=i, yaxs=i) and then the rest of your code. UWe Ligges hist(datobs, prob=TRUE, main =PDF of the sum of two stations,col=yellowgreen, cex.axis=1.2, xlab=Rainfall (mm), ylab=Relative frequency, ylim= c(0,.008), xlim=c(0,600),xaxs=i,yaxs=i) lines(density(dd), lwd=3,col=red) legend(topright, legend = c(observed,fitted), col = c(yellowgreen, red), pch=c(15,NA), lty = c(0, 1), lwd=c(0,3),bty=n, pt.cex=2) box() Thank you. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] using rpart with a tree misclassification condition
Hello I want to build a classification tree for a binary response variable while the condition for the final tree should be : The total misclassification for each group (zero or one) will be less then 10% . for example: if I have in the root 100 observations, 90 from group 0 and 10 from group 1, I want that in the final tree a maximum of 9 and 1 observations out of group 0 and 1, respectively, will be misclassified. Does anyone know what code will be appropriate for implementing this condition? Thank you in advance Meytar -- View this message in context: http://r.789695.n4.nabble.com/using-rpart-with-a-tree-misclassification-condition-tp3053167p3053167.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to combine Date and time in one column
On 22.11.2010 08:24, rnick wrote: Hello everyone, I am trying to built an xts object and i have run into some problems on the data handling. I would really appreciate if someone could help me with the following: 1) I have a OHLC dataset with Time and date in different columns. How could i combine date and time in one column in order to pass on the new column to xts? I have use cbind and data.frame before but i did not manage to yield any good results as the formating of the file changes. DateTime OH L C 1/2/200517:05 1.3546 1.3553 1.3546 1.35495 1/2/200517:10 1.3553 1.3556 1.3549 1.35525 1/2/200517:15 1.3556 1.35565 1.35515 1.3553 1/2/200517:25 1.3551.3556 1.355 1.3555 1/2/200517:30 1.3556 1.3564 1.35535 1.3563 dat$DateTime - strptime(paste(dat$Date, dat$Time), %d/%m/%Y %H:%M) Uwe Ligges 2) It is not clear to me what is the best way to construct the .xts object? Should i use only the Datetime to index or should i also combine it with the rest of the variables? Thanks in advance, N __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] using rpart with a tree misclassification condition
On 22.11.2010 08:32, meytar wrote: Hello I want to build a classification tree for a binary response variable while the condition for the final tree should be : The total misclassification for each group (zero or one) will be less then 10% . for example: if I have in the root 100 observations, 90 from group 0 and 10 from group 1, I want that in the final tree a maximum of 9 and 1 observations out of group 0 and 1, respectively, will be misclassified. Does anyone know what code will be appropriate for implementing this condition? If you mean the misclassification for new observations: no, otherwise I would be extremely rich. If you meant the apparent error rate: Just grow a full tree and then prune step by step until the error is too large for your condition. Then just take the tree model from one step before Uwe Ligges Thank you in advance Meytar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 loop through variables in R?
After importing a table with M variables and N records, I'd like to calculate chi-square statistics, say, between N1, N2; N1, N3, ..., N1, Ni, and then N2, N3, ... N2, Ni, ..., Ni-1, Ni. Two loops should be ok but the manual online help don't show a systematic way to do so but instead show hard-code examples so users have to type in the names themselves one by one... -- View this message in context: http://r.789695.n4.nabble.com/how-to-loop-through-variables-in-R-tp3053214p3053214.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to loop through variables in R?
-Original Message- From: jas4710 wata...@post.com To: r-help@r-project.org Sent: Mon, Nov 22, 2010 4:11 pm Subject: [R] how to loop through variables in R? After importing a table with M variables and N records, I'd like to calculate chi-square statistics, say, between N1, N2; N1, N3, ..., N1, Ni, and then N2, N3, ... N2, Ni, ..., Ni-1, Ni. Two loops should be ok but the manual online help don't show a systematic way to do so but instead show hard-code examples so users have to type in the names themselves one by one... -- Sorry for typo. It should be N variables and M records. Thank you very much. [[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] unexpected numeric constant while reading tab delimited csv file
my csv file is very simple - just one line for purpose of this test: 0{TAB}0 and read function is this: csvdata = read.csv(file=d:/s/test.csv,head=FALSE,sep=\t) then error comes: Error in source(d:/test.csv) : d:/test.csv:1:9: unexpected numeric constant 1: 0 0 but when I change delimiter to ; (colon) then error not shows up anymore -- View this message in context: http://r.789695.n4.nabble.com/unexpected-numeric-constant-while-reading-tab-delimited-csv-file-tp3053252p3053252.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] unexpected numeric constant while reading tab delimited csv file
the problem shows up only in console when script is loaded thru source() and separator character is eighter tab or space, strangely, when I'm running script directly form file in text environment everything is ok. [I'm reposing this because my previous post didn't get on the list because double quote character at the beginning of a subject was eaten up when Re: was added, now everything should be ok ]] -- View this message in context: http://r.789695.n4.nabble.com/unexpected-numeric-constant-while-reading-tab-delimited-csv-file-tp3053252p3053291.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] Lost in POSIX
Dimitri Shvorob wrote: df$dt - as.Date(df$t) Thank you, David, but I need a *time* value. day was a confusing special case; how about min? Your original question was NOT clear on this point... it was not David's fault your question was confusing, and you haven't even hinted at an apology for leading him down the wrong path. Nor would I call this much of an improvement in clarity... what about min? You want to know the minimum? No? You want to truncate to minute? Why then did your original Try 2 attempt to zero out the minute (truncate to hour)? Perhaps the following will be enough help you figure out an answer to whatever your question is. If it doesn't, try asking again with consistent variable naming and sample results you want to obtain. truncMinute - function(dtm) { d - as.POSIXlt(dtm) d$sec - 0 as.POSIXct(d) } df$tt - truncMinute(df$t) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to loop through variables in R?
wata...@post.com wrote: -Original Message- From: jas4710 wata...@post.com To: r-help@r-project.org Sent: Mon, Nov 22, 2010 4:11 pm Subject: [R] how to loop through variables in R? After importing a table with M variables and N records, I'd like to calculate chi-square statistics, say, between N1, N2; N1, N3, ..., N1, Ni, and then N2, N3, ... N2, Ni, ..., Ni-1, Ni. Two loops should be ok but the manual online help don't show a systematic way to do so but instead show hard-code examples so users have to type in the names themselves one by one... Sorry for typo. It should be N variables and M records. Thank you very much. Assuming you are working with a data frame df, and your variable with the name of a column in it is col1, you should be able to extract that column as a vector using df[[col1]]. And yes, the manual does describe this notation. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to apply sample function to each row of a data frame?
On Sun, Nov 21, 2010 at 12:43:21PM -0800, wangwallace wrote: here is the data frame: a b c A B C [1,] 1 2 3 4 5 6 [2,] 7 8 9 10 11 12 [3,] 13 14 15 16 17 18 a, b, c are type I variables A, B, C are type II variables each row represent the data from one subject my purpose is to create a new data frame in which: 1) in each row, there are one random number from type I variables, and two random numbers from type II variables 2) meanwhile, in each row, the two type II numbers have to be only those numbers that are not corresponding to the type I number. For example, if the type I number is 1, the type II numbers should not include 4. 3) type I number and type II numbers in each row should be all from the same subject. the new data frame should be like this: [,1] [,2] [,3] [1,]I IIII [2,]I IIII [3,]I IIII If the two type II objects in a row should be always different, then this may be computed for example as follows. # prepare the input A - matrix(1:18, ncol=6, byrow=TRUE) colnames(A) - c(letters[1:3], LETTERS[1:3]) # prepare random indices for each row ind - t(replicate(nrow(A), sample(3))) # construct the output without a cycle col1 - A[cbind(seq(nrow(A)), ind[, 1])] col2 - A[cbind(seq(nrow(A)), 3 + ind[, 2])] col3 - A[cbind(seq(nrow(A)), 3 + ind[, 3])] B - cbind(col1, col2, col3) # or with a cycle over rows C - matrix(nrow=nrow(A), ncol=3) for (i in seq(nrow(A))) { C[i, 1] - A[i, ind[i, 1]] C[i, 2:3] - A[i, 3 + ind[i, 2:3]] } Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cpgram: access data, confidence bands
Dear R experts, beginners and everyone else, I'm calculating cumulative periodogram using the command cpgram [1] from the MASS library. Here is a short example with the lh (hormone level) dataset: library(MASS) plot(lh,type=l,ylab=value,xlab=time, main=Hormone Levels (lh)) spectrum(lh, main=Hormone Levels (lh)) # periodigram cpgram(lh, main=Hormone Levels (lh)) # cumul. periodigram I got following two questions: 1. The command cpgram plots the cumulative periodogram without any problem. But I could not figure out any way to access the data of the plot (save it in a variable). the following command fails (contains no data): myObject-cpgram(lh, main=Hormone Levels (lh)) summary(myObject) Length Class Mode 0 NULL NULL Is there an easy way to access the data of the cumulative periodogram, or do I need to rewrite the cpgram function? 2. The cpgram function plots with the default options the 95% confidence bands in the plot. The confidence band are defined such that in 95% of the cases the true value will lie inside the bands. For most cases which I tested the cumulative periodogram is outside the confidence band. Does cpgram plot the confidence band of the the cumulative periodogram or for the periodogram (I think it is the cumulative periodigram, is this correct?). How should the confidence band in cpgram be interpreted? Some more description on this would be great. Thanks, Henri 1: http://svn.r-project.org/R/trunk/src/library/stats/R/cpgram.R __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] unexpected numeric constant while reading tab delimited csv file
madr wrote: my csv file is very simple - just one line for purpose of this test: 0{TAB}0 and read function is this: csvdata = read.csv(file=d:/s/test.csv,head=FALSE,sep=\t) then error comes: Error in source(d:/test.csv) : d:/test.csv:1:9: unexpected numeric constant 1: 0 0 but when I change delimiter to ; (colon) then error not shows up anymore You seem to be referencing two different files somehow... one in the root directory of your drive D, and the other in a subdirectory D:/s. This may have something to do with it... or may be extraneous. You haven't indicated what your working environment is, though the OS seems likely to be some variant of Windows. In your other email, you mention a distinction between whatever this environment is (RGui?) and console. Are you using Cygwin? could end-of-line termination (CRLF vs LF) be causing you difficulty? Perhaps you should follow the posting guide instructions... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] xlim=c(min(x), max(x)) still produces extra margin on both sides of x axis in plot()
code: op - par(bg='black',fg='gray',col='gray',col.axis='gray',col.lab='gray',col.main='gray',col.sub='gray',mai=c(0,0,0,0), tck = 0.01, mgp = c(0, -1.4, 0), mar=c(0,0,0,0)) plot(x,y,ylim=c(-20,20),xlim=c(min(x),max(x)),pch='X',col = rgb(1,1,1, 0.5),yaxt=n, ann=FALSE) abline(v=c(min(x),max(x)), lty=3, col=yellow) par - op render: http://i51.tinypic.com/2rz9w0h.png So what I mean is the area between yellow lines and edges of the plotting area, so min(x) and max(x) would be really on the edge of the plot. -- View this message in context: http://r.789695.n4.nabble.com/xlim-c-min-x-max-x-still-produces-extra-margin-on-both-sides-of-x-axis-in-plot-tp3053356p3053356.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] xlim=c(min(x), max(x)) still produces extra margin on both sides of x axis in plot()
i found solution myself: par(xaxs = i, yaxs = i) - it sets axis ranges to actual data ranges sorry for question but maybe this will be easier to find if someone would be searching for this -- View this message in context: http://r.789695.n4.nabble.com/xlim-c-min-x-max-x-still-produces-extra-margin-on-both-sides-of-x-axis-in-plot-tp3053356p3053365.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] xlim=c(min(x), max(x)) still produces extra margin on both sides of x axis in plot()
Hi! After plotting, take a look at par()$usr; it gives you the coordinates of the plotting region. You could use it that way: abline(v=c(par()$usr[1], par()$usr[2])...) Note that you can also use it like this: par(usr)[1] HTH, Ivan Le 11/22/2010 11:04, madr a écrit : code: op- par(bg='black',fg='gray',col='gray',col.axis='gray',col.lab='gray',col.main='gray',col.sub='gray',mai=c(0,0,0,0), tck = 0.01, mgp = c(0, -1.4, 0), mar=c(0,0,0,0)) plot(x,y,ylim=c(-20,20),xlim=c(min(x),max(x)),pch='X',col = rgb(1,1,1, 0.5),yaxt=n, ann=FALSE) abline(v=c(min(x),max(x)), lty=3, col=yellow) par- op render: http://i51.tinypic.com/2rz9w0h.png So what I mean is the area between yellow lines and edges of the plotting area, so min(x) and max(x) would be really on the edge of the plot. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] unexpected numeric constant while reading tab delimited csv file
The folder are the same, I just deleted the long path because it is irrelevant and by mistake left /s i one of the paths, they should be identical. I'm running this package: http://cran.r-project.org/bin/windows/base/R-2.12.0-win.exe on win xp 32 bit -- View this message in context: http://r.789695.n4.nabble.com/unexpected-numeric-constant-while-reading-tab-delimited-csv-file-tp3053252p3053370.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] Making a line in a legend shorter
On 11/22/2010 01:38 PM, Luis Felipe Parra wrote: Hello, I am putting a legend with lines in a line plot and I would like to make the lines in the legend shorter. Does anybody knows how to do this? Hi Felipe, The only rather clunky way I can think of is to use pch=- instead of lty or lwd. There are longer dashes in most character sets to give you a bit of control. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] unexpected numeric constant while reading tab delimited csv file
Date: Mon, 22 Nov 2010 01:57:54 -0800 From: jdnew...@dcn.davis.ca.us To: madra...@interia.pl CC: r-help@r-project.org Subject: Re: [R] unexpected numeric constant while reading tab delimited csv file madr wrote: my csv file is very simple - just one line for purpose of this test: 0{TAB}0 and read function is this: csvdata = read.csv(file=d:/s/test.csv,head=FALSE,sep=\t) then error comes: Error in source(d:/test.csv) : d:/test.csv:1:9: unexpected numeric constant 1: 0 0 but when I change delimiter to ; (colon) then error not shows up anymore You seem to be referencing two different files somehow... one in the root directory of your drive D, and the other in a subdirectory D:/s. This may have something to do with it... or may be extraneous. You haven't indicated what your working environment is, though the OS mention a distinction between whatever this environment is (RGui?) and console. Are you using Cygwin? could end-of-line termination (CRLF vs LF) be causing you difficulty? The OP explained that and if you believe OP changing intended file changes the error message. And, yes, I would strongly suggest getting cygwin so you have some tools other than posting incomplete information of calling tech support LOL. In this case, you would use something like od to verify that your file is as you expect. Just as printing numerical data often truncated digits, unprintable chars don't always show up on printing. od -ax or something may be informative. Changing the tab may have caused editor to change line endings or something else. Smart editors often mess stuff up. Perhaps you should follow the posting guide instructions... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to sample lowess/loess into matrix ?
code: x - rnorm(32) y - rnorm(32) plot(x,y) lines(lowess(x,y),col='red') Now I need to sample the lowess function into matrix where one series will be X and other will be values of lowess at particular X. -- View this message in context: http://r.789695.n4.nabble.com/how-to-sample-lowess-loess-into-matrix-tp3053458p3053458.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] unexpected numeric constant while reading tab delimited csv file
madr wrote: my csv file is very simple - just one line for purpose of this test: 0{TAB}0 and read function is this: csvdata = read.csv(file=d:/s/test.csv,head=FALSE,sep=\t) then error comes: Error in source(d:/test.csv) : d:/test.csv:1:9: unexpected numeric constant 1: 0 0 but when I change delimiter to ; (colon) then error not shows up anymore You used source, not read.csv. They aren't the same thing. If you typed what you said you typed, then you've hidden the real read.csv function behind your own, and your own calls source. But I don't think you typed what you said you typed. 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] Rexcel
Hello I am new to RExcel and I would like to run a source code form the excel worksheet. I would like to run the following code source(C:\\Quantil Aplicativos\\Genercauca\\BackwardSelectionNC.r) from the excel wroksheet. Does anybody know how to do this? Thank you Felipe Parra [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to change number of characters per line for print() to sink()?
I am using r to read and reformat data that is then saved to a text file using sink(), the file has a number of initial lines of comments and summary data followed by print of a data.frame with no row names. for example a-c(100:120) b-c(rnorm(100:120)) c-c(rnorm(200:220)) mydata-data.frame(rbind(a,b,c)) sink(datafile.txt) cat(comments about my data \n) cat(other calculations returned as separate text comments on a line \n) print(mydata,row.names=F) sink() I need the content of the text file to keep each row of the data frame on a single line thus (with intervening columns present of course) datafile.txt comments about my data other calculations returned as separate text comments on a line X1 X2 X3 X4 X5 X6 . X19 X20 X21 100.000 101.00 102.000 103.000 104.000 105.000 ..118.000 119.000 120.000 -0.3380570 -1.400905 1.0396499 -0.5802181 -0.2340614 0.6044928 ...-0.4854702 -0.3677461 -1.2033173 -0.9002824 1.544242 -0.8668653 0.3066256 0.2490254 -1.6429223 . 0.0861146 0.4276929 -0.3408604 How doI change setting for print() or use another function to keep each row of the data frame as a single line ( of greater length up to approx 300 characters) instead of wrapping the data frame into multiple lines of text? The problem : I end up with the data frame split into several sections one under another thus datafile.txt comments about my data other calculations returned as separate text comments on a line X1 X2 X3 X4 X5 X6 100.000 101.00 102.000 103.000 104.000 105.000 -0.3380570 -1.400905 1.0396499 -0.5802181 -0.2340614 0.6044928 -0.9002824 1.544242 -0.8668653 0.3066256 0.2490254 -1.6429223 X7 X8 X9 X10 X11 X12 106.000 107. 108.000 109.000 110.000 111.000 0.3152427 0.15093494 -0.3316172 -0.3603724 -2.0516402 -0.4556241 -0.6502265 -0.08842649 -0.3775335 -0.4942572 -0.0976565 -0.7716651 X13 X14 X15 X16 X17X18 112.000 113.000 114.000 115.000 116. 117.00 0.8829135 0.8851043 -0.7687383 -0.9573476 -0.03041968 1.425754 0.2666777 0.6405255 0.2342905 -0.7705545 -1.18028004 1.303601 X19 X20 X21 118.000 119.000 120.000 -0.4854702 -0.3677461 -1.2033173 0.0861146 0.4276929 -0.3408604 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Invitation à se connecter sur LinkedIn
LinkedIn Aline Uwimana requested to add you as a connection on LinkedIn: -- James, J'aimerais vous inviter à rejoindre mon réseau professionnel en ligne, sur le site LinkedIn. Aline Accept invitation from Aline Uwimana http://www.linkedin.com/e/j2w180-ggtc5u4r-5e/dwA6EuZvdiRUO9LjukuviNUAHj8vHaNg/blk/I2473001097_2/1BpC5vrmRLoRZcjkkZt5YCpnlOt3RApnhMpmdzgmhxrSNBszYOnPsVc34Mc3cTd399bSlUk6ZDtQd6bPkOcP4Sd3kPej4LrCBxbOYWrSlI/EML_comm_afe/ View invitation from Aline Uwimana http://www.linkedin.com/e/j2w180-ggtc5u4r-5e/dwA6EuZvdiRUO9LjukuviNUAHj8vHaNg/blk/I2473001097_2/39vdPAMcj0McPsQcAALqnpPbOYWrSlI/svi/ -- DID YOU KNOW you can be the first to know when a trusted member of your network changes jobs? With Network Updates on your LinkedIn home page, you'll be notified as members of your network change their current position. Be the first to know and reach out! http://www.linkedin.com/ -- (c) 2010, LinkedIn Corporation [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to combine Date and time in one column
On Mon, Nov 22, 2010 at 2:24 AM, rnick nikos.rachma...@gmail.com wrote: Hello everyone, I am trying to built an xts object and i have run into some problems on the data handling. I would really appreciate if someone could help me with the following: 1) I have a OHLC dataset with Time and date in different columns. How could i combine date and time in one column in order to pass on the new column to xts? I have use cbind and data.frame before but i did not manage to yield any good results as the formating of the file changes. Date Time O H L C 1/2/2005 17:05 1.3546 1.3553 1.3546 1.35495 1/2/2005 17:10 1.3553 1.3556 1.3549 1.35525 1/2/2005 17:15 1.3556 1.35565 1.35515 1.3553 1/2/2005 17:25 1.355 1.3556 1.355 1.3555 1/2/2005 17:30 1.3556 1.3564 1.35535 1.3563 2) It is not clear to me what is the best way to construct the .xts object? Should i use only the Datetime to index or should i also combine it with the rest of the variables? Use read.zoo and then as.xts to convert it to xts. The following shows it for chron date/times. Replace textConnection(Lines) with myfile.dat to read it from that file. You can replace the FUN= part with a conversion to any date/time class supported by xts. Here we show it for chron. In the example below we are assuming that the date format is month/day/year. See R News 4/1. Lines - Date Time O H L C 1/2/2005 17:05 1.3546 1.3553 1.3546 1.35495 1/2/2005 17:10 1.3553 1.3556 1.3549 1.35525 1/2/2005 17:15 1.3556 1.35565 1.35515 1.3553 1/2/2005 17:25 1.355 1.3556 1.355 1.3555 1/2/2005 17:30 1.3556 1.3564 1.35535 1.3563 library(xts) # this also pulls in zoo and its read.zoo library(chron) z - read.zoo(textConnection(Lines), header = TRUE, index = list(1, 2), FUN = function(d, t) as.chron(paste(as.Date(chron(d)), t))) x - as.xts(z) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Tinn-R 2.3.7.0 released
Dears users, A new version of Tinn-R was released today. Below details: 2.3.7.0 (Nov/22/2010) * Bug(s) fixed: - A bug related with the intermittent loose of connection (or appear to freeze) with Rgui.exe was fixed. * The versions 2.3.6.4, 2.3.6.5, 2.3.6.6 and 2.3.6.7 restricted to pre-release testers. * The Application options interface was a bit changed: - The Application options/R/Rterm was split in two tabs: Error and Options. The tab Error has a new option: Try to find error in the editor. It enables the user to set Tinn-R in order to find errors in the editor when sending instructions to Rterm. * This version is full compatible with Windows 7 and R 2.12.0. * The component XPmenu was removed from the project. Windows XP users, perhaps, will find the Tinn-R appearance less attractive, but the applicative is now more stable. As soon as possible, the project will get a better option for skins. * Parts of the source code were optimized. All the best, -- ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ Jose Claudio Faria Estatistica - prof. Titular UESC/DCET/Brasil joseclaudio.fa...@gmail.com ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Rexcel
Hello, I am trying to use RExcel and I would like to know if it is possible to use in excel the following function I made for R Pron = function(path=C:\\Quantil Aplicativos\\Genercauca\\V5\\){ library(timeSeries) library(maSigPro) ### CARGAR FUNCIONES source(paste(path,\\fUtilidades\\BackwardSelectionNC.r,sepfile://futilidades//BackwardSelectionNC.r%22,sep =)) source(paste(path,\\fUtilidades\\CriteriosDeComparacion.r,sepfile://futilidades//CriteriosDeComparacion.r%22,sep =)) dataTSORG-read.csv('entrada.csv', header = TRUE, sep = ,, quote=\, dec=.,fill = TRUE, comment.char=) dataTSORG = ts(dataTSORG, start=c(1950,1), frequency=12) dataTSORG = as.timeSeries(dataTSORG) X = prcomp(dataTSORG[,2:40])$x return(X) } Does somebody know if its possible? and if so how can I do it? Thank you Felipe Parra [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to change number of characters per line for print() to sink()?
?options width options(width = 1000) On Mon, Nov 22, 2010 at 7:22 AM, Nevil Amos nevil.a...@gmail.com wrote: I am using r to read and reformat data that is then saved to a text file using sink(), the file has a number of initial lines of comments and summary data followed by print of a data.frame with no row names. for example a-c(100:120) b-c(rnorm(100:120)) c-c(rnorm(200:220)) mydata-data.frame(rbind(a,b,c)) sink(datafile.txt) cat(comments about my data \n) cat(other calculations returned as separate text comments on a line \n) print(mydata,row.names=F) sink() I need the content of the text file to keep each row of the data frame on a single line thus (with intervening columns present of course) datafile.txt comments about my data other calculations returned as separate text comments on a line X1 X2 X3 X4 X5 X6 . X19 X20 X21 100.000 101.00 102.000 103.000 104.000 105.000 ..118.000 119.000 120.000 -0.3380570 -1.400905 1.0396499 -0.5802181 -0.2340614 0.6044928 ...-0.4854702 -0.3677461 -1.2033173 -0.9002824 1.544242 -0.8668653 0.3066256 0.2490254 -1.6429223 . 0.0861146 0.4276929 -0.3408604 How doI change setting for print() or use another function to keep each row of the data frame as a single line ( of greater length up to approx 300 characters) instead of wrapping the data frame into multiple lines of text? The problem : I end up with the data frame split into several sections one under another thus datafile.txt comments about my data other calculations returned as separate text comments on a line X1 X2 X3 X4 X5 X6 100.000 101.00 102.000 103.000 104.000 105.000 -0.3380570 -1.400905 1.0396499 -0.5802181 -0.2340614 0.6044928 -0.9002824 1.544242 -0.8668653 0.3066256 0.2490254 -1.6429223 X7 X8 X9 X10 X11 X12 106.000 107. 108.000 109.000 110.000 111.000 0.3152427 0.15093494 -0.3316172 -0.3603724 -2.0516402 -0.4556241 -0.6502265 -0.08842649 -0.3775335 -0.4942572 -0.0976565 -0.7716651 X13 X14 X15 X16 X17 X18 112.000 113.000 114.000 115.000 116. 117.00 0.8829135 0.8851043 -0.7687383 -0.9573476 -0.03041968 1.425754 0.2666777 0.6405255 0.2342905 -0.7705545 -1.18028004 1.303601 X19 X20 X21 118.000 119.000 120.000 -0.4854702 -0.3677461 -1.2033173 0.0861146 0.4276929 -0.3408604 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] boxplot: reverse y-axis order
A simple alternative is to use at to contrl plot locations: boxplot( ..., at=rev(1:nlevels(depthM))) which just rearranges where they are plotted. Example: set.seed(1023) x - gl(5, 5) y-rnorm(25) boxplot(y~x, horizontal=TRUE) boxplot(y~x, at=rev(1:nlevels(x)), , horizontal=TRUE) Steve E Uwe Ligges lig...@statistik.tu-dortmund.de 21/11/2010 19:38:54 On 21.11.2010 20:30, emorway wrote: Hello, Searching this forum has enabled me to get pretty far in what I'm trying to do. However, there is one more manipulation I would like to make and I haven't found a solution. Using the data and code below, I generate the plot produced by the last command. If possible I would like to reverse the order of the y-axis (bearing in mind horizontal=T) so that 0 is plotted at the upper most part of the y-axis and 3 at the axis intercepts. I've tried the experiment approach to no avail, meaning I've placed rev(...) around various arguments but with wrong results. Thanks, Eric df-read.table(textConnection(Field Date AvgWTD Region variable value hole depth depthM 204 17-Aug-00 2.897428989 US R1 NA R 1 0 [SNIP] 9A 09-Aug-00 1.482089996 US C6 NA C 6 1.8 9B 01-Jun-01 1.409700036 US C6 NA C 6 1.8 9B 09-Aug-00 3.837660074 US C6 NA C 6 1.8),header=T) closeAllConnections() #The folling call doesn't preserve the correct spacing between data boxplot(value~depthM,data=df,horizontal=T,outline=F) #The following command preserves correct spacing, but need to reverse the order boxplot(value~factor(depthM,levels=c(0.0,0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4,2.7,3)),data=df,horizontal=T,outline=F) So if you want to reverse, either specify the levels in reverse order or use rev() as in: boxplot(value ~ factor(depthM, levels = rev(c(0.0,0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4,2.7,3))), data = df, horizontal = TRUE, outline = FALSE) Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] plot inside function does not work
Hello everyone, when I commit a plot using console(command line?) plot works fine. I have created a function that plots based on the input. This function is called plot_shad. When I call this function alone in the command line I get my plot. Then I tried to use another function as depicted_below to do some calculation before calling the function that does the plotting. plot_shad_map-function(f,CRagent,agentid){ for (i in c(1:nrow(shad_map))){ for (j in c(1:ncol(shad_map))){ # Do something } } plot_shad_f(shad_map) # This plots fine when used in command line. But inside this #function does not return(shad_map) } Unfortunately I get no plot . What might be the problem? One more question how to get more plots at the same time. It seems that when I issue a new plot replaces the old plot. I would like to thank you in advance for you help Regards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to sample lowess/loess into matrix ?
I found it, it was SO simple: lowessline - lowess(x,y) write.csv(lowessline, loess.csv) -- View this message in context: http://r.789695.n4.nabble.com/how-to-sample-lowess-loess-into-matrix-tp3053458p3053601.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] plot inside function does not work
Alex, this may be FAQ 7.22 Claudia On 11/22/2010 02:19 PM, Alaios wrote: Hello everyone, when I commit a plot using console(command line?) plot works fine. I have created a function that plots based on the input. This function is called plot_shad. When I call this function alone in the command line I get my plot. Then I tried to use another function as depicted_below to do some calculation before calling the function that does the plotting. plot_shad_map-function(f,CRagent,agentid){ � for (i in c(1:nrow(shad_map))){ ��� for (j in c(1:ncol(shad_map))){ # Do something ��� } � } � plot_shad_f(shad_map) # This plots fine when used in command line. But inside this #function does not � return(shad_map) } Unfortunately I get no plot . What might be the problem? One more question how to get more plots at the same time. It seems that when I issue a new plot replaces the old plot. I would like to thank you in advance for you help Regards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Claudia Beleites Dipartimento dei Materiali e delle Risorse Naturali Università degli Studi di Trieste Via Alfonso Valerio 6/a I-34127 Trieste phone: +39 0 40 5 58-37 68 email: cbelei...@units.it __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rexcel
Hi, For RExcel I would suggest subscribing; http://mailman.csd.univie.ac.at/listinfo/rcom-l They have a website on; http://rcom.univie.ac.at/ B.R. Stephen L - Original Message From: Luis Felipe Parra felipe.pa...@quantil.com.co To: r-help r-help@r-project.org Sent: Mon, November 22, 2010 8:11:39 PM Subject: [R] Rexcel Hello I am new to RExcel and I would like to run a source code form the excel worksheet. I would like to run the following code source(C:\\Quantil Aplicativos\\Genercauca\\BackwardSelectionNC.r) from the excel wroksheet. Does anybody know how to do this? Thank you Felipe Parra [[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] plot inside function does not work
Dear Claudia, I would like to thank you for your reply, according to 7.22 I have to put some print() statement inside my function. What I do not understand is where to put this line (at the beginning or at the end of the code?) I tried both but I get error message. Moreover I would like to ask you if any inputs should be passed to the print(). I tried to pass inside the argument of ggplot but it didnt like it :( Best Regards 7.22 Why do lattice/trellis graphics not work? The most likely reason is that you forgot to tell R to display the graph. Lattice functions such as xyplot() create a graph object, but do not display it (the same is true of ggplot2 graphics, and Trellis graphics in S-Plus). The print() method for the graph object produces the actual display. When you use these functions interactively at the command line, the result is automatically printed, but in source() or inside your own functions you will need an explicit print() statement. --- On Mon, 11/22/10, Claudia Beleites cbelei...@units.it wrote: From: Claudia Beleites cbelei...@units.it Subject: Re: [R] plot inside function does not work To: r-help@r-project.org Date: Monday, November 22, 2010, 1:34 PM Alex, this may be FAQ 7.22 Claudia On 11/22/2010 02:19 PM, Alaios wrote: Hello everyone, when I commit a plot using console(command line?) plot works fine. I have created a function that plots based on the input. This function is called plot_shad. When I call this function alone in the command line I get my plot. Then I tried to use another function as depicted_below to do some calculation before calling the function that does the plotting. plot_shad_map-function(f,CRagent,agentid){ � for (i in c(1:nrow(shad_map))){ ��� for (j in c(1:ncol(shad_map))){ ���� # Do something ��� } � } � plot_shad_f(shad_map) # This plots fine when used in command line. But inside this #function does not � return(shad_map) } Unfortunately I get no plot . What might be the problem? One more question how to get more plots at the same time. It seems that when I issue a new plot replaces the old plot. I would like to thank you in advance for you help Regards Alex    [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Claudia Beleites Dipartimento dei Materiali e delle Risorse Naturali Università degli Studi di Trieste Via Alfonso Valerio 6/a I-34127 Trieste phone: +39 0 40 5 58-37 68 email: cbelei...@units.it __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] Invitation à se connecter sur LinkedIn
LinkedIn Yann Lancien requested to add you as a connection on LinkedIn: -- James, J'aimerais vous inviter à rejoindre mon réseau professionnel en ligne, sur le site LinkedIn. Yann Accept invitation from Yann Lancien http://www.linkedin.com/e/j2w180-ggtf3iot-z/dwA6EuZvdiRUO9LjukuviNUAHj8vHaNg/blk/I2473133047_2/1BpC5vrmRLoRZcjkkZt5YCpnlOt3RApnhMpmdzgmhxrSNBszYOnPsQc3cPcjcTd399bPxgum8Utk5QbPcNdzkQe3kPej4LrCBxbOYWrSlI/EML_comm_afe/ View invitation from Yann Lancien http://www.linkedin.com/e/j2w180-ggtf3iot-z/dwA6EuZvdiRUO9LjukuviNUAHj8vHaNg/blk/I2473133047_2/39vdPgMcPcNcPsQcAALqnpPbOYWrSlI/svi/ -- Why might connecting with Yann Lancien be a good idea? People Yann Lancien knows can discover your profile: Connecting to Yann Lancien will attract the attention of LinkedIn users. See who's been viewing your profile: http://www.linkedin.com/e/j2w180-ggtf3iot-z/wvp/inv18_wvmp/ -- (c) 2010, LinkedIn Corporation [[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] Prob with merge
Hi Im trying to merge 2 data frames using merge but I dont get the result i want Lets make this a small test as my data set is to big to put in here :). t1-data.frame(a=c(1,2,3,4,5,6),b=c(11,11,NA,11,11,11)) t1-data.frame(a=c(1,2,3,4,5,8),b=c(12,12,12,12,12,32)) this gives me: t1 a b 1 1 12 2 2 12 3 3 12 4 4 12 5 5 12 6 8 32 t2 a b 1 1 11 2 2 11 3 3 NA 4 4 11 5 5 11 6 6 11 now when i merge i get: merge(t1,t2, by=a) a b.x b.y 1 1 12 11 2 2 12 11 3 3 12 NA 4 4 12 11 5 5 12 11 But what I want is it to look like: a b.x b.y 1 1 12 11 2 2 12 11 3 3 12 NA 4 4 12 11 5 5 12 11 6 8 32 NA So I keep all of the rows from t1 and get an NA in dose slots at the t2 part of the merge. Anyone know how to accomplice this? Thx //Joel -- View this message in context: http://r.789695.n4.nabble.com/Prob-with-merge-tp3053652p3053652.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] Prob with merge
merge(t1,t2, by=a, all.x = TRUE) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for Nature and Forest team Biometrics 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 Joel Verzonden: maandag 22 november 2010 15:07 Aan: r-help@r-project.org Onderwerp: [R] Prob with merge Hi Im trying to merge 2 data frames using merge but I dont get the result i want Lets make this a small test as my data set is to big to put in here :). t1-data.frame(a=c(1,2,3,4,5,6),b=c(11,11,NA,11,11,11)) t1-data.frame(a=c(1,2,3,4,5,8),b=c(12,12,12,12,12,32)) this gives me: t1 a b 1 1 12 2 2 12 3 3 12 4 4 12 5 5 12 6 8 32 t2 a b 1 1 11 2 2 11 3 3 NA 4 4 11 5 5 11 6 6 11 now when i merge i get: merge(t1,t2, by=a) a b.x b.y 1 1 12 11 2 2 12 11 3 3 12 NA 4 4 12 11 5 5 12 11 But what I want is it to look like: a b.x b.y 1 1 12 11 2 2 12 11 3 3 12 NA 4 4 12 11 5 5 12 11 6 8 32 NA So I keep all of the rows from t1 and get an NA in dose slots at the t2 part of the merge. Anyone know how to accomplice this? Thx //Joel -- View this message in context: http://r.789695.n4.nabble.com/Prob-with-merge-tp3053652p3053652.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] Making a line in a legend shorter
On 2010-11-21 18:38, Luis Felipe Parra wrote: Hello, I am putting a legend with lines in a line plot and I would like to make the lines in the legend shorter. Does anybody knows how to do this? I think the segment length is still hard-coded in legend(). Last July there was a request to lengthen the segment. Maybe this post will help you: https://stat.ethz.ch/pipermail/r-help/2010-July/246599.html Peter Ehlers Thank you Felipe Parra [[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] calculating martingale residual on new data using predict.coxph
This feature has been added in survival 2.36-1, which is now on CRAN. (2.36-2 should appear in another day or so) Terry T. -begin included message I was trying to use predict.coxph to calculate martingale residuals on a test data, however, as pointed out before http://tolstoy.newcastle.edu.au/R/e4/help/08/06/13508.html predict(mycox1, newdata, type=expected) is not implemented yet. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Prob with merge
Thx alot mate. -- View this message in context: http://r.789695.n4.nabble.com/Prob-with-merge-tp3053652p3053675.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] What if geoRglm results showed that a non-spacial model fits?
Hi R-people: Working in geoRglm, it shows me, according to AIC criterion, that the non-spacial model describes the process in a better way. It's the first time that I'm facing up to. These are my results: OP2003Seppos.AICnonsp-OP2003Seppos.AICsp #[1] -4 (OP2003Seppos.lf0.p-exp(OP2003Seppos.lf0$beta)/(1+exp(OP2003Seppos.lf0$beta))) #P non spatial #[1] 0.9717596 (OP2003Seppos.lf.p-exp(OP2003Seppos.lf$beta)/(1+exp(OP2003Seppos.lf$beta))) #P spatial #[1] 0.9717596 It must what have an important influence at kriging, because it shows as following: OP2003Sepposbin.krig-glsm.krige(OP2003Seppos.tune,loc=OP2003Seppospro.pred.grid,bor=OP2003Sepposbor) #glsm.krige: Prediction for a generalised linear spatial model #There are 50 or mode advices (use warnings() to see them) # warnings() #Warning messages: #1: In asympvar(kpl.result$predict, messages = FALSE) ... : # value of argument lag.max is not suffiently long #2: In asympvar(kpl.result$predict, messages = FALSE) ... : # value of argument lag.max is not suffiently long Help me, please. [[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 plotting kohonen maps
Dear all, I recently started using the kohonen package for my thesis project. I have a very simple question which I cannot figure out by myself: When I execute the following example code, from the paper of Wehrens and Buydens (http://www.jstatsoft.org/v21/i05/paper): R library(kohonen) Loading required package: class R data(wines) R wines.sc - scale(wines) R set.seed(7) R wine.som - som(data = wines.sc, grid = somgrid(5, 4, hexagonal)) R plot(wine.som, main = Wine data) I get to have a plot of the codebook vectors of the 5-by-4 mapping of the wine data, and it also includes which variable names correspond to each color. (same picture as in the paper) However, when I run the som() function with my own data and I try to get the plot afterwards: library(kohonen) self_Organising_Map - som(data = tableToCluster, grid = somgrid(5, 2, rectangular), rlen=1000) plot(self_Organising_Map, main = Kohonen Map of Clustered Profiles) the resulting plot does not contain the color labels i.e. the variable names of my data table, even though they exist and are included as column names of tableToCluster. I also tried the following line: plot(self_Organising_Map, type=codes, codeRendering = segments, ncolors=length(colnames(self_Organising_Map$codes)), palette.name=rainbow, main = Kohonen Map of Clustered Profiles \n Codes, zlim =colnames(self_Organising_Map$codes)) but it had the same result. If you could please help with what argument I should use to show the color labels in the codes plot of the kohonen map, please drop a line! Kind regards, Stella -- Stella Pachidi Master in Business Informatics student Utrecht University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ?summaryRprof running at 100% cpu for one hour ...
see below. 2010/11/21 Uwe Ligges lig...@statistik.tu-dortmund.de: On 21.11.2010 18:13, Kjetil Halvorsen wrote: ?save.image And at this point it has been running with one cpu at 100% for over an hour! It's OK to take an hour (due to memory - disc IO) if it uses swap space heavily. Factor of 60 is not much given memory is faster than harddiscs by orders of magnitude. Uwe It takes much more than an hour! I started anew a process with the problem yesterday aroun 18.00, had to kill it this morning around 09.00. That's more than 1|5 hours. Kjetil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ?summaryRprof running at 100% cpu for one hour ...
Date: Mon, 22 Nov 2010 12:03:54 -0300 From: kjetilbrinchmannhalvor...@gmail.com To: lig...@statistik.tu-dortmund.de CC: r-help@r-project.org Subject: Re: [R] ?summaryRprof running at 100% cpu for one hour ... see below. 2010/11/21 Uwe Ligges : On 21.11.2010 18:13, Kjetil Halvorsen wrote: ?save.image And at this point it has been running with one cpu at 100% for over an hour! It's OK to take an hour (due to memory - disc IO) if it uses swap space heavily. Factor of 60 is not much given memory is faster than harddiscs by orders of magnitude. Uwe It takes much more than an hour! I started anew a process with the problem yesterday aroun 18.00, had to kill it this morning around 09.00. That's more than 1|5 hours. Again, see if you can run it under gdb or at least look at tools you have to determine page faults. My brain has been corrupted with 'dohs but in task manager CPU usage drops when page faults start or lock startvation etc. A blocking thread should yield IIRC. Waiting for it to die a natural death may not be practical. I just posted something on this after following another's suggestion but it should be easy for you to get developer tools, execute gdb, point it at R and then break a few times. Debuggers don't speed anything up but presumably it gets into its limit cycle ( infinite futile loop ) within a short time. Also sometimes you get these loops due to memory corruption with native code etc etc so confusing results may take a few different approaches to figure out. Turning on profiling will at best destry any memory coherence and worse ad to VM thrashing. At least try to determine if you are faulting all over. Kjetil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] hierarchical mixture modelling
Hi folks, I have circular data that I'd like to model as a mixture of a uniform and a Von Mises centered on zero. The data are from 2 groups of human participants, where each participant is measured repeatedly within each of several conditions. So, the data frame would look something like: design = expand.grid( person = 1:20 , variable1 = 1:2 , variable2 = 1:3 , repetition = 1:100 ) design$group = design$person %% 2 where each row would have a data point. Now, I know how to fit the mixture of a uniform and Von Mises to each individual cell of the data independently using the EM algorithm, yielding estimates of the mixture proportion and Von Mises concentration per cell. However, I of course want to assess the degree to which the group and other variables in the design affect these model parameters, and at least in the case of the proportion estimate, I'm uncomfortable submitting the raw proportion to a test that is going to assume Gaussian error (eg. ANOVA, or lmer(..., family=gaussian)). I'm aware that lmer lets one specify non-gaussian links, but as I understand it, if I wanted to, say, specify the binomial link (which seems appropriate for a proportion), lmer wants the data to be the raw 1's and 0's, not the proportion estimate obtained from EM. I've heard that there are hierarchical mixture modelling methods out there (possibly Bayesian hierarchical mixture modelling) that might let me achieve model fitting and inference in one step (eg. model the mixture and influence on each parameter from the between and within-person variables, and treating people as random effects), but I'm having trouble tacking down instructions on how to do this. Any pointers would be greatly appreciated! Cheers, Mike -- 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] Check for is.object
Hello, I am trying to recursively append some data from multiple files into a common object For this, I am using in a loop NewObject - rbind(NewObject,tempObject) For the first loop, obviously there is no NewObject ... so I wanted to do NewObject - tempObject[0,] Now when it loops again I want to put the statement do NewObject - tempObject[0,] inside a if statement ... so that it does I can skip it once NewObject has been initialized. But, is.object doesn't seem to work. What is the alternative check that I can do? And is there a better way to achieve what I want? Thanks, S __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fast Two-Dimensional Optimization
Dear R Helpers, I have attempted optim function to solve a two-dimensional optimization problem. It took around 25 second to complete the procedure. However, I want to reduce the computation time: less than 7 second. Is there any optimization function in R which is very rapid? Best Regards, Wonsang - Wonsang You Leibniz Institute for Neurobiology -- View this message in context: http://r.789695.n4.nabble.com/R-Fast-Two-Dimensional-Optimization-tp3053782p3053782.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotting a timeline
2010/11/20 Marcin Gomulka mrgo...@gmail.com I'd rather do this with a dedicated package function ( like axis() ). Probably you have to write your own function, or tune up manually plot. plot(the_data$eventtime, abs(the_data$impact), type=h, frame.plot=FALSE, axes = FALSE, xlab=,ylab=, col=grey,lwd=2,ylim=c(-2,2),xlim=c(1913,2005)) text(the_data$eventtime,the_data$impact+.1, the_data$label,cex=.6,adj=1) lines(x=c(1914,2003),y=c(0,0),lwd=2,col=blue,t=l) axis(1,the_data$eventtime,pos=0,cex.axis=.5,padj=-2,tck=-.01) -- Mi³ego dnia [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] memory profiling
Using: summaryRprof(memory=both) did the trick, thank you. I had not been using that setting when calling summaryRprof. Thanks, Patrick 2010/11/20 Uwe Ligges lig...@statistik.tu-dortmund.de On 19.11.2010 21:48, Patrick Leyshock wrote: I'm trying to configure Version 2.12.0 or R to do memory profiling. I've reconfigured the code: % ./compile --enable-memory-profiling=YES and verified that it's configured correctly by examining the output. I then rebuild R: % make Then I fire up R and run a script, using Rprof with the memory-profiling switch set to TRUE: Rprof(output, memory.profiling=TRUE); # a bunch of R code Rprof(NULL); Wen I do summaryRprof(memory=both) I see an additional column ... but since you have not said what you tried exactly, we cannot help very much. Uwe Ligges When I examine the output, however, using either R CMD Rprof from the shell, or summaryRprof from within R, the output I see is identical to the output I got when I ran R BEFORE I recompiled with memory profiling enabled. Anyone see something that I'm missing? Thanks, Patrick [[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] ?summaryRprof running at 100% cpu for one hour ...
see below. On Mon, Nov 22, 2010 at 12:13 PM, Mike Marchywka marchy...@hotmail.com wrote: Date: Mon, 22 Nov 2010 12:03:54 -0300 From: kjetilbrinchmannhalvor...@gmail.com To: lig...@statistik.tu-dortmund.de CC: r-help@r-project.org Subject: Re: [R] ?summaryRprof running at 100% cpu for one hour ... see below. 2010/11/21 Uwe Ligges : On 21.11.2010 18:13, Kjetil Halvorsen wrote: ?save.image And at this point it has been running with one cpu at 100% for over an hour! It's OK to take an hour (due to memory - disc IO) if it uses swap space heavily. Factor of 60 is not much given memory is faster than harddiscs by orders of magnitude. Uwe It takes much more than an hour! I started anew a process with the problem yesterday aroun 18.00, had to kill it this morning around 09.00. That's more than 1|5 hours. Again, see if you can run it under gdb or at least look at tools you have to determine page faults. My brain has been corrupted with 'dohs but in task manager CPU usage drops when page faults start or lock startvation etc. A blocking thread should yield IIRC. Waiting for it to die a natural death may not be practical. Thanks. Will try. Really, I tried yesterday, to run R under gdb within emacs, but it did'nt work out. What I did (in emacs 23) was, typing Ctrl-u M-x R and then enter the option --debugger=gdb It starts, but Ctrl-C signal do not have any effect! Kjetil I just posted something on this after following another's suggestion but it should be easy for you to get developer tools, execute gdb, point it at R and then break a few times. Debuggers don't speed anything up but presumably it gets into its limit cycle ( infinite futile loop ) within a short time. Also sometimes you get these loops due to memory corruption with native code etc etc so confusing results may take a few different approaches to figure out. Turning on profiling will at best destry any memory coherence and worse ad to VM thrashing. At least try to determine if you are faulting all over. Kjetil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] An empty grey diagram
Stephen Liu sati...@yahoo.com on Sat, 20 Nov 2010 00:12:07 -0800 (PST) writes: Hi Josh and David, Problem solved. Both following steps work. 1) ToothGrowth attach(ToothGrowth) plot(dose,len) # this step is needed. Don't close the diagram. Otherwise following command won't work. matrics=lm(len~dose) abline(matrics) Graph displayed 2) ToothGrowth attach(ToothGrowth) plot(dose, len) # this step is needed. Don't close the diagram. Otherwise following command won't work. abline(lm(len ~ dose, data = ToothGrowth)) Graph displayed Well, it is *VERY BAD* style and error-prone practice nowadays, to attach a data set. [The only thing to attach() are save()d data *files*; there it's often tidier to attach() instead of to load() ...] I have not followed all the things you tried .. or did not try. A much better way of achieving the above (and yes; *never* close the graphics window within these) should be plot (len ~ dose, data=ToothGrowth) abline(lm(len ~ dose, data=ToothGrowth)) and you can see {if you use a fixed-width font in your e-mail, it springs into your eyes} how nicely the formula notation of graphics alings with the same in models. If the above two simple lines do not work correctly, then your R environment is broken in some way, and maybe first doing rm(list = ls()) may help. Martin Maechler, ETH Zurich and R Core Team B.R. Stephen L - Original Message From: Joshua Wiley jwiley.ps...@gmail.com To: Stephen Liu sati...@yahoo.com Cc: r-help@r-project.org Sent: Sat, November 20, 2010 1:39:45 PM Subject: Re: [R] An empty grey diagram On Fri, Nov 19, 2010 at 9:35 PM, Stephen Liu sati...@yahoo.com wrote: Hi David, What happens when you follow the directions... i.e. type: plot.new()#??? abline(lm(len ~ dose, data = ToothGrowth)) plot.new() The grey background changes to white, still an empty graph You cannot just use abline() on an empty graphic (well, you can but you get an empty graph). Please actually run my code, it will create a scatter plot, then add a line. Do not close the graphic device in between. with(ToothGrowth, plot(dose, len)) abline(lm(len ~ dose, data = ToothGrowth)) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ?summaryRprof running at 100% cpu for one hour ...
Date: Mon, 22 Nov 2010 12:41:06 -0300 Subject: Re: [R] ?summaryRprof running at 100% cpu for one hour ... From: kjetilbrinchmannhalvor...@gmail.com To: marchy...@hotmail.com CC: lig...@statistik.tu-dortmund.de; r-help@r-project.org see below. On Mon, Nov 22, 2010 at 12:13 PM, Mike Marchywka wrote: Thanks. Will try. Really, I tried yesterday, to run R under gdb within emacs, but it did'nt work out. What I did (in emacs 23) was, typing Ctrl-u M-x R and then enter the option --debugger=gdb [[elided Hotmail spam]] Kjetil I rarely use gdb but it did seem to work with R but I executed gdb from cygwin windoh and IIRC ctrl-C worked fine as it broke into debugger. I guess you could try that- start gdb and attach or invoke R from gdb. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Check for is.object
I think you want the function ?exists if(!exists(NewObject)) -- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 Is the room still a room when its empty? Does the room, the thing itself have purpose? Or do we, what's the word... imbue it. - Jubal Early, Firefly r-help-boun...@r-project.org wrote on 11/22/2010 10:14:51 AM: [image removed] [R] Check for is.object Santosh Srinivas to: r-help 11/22/2010 10:17 AM Sent by: r-help-boun...@r-project.org Hello, I am trying to recursively append some data from multiple files into a common object For this, I am using in a loop NewObject - rbind(NewObject,tempObject) For the first loop, obviously there is no NewObject ... so I wanted to do NewObject - tempObject[0,] Now when it loops again I want to put the statement do NewObject - tempObject[0,] inside a if statement ... so that it does I can skip it once NewObject has been initialized. But, is.object doesn't seem to work. What is the alternative check that I can do? And is there a better way to achieve what I want? Thanks, S __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] solve nonlinear equation using BBsolve
After my reply you sent me the following privately: Thank you for your respond. Now I adjust the parameters which are close to the value that I'm expected and it gives me the following message: I tried a few combination. My question is why it said Unsuccessful convergence but still give some answers? Can I use the answers? p0 - c(2.5,25,25,0.8) mgf_gammasum(p0) [1] -17.360 -3410.690 0.3508769-1.1028287 BBsolve(par = p0, fn = mgf_gammasum)[[1]] Unsuccessful convergence. [1] 2.066909 44.068739 24.809270 0.972542 source(.trPaths[5], echo=TRUE, max.deparse.length=1) p0 - c(1.7,36,50,0.9) mgf_gammasum(p0) [1]3.840 2601.0300.72320210.2866732 BBsolve(par = p0, fn = mgf_gammasum)[[1]] Unsuccessful convergence. [1] 2.0823407 18.3757502 49.9935914 0.945 p0 - c(2,40,40,0.8) mgf_gammasum(p0) [1] 17.640 2798.7100.4883676 -0.5653881 BBsolve(par = p0, fn = mgf_gammasum)[[1]] Unsuccessful convergence. [1] 2.059853 29.215478 39.882727 0.914894 It is only giving you the values it stopped at. You are only printing [[1]] of BBsolve's result. BBsolve provides more information. You can easily check if the result is usable. Do something like this. p0 - c(2.5,25,25,0.8) bb.result - BBsolve(par = p0, fn = mgf_gammasum) bb.result mgf_gammasum(bb.result$par) You will see that BBsolve has NOT found a solution. If you use nleqslv as follows you will see that the jacobian matrix in your starting point is very ill-conditioned. nleqslv(p0,mgf_gammasum) All your other starting points have similar problems. You really need to rethink your system of equations. In future please also reply to the list and not only to me privately. best Berend -- View this message in context: http://r.789695.n4.nabble.com/solve-nonlinear-equation-using-BBsolve-tp3052167p3053902.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] Alternatives to image(...) and filled.contour(...) for 2-D filled Plots
Hi Jason, You do not say what you want the alternative to do, so its hard to know if this will be helpful. But one alternative is dat - as.data.frame(ak.fan) dat - melt(dat, id.vars=c(x, y)) p - ggplot(dat, aes(x=x, y=variable)) p + geom_tile(aes(fill=value)) -Ista On Sun, Nov 21, 2010 at 9:04 AM, Jason Rupert jasonkrup...@yahoo.com wrote: By any chance are there any alternatives to image(...) and filled.contour(...) I used Rseek to search for that very topic, but didn't turn over any leads... http://www.rseek.org/?cx=010923144343702598753%3Aboaz1reyxd4newwindow=1q=alternative+to+image+and+filled.contoursa=Searchcof=FORID%3A11siteurl=www.rseek.org%252F#1238 I'm sure there are some out there, but curious about some of the favorites and ones folks have had success using. Thanks for any insights and feedback. I would like to use the alternative 2-D fill function with the example I have been messing with in place of image(...) or filled.contour(...): library(akima) hyp_distance-seq(1,15) angle_deg_val-seq(0,15) x_distance_val-NULL y_distance_val-NULL for(ii in 1:length(hyp_distance)) { for(jj in 1:length(angle_deg_val)) { x_distance_tmp-hyp_distance[ii]*cos(angle_deg_val[jj]*pi/180) y_distance_tmp-hyp_distance[ii]*sin(angle_deg_val[jj]*pi/180) x_distance_val-c(x_distance_val, x_distance_tmp) y_distance_val-c(y_distance_val, y_distance_tmp) } } temperature_vals-rnorm(length(x_distance_val), 75, 2) temp_samples-cbind(x_distance_val, y_distance_val, temperature_vals) temp_samples_DF-data.frame(x = x_distance_val, y = y_distance_val, z = temperature_vals) ak.fan - interp(temp_samples[,1], temp_samples[,2], temp_samples[,3] ) length_val-floor(max(temperature_vals) - min(temperature_vals))*2 color_vals_red_to_yellow_to_green-colorRampPalette(c(red, yellow, green), space=Lab)(length_val) color_vals_green_to_yellow_to_red-colorRampPalette(c(green, yellow, red), space=Lab)(length_val) plot(1,1, col = 0, xlim = c(min(x_distance_val), max(x_distance_val)), ylim = c(min(y_distance_val), max(y_distance_val)), xlab = Room X Position (FT), ylab = Room Y Position (FT), main = Room Temp vs Position) grid() # filled.contour(ak.fan, col = color_vals_red_to_yellow_to_green) # filled.contour(ak.fan, col = color_vals_green_to_yellow_to_red) # image(ak.fan, col = color_vals_red_to_yellow_to_green, add = TRUE) image(ak.fan, col = color_vals_green_to_yellow_to_red, add = TRUE) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] statistical test for comparison of two classifications (nominal)
Martin, Pardon the delayed reply. Bootstrap methods have been around for some time (late seventies?), but their popularity seems to have exploded in correspondence with computing technology. You should be able to find more information in most modern books on statistical inference, but here is a brief: The bootstrap is a method often used to establish an empirical null distribution for a test statistic when traditional (analytical) methods fail. The bootstrap works by imposing a null hypothesis on the observed data, followed by re-sampling with replacement. The test statistic is computed at each re-sample and used to build up an empirical null distribution. The idea is to impose the null hypothesis while preserving variability in the observed data, and thus the test statistic. For example, suppose we observe some continuous scalar data and hypothesize that the sample was observed from a population with mean zero. We can impose this hypothesis by subtracting the sample mean from each observation. Re-samples from these transformed data are treated as having been observed under the null hypothesis. In the case of classification and partitioning, the difficulty is formulating a meaningful null hypothesis about the collection of classifications, and imposing the null hypothesis in a bootstrap sampling scheme. -Matt On Wed, 2010-11-17 at 10:01 -0500, Martin Tomko wrote: Thanks Mat, I have in the meantime identified the Rand index, but not the others. I will also have a look at profdpm, that did not pop-up in my searches. Indeed, the interpretation is going to be critical... Could you please elaborate on what you mean by the bootstrap process? Thanks a lot for your helps, Martin On 11/17/2010 3:50 PM, Matt Shotwell wrote: There are several statistics used to compare nominal classifications, or _partitions_ of a data set. A partition isn't quite the same in this context because partitioned data are not restricted to a fixed number of classes. However, the statistics used to compare partitions should also work for these 'restricted' partitions. See the Rand index, Fowlkes and Mallows index, Wallace indices, and the Jaccard index. The profdpm package implements a function (?profdpm::pci) that computes these indices for two factors representing partitions of the same data. The difficult part is drawing statistical inference about these indices. It's difficult to formulate a null hypothesis, and even more difficult to determine a null distribution for a partition comparison index. A bootstrap test might work, but you will probably have to implement this yourself. -Matt On Wed, 2010-11-17 at 08:33 -0500, Martin Tomko wrote: Dear all, I am having a hard time to figure out a suitable test for the match between two nominal classifications of the same set of data. I have used hierarchical clustering with multiple methods (ward, k-means,...) to classify my dat into a set number of classesa, and I would like to compare the resulting automated classification with the actual - objective benchmark one. So in principle I have a data frame with n columns of nominal classifications, and I want to do a mutual comparison and test for significance in difference in classification between pairs of columns. I just need to identify a suitable test, but I fail. I am currently exploring the possibility of using Cohen's Kappa, but I am open to other suggestions. Especially the fact that kappa seems to be moslty used on failible, human annotators seems to bring in limitations taht do not apply to my automatic classification. Any help will be appreciated, especially if also followed by a pointer to an R package that implements it. Thanks Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Matthew S. Shotwell Graduate Student Division of Biostatistics and Epidemiology Medical University of South Carolina __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Check for is.object
Santosh - The simple answer to your question is to initialize NewObject to NULL before the loop, i.e. newObject = NULL However, I should point out this is one of the most inefficient ways to program in R. A far better way is to allocate enough space for NewObject outside your loop, and fill it in in the loop. Here's a simple example to give you an idea of the difference in time the two methods require: system.time({answer = matrix(NA,1000,5); + for(i in 1:1000)answer[i,] - sample(10,5)}) user system elapsed 0.020 0.000 0.017 system.time({answer=NULL; + for(i in 1:1000)answer=rbind(answer,sample(10,5))}) user system elapsed 0.072 0.000 0.070 However, it gets even worse if the sample size is larger: system.time({answer = matrix(NA,1,5); + for(i in 1:1)answer[i,] - sample(10,5)}) user system elapsed 0.184 0.000 0.184 system.time({answer=NULL;for(i in 1:1) + answer=rbind(answer,sample(10,5))}) user system elapsed 5.492 0.032 5.562 Even if you don't know how big your newObject matrix will become, it's still far more efficient to overallocate the matrix and then truncate it at the end. I'd strongly recommend that you avoid building your matrix incrementally inside a loop! - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Mon, 22 Nov 2010, Santosh Srinivas wrote: Hello, I am trying to recursively append some data from multiple files into a common object For this, I am using in a loop NewObject - rbind(NewObject,tempObject) For the first loop, obviously there is no NewObject ... so I wanted to do NewObject - tempObject[0,] Now when it loops again I want to put the statement do NewObject - tempObject[0,] inside a if statement ... so that it does I can skip it once NewObject has been initialized. But, is.object doesn't seem to work. What is the alternative check that I can do? And is there a better way to achieve what I want? Thanks, S __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] negative alpha or custom gradient colors of data dots in scatterplot ?
Hi, I suggest taking a look at the plotting functions in the ggplot2 package. For example: x - rnorm(1) y - x+rnorm(1) dat - data.frame(x,y) library(ggplot2) p - ggplot(dat, aes(x=x, y=y)) p + geom_point() # too much overplotting: compare to dev.new() p + geom_hex(binwidth=c(.1,.1)) Best, Ista On Sun, Nov 21, 2010 at 9:13 AM, madr madra...@interia.pl wrote: I know that by setting alpha to for example col = rgb(0, 0, 0, 0.1) it is possible to see how many overlapping is in the plot. But disadvantage of it is that single points are barely visible on the background. So I wonder if there is possible to make setting that single points would be almost black, but with more and more data on the same spot it would get more and more whiteish. Or maybe it is possible to make sole data points black but overlapped tending to some particular color of choice ? -- View this message in context: http://r.789695.n4.nabble.com/negative-alpha-or-custom-gradient-colors-of-data-dots-in-scatterplot-tp3052394p3052394.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem setting the number of digits in xtable
DEar list members, I am currently using Sweave with LaTeX which is great. I can use xtable for formatting outp of tables but I have a problem setting the number of decimals in xtables when used with dataframe. I have found an example on the net ith matrix and it works. For example this works : tmp - matrix(rnorm(9), 3, 3) xtmp - xtable(tmp) digits(xtmp) - c(0,0,3,4) print(xtmp, include.rownames = FALSE) # row names produced : % latex table generated in R 2.12.0 by xtable 1.5-6 package % Mon Nov 22 17:35:00 2010 \begin{table}[ht] \begin{center} \begin{tabular}{rrr} \hline 1 2 3 \\ \hline -2 -2.158 2.8886 \\ 1 1.330 0.4677 \\ -0 0.486 -0.3319 \\ \hline \end{tabular} \end{center} \end{table} But this won't work : mydata TESTt ddl p CONDITION 2 R1 3.01109061083632 16 0.00828552765650315C1 3 R2 3.30476953908811 16 0.00447412002109504C1 4 DR 2.86343993410509 16 0.0112631908739966C1 5 R1 1.05386387510206 160.30760068470456C2 6 R2 3.04997140665209 16 0.00763921045771104C2 7 DR 2.25175987512241 16 0.0387401575011488C2 but xtable(mydata,digits=2) produced % latex table generated in R 2.12.0 by xtable 1.5-6 package % Mon Nov 22 18:13:47 2010 \begin{table}[ht] \begin{center} \begin{tabular}{rl} \hline TEST t ddl p CONDITION \\ \hline 2 R1 3.01109061083632 16 0.00828552765650315 C1 \\ 3 R2 3.30476953908811 16 0.00447412002109504 C1 \\ 4 DR 2.86343993410509 16 0.0112631908739966 C1 \\ 5 R1 1.05386387510206 16 0.30760068470456 C2 \\ 6 R2 3.04997140665209 16 0.00763921045771104 C2 \\ 7 DR 2.25175987512241 16 0.0387401575011488 C2 \\ \hline \end{tabular} \end{center} \end{table} I have also tried setting the digits with c(0,0,4,0,4,0), using also the 'display' argument to specify the type of each column... noway... What am I missing ? Thanks in advance Sylvain Clément [[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] RCurl : All connection are used ?
     Hi everybody, I got a problem with the ftpUpload function from the RCurl package. My goal is to Upload a lot of files from a local directory to a web server. 1st try : for (i in 1:length(file)){      ftpUpload(what=files[i],to=files[i]) } At i=11 I get : (my server has only 10 available open connections available) : Erreur dans curlPerform(url = to, upload = TRUE, readfunction = uploadFunctionHandler(what, :  Got a 421 ftp-server response when 220 was expected 2 nd Try : ftpConnection=getCurlHandle(userpwd=ftp$userpwd,maxconnects=1,fresh.connect=0) for (i in 1:length(file)){      ftpUpload(what=files[i],to=files[i],curl=ftpConnection) } And I got this error after 30 files (the error is not linked to the web server but to the R session) : Error in file(file, rb) : all conection are used I read the documentation and the options from curl library but I can't find how to solve my problem even if I think that the problem is linked to not closing the position I opened. Do you have any idea how to solve it ? Thanks, Olivier Merle Une messagerie gratuite, garantie à vie et des services en plus, ça vous tente ? Je crée ma boîte mail www.laposte.net [[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] sm.ancova graphic
Hi R-Users, I am working with sm.ancova (in the package sm) and I have two problems with the graph, which is automatically generated when sm.ancova() is run. 1-Besides of the fitted lines, the observed data appeared automatically in the graph. I prefer that only fitted lines appear. I check the sm.options, but I could not find the way that the observed data do not appear in the graph. 2-I would like to change the size of the numbers in the axis. Again, I check the sm.options, but I could not find the correct way. Thank you in advance, Lucía [[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] Plotting a cloud/fog of variable density in rgl
Hi everyone, I want to plot a 3D interpolation of the concentration of aquatic organisms. My goal would be to have the result represented as clouds with a density proportional to the abundance of organisms, so that I could fly (well, swim actually ;) ) through the scene and see the patches here and there. Basically, I want to do something like this: http://www.youtube.com/watch?v=27mo_Y-aU-c but simpler and with only clouds. I though about doing it this way: 1- interpolate to a fine grid 2- plot points at each grid intersection of transparency inversely proportional to abundance 3- blur/fog a bit each point to create the general impression of a cloud So far I am stuck on 3 but maybe there is a better overall solution. Here is some code that reads the result of the interpolation on a coarse grid and plots it: # read a set of gridded data points in 3D d = read.table(http://dl.dropbox.com/u/1047321/R/test3Ddata.txt;, header=T) # plot library(rgl) spheres3d(d$x, d$y, d$z, alpha=alpha, radius=0.05) And here is a version that actually performs the interpolation a random set of points in 3D through kriging in case you want to try with increase precision. # create a set of random data points in 3D n = 50 data3D = data.frame(x = runif(n), y = runif(n), z = runif(n), v = rnorm(n)) # do 3d interpolation via kriging library(gstat) coordinates(data3D) = ~x+y+z range1D = seq(from = 0, to = 1, length = 10) grid3D = expand.grid(x = range1D, y = range1D, z = range1D) gridded(grid3D) = ~x+y+z res3D = krige(formula = v ~ 1, data3D, grid3D, model = vgm(1, Exp, .2)) # convert the result to a data.frame d = as.data.frame(res3D) # compute transparency (proportional to the interpolated value) maxD = max(d$var1.pred) minD = min(d$var1.pred) alpha = (d$var1.pred - minD)/(maxD - minD) # reduce maximum alpha (all points are semi-transparent) alpha = alpha/5 # plot library(rgl) spheres3d(d$x, d$y, d$z, alpha=alpha, radius=0.05) I saw the fog effect but it seems to add a fog in the scene to increase depth. What I want is my scene to actually look like a fog. Thanks in advance for any help. Sincerely, JiHO --- http://maururu.net __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RCurl : All connection are used ?
I guess I would just comment that for many tasks I try to keep the work in dedicated tools. In this case, command line versions of curl or even wget. The reason is things like this that come up talking to foreign entitites. Also the learning curve can be amortized over many other efforts that require same file transfers etc. I just mention this for rebuttals from R experts. From: ome...@laposte.net To: r-help@r-project.org Date: Mon, 22 Nov 2010 18:33:07 +0100 Subject: [R] RCurl : All connection are used ? Hi everybody, I got a problem with the ftpUpload function from the RCurl package. My goal is to Upload a lot of files from a local directory to a web server. 1st try : for (i in 1:length(file)){ ftpUpload(what=files[i],to=files[i]) } At i=11 I get : (my server has only 10 available open connections available) : Erreur dans curlPerform(url = to, upload = TRUE, readfunction = uploadFunctionHandler(what, : Got a 421 ftp-server response when 220 was expected 2 nd Try : ftpConnection=getCurlHandle(userpwd=ftp$userpwd,maxconnects=1,fresh.connect=0) for (i in 1:length(file)){ ftpUpload(what=files[i],to=files[i],curl=ftpConnection) } And I got this error after 30 files (the error is not linked to the web server but to the R session) : Error in file(file, rb) : all conection are used I read the documentation and the options from curl library but I can't find how to solve my problem even if I think that the problem is linked to not closing the position I opened. Do you have any idea how to solve it ? Thanks, Olivier Merle Une messagerie gratuite, garantie à vie et des services en plus, ça vous tente ? Je crée ma boîte mail www.laposte.net [[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] Ordeing Zoo object
And how about if I want to order the series from the smallest to the largest value, keeping the date index in order to see when the values were predominantly negative etc... Thanks, Marco -- View this message in context: http://r.789695.n4.nabble.com/Ordeing-Zoo-object-tp955868p3054192.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] Plotting a cloud/fog of variable density in rgl
On 22/11/2010 12:51 PM, JiHO wrote: Hi everyone, I want to plot a 3D interpolation of the concentration of aquatic organisms. My goal would be to have the result represented as clouds with a density proportional to the abundance of organisms, so that I could fly (well, swim actually ;) ) through the scene and see the patches here and there. Basically, I want to do something like this: http://www.youtube.com/watch?v=27mo_Y-aU-c but simpler and with only clouds. rgl doesn't make everything in OpenGL available. I'm not sure exactly how those clouds were done, but it wouldn't really be easy to do them in rgl. I think you can come closest to what you want within rgl by using sprites rather than rendering transparent spheres. See examples(sprites3d). Duncan Murdoch I though about doing it this way: 1- interpolate to a fine grid 2- plot points at each grid intersection of transparency inversely proportional to abundance 3- blur/fog a bit each point to create the general impression of a cloud So far I am stuck on 3 but maybe there is a better overall solution. Here is some code that reads the result of the interpolation on a coarse grid and plots it: # read a set of gridded data points in 3D d = read.table(http://dl.dropbox.com/u/1047321/R/test3Ddata.txt;, header=T) # plot library(rgl) spheres3d(d$x, d$y, d$z, alpha=alpha, radius=0.05) And here is a version that actually performs the interpolation a random set of points in 3D through kriging in case you want to try with increase precision. # create a set of random data points in 3D n = 50 data3D = data.frame(x = runif(n), y = runif(n), z = runif(n), v = rnorm(n)) # do 3d interpolation via kriging library(gstat) coordinates(data3D) = ~x+y+z range1D = seq(from = 0, to = 1, length = 10) grid3D = expand.grid(x = range1D, y = range1D, z = range1D) gridded(grid3D) = ~x+y+z res3D = krige(formula = v ~ 1, data3D, grid3D, model = vgm(1, Exp, .2)) # convert the result to a data.frame d = as.data.frame(res3D) # compute transparency (proportional to the interpolated value) maxD = max(d$var1.pred) minD = min(d$var1.pred) alpha = (d$var1.pred - minD)/(maxD - minD) # reduce maximum alpha (all points are semi-transparent) alpha = alpha/5 # plot library(rgl) spheres3d(d$x, d$y, d$z, alpha=alpha, radius=0.05) I saw the fog effect but it seems to add a fog in the scene to increase depth. What I want is my scene to actually look like a fog. Thanks in advance for any help. Sincerely, JiHO --- http://maururu.net __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to produce a graph of glms in R?
Look at Predict.Plot (and possibly TkPredict) in the TeachingDemos package. -- 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 Sonja Klein Sent: Saturday, November 20, 2010 4:52 AM To: r-help@r-project.org Subject: [R] How to produce a graph of glms in R? I'm very new to R and modeling but need some help with visualization of glms. I'd like to make a graph of my glms to visualize the different effects of different parameters. I've got a binary response variable (bird sightings) and use binomial glms. The 'main' response variable is a measure of distance to a track and the parameters I'm testing for are vegetation parameters that effect the response in terms of distance. My glm is: glm(Response~NEdist+I(NEdist^2)+Distance+I(Distance^2) which is the basic model and where I add interactions to, like for exampls Visibility as an interaction to Distance (glm(Response~NEdist+I(NEdist^2)+Distance*Visibility+I(Distance^2))) I'd now like to make a graph which has the response variable on the y- axis (obviously). But the x-axis should have distance on it. The NEdist is a vector that is just co-influencing the curve and has to stay in the model but doesn't have any interactions with any other vectors. I'd then like to put in curves/lines for the different models to see if for example visibility effects the distance of the track to the first bird sighting. Is there a way to produce a graph in R that has these features? -- View this message in context: http://r.789695.n4.nabble.com/How-to- produce-a-graph-of-glms-in-R-tp3051471p3051471.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] Plotting a cloud/fog of variable density in rgl
Date: Mon, 22 Nov 2010 13:55:13 -0500 From: murdoch.dun...@gmail.com To: jo.li...@gmail.com CC: r-h...@stat.math.ethz.ch Subject: Re: [R] Plotting a cloud/fog of variable density in rgl On 22/11/2010 12:51 PM, JiHO wrote: Hi everyone, I want to plot a 3D interpolation of the concentration of aquatic organisms. My goal would be to have the result represented as clouds with a density proportional to the abundance of organisms, so that I could fly (well, swim actually ;) ) through the scene and see the patches here and there. Basically, I want to do something like this: http://www.youtube.com/watch?v=27mo_Y-aU-c but simpler and with only clouds. rgl doesn't make everything in OpenGL available. I'm not sure exactly how those clouds were done, but it wouldn't really be easy to do them in rgl. I think you can come closest to what you want within rgl by using sprites rather than rendering transparent spheres. See examples(sprites3d). If you only have 2 things with simple properties, namely point emitters as your organisms and a uniform concsntration of transparent scatters ( the fog) you can probably derive geometrical optics expressions for the ray trace results and just integrate those over your source distribution. This should be reasonably easy in R. I haven't been to siggraph since 1983 so can't help much but you can probably find analyitcal solutions for fog on google and just sum up your source distribution. I guess you could even do some wave optics etc as presumably the fog could be done as a function of wavelength just as easily. In any case, if you only have two basic things with simple disto should be reasonably easy to do in R with your own 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] data acquisition with R?
Thanks a lot, Matt! I will have a look at the options you suggested. Cheers, Mango -- - Never run for the bus. Never skip tea. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Is it possible to make a matrix to start at row 0?
I want to make the matrix to be indexed from row (column) 0, not 1 Can I do that? How? Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Find in R and R books
Alaios ala...@yahoo.com writes: Also when I try to search in google using for example the word R inside the search lemma I get very few results as the R confuses the search engine. When I was looking something in matlab ofcourse it was easier to get results as the search engine performs better. What are your tricks when you want to find some function that provides some functionality? To search R-specific sites the best place to go is this one: http://www.rseek.org/ Cheers, Georg __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Lost in POSIX
Nor would I call this much of an improvement in clarity... what about min? You want to know the minimum? LOL. (And apologies for the insensitivity). Thank you for help, Jeff. This works, but I am still curious to see a solution based on trunc, if anyone can find it. -- View this message in context: http://r.789695.n4.nabble.com/Lost-in-POSIX-tp3052768p3053329.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] Some questione about plot
Q1: How can i draw LSD (Least significant difference) on a plot? Like this... http://r.789695.n4.nabble.com/file/n3053430/LSD.jpg Q2: How can i draw the axis secondary scale? Thanks for help. -- View this message in context: http://r.789695.n4.nabble.com/Some-questione-about-plot-tp3053430p3053430.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] question about constraint minimization
Hi, I have struggled on this bound optimization with equality constraint by using optim function for two days, but still fail to prepare a good input. Can anyone help to prepare the input for my specific case? Many thanks. Best, Hao On Sat, Nov 20, 2010 at 3:17 AM, Hans W Borchers [via R] ml-node+3051338-309339578-202...@n4.nabble.comml-node%2b3051338-309339578-202...@n4.nabble.com wrote: dhacademic at gmail.com dhacademic at gmail.com writes: Hi, I am a beginner of R. There is a question about constraint minimization. A function, y=f(x1,x2,x3x12), needs to be minimized. There are 3 requirements for the minimization: (1) x2+x3+...+x12=1.5 (x1 is excluded); (2) x1=x3=x4; (3) x1, x3 and x5 are in the range of -1~0, respectively. The rest variables (x2, x4, x6, x7, , x12) are in the range of 0~1, respectively. The optim function is used. And part of my input is as follow, where xx1r represents the x12: xx1r=1.5-x[2]-x[1]-x[1]-x[3]-x[4]-x[5]-x[6]-x[7]-x[8]-x[9] start=rnorm(9) up=1:9/1:9*1 lo=1:9/1:9*-1 out=optim(start,f,lower=lo,upper=up,method=L-BFGS-B,hessian=TRUE, control=list(trace=6,maxit=1000)) There are two problems in this input. the up and lo only define a range of -1~1 for x1 to x11, which can not meet the requirement (3). In addition, there is not any constraint imposed on x12. I have no idea how to specify a matrix that can impose different constraints on individual variables in a function. Any suggestion is highly appreciated. Best, Hao I don't see any direct need for real 'constraint' optimization here, it is a 'bounded' optimization where you are allowed to use lower - c(-1,0,-1,0,-1,0,0,0,0,0,0,0) upper - c( 0,1, 0,0, 0,1,1,1,1,1,1,1) Otherwise, your description is confusing: (1) Did you change f to a new function with 9 variables, eliminating x3, x4, and x12 ? (2) x4 (being equal to x1) has to be in [-1, 0] but also in [0, 1]? (3) If you need to restrict x12 to [0, 1] also, you cannot eliminate it. Either keep x12 and use an equality constraint, or use inequality constraints on xxlr. Hans Werner __ [hidden email] http://user/SendEmail.jtp?type=nodenode=3051338i=0mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View message @ http://r.789695.n4.nabble.com/question-about-constraint-minimization-tp3050880p3051338.html To unsubscribe from question about constraint minimization, click herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=3050880code=ZGhhY2FkZW1pY0BnbWFpbC5jb218MzA1MDg4MHwtNjM2Nzc0NA==. -- View this message in context: http://r.789695.n4.nabble.com/question-about-constraint-minimization-tp3050880p3053912.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rexcel
Em 22/11/2010 10:11, Luis Felipe Parra escreveu: Hello I am new to RExcel and I would like to run a source code form the excel worksheet. I would like to run the following code source(C:\\Quantil Aplicativos\\Genercauca\\BackwardSelectionNC.r) from the excel wroksheet. Does anybody know how to do this? Thank you Felipe, Look at the section Startup in the RExcel help. In a nutshell, if you want the code to run immediately at the loading of the spreadsheet, create a workbook called RCode and put your source there. Other options are available. See the docs. -- Cesar Rabak __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] memory profiling
Using: summaryRprof(memory=both) did the trick, thank you. I had not been using that setting when calling summaryRprof. Thanks, Patrick 2010/11/20 Uwe Ligges lig...@statistik.tu-dortmund.de On 19.11.2010 21:48, Patrick Leyshock wrote: I'm trying to configure Version 2.12.0 or R to do memory profiling. I've reconfigured the code: % ./compile --enable-memory-profiling=YES and verified that it's configured correctly by examining the output. I then rebuild R: % make Then I fire up R and run a script, using Rprof with the memory-profiling switch set to TRUE: Rprof(output, memory.profiling=TRUE); # a bunch of R code Rprof(NULL); Wen I do summaryRprof(memory=both) I see an additional column ... but since you have not said what you tried exactly, we cannot help very much. Uwe Ligges When I examine the output, however, using either R CMD Rprof from the shell, or summaryRprof from within R, the output I see is identical to the output I got when I ran R BEFORE I recompiled with memory profiling enabled. Anyone see something that I'm missing? Thanks, Patrick [[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] using rpart with a tree misclassification condition
Thank you for your prompt reply! Yes, I meant the apparent error rate. According to your advice, if I use rpart to build a full tree, what pruning command will be appropriate and will able me to add as an input to the pruning procedure the total error rate i'm looking for? Thank you very much Meytar -- View this message in context: http://r.789695.n4.nabble.com/using-rpart-with-a-tree-misclassification-condition-tp3053167p3053230.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] txtProgressBar strange behavior in R 2.12.0
I believe nobody has responded to far, so maybe this is not a wide-spread issue. However, I have also encountered this since upgrading to R 2.12.0 (Windows 7, 64-bit). In my simulations where I use txtProgressBar(), the problem usually disappears after the bar has progressed to a certain amount, but it's quite strange nonetheless. The characters that appear are gibberish and include some Asian symbols. Here is a screenshot: http://www.wvbauer.com/screenshot.jpg sessionInfo(): R version 2.12.0 (2010-10-15) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base No idea what could be causing this. Best, -- Wolfgang Viechtbauer Department of Psychiatry and Neuropsychology School for Mental Health and Neuroscience Maastricht University, P.O. Box 616 6200 MD Maastricht, The Netherlands Tel: +31 (43) 368-5248 Fax: +31 (43) 368-8689 Web: http://www.wvbauer.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jalla Sent: Saturday, November 20, 2010 23:49 To: r-help@r-project.org Subject: [R] txtProgressBar strange behavior in R 2.12.0 Hi, I am running R 2.12.0 (windows). example(txtProgressBar) gives me some funny screen output with all kinds of special characters appearing and disappearing. It's happening on two different mashines since vs. 2.12.0. Is this a known issue? Best, Jalla -- View this message in context: http://r.789695.n4.nabble.com/txtProgressBar-strange-behavior-in-R-2-12-0- tp3051976p3051976.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] how to apply sample function to each row of a data frame?
I tried it. it works out perfectly. you save my life. -- View this message in context: http://r.789695.n4.nabble.com/Re-how-to-apply-sample-function-to-each-row-of-a-data-frame-tp3050933p3054117.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] arima
Nuncio, No, there is no requirement to subtract the mean. It is required that the residuals are N.I.I.D. (ie constant mean and constant variance). If you have an upward trending series, for example, then the series would need to be deseasonalized so that it is constant. There are many many steps to doing this right. Email me at sa...@autobox.com to hear more. Tom -- View this message in context: http://r.789695.n4.nabble.com/arima-tp2993543p3054206.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how do remove those predictor which have p value greater than 0.05 in GLM?
Hi R user, I am a kind of an intermediate user of R. Now I am using GLM model (library MASS, VEGUS). I used a backward stepwise logistic regression, but i got a problem in removing those predictors which are above 0.05. I don't want to include those variables which were above 0.05 in final backward stepwise logetsic regression model. for example: first I run the model, name-glm(dep~env1+env2..., family= binomial, data=new) after that, I did stepwise for name name.step-step(name, direction=backward) here, I still got those variables which were not significant, for example: secchi was not significant (see below example), but still it was in the model. how can I remove those variables which are not significant in forward/backward stepwise?. another question, when I wrote direction=backward, I got the results same as in the process of forward. It is really strange. why is it same results for backward and forward. I checked in other two statistical software (Statistica and SYSTAT), they provided a correct results, I think. But, I need to use R for further analysis, therefore I need to fix the problem. I am spending so much time to figure it out, but I could not. could you please give your suggestions. It would be really a great help. please see the example of retaining predictors which have p value is greater that 0.05 after stepwise logistic regression. Thank Shubha Pandit, PhD University of Windsor Windsor, ON, Canada summary(step.glm.int.ag1) Call: glm(formula = ag1less ~ GEARTEMP + DOGEAR + GEARDEPTH + SECCHI + GEARTEMP:SECCHI + DOGEAR:SECCHI + GEARTEMP:DOGEAR + GEARTEMP:GEARDEPTH + DOGEAR:GEARDEPTH, family = binomial, data = training) Deviance Residuals: Min 1Q Median 3Q Max -2.1983 -0.8272 -0.4677 0.8014 2.6502 Coefficients: Estimate Std. Error z value Pr(|z|) (Intercept) 3.231623 1.846593 1.750 0.080110 . GEARTEMP -0.004408 0.085254 -0.052 0.958761 DOGEAR -0.732805 0.182285 -4.020 5.82e-05 *** GEARDEPTH -0.249237 0.060825 -4.098 4.17e-05 *** SECCHI 0.311875 0.297594 1.048 0.294645 GEARTEMP:SECCHI-0.080664 0.010079 -8.003 1.21e-15 *** DOGEAR:SECCHI 0.066555 0.022181 3.000 0.002695 ** GEARTEMP:DOGEAR 0.030988 0.008907 3.479 0.000503 *** GEARTEMP:GEARDEPTH 0.008856 0.002122 4.173 3.01e-05 *** DOGEAR:GEARDEPTH0.006680 0.004483 1.490 0.136151 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 3389.5 on 2751 degrees of freedom Residual devia\ n\ ce: 2720.4 on 2742 degrees of freedom AIC: 2740.4uh Number of Fisher Scoring iterations: 6 == glm.int.ag1-glm(ag1less~GEARTEMP+DOGEAR+GEARDEPTH+SECCHI+SECCHI*GEARTEMP+SECCHI*DOGEAR+SECCHI*GEARDEPTH+GEARTEMP*DOGEAR+GEARTEMP*GEARDEPTH+GEARDEPTH*DOGEAR,data=training, family=binomial) summary(glm.int.ag1) Call: glm(formula = ag1less ~ GEARTEMP + DOGEAR + GEARDEPTH + SECCHI + SECCHI * GEARTEMP + SECCHI * DOGEAR + SECCHI * GEARDEPTH + GEARTEMP * DOGEAR + GEARTEMP * GEARDEPTH + GEARDEPTH * DOGEAR, family = binomial, data = training) Deviance Residuals: Min 1Q Median 3Q Max -2.1990 -0.8287 -0.4668 0.8055 2.6673 Coefficients: Estimate Std. Error z value Pr(|z|) (Intercept) 2.909805 1.928375 1.509 0.131314 GEARTEMP0.005315 0.087159 0.061 0.951379 DOGEAR -0.721864 0.183708 -3.929 8.52e-05 *** GEARDEPTH -0.235961 0.064828 -3.640 0.000273 *** SECCHI 0.391445 0.326542 1.199 0.230622 GEARTEMP:SECCHI-0.082296 0.010437 -7.885 3.14e-15 *** DOGEAR:SECCHI 0.065572 0.022319 2.938 0.003305 ** GEARDEPTH:SECCHI -0.003176 0.005295 -0.600 0.548675 GEARTEMP:DOGEAR 0.030571 0.008961 3.412 0.000646 *** GEARTEMP:GEARDEPTH 0.008692 0.002159 4.027 5.66e-05 *** DOGEAR:GEARDEPTH0.006544 0.004495 1.456 0.145484 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 3389.5 on 2751 degrees of freedom Residual deviance: 2720.0 on 2741 degrees of freedom AIC: 2742 Number of Fisher Scoring iterations: 6 -- View this message in context: http://r.789695.n4.nabble.com/how-do-remove-those-predictor-which-have-p-value-greater-than-0-05-in-GLM-tp3053921p3053921.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] Wait for user input with readline()
Hello, I am trying write a script that includes a prompt for user input using readlines(). I am running into the problem that when I run readlines() as a single line the prompt works perfectly, but when I try to run a block of code which includes the readline function, the script doesn't wait for the user input. I have seen this question posted before when I did a search, but I didn't find an suitable answer. Is there a means of ensuring that the script does not proceed until a value has been entered to readline(). Can I put readline in a function that will wait for input? Are there other options for getting user input that allow require that the script wait for user input? Thanks for your help, Nate [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to call web service in R
Hello everyone, I would like to call web service in R, how can I do this? Thank you! Gao Xia [[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] save a regression model that can be used later
Hi everyone I have a question about how to save a regression model in R and how to retrieve it for making predictions in a new session. To be more specific, I fitted a multilevel logistic regression model using the lmer from the lme4 package. I then successfully make predictions using fitted(mymodel). Since data are complex (three levels, nested, numerous categorical and continuous data describing types of laparoscopic surgery), the computer takes quite a while to fit the MLM model. I wonder whether it's possible to save the fitted model so that I don't have to fit it again for making predictions every time I start a new R session. I searched the mailing-list archive. Suggestions include using save () to save the model as mymodel.rda and then use load(mymodel.rda) into the workspace. I tried without success (in Windows), returning the error message: Error in object$fitted : $ operator is invalid for atomic vectors Did I do anything wrong? Any help on this topic is much appreciated BW, Melody -- Dr Melody Ni Imperial College Department of Surgery and Cancer 10th floor, QEQM Building St. Mary's Hospital London W2 1NY Tel/Fax: +44 (0) 20 331 27657/26309 z...@imperial.ac.ukmailto:z...@imperial.ac.uk [[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] Is it possible to make a matrix to start at row 0?
Hi, You can do it, but it would be very difficult (think reworking all indexing yourself) and you probably should not even try (nothing else that was expecting indexing to work as the R gods intended it to would work once you had done your rework). What has lead you to want to index from 0? If it is some problem you are having, I can almost certainly promise you it will be easier for us to show you how to approach it differently and index from 1 than to change the underlying framework so you can index from 0. Cheers, Josh On Mon, Nov 22, 2010 at 10:23 AM, bogdanno bodins...@gmail.com wrote: I want to make the matrix to be indexed from row (column) 0, not 1 Can I do that? How? Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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] question about constraint minimization
I do not understand the constraint x1 = x3 = x4. If this is correct, you only have 10 unknown parameters. If you can correctly formulate your problem, you can have a look at the packages alabama or BB. The function `auglag' in alabama or the function `spg' in BB may be useful. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of dhacade...@gmail.com Sent: Monday, November 22, 2010 11:10 AM To: r-help@r-project.org Subject: Re: [R] question about constraint minimization Hi, I have struggled on this bound optimization with equality constraint by using optim function for two days, but still fail to prepare a good input. Can anyone help to prepare the input for my specific case? Many thanks. Best, Hao On Sat, Nov 20, 2010 at 3:17 AM, Hans W Borchers [via R] ml-node+3051338-309339578-202...@n4.nabble.comml-node%2B3051338-309339578-2 02...@n4.nabble.com wrote: dhacademic at gmail.com dhacademic at gmail.com writes: Hi, I am a beginner of R. There is a question about constraint minimization. A function, y=f(x1,x2,x3x12), needs to be minimized. There are 3 requirements for the minimization: (1) x2+x3+...+x12=1.5 (x1 is excluded); (2) x1=x3=x4; (3) x1, x3 and x5 are in the range of -1~0, respectively. The rest variables (x2, x4, x6, x7, , x12) are in the range of 0~1, respectively. The optim function is used. And part of my input is as follow, where xx1r represents the x12: xx1r=1.5-x[2]-x[1]-x[1]-x[3]-x[4]-x[5]-x[6]-x[7]-x[8]-x[9] start=rnorm(9) up=1:9/1:9*1 lo=1:9/1:9*-1 out=optim(start,f,lower=lo,upper=up,method=L-BFGS-B,hessian=TRUE, control=list(trace=6,maxit=1000)) There are two problems in this input. the up and lo only define a range of -1~1 for x1 to x11, which can not meet the requirement (3). In addition, there is not any constraint imposed on x12. I have no idea how to specify a matrix that can impose different constraints on individual variables in a function. Any suggestion is highly appreciated. Best, Hao I don't see any direct need for real 'constraint' optimization here, it is a 'bounded' optimization where you are allowed to use lower - c(-1,0,-1,0,-1,0,0,0,0,0,0,0) upper - c( 0,1, 0,0, 0,1,1,1,1,1,1,1) Otherwise, your description is confusing: (1) Did you change f to a new function with 9 variables, eliminating x3, x4, and x12 ? (2) x4 (being equal to x1) has to be in [-1, 0] but also in [0, 1]? (3) If you need to restrict x12 to [0, 1] also, you cannot eliminate it. Either keep x12 and use an equality constraint, or use inequality constraints on xxlr. Hans Werner __ [hidden email] http://user/SendEmail.jtp?type=nodenode=3051338i=0mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View message @ http://r.789695.n4.nabble.com/question-about-constraint-minimization-tp30508 80p3051338.html To unsubscribe from question about constraint minimization, click herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscrib e_by_codenode=3050880code=ZGhhY2FkZW1pY0BnbWFpbC5jb218MzA1MDg4MHwtNjM2Nzc0 NA==. -- View this message in context: http://r.789695.n4.nabble.com/question-about-constraint-minimization-tp30508 80p3053912.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Is it possible to make a matrix to start at row 0?
Eh??? Why would you want to do that?? (R isn't C). So the simple answer is: you can't. The other answer is, well of course you sort of can via, e.g. for(i in 0:9) { z - myMatrix[i+1,] ... } But as Josh said, I think this falls into the class of You are just asking for trouble, so don't do it. Cheers, Bert On Mon, Nov 22, 2010 at 10:23 AM, bogdanno bodins...@gmail.com wrote: I want to make the matrix to be indexed from row (column) 0, not 1 Can I do that? How? Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical 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.
Re: [R] RGoogleDocs stopped working
No joy for me. :( I'd had version 0.4-1 installed previously, and re-pulling that URL and reinstalling, plus setting RCurlOptions as specified, do not help for me. Exactly the same behavior. It doesn't matter whether I call getGoogleAuth directly or let getGoogleDocsConnection do it for me. -Harlan On Fri, Nov 19, 2010 at 10:27 PM, Farrel Buchinsky fjb...@gmail.com wrote: Harlan and Tal have had problems. I had lots too. I spent hours getting it to work. Terrible process to go through but RGoogleDocs is so useful that the time was worth it - I think! My problems were overcome when 1. I used the latest zip file by Duncan Temple Lang see below 2. I inserted an options line that loosened the ssl security - do not know if that was a good thing or not but it got it to work Duncan said: I have put an updated version of the source of the package with these changes. It is available from http://www.omegahat.org/RGoogleDocs/RGoogleDocs_0.4-1.tar.gz There is a binary for Windows in http://www.omegahat.org/RGoogleDocs/RGoogleDocs_0.4-1.zip Here is my script that works. Does yours look like this? library(RGoogleDocs) packageDescription( RGoogleDocs) ps -readline(prompt=get the password in ) options(RCurlOptions = list(capath = system.file(CurlSSL, cacert.pem, package = RCurl), ssl.verifypeer = FALSE)) sheets.con = getGoogleDocsConnection(getGoogleAuth(fjb...@gmail.com, ps, service =wise)) ts2=getWorksheets(OnCall,sheets.con) #OnCall is just the name of a spreadsheet names(ts2) y2005-sheetAsMatrix(ts2$y2005,header=TRUE, as.data.frame=TRUE, trim=TRUE) Finally, I am willing to offer you a TeamViewer session where we can take control of one another's computers and see if the problem is code or the installation. I warn you that I am neither a programmer nor a developer, just a very enthusiastic RGoogleDocs user who probably perseveres more than is good for him. Farrel Buchinsky On Fri, Nov 19, 2010 at 1:35 PM, Tal Galili tal.gal...@gmail.com wrote: I second Harlan's call. Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Fri, Nov 19, 2010 at 5:00 PM, Harlan Harris har...@harris.name wrote: Any new thoughts on this? I really want to get this working again! Is there someone else that can help or somewhere else I should be asking? Thanks! -Harlan On Wed, Nov 17, 2010 at 10:16 AM, Harlan Harris har...@harris.name wrote: Following up again. I found on the forums for the Google Apps API this thread that seems to be about a similar issue: http://www.google.com/support/forum/p/apps-apis/thread?tid=1c22cb44eb5cbba6hl=ensearch_impression_id=ab161b010ecf8803%3A12c5a65ce83search_source=related_question It's using Java and is rather over my head, but it seems to suggest that something related to the content type might be wrong? Does this offer any suggestions on how to fix my use of RGoogleDocs? Thanks, -Harlan On Mon, Nov 15, 2010 at 12:16 PM, Harlan Harris har...@harris.name wrote: Thanks, Duncan. Finally getting a chance to follow up on this... I tried again, changing and resetting my password, and trying to specify my login and password manually in the getGoogleDocsConnection argument list. I also tried removing either or both of the service and error options. No luck in any case. I also tried a different Google account, also with no luck. I've also tried tweaking the URL being generated by the code, and in all cases, I get a 403: Forbidden error with content Error=BadAuthentication. I don't really know enough about how authentication is supposed to work to get much farther. Can you help? Should I try the Google API forum instead? -Harlan From: Duncan Temple Lang dun...@wald.ucdavis.edu To: r-help@r-project.org Date: Wed, 10 Nov 2010 10:33:47 -0800 Subject: Re: [R] RGoogleDocs stopped working Hi Harlan I just tried to connect to Google Docs and I had ostensibly the same problem. However, the password was actually different from what I had specified. After resetting it with GoogleDocs, the getGoogleDocsConnection() worked fine. So I don't doubt that the login and password are correct, but you might just try it again to ensure there are no typos. The other thing to look at is the values for Email and Passwd sent in the URL, i.e. the string in url in your debugging below. (Thanks for that by the way). If either has special characters, e.g. , it is imperative that they are escaped correctly, i.e. converted to %24. This should happen and nothing should have changed, but it is worth verifying. So things still seem to work for me. It is a data
Re: [R] sm.ancova graphic
On 2010-11-22 09:47, Lucia Cañas wrote: Hi R-Users, I am working with sm.ancova (in the package sm) and I have two problems with the graph, which is automatically generated when sm.ancova() is run. 1-Besides of the fitted lines, the observed data appeared automatically in the graph. I prefer that only fitted lines appear. I check the sm.options, but I could not find the way that the observed data do not appear in the graph. 2-I would like to change the size of the numbers in the axis. Again, I check the sm.options, but I could not find the correct way. Your second request is easy: just issue a par(cex.axis = ) call before the sm.ancova call. For your first problem, I can't see a simple way; this seems to be hard-coded in the function. But the function is easy to modify. Just look for a couple of short loops containing this: text(rawdata$ (It's best to work with the source code in the *.tar.gz file.) Remove or comment out those loops and save the function as, say, my.sm.ancova. You'll also have to set the environment of my.sm.ancova to that of sm.ancova. Seems to me that it might be worth suggesting this and the ability to fiddle with graphics parameters to the maintainer of sm. Peter Ehlers Thank you in advance, Lucía [[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] Wait for user input with readline()
Hi Nate, There may be better ways, but on the couple instances I've wanted to wait for keyboard input I used this type of paradigm: foo - function() { x - 1:10 y - rnorm(10) input - NA while(!isTRUE(input == 1) !isTRUE(input == 2)) { cat(Please type '1' if you want the first variable on the x axis and '2' if you want the second., fill = TRUE) input - scan(, what = character) if(input == 1) { plot(x, y) } else if (input == 2) { plot(y, x) } else {cat(Sorry, I didn't catch that, fill = TRUE)} } } Perhaps it will be of some use to you. Best regards, Josh On Mon, Nov 22, 2010 at 11:13 AM, Nathan Miller natemille...@gmail.com wrote: Hello, I am trying write a script that includes a prompt for user input using readlines(). I am running into the problem that when I run readlines() as a single line the prompt works perfectly, but when I try to run a block of code which includes the readline function, the script doesn't wait for the user input. I have seen this question posted before when I did a search, but I didn't find an suitable answer. Is there a means of ensuring that the script does not proceed until a value has been entered to readline(). Can I put readline in a function that will wait for input? Are there other options for getting user input that allow require that the script wait for user input? Thanks for your help, Nate [[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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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] Ordeing Zoo object
On Mon, Nov 22, 2010 at 1:35 PM, Manta mantin...@libero.it wrote: And how about if I want to order the series from the smallest to the largest value, keeping the date index in order to see when the values were predominantly negative etc... If you just want to look at it in this order then: as.data.frame(dat)[length(dat):1,,drop = FALSE] -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is it possible to make a matrix to start at row 0?
Bert Gunter gunter.berton at gene.com writes: Eh??? Why would you want to do that?? (R isn't C). So the simple answer is: you can't. The other answer is, well of course you sort of can via, e.g. for(i in 0:9) { z - myMatrix[i+1,] ... } But as Josh said, I think this falls into the class of You are just asking for trouble, so don't do it. Cheers, Bert But if you still want to after all those warnings, you can ... see the Oarray package, where the first letter of the package name is a capital letter oh (O), not a zero (0). library(fortunes); fortune(Yoda) There ought also to be a clever fortune() expressing the sentiment that you may eventually find (weeks, months, or years later) that changing the way you solve your problem to go with R's flow would have been easier than implementing a solution that works around the flow (examples abound: -, zero-based arrays, eval(parse()), storing names of variables as character vectors and using get() [FAQ 7.21], etc, etc, etc ...) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] save a regression model that can be used later
On Nov 22, 2010, at 10:02 AM, Ni, Melody Zhifang wrote: Hi everyone I have a question about how to save a regression model in R and how to retrieve it for making predictions in a new session. To be more specific, I fitted a multilevel logistic regression model using the lmer from the lme4 package. I then successfully make predictions using fitted(mymodel). Since data are complex (three levels, nested, numerous categorical and continuous data describing types of laparoscopic surgery), the computer takes quite a while to fit the MLM model. I wonder whether it's possible to save the fitted model so that I don't have to fit it again for making predictions every time I start a new R session. I searched the mailing-list archive. Suggestions include using save () to save the model as mymodel.rda and then use load(mymodel.rda) into the workspace. I tried without success (in Windows), returning the error message: Error in object$fitted : $ operator is invalid for atomic vectors How? ... did you try that is. Need code, not vague reports of failure. Did I do anything wrong? Any help on this topic is much appreciated BW, Melody -- Dr Melody Ni Imperial College Department of Surgery and Cancer 10th floor, QEQM Building -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to round only one column of a matrix ?
round() function affects all values of a matrix, I want only to round column that is called 'y'. -- View this message in context: http://r.789695.n4.nabble.com/how-to-round-only-one-column-of-a-matrix-tp3054363p3054363.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] Is it possible to make a matrix to start at row 0?
Apparently He who starts from 0 needn't be called unfortunate, fortune('indexed') baptiste On 22 November 2010 20:59, Ben Bolker bbol...@gmail.com wrote: Bert Gunter gunter.berton at gene.com writes: Eh??? Why would you want to do that?? (R isn't C). So the simple answer is: you can't. The other answer is, well of course you sort of can via, e.g. for(i in 0:9) { z - myMatrix[i+1,] ... } But as Josh said, I think this falls into the class of You are just asking for trouble, so don't do it. Cheers, Bert But if you still want to after all those warnings, you can ... see the Oarray package, where the first letter of the package name is a capital letter oh (O), not a zero (0). library(fortunes); fortune(Yoda) There ought also to be a clever fortune() expressing the sentiment that you may eventually find (weeks, months, or years later) that changing the way you solve your problem to go with R's flow would have been easier than implementing a solution that works around the flow (examples abound: -, zero-based arrays, eval(parse()), storing names of variables as character vectors and using get() [FAQ 7.21], etc, etc, etc ...) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to round only one column of a matrix ?
Is this what you're looking for? mymatrix = matrix(rnorm(15),5,3,dimnames=list(NULL,c('x','y','z'))) mymatrix x y z [1,] -0.4459162 -2.3936837 -0.7401963 [2,] 0.9886466 -1.3955161 -1.3390314 [3,] -0.2086743 1.7984620 -0.8532579 [4,] 1.0985411 0.9315553 -1.3981632 [5,] 0.5787438 0.1719177 0.2246174 mymatrix[,'y'] = round(mymatrix[,'y']) mymatrix x y z [1,] -0.4459162 -2 -0.7401963 [2,] 0.9886466 -1 -1.3390314 [3,] -0.2086743 2 -0.8532579 [4,] 1.0985411 1 -1.3981632 [5,] 0.5787438 0 0.2246174 - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Mon, 22 Nov 2010, madr wrote: round() function affects all values of a matrix, I want only to round column that is called 'y'. -- View this message in context: http://r.789695.n4.nabble.com/how-to-round-only-one-column-of-a-matrix-tp3054363p3054363.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] How to call web service in R
Hi, On Mon, Nov 22, 2010 at 4:51 AM, 夏高 xiagao1...@gmail.com wrote: Hello everyone, I would like to call web service in R, how can I do this? Thank you! Is RCurl what you're looking for? http://cran.r-project.org/web/packages/RCurl/index.html -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] aggregate a Date column does not work?
Hi, I am trying to aggregate max a Date type column but have weird result, how do I fix this? a - rbind( + data.frame(name='Tom', payday=as.Date('1999-01-01')), + data.frame(name='Tom', payday=as.Date('2000-01-01')), + data.frame(name='Pete', payday=as.Date('1998-01-01')), + data.frame(name='Pete', payday=as.Date('1999-01-01')) + ) a name payday 1 Tom 1999-01-01 2 Tom 2000-01-01 3 Pete 1998-01-01 4 Pete 1999-01-01 aggregate(a$payday, list(a$name), max) Group.1 x 1 Tom 10957 2Pete 10592 Thanks, Richard [[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] R2WinBUGS help
When I use the 'bugs' function from R, WinBUGS runs correctly, but R freezes. The only way to use R after this is to stop calculations (without my file that documents the calculation). However, I want to save the output in R so I can use it in further models. Does anyone know how to fix this problem? -- View this message in context: http://r.789695.n4.nabble.com/R2WinBUGS-help-tp3054411p3054411.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] FW: help with time Series regression please
Cathy, How does this model look? [(1-B**4)]Y(T) = 20.767 +[X1(T)][(1-B**4)][(+ 56.1962)] :PULSE 7/ 4 I~P00028test +[X2(T)][(1-B**4)][(+ 74.4301)] :PULSE 9/ 4 I~P00036test +[X3(T)][(1-B**4)][(- 59.9872)] :PULSE 6/ 3 I~P00023test +[X4(T)][(1-B**4)][(- 27.2187)] :PULSE 7/ 1 I~P00025test + [(1- .435B** 1)]**-1 [A(T)] -- View this message in context: http://r.789695.n4.nabble.com/errors-appears-in-my-time-Series-regression-fomula-tp1016593p3054417.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.