[R] Welch Anova ?

2009-07-23 Thread Hardi
Hi, I need to do factor analysis with non-constant variance. Is there a package that contains Welch ANOVA ? 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-projec

[R] multiple error bars when NA present

2009-07-23 Thread Junqian Gordon Xu
package: psych function: error.bars() R version: 2.9.1 OS: both linux and windows a<-c(1,2,3,4,5) b<-c(1,2,3,4,4) c<-c(1,2,3,NA,5) data<-data.frame(a,b,c) error.bars(data[,1:2],ylim=c(0,6)) looks fine however error.bars(data,ylim=c(0.6)) shows multiple error bars for each vector and the num

Re: [R] How to find the min and max of two variables in a data frame

2009-07-23 Thread Dimitris Rizopoulos
try this: set.seed(123) dat <- data.frame(x = round(rnorm(10)), y = round(rnorm(10))) dat$Min <- pmin(dat$x, dat$y) dat$Max <- pmax(dat$x, dat$y) dat ind <- dat$Min != dat$Max dat[ind, ] I hope it helps. Best, Dimitris kxk wrote: I have two variables in a data frame, I want to generate tw

Re: [R] ggplot2 : commands on one line vs two lines.

2009-07-23 Thread Kingsford Jones
Hi John, Thank you for the easily cut-and-pastable example. You are providing syntactically complete code on the first line so the second line is not seen as a continuation. Try moving the '+' on the second line to the first. E.g, pb1 <- p + geom_point(aes(Area, Pcode)) + geom_segment() +

Re: [R] Simply matrix slice question

2009-07-23 Thread Dimitris Rizopoulos
yes, you need to use the 'drop' argument; have a look at the help file ?"[" and then try this: z <- matrix(rnorm(20), ncol = 5) z[1, , drop = FALSE] z[, 1, drop = FALSE] I hope it helps. Best, Dimitris Jim Nemesh wrote: Is there any way to force a slice of a matrix to stay a matrix? R tends

[R] How to find the min and max of two variables in a data frame

2009-07-23 Thread kxk
I have two variables in a data frame, I want to generate two additional variables. For every observations (i.e. every row), I want the first new variable 'min' to carry the minimum of the two existing variables, and I want the second new variable 'max' to carry the maximum of the two existing vari

[R] Simply matrix slice question

2009-07-23 Thread Jim Nemesh
Is there any way to force a slice of a matrix to stay a matrix? R tends to convert a single row of a matrix into a vector. Example: z<-matrix (rnorm(20), ncol=5) zz<-z[1,] is.matrix(zz) #FALSE I usually resort to: zz<-matrix(z[1,], ncol=dim(z)[2], dimnames=list(rownames(z)[1], colnames(z))

Re: [R] Question about the lars package

2009-07-23 Thread lulu9797
Thanks a lot for the reply. 1. How I compare the lars v.s. lm Your understand is correct. 2. Answer to my question. I guess in each step of lars, the coeff are not the same as the lm function returns using the same "model", because the coeff of lars are the "accumulated steps" towards the s

[R] Making rq and bootcov play nice

2009-07-23 Thread John Gardner
I have a quick question, and I apologize in advance if, in asking, I expose my woeful ignorance of R and its packages. I am trying to use the bootcov function to estimate the standard errors for some regression quantiles using a cluster bootstrap. However, it seems that bootcov passes arguments tha

Re: [R] alternative to rbind within a loop

2009-07-23 Thread Denis Chabot
Hi Greg, Thanks, very encouraging: with my example, this is 10x more efficient than my loop: utilisateur système écoulé 13.819 5.510 20.204 utilisateur système écoulé 156.206 44.859 202.150 In real life, I did some work on each file before doin

Re: [R] computing the radius of an arc

2009-07-23 Thread Bert Gunter
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gabor Grothendieck Sent: Thursday, July 23, 2009 7:33 PM To: Nair, Murlidharan T Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] computing the radius of an arc See ?draw.arc in the plo

[R] adjusting grid on Xaxis ticks

2009-07-23 Thread wapita wapita
Hello, I have been trying to plot correctly a graph for 2 month now, with no success.I want to put a grid, adjusted on the X axis tickers. Here is the way I build my X-Axis and my grid: grid(11, NULL, col="grey40") axis(2) # build the tickers on the beginning of each monthticks.at <- seq(IS

Re: [R] Computer Modern

2009-07-23 Thread Paul Murrell
Hi Mr Derik wrote: Thank you for your help. I've read all the documentation I can find and I still can't get this to work. postscriptFonts() in my console produces a list of fonts already mapped yes? one of which is: $ComputerModernItalic $family [1] "ComputerModernItalic" $metrics [1] "C

