[R] density estimation for d>2 for the DPpackage

2009-02-22 Thread rodrigo herrera
Dear List, I am trying to estimate a 3 dimensional density through the DPpackage. For example # model sigma <- matrix(c(0.1,0.05,0.05,0.05,0.1,0.05,0.05,0.05,0.1), ncol=3) rnormm<- rmvnorm(n=100, mean=c(5,100,150), sigma=sigma) sigma2 <- matrix(c(10,0.05,0.05,0.05,10,0.05,0.05,0.05,10), ncol=3)

[R] Extracting xy from raster based on raster value

2009-02-22 Thread Michelle Greve
I have a raster (which I called glc), which I read into R as a raster with "raster.create.from.file" from the raster package (R-forge). Values in glc range between 1 and 27 (whole numbers only). I'd like to extract all cells with a value of 1 to create a new raster with only the cells that have a

[R] Function with 'data' parameter

2009-02-22 Thread Greg
I'm trying to write a simple function with a data parameter. tfun <- function(x, y, data = NULL) { if(missing(data)) dt <- data.frame(x=x, group=y) else { dt <- with(data, data.frame(x=x, group=y)) } return(dt) } If I pass variables

[R] Zoo or TS

2009-02-22 Thread miya
Hi everyone, I'm trying to plot some data across time. I have a list of articles, ranks, date/times, authors, etc. Someone suggested using zoo and someone suggested using ts. I'm pretty new at this and have been trying a simple if() plot() statement, but it doesn't seem to work. I keep getting an

[R] error using scan

2009-02-22 Thread Sharai Gomez
Hi, I hope you are fine. I am trying to use scan to open a file "prueba" extension txt. I am using the scan command as scan("C:/prueba") and I get the following error: Error in file(file, "r") : cannot open the connection In addition: Warning message: In file(file, "r") : cannot open file 'prueba

Re: [R] Convert a list to matrix

