[R] merging two maxtrices

2010-09-05 Thread steven mosher
j-matrix(nrow=10,ncol=10) k-matrix(seq(1:50), ncol=10) row.names(k) - seq(2,10,by=2) j [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] NA NA NA NA NA NA NA NA NANA [2,] NA NA NA NA NA NA NA NA NANA [3,] NA NA NA NA NA

Re: [R] merging two maxtrices

2010-09-05 Thread Dennis Murphy
j[as.numeric(rownames(k)), ] - k j [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] NA NA NA NA NA NA NA NA NANA [2,]16 11 16 21 26 31 36 4146 [3,] NA NA NA NA NA NA NA NA NANA [4,]27 12 17 22

Re: [R] merging two maxtrices

2010-09-05 Thread Bill.Venables
Is this all you want? j - matrix(nrow=10,ncol=10) k - matrix(seq(1:50), ncol=10) row.names(k) - seq(2,10,by=2) row.names(j) - 1:10 j[row.names(k), ] - k j [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] 1NA NA NA NA NA NA NA NA NANA 2 16 11 16

Re: [R] merging two maxtrices

2010-09-05 Thread steven mosher
weird, I tried that but it didnt appear to work.. hmm. Thanks I try it again On Sun, Sep 5, 2010 at 12:21 AM, bill.venab...@csiro.au wrote: Is this all you want? j - matrix(nrow=10,ncol=10) k - matrix(seq(1:50), ncol=10) row.names(k) - seq(2,10,by=2) row.names(j) - 1:10

Re: [R] merging two maxtrices

2010-09-05 Thread steven mosher
ya, unfortunately k was actually a dataframe and not a matrix when it was returned from the function, which explains why I got unexpected results On Sun, Sep 5, 2010 at 12:21 AM, bill.venab...@csiro.au wrote: Is this all you want? j - matrix(nrow=10,ncol=10) k - matrix(seq(1:50), ncol=10)

Re: [R] tail.matrix returns matrix, while tail.mts return vector

2010-09-05 Thread mat
Thanks Ista! Indeed this is the workaround I had found, but not very practical as it fails on univariate series, so you should know before which class is the object... I feel a head.mts would make sense, or did I misunderstand something? Thanks! Matthieu Le 04. 09. 10 16:09, Ista Zahn a

Re: [R] Linear Logistic Regression - Understanding the output (and possibly the test to use!)