Re: [R] Duplicated date values aren't duplicates

2009-07-23 Thread jim holtman
What you are reporting is that there are two duplicated dates in your data. 'duplicated' returns a logical vector that is TRUE for the second and subsequent duplicates. Notice what is returned: > x <- c(1,2,2,3,4,4,5,6,4,7,3) > x[duplicated(x)] [1] 2 4 4 3 > On Thu, Jul 23, 2009 at 8:50 PM, T

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Gabor Grothendieck
If by "problem" you mean the problem of determining how, in general, you should proceed perhaps you need an introductory guide on R and time series such as Cowpertwait's book. On Thu, Jul 23, 2009 at 10:37 PM, Hongwei Dong wrote: > Hi, Gabor, it seems ARIMA model does not have that problem. For ex

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Hongwei Dong
Hi, Gabor, it seems ARIMA model does not have that problem. For example: set.seed(123) y<-ts(c(1:20)) x = ts(rnorm(20)) z = ts(rnorm(20)) tt<-ts(cbind(x, lag(x,-1),lag(x,-2),z)) fit <- arima(y[1:15],order=c(1,0,0),xreg=tt[(1:15),]) fit pred <- predict(fit, n.ahead=5,tt[(16:20),]) pred What do you

Re: [R] computing the radius of an arc

2009-07-23 Thread Gabor Grothendieck
See ?draw.arc in the plotrix package to draw an arc. On Thu, Jul 23, 2009 at 10:13 PM, Nair, Murlidharan T wrote: > Hi!! > > I am interesting in computing the radius of an arc that best approximates a > curve. Is there an R function that I can use to draw an arc? > Nothing useful came up when I s

[R] computing the radius of an arc

2009-07-23 Thread Nair, Murlidharan T
Hi!! I am interesting in computing the radius of an arc that best approximates a curve. Is there an R function that I can use to draw an arc? Nothing useful came up when I searched help.search. Does anyone have any suggestion to do this? Thanks ../Murli ___

Re: [R] Sum with Conditions