2009-02-22 Thread Dimitris Rizopoulos
one way is the following: m <- list(A = 1, B = 1:2, C = 1:3, D = 1:4) n <- max(sapply(m, length)) t(sapply(m, function (x) c(x, rep(NA, n - length(x) I hope it helps. Best, Dimitris Daren Tan wrote: I would like to convert a list to matrix. This can be easily achieved via do.call. The

Re: [R] how to recover a list structure

2009-02-22 Thread Dimitris Rizopoulos
another option is to use relist(), e.g., x <- list(a=runif(10), b=runif(30), c=runif(25)) x <- as.relistable(x) ux <- unlist(x) ux[order(ux)[1:5]] <- -1 relist(ux) Best, Dimitris jim holtman wrote: Here is one way that might work. x <- list(a=runif(10), b=runif(30), c=runif(25)) # unlist a

Re: [R] Function with 'data' parameter

2009-02-22 Thread Jim Lemon
Greg wrote: I'm trying to write a simple function with a data parameter. tfun <- function(x, y, data = NULL) { if(missing(data)) dt <- data.frame(x=x, group=y) else { dt <- with(data, data.frame(x=x, group=y)) } return(dt) } If I

Re: [R] Zoo or TS

2009-02-22 Thread Tony Breyal
I think you need to put quotes around the column header name, something like: NYT["Title"] example: > my.df <- data.frame(header1=1:3, header2=1:3) > my.df[header2] Error in `[.data.frame`(my.df, header2) : object "header2" not found > my.df["header2"] header2 1 1 2 2 3 3 Hope

[R] Error in var(x, na.rm = na.rm) : no complete element pairs

2009-02-22 Thread Carlos Morales
Hello all, I'm trying to calculate the standar desviation and I'm using the function sd(x,na.rm=TRUE) and I have this error:  Error in var(x, na.rm = na.rm) : no complete element pairs . Why happen this?, What can I do to solve it?. x is list of three numbers which I have from a table. Thanks

[R] Setting global variables in a function

2009-02-22 Thread Will Stone
Hi, I am writing a function that plots many graphs so therefore I have it turn recording on. The problem is; that when it is run again, the new graphs get added to the old ones, doubling the amount recorded. I know that .SavedPlots<-NULL removes the recorded plots but how can this be done from insi

Re: [R] variable/model selction (step/stepAIC) for biglm ?

2009-02-22 Thread Thomas Lumley
On Sat, 21 Feb 2009, Charles C. Berry wrote: On Sat, 21 Feb 2009, Tal Galili wrote: Hello dear R mailing list members. I have recently became curious of the possibility applying model selection algorithms (even as simple as AIC) to regressions of large datasets. Large in the sense of many

[R] Error in var(x, na.rm = na.rm) : no complete element pairs

2009-02-22 Thread Carlos Morales
Hello all, I'm trying to calculate the standar desviation with sd(x,na.rm=TRUE) and I don't know why I have this error Error in var(x, na.rm = na.rm) : no complete element pairs when I try to calculate it, I have been looking for information about this error but nothing. Why it happens?. What

Re: [R] Matrix package: band matrix

2009-02-22 Thread Thomas Lumley
Exactly what I wanted. Thanks much. -thomas On Sat, 21 Feb 2009, Martin Maechler wrote: "KK" == Ken Knoblauch on Fri, 20 Feb 2009 14:11:55 + (UTC) writes: KK> Thomas Lumley u.washington.edu> writes: >> I want to construct a symmetric band matrix in the Matrix >> pa

Re: [R] variable/model selction (step/stepAIC) for biglm ?

2009-02-22 Thread Tal Galili
Hi Thomas, What you just wrote is very interesting to me - do you have any suggestion then as to how to implement leaps (or any other package/code) to iterate on the final lm model produced by biglm ? Any advice would be very welcomed! p.s: My purpose is to use a different algorithm than that of

Re: [R] variable/model selction (step/stepAIC) for biglm ?

2009-02-22 Thread Thomas Lumley
On Sun, 22 Feb 2009, Tal Galili wrote: Hi Thomas, What you just wrote is very interesting to me - do you have any suggestion then as to how to implement leaps (or any other package/code) to iterate on the final lm model produced by biglm ? Any advice would be very welcomed! If you look at th

Re: [R] Setting global variables in a function

2009-02-22 Thread Eik Vettorazzi
see ?'<<-' hth. Will Stone schrieb: Hi, I am writing a function that plots many graphs so therefore I have it turn recording on. The problem is; that when it is run again, the new graphs get added to the old ones, doubling the amount recorded. I know that .SavedPlots<-NULL removes the recorded

Re: [R] variable/model selction (step/stepAIC) for biglm ?

2009-02-22 Thread Tal Galili
Thanks Thomas! I'll give it a go and will send updates as to how I am doing. Cheers, Tal On Sun, Feb 22, 2009 at 1:52 PM, Thomas Lumley wrote: > On Sun, 22 Feb 2009, Tal Galili wrote: > > Hi Thomas, >> >> What you just wrote is very interesting to me - do you have any suggestion >> then as t

Re: [R] error using scan

2009-02-22 Thread Eik Vettorazzi
Hi Sharai, I think scan() needs the extension as well. Have you tried scan("C:/prueba.txt") (this assumes that prueba.txt resides in your c-root dir) hth. Sharai Gomez schrieb: Hi, I hope you are fine. I am trying to use scan to open a file "prueba" extension txt. I am using the scan command a

Re: [R] variable/model selction (step/stepAIC) for biglm ?

2009-02-22 Thread Tal Galili
Hi Thomas, On second thought - I will need some more help: What I only now noticed is that leaps is "an exhaustive search for the best subsets of the variables in x for predicting y in linear regression", while what I am aiming for (for now) is a method to implement forward selection (on biglm) - a

[R] line joining graphs

2009-02-22 Thread rajesh j
hi, I need to draw a line joining graphs,but abline stops within a graph.What do i do to cover portions between two graphs -- Rajesh.J [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listi

[R] split/decompose lines

2009-02-22 Thread Mafalda Viana
Dear R users, I have a very simple problem but I can't find the function in R to deal with it. I need to split (or decompose) one line into many lines using one field as a reference. I have a table with the following format: A B Frequency 23 3 2 24 2 5 25 1 3 And need to split eac

[R] How to parse text file into a table?

2009-02-22 Thread Daren Tan
I am given a text file of records to be converted into a table format. I have searched related topics or packages, but can't find any similar cases. Please help. Sample record is given below. Take note the last element doesn't have a semi colon. ###-Start of record--

Re: [R] variable/model selction (step/stepAIC) for biglm ?

2009-02-22 Thread Thomas Lumley
On Sun, 22 Feb 2009, Tal Galili wrote: Hi Thomas, On second thought - I will need some more help: What I only now noticed is that leaps is "an exhaustive search for the best subsets of the variables in x for predicting y in linear regression", while what I am aiming for (for now) is a method to

[R] how to deal with a changed plotting title?

2009-02-22 Thread Oliver
hi, I am trying to plot a series of graph with varied titles (slightly). So I was trying to format it and pass it to "main" in the plot function, but it doesn't seem to work: for example: i is variable part plot( main=format(c("graph ", i)) ...) what is the correct way of handling this? T

Re: [R] how to deal with a changed plotting title?

2009-02-22 Thread Eik Vettorazzi
Hi Oliver, this a classic "paste" task ...main=paste("graph", i)... hth. Oliver schrieb: hi, I am trying to plot a series of graph with varied titles (slightly). So I was trying to format it and pass it to "main" in the plot function, but it doesn't seem to work: for example: i is variable

Re: [R] How to parse text file into a table?

2009-02-22 Thread Ben Bolker
Daren Tan gmail.com> writes: > > I am given a text file of records to be converted into a table format. > I have searched related topics or packages, but can't find any similar > cases. Please help. > > Sample record is given below. Take note the last element doesn't have > a semi colon. > > #

Re: [R] split/decompose lines

2009-02-22 Thread Ben Bolker
Mafalda Viana-2 wrote: > > > I need to split (or decompose) one line into many lines using one field as > a > reference. > > I have a table with the following format: > > A B Frequency > 23 3 2 > 24 2 5 > 25 1 3 > > olddata[rep(1:nrow(olddata),olddata$B),] repeats the rows o

Re: [R] How to parse text file into a table?

2009-02-22 Thread jim holtman
Here is one way of reading in your data: > input <- readLines(textConnection("###-Start of > record-- + + Name: John + Height: 170cm + Weight: 70kg + Age: 30 + + Status: Married + Children: 2 + + Employment: Engineer + + ###-End of record--

Re: [R] Zoo or TS

2009-02-22 Thread miya
Thank you Tony. I tried that, but still got an error. This is what I got. if(df["Title"]=="A") + plot(df["B"]) Error in `[.data.frame`(df, "Title") : undefined columns selected I Think there is something wrong with my file because when I call [,1] It gives me the whole data set, but when I cal

[R] a coding problem from Ross Simulation book

2009-02-22 Thread Ssophia
Hi, there could you help me coding this problme? I am just starting to leard the R. So I really need help Question is from Ross, Simulation, 4th Edition. ch3 14. with x1=23, x2=66 Xn=3*Xn-1+5*Xn-2 mod(100) n>=3 we will call the sequence Un=Xn/100 n>=1 fi

Re: [R] how to deal with a changed plotting title?

2009-02-22 Thread Tal Galili
BTW, if we are on the subject, here is a cool trick I came a cross the other day about creating a title with multi-coloured words.: http://blog.revolution-computing.com/2009/01/multicolor-text-in-r.html Tal On Sun, Feb 22, 2009 at 4:13 PM, Eik Vettorazzi < e.vettora...@uke.uni-hamburg.de> wr

Re: [R] Zoo or TS

2009-02-22 Thread Robert W. Baer, Ph.D.
You have not really made it clear what you are trying to do, and I don't see the zoo vs ts involvement in your question. Also, your test data and code snippet you give are not quite consistent. Thus, my advice is really a long-shot guess. Assume your data looks like: Time Date Rank Topic Titl

Re: [R] Extracting xy from raster based on raster value

2009-02-22 Thread Kingsford Jones
Hi Michelle, The r-sig-geo list would be the ideal place for this question since the authors of 'raster' would be likely to see it. I haven't used the raster package before, but this seems to work: #install.packages("raster", repos="http://R-Forge.R-project.org";) r <- raster() r <- setValues(r

[R] calculating compound growth rates - creating a flexible function

2009-02-22 Thread simeon duckworth
R-listers I am still finding my way with R - and feel that I am making a complete dogs dinner of something that should be pretty simple. What I'd like to do is to create a simple function that i can use to calculate compound growth rates (CAGRs) over a data frame. I'd like the function to be fle

Re: [R] how to deal with a changed plotting title?

2009-02-22 Thread Oliver
Great. That works. thanks Oliver On Feb 22, 9:13 am, Eik Vettorazzi wrote: > Hi Oliver, > this a classic "paste" task > > ...main=paste("graph", i)... > > hth. > > Oliver schrieb: > > > > > hi, > > > I am trying to plot a series of graph with varied titles (slightly). > > So I was trying to fo

Re: [R] Function with 'data' parameter

2009-02-22 Thread Gavin Simpson
On Sun, 2009-02-22 at 20:52 +1100, Jim Lemon wrote: > Greg wrote: > > I'm trying to write a simple function with a data parameter. > > > > tfun <- function(x, y, data = NULL) { > > if(missing(data)) > > dt <- data.frame(x=x, group=y) > > else { > > dt <- with(data, d

Re: [R] a coding problem from Ross Simulation book

2009-02-22 Thread Rolf Turner
On 23/02/2009, at 6:57 AM, Ssophia wrote: could you help me coding this problme? I am just starting to leard the R. So I really need help Question is from Ross, Simulation, 4th Edition. ch3 14. with x1=23, x2=66 Xn=3*Xn-1+5*Xn-2 mod(100) n>=3 we will call the sequence Un

[R] filtering a simple matrix

2009-02-22 Thread Juan Pablo Fededa
Hi all, I have the next matrix: ab c 1223 2342 3054 4523 5022 6721 7120 8919 I want to filter the rows with the values of b higher than 1 in a way tha

Re: [R] Zoo or TS

2009-02-22 Thread miya
Hello all, I've been able to separate the columns now so that when I call NYT[,9] it gives me just that column. I'm still trying to plot however. When I used the previous if()plot() statement it plots something, but its not what I want. I want to plot the rank vs time, but its just plotting the sa

Re: [R] Zoo or TS

2009-02-22 Thread miya
Sorry, forgot to attach the error it is giving me. > if(NYT["Title"]=="A") + plot(NYT["B"],ylim=c(0,50),xlim=c(0,50),ylab="B",xlab="A") Warning message: In if (NYT["Title"] == "A") plot(NYT["B"], : the condition has length > 1 and only the first element will be used Thank you Tony Breyal w

Re: [R] filtering a simple matrix

2009-02-22 Thread Jorge Ivan Velez
Dear Juan Pablo, If "mymat" is your matrix, you could use something like this: # Option 1 mymat[mymat$b>1,] # Option 2 mymat[with(mymat,b>1),] HTH, Jorge On Sun, Feb 22, 2009 at 1:10 PM, Juan Pablo Fededa wrote: > Hi all, > > I have the next matrix: > > > ab c > > 12

Re: [R] filtering a simple matrix

2009-02-22 Thread jim holtman
Did you read the Introduction to R and the use of indexing to 'filter'? > x <- read.table(textConnection("ab c + + 1223 + 2342 + 3054 + 4523 + 5022 + 6721 + 7120 + 8

Re: [R] joining "one-to-many"

2009-02-22 Thread eugen pircalabelu
A not so elegant way of obtaining your result (compared to merge()) would be: > t1$ val3<-rep(t2$val3, table(t1$loc)) > t1$ val4<-rep(t2$val4, table(t1$loc)) Eugen. --- On Tue, 2/17/09, Monica Pisica wrote: > From: Monica Pisica > Subject: Re: [R] joining "one-to-many" > To: ggrothendi...

Re: [R] Zoo or TS

2009-02-22 Thread jim holtman
What is NYT? Is it a dataframe? Is "Title" a column? What exactly are you wanting to plot? Is it just the values in column "B" where "Title" is equal to "A"? The posting guide does suggest that you provide a reproducible set of code/data. You can probably do what you want if you can explain w

[R] Semantics of sequences in R

2009-02-22 Thread Stavros Macrakis
Inspired by the exchange between Rolf Turner and Wacek Kusnierczyk, I thought I'd clear up for myself the exact relationship among the various sequence concepts in R, including not only generic vectors (lists) and atomic vectors, but also pairlists, factor sequences, date/time sequences, and diffti

Re: [R] line joining graphs

2009-02-22 Thread Eik Vettorazzi
hi, you can use par(xpd=TRUE) and draw the joining line in every sub graph - don't know if there is another way with simple graphs eg: par(mfcol=c(1,2)) plot(1,1,xlim=c(0,5),main="1st") op<-par(xpd=TRUE) abline(h=1) plot(1,1,xlim=c(0,5),main="2nd") abline(h=1) hth. rajesh j schrieb: hi, I

Re: [R] line joining graphs

2009-02-22 Thread Ben Bolker
rajesh j gmail.com> writes: > I need to draw a line joining graphs,but abline stops within a graph.What do > i do to cover portions between two graphs try par(xpd=NA) ?segments may be useful too __ R-help@r-project.org mailing list https://stat.e

[R] lattice contourplot line types

2009-02-22 Thread Andrew Beckerman
Dear all - I would like to adjust the line type of specific contours in contourplot from the lattice package, but it seems like lty does not take a list in the call. Here is my call to contourplot: contourplot(preds~size+trt|Size.Name, data=pred.dat,layout=c(2,4), at=c(0.02

Re: [R] Semantics of sequences in R

2009-02-22 Thread Duncan Murdoch
I think this was posted to the wrong list, so my followup is going to R-devel. On 22/02/2009 3:42 PM, Stavros Macrakis wrote: Inspired by the exchange between Rolf Turner and Wacek Kusnierczyk, I thought I'd clear up for myself the exact relationship among the various sequence concepts in R, in

[R] Fourier Row and spectral analysis

2009-02-22 Thread Peterko
Hello, i need to find in time serie, k=1,2,3...(how if possible) most domain frequencies and than smooth original serie by Fourier row y=mean + a1*Cos(2*pi/freq*t)+b1*Sin(2*pi/freq*t)+a2.. numbers a1,b1 ... i will have from simple regresion, i need only to find k msot domain frequensies a th

Re: [R] lattice contourplot line types

2009-02-22 Thread Sundar Dorai-Raj
The only way I can figure out to do this is to use two calls to panel.contourplot: library(lattice) x <- seq(-2, 2, length = 20) y <- seq(-2, 2, length = 20) grid <- expand.grid(x=x, y=y) grid$z <- dnorm(grid$x) * dnorm(grid$y) contourplot(z ~ x * y, grid, panel = function(at, lty, col

Re: [R] lattice contourplot line types

2009-02-22 Thread Andrew Beckerman
Sundar - Thanks for the help! Here is my modified code. Just what I wanted. However, it is odd that the at= call in contourplot won't take a single value - I have had to trick it into plotting the "0" contour along with the 0.5 to make this work. contourplot(preds~size+trt|Size.Name,

[R] Dates and times from Excel

2009-02-22 Thread David Scott
I have used xlsReadWrite to read data from an Excel spreadsheet. I had a problem with converting times of the day so that I could create POSIXct date-time objects. I was wondering if there was a better solution. Excel stores times of the day as fractions of a day so I wrote a function to co

Re: [R] Dates and times from Excel

2009-02-22 Thread Gabor Grothendieck
The chron package stores times as a fraction of the day. See R News 4/1. On Sun, Feb 22, 2009 at 8:26 PM, David Scott wrote: > > I have used xlsReadWrite to read data from an Excel spreadsheet. > > I had a problem with converting times of the day so that I could create > POSIXct date-time objects

[R] Filtering a data frame using a string for colum header

2009-02-22 Thread Tony Breyal
Hi all, I was just radomly playing with R and got the following error when trying to filter a data frame using a string: > Angel <- c(7,8,6,9,10) > Buffy <- c(8,9,4,9,10) > Firefly <- c(9,9,10,10,10) > DrHorrible <- c(10,9,9,10,10) > my.df <- data.frame(Angel, Buffy, Firefly, DrHorrible) > my.df[

Re: [R] Filtering a data frame using a string for colum header

2009-02-22 Thread Chun-Hao Tu
Hi Tony, I "GUESS" my.df[-"DrHorrible"] does not tell R which column "NUMBER" would like to remove. As we know, we could use my.df[-4] and it exactly tells R which column must remvoer from your data. > my.df[-4] Angel Buffy Firefly 1 7 8 9 2 8 9 9 3 6 4

[R] 1.095e+09 for integers

2009-02-22 Thread Alexy Khrabrov
I've had a very long file written out by R with write.table, with fields of time values, converted from POSIXlt as.numeric. Among 2.5 million values, very few had 6 trailing zeroes, and those were output in scientific notation as in the subject. Is this the default behavior for long integ

[R] running multiple commands in one system() call

2009-02-22 Thread Nick Matzke
Hi all, I'm on Mac OS X 10.4... So I've got a small python script I need to run from R. However, to get the python script working, I need to have the shell that R calls get settings from my .bash_profile file, which apparently it doesn't currently (the shell R calls uses an older version of

Re: [R] 1.095e+09 for integers

2009-02-22 Thread Prof Brian Ripley
I don't think you had 'integers' but integer-valued doubles: try as.integer to get an integer variable. E.g. x <- 1.1*(10^(1:8)) write.table(data.frame(x, as.integer(x)), "") "x" "as.integer.x." "1" 11 11 "2" 110 110 "3" 1100 1100 "4" 11000 11000 "5" 11 11 "6" 110 110 "7" 1.1e+

Re: [R] running multiple commands in one system() call

2009-02-22 Thread Prof Brian Ripley
On Sun, 22 Feb 2009, Nick Matzke wrote: Hi all, I'm on Mac OS X 10.4... For which there is a separate mailing list, R-sig-Mac . So I've got a small python script I need to run from R. However, to get the python script working, I need to have the shell that R calls get settings from my .ba

Re: [R] Fourier Row and spectral analysis

2009-02-22 Thread Dieter Menne
Peterko gmail.com> writes: > Hello, i need to find in time serie, k=1,2,3...(how if possible) most domain > frequencies and than smooth original serie by Fourier row y=mean + > a1*Cos(2*pi/freq*t)+b1*Sin(2*pi/freq*t)+a2.. > > numbers a1,b1 ... i will have from simple regresion, i need only

Re: [R] Filtering a data frame using a string for colum header

2009-02-22 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 23.02.2009 03:44:41: > > Hi Tony, > > I "GUESS" my.df[-"DrHorrible"] does not tell R which column "NUMBER" would > like to remove. > As we know, we could use my.df[-4] and it exactly tells R which column must > remvoer from your data. > > > my.df