2010-09-05 Thread stats
David Winsemius wrote: 1. is glm the right thing to use before I waste my time Yes, but if your outcome variable is binomial then the family argument should be binomial. (And if you thought it should be poisson, then why below did you use gaussian??? Used gaussian below because it was

Re: [R] simple ts() object question

2010-09-05 Thread StatWM
Thanks for the fast answers! -- View this message in context: http://r.789695.n4.nabble.com/simple-ts-object-question-tp2527085p2527222.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

Re: [R] Function try and Results of a program

2010-09-05 Thread Evgenia
David, your example clarify me the use of sink. I really appreciate your help Evgenia -- View this message in context: http://r.789695.n4.nabble.com/Function-try-and-Results-of-a-program-tp2526621p2527227.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Please explain do.call in this context, or critique to stack this list faster

2010-09-05 Thread baptiste auguie
Another way that I like is reshape::melt.list() because it keeps track of the name of the original data.frames, l = replicate(1e4, data.frame(x=rnorm(100),y=rnorm(100)), simplify=FALSE) system.time(a - rbind.fill(l)) # user system elapsed # 2.482 0.111 2.597 system.time(b - melt(l,id=1:2))

Re: [R] Levels in returned data.frame after subset

2010-09-05 Thread Ulrik Stervbo
Thanks for the replies! Obviously I must have used to wrong search terms - sorry. @greg: I care about the levels after the subset, because if they are not dropped, then they still appear in the subsequent heatmap I make with ggplot (with my read data-set of course). Admittedly I am quite green,

Re: [R] Linear Logistic Regression - Understanding the output (and possibly the test to use!)

2010-09-05 Thread David Winsemius
On Sep 5, 2010, at 6:06 AM, st...@wittongilbert.free-online.co.uk wrote: David Winsemius wrote: 1. is glm the right thing to use before I waste my time Yes, but if your outcome variable is binomial then the family argument should be binomial. (And if you thought it should be

[R] converting string vector to integer/numeric vector

2010-09-05 Thread rajesh j
Hi, Is it possible to convert a string vector to integer or numeric vector? In my situation I receive data in a string vector and have to convert it based on a given type. -- Rajesh.J [[alternative HTML version deleted]] __

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread Ista Zahn
See ?numeric ?integer and possible the colClasses argument of read.table -Ista On Sun, Sep 5, 2010 at 12:48 PM, rajesh j akshay.raj...@gmail.com wrote: Hi, Is it possible to convert a string vector to integer or numeric vector? In my situation I receive data in a string vector and have to

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread David Winsemius
On Sep 5, 2010, at 8:48 AM, rajesh j wrote: Hi, Is it possible to convert a string vector to integer or numeric vector? In my situation I receive data in a string vector and have to convert it based on a given type. Can you give an example? I don't understand either what sort of

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread rajesh j
for e.g., I get the following as a string vector int 4 5 6 after reading the first element, I have to convert this to a integer vector On Sun, Sep 5, 2010 at 6:44 PM, David Winsemius dwinsem...@comcast.netwrote: On Sep 5, 2010, at 8:48 AM, rajesh j wrote: Hi, Is it possible to convert a

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread David Winsemius
On Sep 5, 2010, at 9:22 AM, rajesh j wrote: for e.g., I get the following as a string vector int 4 5 6 after reading the first element, I have to convert this to a integer vector But what is the right answer? And what number of items are possble per line? And what are the other

Re: [R] Linear Logistic Regression - Understanding the output (and possibly the test to use!)

2010-09-05 Thread Peng, C
Calum-4 wrote: Hi I know asking which test to use is frowned upon on this list... so please do read on for at least a couple on sentences... I have some multivariate data slit as follows Tumour Site (one of 5 categories) # Chemo Schedule (one of 3 cats) ## Cycle (one of 3 cats*) ##

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread rajesh j
The string vector actually comes as a part of a list, and the vector is named int, and the numbers are strings. I then have to make it a vector that is still called int and has 4,5,6 etc. the types are either integer or numeric. The number of items in the vector is unknown. here's an example, a

[R] Warning messages: not meaningful for factors

2010-09-05 Thread Dr Shrink
Dear Experts, I need to include the repeated structure in our data set object, recall.sums.df, before using gls function. Thus I used groupedData. But I encountered error messages which may mean '*' is not not meaningful factor. Please let me know what I have to do. Thanks, Jeong

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread David Winsemius
So there is one item per line and the task is to recognize the strings INT and NUM and create variables with numeric type and INT=c(2,3,4) NUM=c(2.37, 4.56) # ??? I worry that is not a full description of the task if there be more than just two variable names and if all the INTs have

Re: [R] Linear Logistic Regression - Understanding the output (and possibly the test to use!)

2010-09-05 Thread Frank Harrell
On Sun, 5 Sep 2010, st...@wittongilbert.free-online.co.uk wrote: David Winsemius wrote: 1. is glm the right thing to use before I waste my time Yes, but if your outcome variable is binomial then the family argument should be binomial. (And if you thought it should be poisson, then why

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread rajesh j
I'm sorry. you seem to have misunderstood my data representation for input. Here's what I have c-list(INT=c(1,2,3),NUM=c(2.34,4.56,6.78)) I need c-list(INT=c(1,2,3),NUM=c(2.34,4.56,6.78)) On Sun, Sep 5, 2010 at 7:57 PM, David Winsemius dwinsem...@comcast.netwrote: So there is one item per line

[R] dirichlet models

2010-09-05 Thread Donald Braman
Does anyone know of a package (or workaround) for fitting a dirichlet distribution by maximum likelihood? (I'm looking for something like this: http://repec.org/bocode/d/dirifit.html, that allows for both dependent variables summing to 1 predictive variables of any sort.) Don -- Donald

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread David Winsemius
On Sep 5, 2010, at 10:47 AM, rajesh j wrote: I'm sorry. you seem to have misunderstood my data representation for input. Because you did not follow the Posting Guide's advice regarding producing examples using valid R code. You give me text; I work on text. #- PLEASE do read the

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread Joshua Wiley
Hi Rajesh, This will work, unfortunately it seems like lapply() drops the names before it passes each element of the list which lead to my clumsy work around using which(). I'm sure there are other ways. dat - list(INT = c(1,2,3), NUM = c(2.34,4.56,6.78), INT = c(4, 5,

Re: [R] dirichlet models

2010-09-05 Thread David Winsemius
On Sep 5, 2010, at 10:53 AM, Donald Braman wrote: Does anyone know of a package (or workaround) for fitting a dirichlet distribution by maximum likelihood? Searching: RSiteSearch(fitting dirichlet distribution maximum likelihood) (Rapidly) produces this candidate:

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread Joshua Wiley
On Sun, Sep 5, 2010 at 8:16 AM, rajesh j akshay.raj...@gmail.com wrote: Hi, in a way similar to names(dat), can I address a particular index of every vector? like [0] of all the vectors? So that I could do something like, ints-which(required usage==x) Not sure I follow you exactly, but you

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread rajesh j
No, the examples dont cover it...if i have dat - list(INT = c(1,2,3), NUM = c(2.34,4.56,6.78), INT = c(4, 5, 6), NUM = c(3.44)) I need to do a which on INT[0],NUM[0],INT[0] and NUM[0]...ie the [0] index of all the vectors... and test if they hold a value On

[R] Greek symbols (again but more complicated)

2010-09-05 Thread John Helly
Hi. I'm trying to get 'mu' to show up as a Greek symbol but, despite trying every example I could find, can't get it to work. Any insights would be welcome. This is what I'm using that works, but displays mu with the letter u. plotTimeXMastPAR - qplot(DT,MastPAR, data=A, xlab = , ylab =

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread rajesh j
Hi, in a way similar to names(dat), can I address a particular index of every vector? like [0] of all the vectors? So that I could do something like, ints-which(required usage==x) On Sun, Sep 5, 2010 at 8:34 PM, Joshua Wiley jwiley.ps...@gmail.com wrote: Hi Rajesh, This will work,

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread rajesh j
this should work great. thanks On Sun, Sep 5, 2010 at 8:34 PM, Joshua Wiley jwiley.ps...@gmail.com wrote: Hi Rajesh, This will work, unfortunately it seems like lapply() drops the names before it passes each element of the list which lead to my clumsy work around using which(). I'm sure

Re: [R] Greek symbols (again but more complicated)

2010-09-05 Thread Dieter Menne
John Helly wrote: I'm trying to get 'mu' to show up as a Greek symbol but, despite trying every example I could find, can't get it to work. Try library(ggplot2) qplot(mpg, wt, data=mtcars, xlab = , ylab = bquote(mu~(E ~m^-2~s^-1)), geom=line) (thanks to Baptiste and David in

Re: [R] dirichlet models

2010-09-05 Thread Spencer Graves
install.packages('sos') # if you haven't already library(sos) dch - ???dirichlet # found 288 matches = help pages on contributed packages summary(dch) # in 65 packages dch # lists the 288 matches in a table in a browser with links the help pages # sorted to put the package with the most matches

[R] assignment by value or reference

2010-09-05 Thread Xiaobo Gu
Hi Team, Can you please tell me the rules of assignment in R, by value or by reference. From my about 3 months of experience of part time job of R, it seems most times it is by value, especially in function parameter and return values assignment; and it is by reference when

Re: [R] Warning messages: not meaningful for factors

2010-09-05 Thread Dieter Menne
Dr Shrink wrote: I need to include the repeated structure in our data set object, recall.sums.df, before using gls function. Thus I used groupedData. But I encountered error messages which may mean '*' is not not meaningful factor. I know that when reading Pinheiro/Bates one has the

[R] cov.unscaled in NLS - how to define cov.scaled to make comparable to SAS proc NLIN output - and theoretically WHY are they different

2010-09-05 Thread Monte Shaffer
I am running a 3-parameter nonlinear fit using the default Gauss-Newton method of nls. initialValues.L = list(b=4,d=0.04,t=180); fit.nls.L = nls( myModel.nlm , fData.L, start = initialValues.L, control = nls.control(warnOnly = TRUE), trace=T ); summary.nls.L = summary(fit.nls.L); I run the

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread Joshua Wiley
On Sun, Sep 5, 2010 at 8:36 AM, rajesh j akshay.raj...@gmail.com wrote: No, the examples dont cover it...if i have dat - list(INT = c(1,2,3),             NUM = c(2.34,4.56,6.78),             INT = c(4, 5, 6),             NUM = c(3.44)) I need to do a which on INT[0],NUM[0],INT[0] and

Re: [R] Greek symbols (again but more complicated)

2010-09-05 Thread David Winsemius
On Sep 5, 2010, at 11:41 AM, John Helly wrote: Hi. I'm trying to get 'mu' to show up as a Greek symbol but, despite trying every example I could find, can't get it to work. Any insights would be welcome. This is what I'm using that works, but displays mu with the letter u.

Re: [R] converting string vector to integer/numeric vector

2010-09-05 Thread rajesh j
great! Thanks On Sun, Sep 5, 2010 at 9:31 PM, Joshua Wiley jwiley.ps...@gmail.com wrote: On Sun, Sep 5, 2010 at 8:36 AM, rajesh j akshay.raj...@gmail.com wrote: No, the examples dont cover it...if i have dat - list(INT = c(1,2,3), NUM = c(2.34,4.56,6.78), INT =

[R] Need Help .RData in Mac OS X, Please

2010-09-05 Thread Chunhao
Hi R Users, I was accidentally save R file when I quit R program. I try to delete but I am not sure the R saved file was successfuly delete or not. Now everyt time when I open the R, it always appears [R.app GUI 1.34 (5589) i386-apple-darwin9.8.0] [Workspace restored from /Users/ctu/.RData] I

Re: [R] R time series analysis

2010-09-05 Thread lord12
How do I get the predicted values and the errors for each arima model? -- View this message in context: http://r.789695.n4.nabble.com/R-time-series-analysis-tp2527513p2527533.html Sent from the R help mailing list archive at Nabble.com. __

[R] appending to a list

2010-09-05 Thread Aks Ism
Hi, I've looked at previous discussions and did not get anything. I want to be able to append to a list in a loop. Is this possible? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

[R] Plotting multiple edges with iGraph

2010-09-05 Thread sashaBsAs
Hello, I am working with the igraph package and I am wondering if it is possible to get the plot function to plot multiple edges (and multiple loops) as separate lines. Thanks in advance for any help on this. sasha -- View this message in context:

Re: [R] appending to a list

2010-09-05 Thread David Winsemius
On Sep 5, 2010, at 1:21 PM, Aks Ism wrote: Hi, I've looked at previous discussions and did not get anything. I want to be able to append to a list in a loop. Is this possible? Of course: ?c ?[[ -- David Winsemius, MD West Hartford, CT __

Re: [R] appending to a list

2010-09-05 Thread jim holtman
x - list() for (i in whatever){ x[[length(x) + 1L]] - someValuesForList } On Sun, Sep 5, 2010 at 1:21 PM, Aks Ism aksi...@gmail.com wrote: Hi, I've looked at previous discussions and did not get anything. I want to be able to append to a list in a loop. Is this possible?        

Re: [R] how to free memory? (gc() doesn't work for me)

2010-09-05 Thread jim holtman
Depending on your operating system, the freed up memory might not be returned to the operating system, but kept in the process space. On Sat, Sep 4, 2010 at 10:17 PM, Hyunchul Kim sun...@sfc.keio.ac.jp wrote: Hi, all Thank you for your comments. I think that I misunderstood what gc() does

Re: [R] Need Help .RData in Mac OS X, Please

2010-09-05 Thread David Winsemius
On Sep 5, 2010, at 12:50 PM, Chunhao wrote: Hi R Users, I was accidentally save R file when I quit R program. I try to delete but I am not sure the R saved file was successfuly delete or not. Now everyt time when I open the R, it always appears [R.app GUI 1.34 (5589)

Re: [R] R time series analysis

2010-09-05 Thread lord12
How do you evaluate the predictive models? For example if I have: arima1 = arima(training, order = c(1,1,1)) arima2 = arima(training, order = c(0,0,0)) x.fore = predict(arima1, n.ahead=5) x.fore1 = predict(arima2, n.ahead = 5) How do I know which arima model is better for prediction? --

Re: [R] Need Help .RData in Mac OS X, Please

2010-09-05 Thread Chunhao
Hi David, This rm .RData works perfectly. Many Many Thanks Chunhao -- View this message in context: http://r.789695.n4.nabble.com/Need-Help-RData-in-Mac-OS-X-Please-tp2527456p2527674.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] R time series analysis

2010-09-05 Thread Stephan Kolassa
Hi, basically, you know 5 periods later. If you use a good error measure, that is. I am a big believer in AIC for model selection. I believe that arima() also gives you the AIC of a fitted model, or try AIC(arima1). Other ideas include keeping a holdout sample or some such. I'd recommend

Re: [R] Question regarding significance of a covariate in a coxme survival model

2010-09-05 Thread Teresa Iglesias
David Winsemius wrote: That is different than my understanding of AIC. I thought that the AIC and BIC both took as input the difference in -2LL and then adjusted those differences for the differences in number of degrees of freedom. David! Your words make sense to me now. Sorry

[R] CRAN (and crantastic) updates this week

2010-09-05 Thread Crantastic
CRAN (and crantastic) updates this week New packages * CFL (0.1) Maintainer: Pablo Michel Marin Ortega Author(s): Pablo Michel Marin Ortega, Kornelius Rohmeyer http://crantastic.org/packages/CFL The main results on this project are: a package to analyze the data based on

[R] Add y-title to a plot with two y axis

2010-09-05 Thread Magali teurlai
Hi all, We managed to plot two series on the same graph, with two y-axis, however, we haven't managed to add a title to the second y-axis x1=rnorm(25, mean=0, sd=1) y1=dnorm(x1, mean=0, sd=1) x2=rnorm(25, mean=0, sd=1) y2=dnorm(x2, mean=0, sd=1) plot(x1, y1, type='p', xlab='x', ylab='y')

Re: [R] Add y-title to a plot with two y axis

2010-09-05 Thread jim holtman
?mtext mtext(secondary y-axis label, 4, line=-1) you will have to adjust 'line to get your spacing the way you want it. On Sun, Sep 5, 2010 at 7:52 PM, Magali teurlai teurlaima...@gmail.com wrote: Hi all, We managed to plot two series on the same graph, with two y-axis, however, we haven't

[R] colorRamp of image to span larger range than dataset

2010-09-05 Thread Daisy Englert Duursma
Hello and thanks in advance, Using the dataset volcano: ascols = colorRampPalette(c(gray,yellow,darkgoldenrod1,orange,red),interpolate=spline) x - 10*(1:nrow(volcano)) y - 10*(1:ncol(volcano)) image(x, y, volcano, col = ascols, axes = FALSE) In the example above, how would I change my

Re: [R] colorRamp of image to span larger range than dataset

2010-09-05 Thread Bill.Venables
colorRampPalette returns a function, not a list of colours. You might want to try something like: ascols - colorRampPalette(c(gray, yellow, darkgoldenrod1, orange, red), interpolate=spline) x - 10*(1:nrow(volcano)) y - 10*(1:ncol(volcano)) image(x, y, volcano, col = ascols(300), axes =

[R] Seed value in ARIMA models

2010-09-05 Thread smilinglight
Hello, I am now learning to use the arima.sim command to model an AR(1) process. The AR(1) equations looks something like: r_t = phi_0 + phi_1*r_t-1 + u_t While simulating the AR(1) model, we specify the value of phi_1 in the equation. For example, arima.sim(list(c(1,0,0),ar=0.9),200) Could

[R] how do I transform this to a for loop

2010-09-05 Thread lord12
arima1 = arima(data.ts[1:200], order = c(1,1,1)) arima2 = arima(data.ts[5:205], order = c(1,1,1)) arima3 = arima(data.ts[10:210], order = c(1,1,1)) arima4 = arima(data.ts[15:215], order = c(1,1,1)) arima5 = arima(data.ts[20:220], order = c(1,1,1)) arima6 = arima(data.ts[25:225], order = c(1,1,1))

[R] TimeStamp

2010-09-05 Thread Roberto Badilla Fuentes
Hi, I have a dataset in .dbf format. It contains Coordinates and Time. The TIMESTAMP is as follows: 03/18/2006 13:30:37 I am not working with the TIMESTAMP column, but when I print out my manipulated dataset using *write.dbf* I get the value *390 *where the TIMESTAMP value should be. Can

Re: [R] appending to a list

2010-09-05 Thread Aks Ism
No, I mean dynamically. Like list.push_back On Mon, Sep 6, 2010 at 1:01 AM, David Winsemius dwinsem...@comcast.netwrote: On Sep 5, 2010, at 1:21 PM, Aks Ism wrote: Hi, I've looked at previous discussions and did not get anything. I want to be able to append to a list in a loop. Is this

Re: [R] R time series analysis

2010-09-05 Thread Johnson, Cedrick W.
You also may want to look at auto.arima in the 'forecast' package, which will return the best ARIMA model based on AIC/AICc/BIC values ?auto.arima hth c On 09/05/2010 06:02 PM, Stephan Kolassa wrote: Hi, basically, you know 5 periods later. If you use a good error measure, that is. I am

Re: [R] appending to a list

2010-09-05 Thread David Winsemius
On Sep 5, 2010, at 10:11 PM, Aks Ism wrote: No, I mean dynamically. Like list.push_back Not sure what you mean by dynamically and my Google search for the unspecified function list.push_back uncovered a C++ function that is at least as complex as what I believe would be the equivalent R

[R] extracting x,y coordinates from a contour plot

2010-09-05 Thread Charles Annis, P.E.
Requisite info: R version 2.11.1 (2010-05-31) running on a 64 bit HP Windows 7 machine. Greetings, R-ians: I have used contour() for several years. Now I would like to extract from a contour plot the x, y coordinates of a contour z=constant. This seems as though it would be

Re: [R] how do I transform this to a for loop

2010-09-05 Thread Bill.Venables
sseq - c(1, seq(5, 40, by = 5)) for(i in 1:length(sseq)) assign(paste(arima, i, sep=), arima(data.ts[sseq[i]:(sseq[i]+200)], order=c(1,1,1))) ...but why would you want to do so? -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On

Re: [R] extracting x,y coordinates from a contour plot

2010-09-05 Thread David Winsemius
On Sep 5, 2010, at 11:48 PM, Charles Annis, P.E. wrote: Requisite info: R version 2.11.1 (2010-05-31) running on a 64 bit HP Windows 7 machine. Doubt that makes much of a difference here. I have used contour() for several years. Now I would like to extract from a contour plot the x, y