2009-07-23 Thread jimdare
Thanks very much :) Daniel Malter wrote: > > length(datasetname$Events[datasetname$Length<28 & > datasetname$Method%in%c(1,2,3) ...additional conditions... , ] > returns > the number of rows > sum(datasetname$Events[datasetname$Length<28 & > datasetname$Method%in%c(1,2,3) ...additional con

Re: [R] Help with Loop!

2009-07-23 Thread Steve Lianoglou
Hi, On Jul 23, 2009, at 7:30 PM, Lars Bishop wrote: Dear experts, I'm new in R and trying to learn by writing a version of the Perceptron Algorithm. How can I tell in the code below to stop the iteration when the condition in the "for loop" is not satisfied for all training examples? T

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Gabor Grothendieck
Try this: library(dyn) set.seed(123) tz <- zoo(cbind(Y = 0, x = rnorm(10), z = rnorm(10))) # simulate values for(i in 2:10) { tz$Y[i] <- with(tz, 2*Y[i-1] + 3*z[i] +4* x[i] + 5*x[i-1] + rnorm(1)) } # keep copy of tz to compare later to simulated Y's tz.orig <- tz # NA out Y's that are to be p

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Hongwei Dong
What I want R to do is to use the estimated Y at t-1 to be the lag(Y,-1) in the forecast equation for time t. Is there anyway I can realize this with R? For example, when the Y value for year 18 is forecast, the estimated Y for year 17 is used, not the actual Y for year 17 already in the data. Than

Re: [R] Sum with Conditions

2009-07-23 Thread Daniel Malter
length(datasetname$Events[datasetname$Length<28 & datasetname$Method%in%c(1,2,3) ...additional conditions... , ] returns the number of rows sum(datasetname$Events[datasetname$Length<28 & datasetname$Method%in%c(1,2,3) ...additional conditions... , ] returns the sum of the Events variable

Re: [R] Assigning rank based on total count

2009-07-23 Thread ws
> > Here's a way to get to your solution, but it's not very pretty: > > testdfr <- data.frame(POB=c("Oregon","Oregon","Oregon","New > York","California","California")) > > nstates <- length(unique(testdfr$POB)) > testdfr$ POBR <- c(nstates:1)[table(testdfr$POB)][testdfr$POB] Hmm I will hav

[R] Duplicated date values aren't duplicates

2009-07-23 Thread Tim Clark
Dear list, I just had a function (as.ltraj in Adehabitat) give me the following error: "Error in as.ltraj(xy, id, date = da) : non unique dates for a given burst" I checked my dates and got the following: > dupes<-mydata$DateTime[duplicated(mydata$DateTime)] > dupes [1] (07/30/02 00:00:00) (

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Gabor Grothendieck
You can't remove Y since its in the rhs of your model. On Thu, Jul 23, 2009 at 8:25 PM, Hongwei Dong wrote: > Thanks, Gabor. Here are the problems I'm trying to solve. > FIRST, I run this to simulate a 20 years time series process. The data from > 1-15 years are used to estimate the model, and thi

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Hongwei Dong
Thanks, Gabor. Here are the problems I'm trying to solve. *FIRST*, I run this to simulate a 20 years time series process. The data from 1-15 years are used to estimate the model, and this model is used to predict the year from 16-20. The following script works. set.seed(123) tt <- ts(cbind(Y = 1:2

Re: [R] rows missing after dataset loaded to R

2009-07-23 Thread Gabor Grothendieck
Another situation would be if you have comment characters in strings that are intended to be content. On Thu, Jul 23, 2009 at 5:35 PM, Greg Snow wrote: > Some programs quote everything to be "safe", others only quote when needed.   > The only case that I know of that read.table and friends require

[R] Sum with Conditions

2009-07-23 Thread jimdare
Dear R-Users, I have a huge data set (172,696 rows) that is set out in the following way: Area | Length | Species | Method | Date | Events I want to sum the number of Events if: Length < 28AND Species is NOT "X" ,"Y", or "Z" AND Method is either "1

Re: [R] Navigate to Index page of a package from R command prompt

2009-07-23 Thread Gabor Grothendieck
Try enter at the R console: help.start() and then when the help comes up in your browser click on Packages and then click on the package you want and then click on the help file you want On Thu, Jul 23, 2009 at 3:30 PM, Steven McKinney wrote: > > Hi all, > > Is there a way to navigate directly to

Re: [R] Random # generator accuracy

2009-07-23 Thread Jim Bouldin
Perfectly explained Ted. One might, at first reflection, consider that simply repeating the values 7 through 12 and sampling (w/o replacement) from among the 18 resulting values, would be similar to just doubling the selection probabilities for 7 through 12 and then sampling. That would clearly

[R] Help with Loop!

2009-07-23 Thread Lars Bishop
Dear experts, I'm new in R and trying to learn by writing a version of the Perceptron Algorithm. How can I tell in the code below to stop the iteration when the condition in the "for loop" is not satisfied for all training examples? Thanks in advance for your help! ## Generate a linearly separa

[R] ggplot2 : commands on one line vs two lines.

2009-07-23 Thread John Kane
I have just started using ggplot2 and I seem to be doing something stupid in writing ggplot2 commands on more than one line. In the example below the commands on one line are working fine, but as soon as I put them on two lines I get an error. Can any one point out what I am doing wrong? It must

Re: [R] Random # generator accuracy

2009-07-23 Thread Ted Harding
On 23-Jul-09 22:16:39, Thomas Lumley wrote: > On Thu, 23 Jul 2009 ted.hard...@manchester.ac.uk wrote: > >> The general problem, of sampling without replacement in such a way >> that for each item the probability that it is included in the sample >> is proportional to a pre-assigned weight ("sampli

Re: [R] alternative to rbind within a loop

2009-07-23 Thread Don MacQueen
Another approach that might be worth trying is to create an empty data frame with lots and lots of rows before looping, and then replace rather than append. Of course, this requires knowing at least approximately how many rows total you will have. This suggestion comes from the help page for

Re: [R] Assigning rank based on total count

2009-07-23 Thread Remko Duursma
Here's a way to get to your solution, but it's not very pretty: testdfr <- data.frame(POB=c("Oregon","Oregon","Oregon","New York","California","California")) nstates <- length(unique(testdfr$POB)) testdfr$ POBR <- c(nstates:1)[table(testdfr$POB)][testdfr$POB] greetings, Remko ---

[R] Assigning rank based on total count

2009-07-23 Thread ws
Hi all, I am using ACS micro data (PUMS) with one of the columns as a factor for the place of birth (POBPF). I would like to create a column (POBR) containing a rank corresponding to the place of the observation in the POBPF rankings. For example, if a person is from Oregon, Oregon is the

Re: [R] Calculate weighted mean for each group

2009-07-23 Thread David Freedman
After you fix your data frame and if you don't using 2 packages, you might try something like: lib(plyr) #for 'by' processing lib(Hmisc) # for its wtd.mean function d=data.frame(x=c(15,12,3,10,10),g=c(1,1,2,2,3),w=c(2,1,5,2,5)) ; d ddply(d,~g,function(df) wtd.mean(df$x,df$w)) milton ruser wrot

Re: [R] Random # generator accuracy

2009-07-23 Thread Thomas Lumley
On Thu, 23 Jul 2009 ted.hard...@manchester.ac.uk wrote: The general problem, of sampling without replacement in such a way that for each item the probability that it is included in the sample is proportional to a pre-assigned weight ("sampling with probability proportional to size") is quite tr

Re: [R] Random # generator accuracy

2009-07-23 Thread Ted Harding
Indeed, Jim! And that's why I said to read carefully what is said about "prob" in '?sample': If 'replace' is false, these probabilities are applied sequentially, that is the probability of choosing the next item is proportional to the weights amongst the remaining items. Whereas, if you r

Re: [R] Creating a loop to read 3D dataset

2009-07-23 Thread Greg Snow
Something like this (untested) may work for you: > for (i in 1:132) { + a <- clim[ , , i] + nm <- sprint('clim%03d.txt',i) + write.table(a,nm) + } Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Origi

Re: [R] Calculate weighted mean for each group

2009-07-23 Thread Marc Schwartz
On Jul 23, 2009, at 4:18 PM, Alexis Maluendas wrote: Hi R experts, I need know how calculate a weighted mean by group in a data frame. I have tried with aggragate() function: data.frame(x=c(15,12,3,10,10),g=c(1,1,1,2,2,3,3),w=c(2,3,1,5,5,2,5)) -> d aggregate(d$x,by=list(d$g),weighted.mea

Re: [R] Calculate weighted mean for each group

2009-07-23 Thread Chuck Cleland
On 7/23/2009 5:18 PM, Alexis Maluendas wrote: > Hi R experts, > > I need know how calculate a weighted mean by group in a data frame. I have > tried with aggragate() function: > > data.frame(x=c(15,12,3,10,10),g=c(1,1,1,2,2,3,3),w=c(2,3,1,5,5,2,5)) -> d > aggregate(d$x,by=list(d$g),weighted.mean,

Re: [R] Calculate weighted mean for each group

2009-07-23 Thread milton ruser
try your first "reproducible line" first :-) On Thu, Jul 23, 2009 at 5:18 PM, Alexis Maluendas wrote: > Hi R experts, > > I need know how calculate a weighted mean by group in a data frame. I have > tried with aggragate() function: > > data.frame(x=c(15,12,3,10,10),g=c(1,1,1,2,2,3,3),w=c(2,3,1,

Re: [R] Java to R interface

2009-07-23 Thread peterburzhec
I already posted this on another forum I kept having the same problem. Turns out the issue was - I set my pathwrong. Make sure you have both, the path to R.dll and jri.dll in your path CORRECTLY, and make sure that you don't put any spaces inbetween values in the path. madhura wrote: > > The p

Re: [R] rows missing after dataset loaded to R

2009-07-23 Thread Greg Snow
Some programs quote everything to be "safe", others only quote when needed. The only case that I know of that read.table and friends require quotes for is when a separator is inside of a string, for example if you are using spaces as the separator and have some names with spaces in them (e.g. "

Re: [R] Navigate to Index page of a package from R command prompt

2009-07-23 Thread Steven McKinney
> -Original Message- > From: Marc Schwartz [mailto:marc_schwa...@me.com] > Sent: Thursday, July 23, 2009 2:04 PM > To: Steven McKinney > Cc: R-help@r-project.org > Subject: Re: [R] Navigate to Index page of a package from R command > prompt > > On Jul 23, 2009, at 3:30 PM, Steven McKinney

Re: [R] alternative to rbind within a loop

2009-07-23 Thread Greg Snow
Try something like (untested): > mylist <- lapply(all.files, function(i) read.csv(i) ) > mydf <- do.call('rbind', mylist) If all the csv files are conformable that rbind works on them (if the loop method works then that should be the case) then this will read in each file, store the data frames

Re: [R] Navigate to Index page of a package from R command prompt

2009-07-23 Thread Marc Schwartz
On Jul 23, 2009, at 3:30 PM, Steven McKinney wrote: Hi all, Is there a way to navigate directly to the "Index" page of help for a package? Here's my connundrum: I download and install package "foo". I don't know what functions are in package "foo", so I can't invoke the help for package "foo

[R] Calculate weighted mean for each group

2009-07-23 Thread Alexis Maluendas
Hi R experts, I need know how calculate a weighted mean by group in a data frame. I have tried with aggragate() function: data.frame(x=c(15,12,3,10,10),g=c(1,1,1,2,2,3,3),w=c(2,3,1,5,5,2,5)) -> d aggregate(d$x,by=list(d$g),weighted.mean,w=d$w) Generating the following error: Error en FUN(X[[1L]

Re: [R] Automatic differentiation in R

2009-07-23 Thread Hans W. Borchers
Having given a lecture on "Numerical Derivatives" just a short time ago, I would like to mention the following: Many functions, especially in engineering, are not available as formulas built simply from arithmetical operators and elementary functions. They are provided as intricate procedures, a

Re: [R] Random # generator accuracy

2009-07-23 Thread Jim Bouldin
You are absolutely correct Ted. When no weights are applied it doesn't matter if you sample with or without replacement, because the probability of choosing any particular value is equally distributed among all such. But when they're weighted unequally that's not the case. It is also interestin

Re: [R] mathematical notation in R

2009-07-23 Thread Steven McKinney
Hi Mary, Something such as > plot(1,1) > title(expression(paste("LBAuo = -", infinity))) Is this what you're after? Best Steve McKinney From: Mary A. Marion [mms...@comcast.net] Sent: July 23, 2009 4:23 PM To: Steven McKinney Subject: Re: [R] mathemati

[R] Creating a loop to read 3D dataset

2009-07-23 Thread Andrew Aldersley
Dear all, I have in my possession a netcdf from which I want to extract some data files. I have used the "ncdf" package to read the netcdf file and used the "get.var.ncdf" function to identify the variable i wish to use. The data is in the form of a time-series of geographical data points that

[R] Navigate to Index page of a package from R command prompt

2009-07-23 Thread Steven McKinney
Hi all, Is there a way to navigate directly to the "Index" page of help for a package? Here's my connundrum: I download and install package "foo". I don't know what functions are in package "foo", so I can't invoke the help for package "foo" via > ?someFunction help(package = "foo") pops up so

Re: [R] Help

2009-07-23 Thread Jorge Ivan Velez
Dear Alberto, Try this: Res <- apply( bm[,colnames(bm) %in% d], 1, function(x) sum( as.numeric(x) ) ) cbind(bm, Res) HTH, Jorge On Thu, Jul 23, 2009 at 3:31 PM, Alberto Lora M wrote: > Dear R project group > > I have the following problem > > Let suppose the following data: > > > > b<-c("0",

Re: [R] Random # generator accuracy

2009-07-23 Thread Ted Harding
OOPS! The result of a calculation below somehow got omitted! (325820+326140+325289+325098+325475+325916)/ (174873+175398+174196+174445+173240+174110) # [1] 1.867351 to be compared (as at the end) with the ratio 1.867471 of the expected number of "weight=2" to expected number of "weight=1"

Re: [R] rows missing after dataset loaded to R

2009-07-23 Thread Rnewbie
Thank you very much for the reply. I checked the rows and it was the unbalanced " quote marks in some of the rows that caused the problem. Once I disabled quoting altogether, the problem is solved. I have one more basic question. I disabled quoting when loading the file to R, and all the columns

Re: [R] Question about the lars package

2009-07-23 Thread Steve Lianoglou
Hi, On Jul 22, 2009, at 6:18 PM, lulu9797 wrote: The returned values of lars function include R squares along the variable selection path. Correct. However, such values are always slightly different from the R squares returned by the regression function lm using the same models. Anyone

Re: [R] Help

2009-07-23 Thread Greg Snow
Try: > cbind( bm, res=apply(bm[,d],1 , sum) ) -- 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 Alberto Lora M

[R] alternative to rbind within a loop

2009-07-23 Thread Denis Chabot
Hi, I often have to do this: select a folder (directory) containing a few hundred data files in csv format (up to 1000 files, in fact) open each file, transform some character variables in date-tiime format make into a dataframe (involves getting rid of a few variables I don't need conc

[R] Help

2009-07-23 Thread Alberto Lora M
Dear R project group I have the following problem Let suppose the following data: b<-c("0","1","1","1","0","1","0","0","1","0","1","1","1","0","1","1","0","1","1","0") bm<-matrix(b,ncol=4) colnames(bm)<-c("F1", "F2", "F3", "F4") d<-c("F1","F4") For the matrix bm i need to create a fifth colum

Re: [R] Random # generator accuracy

2009-07-23 Thread Ted Harding
On 23-Jul-09 17:59:56, Jim Bouldin wrote: > Dan Nordlund wrote: > "It would be necessary to see the code for your 'brief test' > before anyone could meaningfully comment on your results. > But your results for a single test could have been a valid > "random" result." > > I've re-created what I did

Re: [R] I might be dumb : a simple question about "foreach"

2009-07-23 Thread Daya Atapattu
This problem is due to a bug in the iterators package. It has been fixed in version 1.0.2 of iterators, which is on CRAN now. - Daya Daya Atapattu Revolution Computing Olivier ETERRADOSSI wrote: Many thanks David for making the connection betweeen the two reports. If I understand, other frenc

Re: [R] Constructing lists (yet, again)

2009-07-23 Thread roger koenker
Marc, Thanks, sapply(ls(pat = "^name"),get) was exactly what I was after. The default behavior for vectors of equal length is nice too, but I was most interested in the ragged case, which produces a list. url:www.econ.uiuc.edu/~rogerRoger Koenker emailrkoen...@uiu

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Gabor Grothendieck
Best thing is to test it out on simulated data for which you already know the answer. library(dyn) set.seed(123) DF <- data.frame(x = rnorm(10), z = rnorm(10)) DF$Y <- 0 for(i in 2:10) { DF$Y[i] <- with(DF, 2*Y[i-1] + 3*z[i] +4* x[i] + 5*x[i-1] + rnorm(1)) } DF.zoo <- do.call(merge, lapply(DF, z

Re: [R] Constructing lists (yet, again)

2009-07-23 Thread Greg Snow
There are a couple of options: The help page for lapply also includes the help for sapply and sapply has a USE.NAMES argument that may do what you want (specify simplify=FALSE to force the same behavior as lapply). You can post specify the names like: > names(mylist) <- vector.of.names Do eit

Re: [R] Constructing lists (yet, again)

2009-07-23 Thread Marc Schwartz
On Jul 23, 2009, at 9:19 AM, roger koenker wrote: This is an attempt to rescue an old R-help question that apparently received no response from the oblivion of collective silence, and besides I'm also curious about the answer From: Griffith Feeney (gfee...@hawaii.edu) Date: Fri 28 Jan 2000

Re: [R] Random # generator accuracy

2009-07-23 Thread Greg Snow
Well one quick way (for non-generics) is the 'args' function: > args(sample) function (x, size, replace = FALSE, prob = NULL) NULL A similar line appears near the top of the help page when you do '?sample'. The "replace = FALSE" in the line above means that false is the default (with the assu

Re: [R] howto create a list row-by-row as input to function call?

2009-07-23 Thread Mark Knecht
On Thu, Jul 23, 2009 at 11:04 AM, Mark Knecht wrote: > Hi, >   I'm having trouble within my function CalcPos to get it to call > CalcHorz with values from each row. I *think* it's calling CalcHorz > with the final values of the inputs and not the values from each row. > How can I do this properly i

[R] Constructing lists (yet, again)

2009-07-23 Thread roger koenker
This is an attempt to rescue an old R-help question that apparently received no response from the oblivion of collective silence, and besides I'm also curious about the answer From: Griffith Feeney (gfee...@hawaii.edu) Date: Fri 28 Jan 2000 - 07:48:45 EST wrote (to R-help) Constructing lis

Re: [R] Split plot analysis problems

2009-07-23 Thread Mark Difford
Hi Jean-Paul, >> However, I've tried both solutions on my model, and I got different >> residuals :... >> What could be the difference between the two? There is no difference. You have made a mistake. ## tt <- data.frame(read.csv(file="tt.csv", sep="")) ## imports your data set T.aov <- aov(PH

Re: [R] setting up LMER for repeated measures and how do I get a p value for my fixed effect, group?

2009-07-23 Thread Kingsford Jones
On Thu, Jul 23, 2009 at 12:36 PM, Kingsford Jones wrote: > > As you might have suspected from the lmer t-value close to 0, the > associated p-value is about .5. you can ignore the sentence above -- it's a two sided test and the t-value is not that close to 0... > > hth, > > Kingsford Jones > >>

Re: [R] Random # generator accuracy

2009-07-23 Thread Jim Bouldin
Thanks Greg, that most definitely was it. So apparently the default is sampling without replacement. Fine, but this brings up a question I've had for a bit now, which is, how do you know what the default settings are for the arguments of any given function? The HTML help files don't seem to ind

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Hongwei Dong
Hi, Gabor, got it. Thanks a lot. I have one more question about how the "predict" function works here, especially for the lag(Y,-1) part. In my model, I assume I know predictors x and z in the next two years, and use them to predict Y. For each forecast step at time t, the lag(Y,-1) in the model s

Re: [R] Elementary Symmetric Polynomials

2009-07-23 Thread davidr
How's this? f2 <- function(v) { n <- length(v) s <- matrix(0,n,n) for(i in 1:n) for(j in 1:i) s[j,i] <- ifelse(i>1, s[j,i-1]+v[i]*ifelse(j>1, s[j-1,i-1], 1), v[i]) c(1,s[,n]) } > system.time(f2.result <- f2(1:20)) user system elapsed 0 0 0 > system.time(f

Re: [R] How to perform a calculation in each element of my list?

2009-07-23 Thread Erik Iverson
Mark, My example is essentially identical to Jorge's. This is a good opportunity to compare two solutions to a problem, one using "for" loops, and one using the apply family of functions. Compare this with Daniel's solution. ## BEGIN EXAMPLE ## sample list of data.frames, different number o

Re: [R] setting up LMER for repeated measures and how do I get a p value for my fixed effect, group?

2009-07-23 Thread Kingsford Jones
On Thu, Jul 23, 2009 at 9:02 AM, John Sorkin wrote: > R 2.8.1 > Windows XP > > I am trying to analyze repeated measures data (the data are listed at the end > of this Email message) and I need help to make sure that I have properly > specified my model, and would like to know why lmer does not re

Re: [R] Random # generator accuracy

2009-07-23 Thread Greg Snow
Try adding replace=TRUE to your call to sample, then you will get numbers closer to what you are expecting. -- 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 [mailt

Re: [R] dimension trouble for a matrix

2009-07-23 Thread Steve Lianoglou
Hi Erin, On Jul 23, 2009, at 2:12 PM, Erin Hodgess wrote: Dear R People: I'm having trouble with something that should be very simple. I'm setting up a matrix outside of a loop and writing items into it during the loop. Here is the output: glob3b("sites.info") dim 27 3 [1] "/raid1/osg-app

Re: [R] How to perform a calculation in each element of my list?

2009-07-23 Thread Daniel Malter
Hi Mark, study the following example. The two simulated dataframes are put in a list called listdata. The loop iterates throught the elements in the list and multiplies the last column "listdata[[i]][,length(listdata[[i]])]" by the column before the last "listdata[[i]][,length(listdata[[i]])-1]". T

Re: [R] How to perform a calculation in each element of my list?

2009-07-23 Thread Jorge Ivan Velez
Dear Mark, Try this: lapply(yourlistofdataframes, function(d){ k <- ncol(d) d$product <- d[,k-1] * d[,k] d } ) HTH, Jorge On Thu, Jul 23, 2009 at 2:05 PM, Mark Na wrote: > Hi R-helpers, > > I have a list

[R] dimension trouble for a matrix

2009-07-23 Thread Erin Hodgess
Dear R People: I'm having trouble with something that should be very simple. I'm setting up a matrix outside of a loop and writing items into it during the loop. Here is the output: > glob3b("sites.info") dim 27 3 [1] "/raid1/osg-app" Error in xy[i, ] : incorrect number of dimensions Here is

[R] How to perform a calculation in each element of my list?

2009-07-23 Thread Mark Na
Hi R-helpers, I have a list containing 10 elements, each of which is a dataframe. I wish to add a new column to each list element (dataframe) containing the product of the last two columns of each dataframe. I'd appreciate any pointers, thanks! Mark Na [[alternative HTML version deleted

[R] howto create a list row-by-row as input to function call?

2009-07-23 Thread Mark Knecht
Hi, I'm having trouble within my function CalcPos to get it to call CalcHorz with values from each row. I *think* it's calling CalcHorz with the final values of the inputs and not the values from each row. How can I do this properly in R? The values aa,bb,cc,dd are inputs. CalcPos first calc

[R] Random # generator accuracy

2009-07-23 Thread Jim Bouldin
Dan Nordlund wrote: "It would be necessary to see the code for your 'brief test' before anyone could meaningfully comment on your results. But your results for a single test could have been a valid "random" result." I've re-created what I did below. The problem appears to be with the weighting

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Gabor Grothendieck
Please provide your code in a reproducible form (as requested previously). Here we fit with first 9 points and then add a point for prediction. (Of course your model can only predict the current value of Y so you may have to rethink your model even aside from the implementation if you really want

[R] How to pass a character argument which contains expressions to arg.names in barplot?

2009-07-23 Thread jcano
Hi all Can anybody help me with this? I am trying to include in an automatic way the argument in arg.names in a barplot. I generate the labels I want to appear below the bars with a for loop, and they contain subscripts, so I need to use expression anch<-0.05 esp<-4 for (i in 1:dim(Ntot)[1

Re: [R] simple question about exporting data...

2009-07-23 Thread John Kane
I vote for it. --- On Thu, 7/23/09, Marc Schwartz wrote: > From: Marc Schwartz > On Jul 23, 2009, at 8:59 AM, Greg Snow wrote: > > > Doing the computations in R then the graphs in Excel > reminds me of the maxim: > > > > Measure with a micrometer > > Mark with chalk > > Cut with an ax > >

Re: [R] error message: .Random.seed is not an integer vector but

2009-07-23 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Jim Bouldin > Sent: Thursday, July 23, 2009 9:49 AM > To: ted.hard...@manchester.ac.uk; ted.hard...@manchester.ac.uk; r-h...@r- > project.org > Subject: Re: [R] error message: .Ran

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Hongwei Dong
Hi, Gabor and Other R users, I'm re-posting my script and the results I got. here is the dynamic model I used to estimate in-sample model (1996-2006) and it works: fit<-dyn$lm(Y~lag(Y,-1)+z+x+lag(x,-1)+lag(x,-2)+lag(x,-3)+lag(x,-4)) Then I used this model to do out sample forecast with t

[R] How to get w in SVR with e1071 package

2009-07-23 Thread marlene marchena
> > Hi all, > > I need some help about how to calculate w in a SVR in package e1071. > > I have a regression y_i=f(x_i)+e > > where f(*x*)=(w,phi(x))+b > > then go on with the SVR calculation I know that w*=Sum_i=1^n [(á_i - > á*_i)K(x,x_i) ] where á_i and á*_i are the lagrangian multipliers of the

Re: [R] error message: .Random.seed is not an integer vector but

2009-07-23 Thread Jim Bouldin
Thanks much Ted. I actually had just tried what you suggest here before you posted, and resolved the problem. Thanks also for the other tips. I wrote x = as.vector(c(1:12)) because I thought that the mode of x might be the problem, the error message pointing to .Random.seed notwithstanding. On

Re: [R] help with randomisation test...

2009-07-23 Thread Greg Snow
I am not sure that I fully understand what all you want to do (and I don't understand why you need the correlation and if a correlation based on 3 pairs is even meaningful), but here is a first stab at what you are trying to do: tmp <- "Species Control_CR Damage_DR A 10 2 A 9 3 A 7 4 A 9 2 A 8 3

[R] using k-means clustering in conjunction with heatmap.2 function

2009-07-23 Thread Suzanne Matthews
Hello, I am trying to create a heatmap that clusters based on a k-means scheme rather than a hierarchical clustering scheme. Suppose I have the following input data, located in sample.table: x1 x2 x3 x4 x1 17.198 16.306 16.806 16.374 x2 14.554 10.866 15.780 14.596 x3 14.374 14.118 14.569 17.352 x

Re: [R] read.csv greater than

2009-07-23 Thread stephen sefick
here is the solution x <- subset(read.csv("foo.csv"), VALUE>0) On Thu, Jul 23, 2009 at 11:28 AM, stephen sefick wrote: > I have a csv file that I am trying to read in and know that values <0 > are erroneous - is there a way to read only value grater than 0. > > thanks, > > -- > Stephen Sefick > >

[R] read.csv greater than

2009-07-23 Thread stephen sefick
I have a csv file that I am trying to read in and know that values <0 are erroneous - is there a way to read only value grater than 0. thanks, -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us

Re: [R] error message: .Random.seed is not an integer vector but

2009-07-23 Thread Ted Harding
On 23-Jul-09 16:08:17, Jim Bouldin wrote: >> Jim Bouldin wrote: >> > Thank you. However, when I tried that, I got this message: >> >> > Warning message: >> > In rm(.Random.seed) : variable ".Random.seed" was not found >> >> In that case, have you attached some package that has its own >> .Random

Re: [R] error message: .Random.seed is not an integer vector but

2009-07-23 Thread Ted Harding
On 23-Jul-09 15:30:05, Jim Bouldin wrote: > I'm trying to run this simple random sample procedure and keep > getting the error message shown. I don't understand this; I've > Thanks. > >> x = as.vector(c(1:12));x > [1] 1 2 3 4 5 6 7 8 9 10 11 12 >> mode(x) > [1] "numeric" >> sample(x, 3)

Re: [R] error message: .Random.seed is not an integer vector but of type 'list'

2009-07-23 Thread Jim Bouldin
> > > Jim Bouldin wrote: > > Thank you. However, when I tried that, I got this message: > > > > Warning message: > > In rm(.Random.seed) : variable ".Random.seed" was not found > > > In that case, have you attached some package that has its own > .Random.seed? > Try to find where the current

  1   2   >