Re: [R] How to apply a function to every element of a dataframe, when the function uses for each colummn and row different values to calculate with?

2013-08-20 Thread peter dalgaard
On Aug 21, 2013, at 00:01 , David Winsemius wrote: > > fmat <- (abs(x - E) )^2/E > > (I'm not sure why that abs is in the `chisq.test` code.) A bit of a misquote there; chisq.test has STATISTIC <- sum((abs(x - E) - YATES)^2/E) The abs() ensures that the Yates correction is towar

Re: [R] italic(mu)

2013-08-20 Thread Pascal Oettli
Hello, You may find hints in the following thread: https://stat.ethz.ch/pipermail/r-help/2011-June/281493.html Regards, Pascal 2013/8/21 Beaulieu, Jake > Hi, > > I would like to include the greek letter mu, in italics, in an axis title. > The following gets close, but the mu isn't italiciz

Re: [R] ave function

2013-08-20 Thread arun
HI, I guess your original dataset would have some list elements as empty. Clean<- structure(list(GRADE = c(1, 2, 3, 1.5, 1.75, 2, 0.5, 2, 3.5, 3.5, 3.75, 4), TERM = c(9L, 9L, 9L, 8L, 8L, 8L, 9L, 9L, 9L, 8L, 8L, 8L), INST_NUM = c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L)), .Names = c("GR

Re: [R] alignment problem for italicised legend text in pdf output from a barplot

2013-08-20 Thread David Winsemius
On Aug 20, 2013, at 2:28 PM, Nixon, John wrote: > A minimal R source code file producing this is: > > data=c(1,2) > pdf(file="error.pdf") > barplot(data) > legend(1.5,c(expression(italic("C.sativa"),italic("B.rapa"))),horiz=TRUE) > dev.off() > > The problem is that the two italicised strings ar

[R] alignment problem for italicised legend text in pdf output from a barplot

2013-08-20 Thread Nixon, John
A minimal R source code file producing this is: data=c(1,2) pdf(file="error.pdf") barplot(data) legend(1.5,c(expression(italic("C.sativa"),italic("B.rapa"))),horiz=TRUE) dev.off() The problem is that the two italicised strings are not aligned in the pdf output, with the string on the left being

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Bert Gunter
Rolf: Thanks for this. It nicely illustrates what to me is a fundamental problem: For many scientists, it is not math ("stats") that is the stumbling block, but rather the failure to understand how variability ("noise") affects the experimental/observational process. One does tend to get more phi

Re: [R] ave function

2013-08-20 Thread Robert Lynch
I tried > lapply(split(Clean,list(Clean$TERM,Clean$INST_NUM)),function(x) shapiro.test(x$GRADE)) and I got >Error in shapiro.test(x$GRADE.) : sample size must be between 3 and 5000 I also tried with(Clean, aggregate(GRADE,list(TERM,INST_NUM),FUN=shapiro.test)) and got Group.1 Group.2 x

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Rolf Turner
On 21/08/13 11:23, Ye Lin wrote: > T > hanks for your insights Rolf! The model I want to fit is y=x/a+x with > no intercept, so I transformed it to 1/y=1+a/x as they are the same. For crying out loud, they are ***NOT*** the same. The equations y = x/(a+x) and 1/y = 1 + a/x are indeed algebraica

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Ye Lin
T hanks for your insights Rolf! The model I want to fit is y=x/a+x with no intercept, so I transformed it to 1/y=1+a/x as they are the same. but i will look up nls() and see how to fit the model without transformation. On Tue, Aug 20, 2013 at 2:45 PM, Rolf Turner wrote: > > (1) It is not accept

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Rolf Turner
(1) It is not acceptable to use "wanna" in written English. You should say "I want to fit a model ". (2) The model you have fitted is *not* equivalent to the model you first state. If you write "y ~ x/(a+x)" you are tacitly implying that y = x/(a+x) + E where the "errors" E ar

Re: [R] italic(mu)

2013-08-20 Thread David Winsemius
On Aug 20, 2013, at 12:06 PM, Beaulieu, Jake wrote: > Hi, > > I would like to include the greek letter mu, in italics, in an axis title. > The following gets close, but the mu isn't italicized. > > x <- 1:10 > y <- 1:10 > plot(y ~x, ylab = expression(paste('Greek ', italic(mu > The Symb

Re: [R] How to apply a function to every element of a dataframe, when the function uses for each colummn and row different values to calculate with?

2013-08-20 Thread David Winsemius
PLEASE do not crosspost to Rhelp and googlegroups. (removed that address.) On Aug 20, 2013, at 9:43 AM, Jacqueline Oehri wrote: > Dear R users > > > I have a question concerning applying a function to each element of a > dataframe: > > > 1) > --> I have a dataframe like this: "d": > (column

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread David Carlson
?curve set.seed(42) x <- 1:15 y <- x/(1+x)+rnorm(15, 0, .02) plot(y~x) lm.out <- lm((1/y-1)~I(1/x)+0) curve(x/(coef(lm.out)+x), 1, 15, add=TRUE) - David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77840-4352 -Orig

[R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Ye Lin
Hey All, I wanna to fit a model y~x/(a+x) to my data, here is the code I use now: lm((1/y-1)~I(1/x)+0, data=b) and it will return the coefficient which is value of a however, if I use the code above, I am not able to draw a curve the presents this equation. How can I do this? Thanks for your

[R] Problems about nonparametric regression with multivariate dependent variables

2013-08-20 Thread Ying Zheng
My problem is to evaluate several conditional moments nonparametrically. That is to evaluate E(y|x=x_0) and Var(y|x=x_0) with y a 2x1 variable. I have tried several commands in "np" package, like "npregbw". I cannot find a command that can apply to the case with multivariate dependent variables,

Re: [R] How to apply a function to every element of a dataframe, when the function uses for each colummn and row different values to calculate with?

2013-08-20 Thread Wuming Gong
Hi Jacqueline, (1) x <- as.matrix(d[rownames(d) != 'nc', colnames(d) != 'nr']) nc <- d['nc', ] nr <- d[, 'nr'] e <- (x - nc %o% nr)^2 / (nc %o% nr / 2) (2) if I understand correctly, ?max.col is what you need. Wuming On Tue, Aug 20, 2013 at 11:43 AM, Jacqueline Oehri < jacqueline.oe...@gmai

Re: [R] rcode problem

2013-08-20 Thread arun
HI, nuru<- read.table("NS.diet.txt",header=TRUE,stringsAsFactors=FALSE,sep="\t",fill=TRUE,check.names=FALSE) colnames(nuru) # [1] "Species"   "Fish ID"   "Date"  #[4] "Time"  "Depth (m)" "Haul.No."  #[7] "Longitude

Re: [R] Weighted SUR/NSUR

2013-08-20 Thread Arne Henningsen
Dear Ariel Thank you for your detailed explanations and the example. Indeed, it should be rather straightforward to implement observation-specific weights in systemfit (i.e. in the estimation of systems of linear or non-linear equations). As you indicated that many people are looking for this feat

[R] Generating random values from zero inflated negative binomial distribution with rZINBI {gamlss.dist}

2013-08-20 Thread flavie.vial
Good afternoon, I have two years of count data (daily time-series data). My Y variable can be modeled using a ZINB model with "day of the week" and "month" effects (both x variables retained in the logistic and negative binomial part of the model). Now I would like to simulate 100 years of coun

[R] rcode problem

2013-08-20 Thread Garkuwa, Nuru Adamu
Hi, Please find attached rcode and my data.There seems to be a problem in the following rcodes: plot(diet~class.f, data=nuru) points(pred.mod1~midpoints,type="b") please I need your help. Kind Regards, Nuru Species Fish ID DateTimeDepth (m) Haul.No.Longitude

Re: [R] Interpreting lmp() results

2013-08-20 Thread Ann Marie Reinhold
Thanks, Bert. Perhaps it would serve me to be more direct and concise. Why am I unable to replicate lm() results using lmp() when the documentation indicates that the results should be the same when perm="", seqs=TRUE, center=FALSE? Some of the estimates are different. In addition, the standard

[R] italic(mu)

2013-08-20 Thread Beaulieu, Jake
Hi, I would like to include the greek letter mu, in italics, in an axis title. The following gets close, but the mu isn't italicized. x <- 1:10 y <- 1:10 plot(y ~x, ylab = expression(paste('Greek ', italic(mu Anybody know how to accomplish this? Thanks, Jake =

[R] multiple core

2013-08-20 Thread Andrea Lamont
Hello: I have somewhat of a generic question. How do you use multiple CPU/core processors in R? For those familiar with Mplus software, I'm looking for something analogous to PROCESSORS command in Mplus to speed up processing. I searched previous helps/googled it and see that there is a multico

Re: [R] R code queries

2013-08-20 Thread Richard M. Heiberger
You have been trapped by attempting to use double quotes inside double quotes. Use single quotes on the inside “etsz <- ets(zz,model='ZZZ')" Please send only minimal data to the list. dput(head(mydata)) is the preferred format. That way a reader of this list can pick it up from the email and d

Re: [R] Confidence Intervals for survreg (survival)

2013-08-20 Thread David Winsemius
On Aug 20, 2013, at 7:04 AM, Luis Antunes wrote: > Hello, > I am fitting a weibull regression model to a survival data set, using survreg > from the survival package.I would like to obtain the confidence interval for > the regression coefficients estimates, but I not seeing how.Can anyone help

Re: [R] SEM polychoric lavaan

2013-08-20 Thread yrosseel
On 08/12/2013 05:55 PM, Pablo Menese Camargo wrote: fitcfa <- cfa(mcfa, data = data_analisis) summary(fitcfa, standardized = TRUE, fit.measure=TRUE) standardizedSolution(fitcfa, type = "std.all") anyone know what y should do to apply polychoric? See the manual: http://lavaan.ugent.be/tutoria

Re: [R] function on columns of two arrays

2013-08-20 Thread Folkes, Michael
That's much more fair I failed to note that extra line of work. Good to know looping can be avoided. Thanks! -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: August 20, 2013 11:11 AM To: Folkes, Michael Cc: R help Subject: Re: function on columns of two arrays Hi Mich

Re: [R] function on columns of two arrays

2013-08-20 Thread arun
Hi Michael, I run it on my system after deleting one of the lines from method1 (as it was not necessary) method1 <- function(){   a1<- data.frame(a)   b1<- data.frame(b)   lapply(seq_len(ncol(a1)),function(i) summary(lm(b1[,i]~a1[,i]))$coef) } linRegFun<- function(x,y){  res<- summary(lm(y~x))$

Re: [R] R code queries

2013-08-20 Thread Rui Barradas
Hello, Address your questions to R-Help, please: r-help@r-project.org I don't use VBA, so I can't help you with what you need. Does your code run in R? As a first line of code, you should have written library(forecast) rest of answer inline. Em 20-08-2013 17:10, siddhartha.ged...@eclerx.co

Re: [R] function on columns of two arrays

2013-08-20 Thread Folkes, Michael
Here's a tiny summary of the speed results using different methods to run lm on common columns from two arrays. Sadly looping is fastest. I don't know if any are sensitive to array dimensions (more columns, fewer layers etc). I invite correction, or suggestions for improvement to avoid looping. Goi

Re: [R] R HELP! How to create a matrix consisting of several matrices in R?

2013-08-20 Thread arun
Hi, May be this helps:  A<- matrix(list(),3,3)  A[[1]]<- matrix(1,4,4)  A[[2]]<- matrix(1:15,3,5)  A[[3]]<- matrix(1:10,5,2) --- str(A) #List of 9 # $ : num [1:4, 1:4] 1 1 1 1 1 1 1 1 1 1 ... # $ : int [1:3, 1:5] 1 2 3 4 5 6 7 8 9 10 ... # $ : int [1:5, 1:2] 1 2 3 4 5 6 7

[R] How to apply a function to every element of a dataframe, when the function uses for each colummn and row different values to calculate with?

2013-08-20 Thread Jacqueline Oehri
Dear R users I have a question concerning applying a function to each element of a dataframe: 1) --> I have a dataframe like this: "d": (columnames: names of Landcovertypes, rownames: coordinates, nr: rowsums, nc:colummnsums) (look at the end of the mail for the structure of d, dput(d) ) here,

Re: [R] Change number of rows in console

2013-08-20 Thread John Kane
Really a question for RStudio support and I don't know if this is still true http://support.rstudio.org/help/discussions/questions/724-console-line-limit but I'd also suggest just using sink() and viewing the results in a text editor or word processor. John Kane Kingston ON Canada > -Orig

Re: [R] function on columns of two arrays

2013-08-20 Thread Folkes, Michael
I know have multiple ways to skin the metaphorical cat. Thanks to Jason and A.K. Michael -Original Message- From: Law, Jason [mailto:jason@portlandoregon.gov] Sent: August 20, 2013 9:54 AM To: Folkes, Michael Cc: R help Subject: RE: function on columns of two arrays library(abind) l

Re: [R] function on columns of two arrays

2013-08-20 Thread Folkes, Michael
Well that was frightfully simple. It's true that if data structure allows it seems best to flatten the data, yes? Thanks to A.K. Michael -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: August 20, 2013 4:43 AM To: Folkes, Michael Cc: R help Subject: Re: [R] function o

Re: [R] function on columns of two arrays

2013-08-20 Thread Law, Jason
library(abind) library(plyr) c <- abind(a,b, along = 4) results <- alply(c, c(2,3), function(x) lm(x[,2] ~ x[,1])) ldply(results, function(x) summary(x)$coef) Jason Law Statistician City of Portland Bureau of Environmental Services Water Pollution Control Laboratory 6543 N Burlington Avenue Portl

Re: [R] lasso cross-validation

2013-08-20 Thread Adams, Jean
Samuel, Typically when someone specifies 10-fold cross validation, it implies that a single series of 10 validations are run. No repeats. You can read more about cross-validation here ... http://en.wikipedia.org/wiki/Cross-validation_(statistics)#K-fold_cross-validation . Jean On Mon, Aug 19,

Re: [R] igraph vertex.label.font sans serif

2013-08-20 Thread Witold E Wolski
recall. it's: vertex.label.family sorry On 20 August 2013 17:30, Witold E Wolski wrote: > Would like to plot vertex labels without serif. > there is vertex.label.font param but he lets me choose only between > one font type in normal bold and emph. > > any suggestions welcome. > > > -- > Witold

[R] igraph vertex.label.font sans serif

2013-08-20 Thread Witold E Wolski
Would like to plot vertex labels without serif. there is vertex.label.font param but he lets me choose only between one font type in normal bold and emph. any suggestions welcome. -- Witold Eryk Wolski __ R-help@r-project.org mailing list https://sta

Re: [R] using functions from other packages in own package

2013-08-20 Thread Prof Brian Ripley
On 20/08/2013 15:51, Jannis wrote: Dear R community, I am creating my own package which uses functions from other packages. After reading several books/help pages I now would do the following to safely use some functions from other packages: 1. list them in Imports: (DESCRIPTION file) 2. put im

[R] using functions from other packages in own package

2013-08-20 Thread Jannis
Dear R community, I am creating my own package which uses functions from other packages. After reading several books/help pages I now would do the following to safely use some functions from other packages: 1. list them in Imports: (DESCRIPTION file) 2. put importFrom(packagename, functionnam

[R] The easi Package - incorporating panel data?

2013-08-20 Thread n.g.chalmers
Hi, Does anybody know how to incorporate panel data into Hoareau et al "*easi*" Package? In Hoareau et al "easi" Package they use cross sectional data and I would like to know how I could include 5 years worth of panel data? Many thanks, Neil -- View this message in context: http://r.78969

[R] Confidence Intervals for survreg (survival)

2013-08-20 Thread Luis Antunes
Hello, I am fitting a weibull regression model to a survival data set, using survreg from the survival package.I would like to obtain the confidence interval for the regression coefficients estimates, but I not seeing how.Can anyone help me? Thanks,Luis

Re: [R] Change number of rows in console

2013-08-20 Thread Jeff Newmiller
Then you are asking your question in the wrong forum. RStudio has their own support website. Please read the Posting Guide and list topic info before posting again. Many people also find [1] helpful in getting of on the right foot here. [1] http://stackoverflow.com/questions/5963269/how-to-mak

Re: [R] Change number of rows in console

2013-08-20 Thread Berend Hasselman
On 20-08-2013, at 13:40, TMiller wrote: > I am sorry for the confusing message. I am using R-Studio. In the picture you > see a print screen, I mean the console at the bottom left. I am using Mac OS > X. If anyone could help me, I'd really appreciate it. > Many thanks > Tom 1. Picture on nabble

Re: [R] Appropriateness of R functions for multicore

2013-08-20 Thread Hadley Wickham
> For tasks which don't involve I/O but fail with mclapply, how does one > work out where the problem is? The handy browser() function which > allows for interactive diagnosis won't work with parallel jobs. > > What other approaches can one use? ?dump.frames - interactive debugging after the fac

Re: [R] function on columns of two arrays

2013-08-20 Thread arun
Also, if you need ?mapply() linRegFun<- function(x,y){  res<- summary(lm(y~x))$coef}  res1<-sapply(seq_len(ncol(a1)),function(i) summary(lm(b1[,i]~a1[,i]))$coef)  res2<-mapply(linRegFun,a1,b1) attr(res2,"dimnames")<-NULL identical(res1,res2) #[1] TRUE A.K. - Original Message - From: aru

Re: [R] function on columns of two arrays

2013-08-20 Thread arun
Hi, May be this helps.   a1<- data.frame(a)  b1<- data.frame(b)  lapply(seq_len(ncol(a1)),function(i) lm(b1[,i]~a1[,i]))  lapply(seq_len(ncol(a1)),function(i) summary(lm(b1[,i]~a1[,i]))$coef) A.K. - Original Message - From: "Folkes, Michael" To: r-help@r-project.org Cc: Sent: Tuesday,

Re: [R] Change number of rows in console

2013-08-20 Thread TMiller
I am sorry for the confusing message. I am using R-Studio. In the picture you see a print screen, I mean the console at the bottom left. I am using Mac OS X. If anyone could help me, I'd really appreciate it. Many thanks Tom

[R] Problems installing FAME package on Windows 7.

2013-08-20 Thread Andreas Dibiasi
I have problems to install the FAME package. I have installed the fame client 9.3.32.2 and the environmental variable is set. However, for some reason, the warnings "error: argument "lib.loc" > is missing, with no default" pops up under the i386 installation and "LoadLibrary failure: %1 is not a v

[R] Visualising SOM as hexagonal heatmaps

2013-08-20 Thread Adam Szałucha
I have a kohonen object generated with grid parameters grid = somgrid(20, 20, "hexagonal"). Standard plot shows the codebook vectors for all variables. I want to have a hexagonal heatmap for each variable. I found in Applied Spatial Data Analysis with R code to generate hexagonal grid. library("s

Re: [R] Change number of rows in console

2013-08-20 Thread Prof Brian Ripley
On 20/08/2013 09:58, TMiller wrote: Hello This is probably a really basic question, still I couldn't find an answer in the web. I am running more than 200 regressions, but I can only see about 40 in the console display. Is there any possibility to change the number of rows which are displayed in

[R] Change number of rows in console

2013-08-20 Thread TMiller
Hello This is probably a really basic question, still I couldn't find an answer in the web. I am running more than 200 regressions, but I can only see about 40 in the console display. Is there any possibility to change the number of rows which are displayed in the console? Many thanks already in a

Re: [R] Interpreting lmp() results

2013-08-20 Thread Bert Gunter
I suggest you post (a shortened version of?) your tome to the r-sig-ecology list instead. Cheers, Bert On Mon, Aug 19, 2013 at 3:47 PM, Ann Marie Reinhold wrote: > I am running permutation regressions in package lmPerm using lmp(). I > am getting what I find to be confusing results and I would

[R] function on columns of two arrays

2013-08-20 Thread Folkes, Michael
I've spent a bit too long searching the help history and attempting to apply some logic to the following: I have two 3D arrays each with same dim. I wish to run lm on the respective columns of each array, preferably without loops. We often hear chatter that sometimes apply() won't be faster "just