Re: [R] how to use a column name from the data frame in the function

2013-08-22 Thread Steve Lianoglou
Hi, On Thu, Aug 22, 2013 at 9:49 PM, Jeff Newmiller wrote: > Please don't post in HTML format... it messes with code examples. > > Use character indexing (please read the Introduction to R... again if > necessary). > > myf <- function(df, colname){ > df[ ,colname ] > } Or df[[colname]] for da

[R] How to view the source of code?

2013-08-22 Thread Marino David
Hi all R mailing listers: I am using the coda package. I tried to view the source of HPDinterval code by typing fix(HPDinterval), it dispalys as follows: function (obj, prob = 0.95, ...) UseMethod("HPDinterval") Then I search the answers about this case (see below), it still failed. Thank you in

Re: [R] how to use a column name from the data frame in the function

2013-08-22 Thread Jeff Newmiller
Please don't post in HTML format... it messes with code examples. Use character indexing (please read the Introduction to R... again if necessary). myf <- function(df, colname){ df[ ,colname ] } colname <- "a" myf(m,colname) Until you learn simple R syntax, I strongly recommend avoiding wri

[R] how to use a column name from the data frame in the function

2013-08-22 Thread song song
m=as.data.frame(outer(1:5,6:9)) colnames(m)=c('a','b','c','d') tf=function(df, col){list(mean(eval(substitute(col),df,parent.frame())),col )} tf(m,a) will issue error: Error in tf(m, a) : object 'a' not found How can I replace the col as char 'a' in the function? Thank you [[alternat

[R] how to use a column name from the data frame in the function

2013-08-22 Thread song song
for example I have data frame m as below: m=as.data.frame(outer(1:5,6:9)) colnames(m)=c('a','b','c','d') and I define the function myf=function(df, colname){ suppose colname is a, then: how can I get the column 'a' and how to get the colname as a string, 'a' } Thank you! [[a

[R] ANOVA nested model with random and fixed effects

2013-08-22 Thread Belyaeva Anna
Hello, I am confused with the design of experiment and I need your help. I study macroinvertebrates from 40 lakes. Each lake was sampled employing stratified random technique. Each lakes was divided into 3 different lake zones based on light penetration: near-shore area, transitional, and the d

[R] A couple of questions regarding the survival:::cch function

2013-08-22 Thread Ryung Kim
Dear all, I have a couple of questions regarding the survival:::cch function. 1) I notice that Prentice and Self-Prentice functions are giving identical standard errors (not by chance but by programming design) while their beta estimates are different. My guess is they are both using the

Re: [R] cross-sectional analysis of a financial time series

2013-08-22 Thread Brijesh Gulati
Hello Joshua: First of all, I thank you for the solution. The solution is quite elegant and concise. I have one follow-up question/comments. Everything seems ok but the problem comes if the last month stops somewhere in the middle of the month. For instance, if I run the data as of yesterda

[R] A couple of questions regarding the survival:::cch function

2013-08-22 Thread Ryung Kim
Dear all, I have a couple of questions regarding the survival:::cch function. 1) I notice that Prentice and Self-Prentice functions are giving identical standard errors (not by chance but by programming design) while their estimates are different. My guess is they are both using the stan

Re: [R] Error: cannot allocate vector of size 18.4 Gb (NbClust)

2013-08-22 Thread Ben Harrison
On 22/08/13 21:57, Michael Weylandt wrote: On Aug 22, 2013, at 7:39, Ben Harrison wrote: No idea about the problem specifics but what are your OS and version of R? You might be limited there. I have 64-bit Ubuntu 12.04, R version 3.0.1. More likely, however, is that your problem is j

Re: [R] graph related question

2013-08-22 Thread David Winsemius
On Aug 22, 2013, at 4:17 PM, Jim Lemon wrote: > On 08/23/2013 04:32 AM, Jie wrote: >> Dear All, >> >> I would like to draw a graph to illustrate the mapping between two vectors. >> For instance, >> a = c(2, 8, 5) ; mapped.a = c(8, 2, 5) >> >> I would like to get some picture as >> http://www.fl

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

2013-08-22 Thread Rolf Turner
I tried your suggestion on the toy example that was posted by David Carlson a while back: set.seed(42) x <- 1:15 y <- x/(1+x) + rnorm(15,0,0.02) I found that I had to: (a) Wrap the "1/x" inside "I()". (b) Set the offset term to be rep(1,length(x)). Bottom line: fit <- glm(y ~ 0+I(1/

Re: [R] data import: strange experience

2013-08-22 Thread jwd
On Wed, 21 Aug 2013 10:35:53 -0400 SH wrote: It looks like your problem has already been answered, however, as a rule of thumb anytime you see a peculiarity like this you should look for minor variations between what you expected to export and what Excel really exported as delimited text. Occasi

Re: [R] graph related question

2013-08-22 Thread Jim Lemon
On 08/23/2013 04:32 AM, Jie wrote: Dear All, I would like to draw a graph to illustrate the mapping between two vectors. For instance, a = c(2, 8, 5) ; mapped.a = c(8, 2, 5) I would like to get some picture as http://www.flickr.com/photos/96546690@N02/9569526581/ Basically, plot all points of

[R] Rcmdr version 2.0-0 now on CRAN

2013-08-22 Thread John Fox
Dear R-help list members, Version 2.0-0 of the Rcmdr package is now on CRAN and should appear presently on the various CRAN mirrors. As its number implies, this version represents a milestone in the development of the package, which first appeared on CRAN more than 10 years ago. The transition to

Re: [R] download.file error - corrupt: Can't read SAT; charset=binary'

2013-08-22 Thread Uwe Ligges
On 22.08.2013 19:52, Tal Galili wrote: Dear Uwe, Here is the updated code and error massage I get: exe_URL = 'http://pandoc.googlecode.com/files/pandoc-1.11.1.msi' exe_filename <- file.path(tempdir(), basename(exe_URL)) download.file(exe_URL, destfile = exe_filename, mode = "wb", method= "int

Re: [R] lattice: bwplot: getting two plots into one.

2013-08-22 Thread Richard M. Heiberger
The factor gm has nine levels, therefore you need to use a pch vector with 9 values (duplicates are ok). Therefore this will work. bwplot(var1 ~ gm, data=mydata, col="black", pch=rep(1:3,3), ##par.settings=list(box.dot=list(pch=1:3)), panel=panel.bwplot.intermediate.hh,

Re: [R] Quanteg problem in R

2013-08-22 Thread David Winsemius
On Aug 22, 2013, at 9:23 AM, Garkuwa, Nuru Adamu wrote: > I used the codes below trying to fit a model at .95 c.i. of size relationship > but it fails. > > library(quantreg) > range(len$length) # [1] 28 98 > range(len$preyl) > x<-rq(len$preyl~len$length,tau=0.95) > plot(x, type="b", xlab="le

Re: [R] R.oo in R-3.0.1

2013-08-22 Thread Grach, Alexander
Dear Henrik, Thanks for getting back to me. Apologies - have resolved the problem myself. The package in question has quite a bit of legacy code written by others and as it appeared had explicit library() calls inside the source code on the top level. After removing those calls things started w

[R] varpart

2013-08-22 Thread Sibylle Stöckli
Dear R-users I applied vegan's varpart function to partition the effects of explanatory matrices. Adj. R square for the unique fraction [a] is 0.25. Does anyone know why the decomposition by hand using rda gives me a different result for [a] (constrained proportion is 0.32)? I used cbind()

[R] Rexcel macro query

2013-08-22 Thread Geddam Siddharth
*Issue:* Usage of ETS R codes through RExcel macros in VBA Given below is my command code: Rinterface.runrcodefromrange Range(“Sheet1!B2:D8”) Following are the codes written in the given cell reference: #!rput zz 'Sheet1'!$B$2:$B$22 library(forecast) zz <- ts(zz,freq=365,start=c(20

[R] labcurve - use of putKey function

2013-08-22 Thread Igor Ribeiro
Dear all, I have a plot with two lines and I'm using labcurbe (package Hmisc) to show the legend. Everything works well, except that the line displayed in legend box should have same style (plotting character) as the line in the plot. This is achieved by pch parameter and looks like that it's only

Re: [R] download.file error - corrupt: Can't read SAT; charset=binary'

2013-08-22 Thread Henrik Bengtsson
On Thu, Aug 22, 2013 at 12:23 PM, Tal Galili wrote: > Quick update - I think most of the problem is resolved. > After more checks (following Uwe comments): > 1) I see that the installer file runs properly when I set "mode='wb'", and > fails when "mode='w'" (so that solves why some of the time the

Re: [R] graph related question

2013-08-22 Thread David Carlson
It is not hard to create a basic function for that purpose: map.vec <- function(x, y) { dfa <- data.frame(a=x, x0=rep(1, length(x)), y0=length(x):1) dfamap <- data.frame(a=y, x1=rep(2, length(y)), y1=length(y):1) vec <- merge(dfa, dfamap, by=1) plot

Re: [R] R.oo in R-3.0.1

2013-08-22 Thread Henrik Bengtsson
Hi, R.oo author here: This looks like a possible namespace issues, which might have gone under the radar if you have only used R v2.11.x until now. Could you forward me your MyPackage test package so I can troubleshoot/reproduce (I think the answer is in your DESCRIPTION/NAMESPACE file). /Henrik

Re: [R] download.file error - corrupt: Can't read SAT; charset=binary'

2013-08-22 Thread Tal Galili
Quick update - I think most of the problem is resolved. After more checks (following Uwe comments): 1) I see that the installer file runs properly when I set "mode='wb'", and fails when "mode='w'" (so that solves why some of the time the installer didn't run) 2) I still get the error massage mentio

[R] Quanteg problem in R

2013-08-22 Thread Garkuwa, Nuru Adamu
I used the codes below trying to fit a model at .95 c.i. of size relationship but it fails. library(quantreg) range(len$length) range(len$preyl) x<-rq(len$preyl~len$length,tau=0.95) plot(x, type="b", xlab="length (cm)",ylab="preyl (cm)",ylim=c(5,35), xlim=c(10,100), data=len) Cheers, Nuru

[R] Close with a ggplot chart but need a little assistance

2013-08-22 Thread Walter Anderson
I have the following code and data data.csv "","Goal","Frequency","Weight","Group" "1","Move",13,0.245283018867925,"Public" "2","Create",10,0.188679245283019,"Public" "3","Strengthen",30,0.566037735849057,"Public" "4","Move",6,0.6,"Board" "5","Create",0,0,"Board" "6","Strengthen",4,0.4,"Board" "

[R] graph related question

2013-08-22 Thread Jie
Dear All, I would like to draw a graph to illustrate the mapping between two vectors. For instance, a = c(2, 8, 5) ; mapped.a = c(8, 2, 5) I would like to get some picture as http://www.flickr.com/photos/96546690@N02/9569526581/ Basically, plot all points of a in a vertical line, and mapped.a in

Re: [R] corrgram (package corrgram): how to plot multiple correlograms in the same page?

2013-08-22 Thread Kevin Wright
When you are using a package from CRAN, you should probably contact the author of the package (in this case, that is me) with questions, instead of asking on R-help. The corrgram package DOES use base graphics. For instance, when using 3 variables, each one of the squares of the corrgram is using

Re: [R] download.file error - corrupt: Can't read SAT; charset=binary'

2013-08-22 Thread Tal Galili
Dear Uwe, Here is the updated code and error massage I get: exe_URL = 'http://pandoc.googlecode.com/files/pandoc-1.11.1.msi' exe_filename <- file.path(tempdir(), basename(exe_URL)) download.file(exe_URL, destfile = exe_filename, mode = "wb", method= "internal") # ### Error massage: tr

Re: [R] Rexcel

2013-08-22 Thread Erich Neuwirth
Free support for RExcel is available by subscribing to the mailing list at rcom.univie.ac.at and posting questions to the list. On Aug 22, 2013, at 7:04 PM, Jeff Newmiller wrote: > This is not on topic for this mailing list. See the Statconn website for > support for RExcel. __

Re: [R] Rexcel

2013-08-22 Thread Jeff Newmiller
This is not on topic for this mailing list. See the Statconn website for support for RExcel. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go...

Re: [R] converting a summary table to survey database form

2013-08-22 Thread arun
Hi, May be this helps: dat1<- structure(...  dat1$ID<- row.names(dat1) library(reshape2) dat2<-melt(dat1,id.vars="ID") dat2New<-dat2[order(as.numeric(dat2$ID)),]  head(dat2New) #   ID variable value #1   1   Ramses 4 #11  1   Sheiks 5 #21  1  Trojans 7 #31  1  Unnamed 2 #2   2   R

[R] converting a summary table to survey database form

2013-08-22 Thread Pancho Mulongeni
Hi! I am looking to choose a condom based on its pleasure score. I received some summarised data from 10 individuals: structure(list(Ramses = c(4, 4, 5, 5, 6, 3, 4, 4, 3, 4), Sheiks = c(5, 5, 6, 4, 7, 6, 4, 5, 6, 3), Trojans = c(7, 8, 7, 9, 6, 3, 2, 2, 2, 3), Unnamed = c(2, 1, 1, 3, 3, 4, 5, 4, 4

[R] corrgram (package corrgram): how to plot multiple correlograms in the same page?

2013-08-22 Thread Giuseppe Pagnoni
Hello, I am trying to plot a few correlograms on the same figure, with the function corrgram() from the package corrgram. However, the function does not seem to use the base graphic system, as setting out the multiple figure layout with, e.g., par(mfrow=c(2, 2,)) does not work. Does anybody k

Re: [R] filtering out replicate (duplicate) observations under special conditions

2013-08-22 Thread arun
Hi, Also, you could use: library(data.table)  dt1<- data.table(dat1,key=c('SampDate','DepthM')) unique(dt1) #   SiteID    SiteName   SampDate DepthM PDesc MAbbr Measure   DNU #1:  1 Big Platte Lake 2006-09-20  0.000    TP  Grab    6.58 FALSE #2:  1 Big Platte Lake 2006-09-20  2.286   

Re: [R] filtering out replicate (duplicate) observations under special conditions

2013-08-22 Thread arun
HI Samuel, Based on the output you wanted: (It would be better to use ?dput() to show the example dataset) dat1<- structure(list(SiteID = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), SiteName = c("Big Platte Lake", "Big Platte Lake", "Big Platte Lake", "Big Platte Lake", "Big

[R] Usage of ETS R codes through RExcel macros in VBA

2013-08-22 Thread Siddharth
Issue: Usage of ETS R codes through RExcel macros in VBA Given below is my command code: Rinterface.runrcodefromrange Range(“Sheet1!B2:D8”) Following are the codes written in the given cell reference: #!rput zz 'Sheet1'!$B$2:$B$22 library(forecast) zz <- ts(zz,freq=365,start=c(2009

Re: [R] lattice: bwplot: getting two plots into one.

2013-08-22 Thread Anna Zakrisson Braeunlich
Genious! Thank's a lot! One final question: I am making black and white plots and will have to change the pch=c(...) setting. The problem is that every time I change this setting I get an error message and have to close RStudio and re-open it for anything to work again. I can change the pch=c(..

Re: [R] italic(mu)

2013-08-22 Thread Beaulieu, Jake
This works: expression(paste('Greek', italic('\uo3bc')) thanks! Jake -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Thursday, August 22, 2013 2:01 AM To: David Winsemius Cc: Beaulieu, Jake; r-help@r-project.org Subject: Re: [R] italic(mu) On Aug 20, 2013

Re: [R] Rexcel

2013-08-22 Thread Rui Barradas
Hello, I must tell you once again to address your questions to r-help@r-project.org And since there was no subject line, I've made up one. Your question seems to be a question about excel, and I really can't help you. Maybe someone else can. But if you write.table(etszP) can't you read that

Re: [R] Interpreting the result of 'cutree' from hclust/heatmap.2

2013-08-22 Thread David Carlson
You specified 10 cuts to the dendrogram (all possible) so each column represents the cluster membership for that number of clusters. Column 1 is all ones because all rows belong to a single cluster and in column 10 all the rows belong to different clusters. For g9-9, 8 means that g9 belongs to clus

[R] From POSIXct to numeric and back with time zone

2013-08-22 Thread Daniel Haugstvedt
>From POSIXct to numeric and back with time zone I am running regressions on data which has time series with different time resolution. Some data has hourly resolution, while most has either daily or weekly resolution. Aggregation is used to make the hourly data daily, while liner interpolatio

Re: [R] cross-sectional analysis of a financial time series

2013-08-22 Thread Joshua Ulrich
Below are two ways to accomplish this. The last() function will not pad with NA if you request more days than available, so you may need to handle that if it's an issue. I prefer the period.apply method because it keeps the data in an xts object, which I find easier to work with. getSymbols("YHO

Re: [R] Error: cannot allocate vector of size 18.4 Gb (NbClust)

2013-08-22 Thread Michael Weylandt
On Aug 22, 2013, at 7:39, Ben Harrison wrote: > I have a 70363 x 5 double matrix that I am playing with. > > > head(df) >GR SP SN LN NEUT > 1 1.458543 1.419946 -0.2928088 -0.2615358 -0.5565227 > 2 1.432041 1.418573 -0.2942713 -0.2634204 -0.5927334 > 3 1.4066

[R] Error: cannot allocate vector of size 18.4 Gb (NbClust)

2013-08-22 Thread Ben Harrison
I have a 70363 x 5 double matrix that I am playing with. > head(df) GR SP SN LN NEUT 1 1.458543 1.419946 -0.2928088 -0.2615358 -0.5565227 2 1.432041 1.418573 -0.2942713 -0.2634204 -0.5927334 3 1.406642 1.418226 -0.2958296 -0.2652920 -0.6267121 4 1.382284 1.4188

Re: [R] download.file error - corrupt: Can't read SAT; charset=binary'

2013-08-22 Thread Uwe Ligges
Tal, please quote the whole message! I had to look for the original one now. And then I found that code was not reproducible for me: exe_URL = 'http://pandoc.googlecode.com/files/pandoc-1.11.1.msi' exe_filename <- file.path(tempdir(), file.name.from.url(exe_URL)) Error in file.path(tempdir()

Re: [R] stepAIC problem

2013-08-22 Thread Prof Brian Ripley
On 22/08/2013 09:24, Sachinthaka Abeywardana wrote: Hi all, I get the expected behaviour of getting a useful model if I do the following This is an 'expectation problem', not a 'stepAIC problem'. And stepAIC is not part of R and you are not crediting the tools you use. fit<-lm( expressions

[R] stepAIC problem

2013-08-22 Thread Sachinthaka Abeywardana
Hi all, I get the expected behaviour of getting a useful model if I do the following fit<-lm( expressions[,i]~expressions[,pa_all[1]]+expressions[,pa_all[2]]+expressions[,pa_all[3]]+expressions[,pa_all[4]]+expressions[,pa_all[5]]) step<-stepAIC(fit, direction="both") Output: Step: AIC=-78.75 ex