[R] confirmatory factor analysis in R

2011-03-10 Thread rvohen
In R software,does it have packages about confirmatory factor analysis in R software? 3Q -- View this message in context: http://r.789695.n4.nabble.com/confirmatory-factor-analysis-in-R-tp3347618p3347618.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] lattice (panel.3dscatter): how to make plot symbol thicker?

2011-03-10 Thread Marius Hofert
Dear Deepayan, many thanks for answering. Another thing I am wondering is the following: I know you can have (3d-like) "crosses" in the wireframe plot. But are there any other 3d-like plot symbols? Of course one can use different colors to distinguish between several points. The problem is th

Re: [R] .Library in R 2.12.2 for windows

2011-03-10 Thread Prof Brian Ripley
.libPaths() (on the same help page as .Library): and nothing has changed since R 2.11.1. However, to find a package, use .find.package, and your package should almost certainly be using system.file(package='pkgname'). On Thu, 10 Mar 2011, Oxxx wrote: I installed a custom package which needs

[R] Seasonality in STL Decomposition

2011-03-10 Thread vioravis
I having issues with interpreting the results of STL decomposition. The following is the data used as well as the decompsed seasonality, trend and the remainder components. It is a weekly data. The original data doesn't appear to be seasonal. But there seems to be a periodic peak in the seasonal c

Re: [R] lattice (panel.3dscatter): how to make plot symbol thicker?

2011-03-10 Thread Deepayan Sarkar
On Wed, Mar 9, 2011 at 7:57 AM, Peter Ehlers wrote: > On 2011-03-08 17:07, Jannis wrote: >> >> Searching the archive of the mailing list points to the following thread: >> >> https://stat.ethz.ch/pipermail/r-help/2009-March/193338.html >> >> Perhaps it helps you... >> >> On 03/08/2011 11:48 PM, Ma

Re: [R] Is there an exact binomial k-sample test of equivalence?

2011-03-10 Thread Albyn Jones
Presumably the null hypothesis is that at least one of the differences is larger in absolute magnitude than the chosen epsilon. I expect that your procedure would be conservative: if it rejects the null hypothesis, then you are ok, but presumably what you really want would be based on a joint

Re: [R] Easy 'apply' question

2011-03-10 Thread Joshua Wiley
Dear Aaron, The problem is not with your function, but using apply(). Look at the "Details" section of ?apply You will see that if the data is not an array or matrix, apply will coerce it to one (or try). Now go over to the "Details" section of ?matrix and you will see that matrices can only co

[R] variance explained by each term in a GAM

2011-03-10 Thread Pierre Kleiber
Picking up an ancient thread (from Oct 2007), I have a somewhat more complex problem than given in Simon Wood's example below. My full model has more than two smooths as well as factor variables as in this simplified example: b <- gam(y~fv1+s(x1)+s(x2)+s(x3)) Judging from Simon's example, my g

Re: [R] .Library in R 2.12.2 for windows

2011-03-10 Thread Gabor Grothendieck
On Thu, Mar 10, 2011 at 9:56 PM, Oxxx wrote: > I installed a custom package which needs to know its own location on the > disk. (It runs an executable that is included in the package.)  In version > 2.11.1 the .Library command gave me the necessary information.  It returned > the path C:\Program F

Re: [R] still a problem remainingRE: Data lebals xylattice plot: RE: displaying label meeting condition (i.e. significant, i..e p value less than 005) in plot function

2011-03-10 Thread Umesh Rosyara
Thank you so much for the advice. The R could not find function "intersection". Do I need additional package to have this function active. I tried "intersect" instead has no effect. xyplot(p ~ xvar|chr, data=dataf, panel=function(x, y, subscripts){ panel.xyplot(x, y) ok= intersection(subscripts,

[R] Lattice: Feature Request

2011-03-10 Thread Jim Price
Hi, I'm currently designing some global themes for use with lattice, and have hit a snag. There doesn't appear to be (in xyplot at least) a way of setting a lattice option for the 'scales' parameter at a global level - changes have to be made in each function call. For example, consider the follow

[R] Easy 'apply' question

2011-03-10 Thread Aaron Polhamus
Dear list, I couldn't find a solution for this problem online, as simple as it seems. Here's the problem: #Construct test dataframe tf <- data.frame(1:3,4:6,c("A","A","A")) #Try the apply function I'm trying to use test <- apply(tf,2,function(x) if(is.numeric(x)) mean(x) else unique(x)[1]) #Lo

[R] .Library in R 2.12.2 for windows

2011-03-10 Thread Oxxx
I installed a custom package which needs to know its own location on the disk. (It runs an executable that is included in the package.) In version 2.11.1 the .Library command gave me the necessary information. It returned the path C:\Program Files\R\R-2.11.1\library. I have noticed that in the 2

Re: [R] Main title in a multiple display of graphs

2011-03-10 Thread Peter Ehlers
On 2011-03-10 13:37, Marcos Prunello wrote: Hello! I want to display four xyplots in the same window (sorry if I don't use the propers words, but my English is rude) I know that if I use plot(y~x) then x=(1:100) y=(1:100) par(mfrow=c(2,2)) plot(y~x) plo

Re: [R] A question about data frame

2011-03-10 Thread Gang Chen
Yes, indeed I wanted them stored as characters instead of factor levels. Thanks a lot for the help, Jim and Phil! Gang On Thu, Mar 10, 2011 at 5:19 PM, Phil Spector wrote: > Gang - >   It sounds like you want your character variables to > be stored as character values, not factor values.  If tha

Re: [R] ERROR: gamm function (mgcv package). attempt to set an attribute on NULL

2011-03-10 Thread Ben Bolker
wang cheng yahoo.com.cn> writes: > > Hello:I run a gamm with following call > :mode<-gamm(A~B,random=list(ID=~1),family=gaussian,na.action=na.omit,data=rs) an error > happened:ERROR names(object$sp) <- names(G$sp) : attempt to set an attribute on NULL with mgcv version 1.7-3 What so? How

Re: [R] Timezone issue with strftime/strptime and %z and %Z

2011-03-10 Thread David Winsemius
On Mar 10, 2011, at 11:17 AM, Daniel Nüst wrote: Hello! I've been trying to get this right for quite a while now and fear there is an easy solution I just don't see. I did not have this problem in Linux, and I searched r-help and Google but did not find a solution, but of course I am grateful

Re: [R] Adjust the distance between tick mark labels and axis

2011-03-10 Thread Peter Ehlers
On 2011-03-10 11:37, Al Roark wrote: Hi all: I've been trying to figure out a way to move the tick mark labels in my lattice plots closer to the the axes. I've tinkered with a lot of the "buffer" parameters (those listed by trellis.par.get()), but haven't had any luck. Any ideas? If I underst

Re: [R] getting percentiles by factor

2011-03-10 Thread David Winsemius
On Mar 10, 2011, at 11:08 AM, Paolo Cavatore wrote: Hi David, thanks for your comment...I managed to sort it out. Below the final code...paolo # myExample <- data.frame(Ret=seq(-2, 2.5, by=0.5),PE=seq(10,19),Sectors=rep(c("Financial","Industrial"),5)) myExa

Re: [R] identical values not so identical? newbie help please!

2011-03-10 Thread Berwin A Turlach
G'day Maja, On Thu, 10 Mar 2011 11:44:28 -0800 (PST) maiya wrote: > Aaah, it truly is wonderful, this technology! > I guess I'm going to have to override it a bit though.. > Along the lines of > > tae <- ifesle(all.equal(obs, exp) == TRUE, 0, sum(abs(obs - exp))) Please read the help page on

Re: [R] biplot breakdown help

2011-03-10 Thread Peter Ehlers
On 2011-03-09 12:14, chris20 wrote: Hi, I am trying to understand how the biplot.prcomp is constructed so I can manipulate it to emphasise particular observations and reduce the number of variables shown. The prcomp model I have ran has cor=TRUE and scale=TRUE I have worked out from looking at

[R] Revolutions Blog: Jan/Feb Roundup

2011-03-10 Thread David Smith
I write about R every weekday at the Revolutions blog: http://blog.revolutionanalytics.com and every month (usually) I post a summary of articles from the previous month of particular interest to readers of r-help. I somehow missed this past January, though, so here are selected highlights from Ja

Re: [R] Rearranging the data

2011-03-10 Thread John Kane
Isn't reshape sun at first :). The not obvious thing is that you don't need to cast anything. All you need is the proper melt command (and a final sort if you want the table you have). = library(reshape) xx = data.frame(country

Re: [R] Reshape, melt and cast query

2011-03-10 Thread John Kane
I think we need a sample of the orginal data or reasonable facsimile to get an idea of what you are doing. Have a look at ?dput as a way to provide the data in a handy format. --- On Thu, 3/10/11, Muzna Alvi wrote: > From: Muzna Alvi > Subject: [R] Reshape, melt and cast query > To: r-help@r-

Re: [R] Sample or Probability Weights in LM4, NLME (and PLM) package

2011-03-10 Thread Thomas Lumley
On Fri, Mar 11, 2011 at 11:07 AM, Arne Jonas Warnke wrote: > Dear all, > > > > First, I would like to thank you for your immense work. My question is > about a frequent topic which I am not able to solve - even after hours > of search in the mailing lisy. > > I would like to analyse random-effects

Re: [R] sum of variables in function

2011-03-10 Thread Dennis Murphy
Hi: Assuming that z constitutes the last two elements of your input vector, try2 <- function(x) { n <- length(x) y <- x[1:(n - 2)] z <- x[n - 1] + x[n] sum(y) * z } x0 <- 1:4# result should be 21 x1 <- 1:8# z = 15, result = 21 * 15 = 315 try2(x0) try2(x1) HTH, Dennis On

Re: [R] R beginner - Error in as.vector(x, mode)

2011-03-10 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Arne Henningsen > Sent: Thursday, March 10, 2011 12:09 PM > To: Alex Olssen; r-help@r-project.org > Subject: Re: [R] R beginner - Error in as.vector(x, mode) > > Dear Alex > > O

Re: [R] within group sequential subtraction

2011-03-10 Thread jim holtman
Try this: > data$diff <- ave(as.numeric(data$date_obs), data$group, FUN=function(x)c(NA, > diff(x))) > data group date_obs diff 1 IND1 1987-09-17 NA 2 IND1 1989-05-04 595 3 IND2 1997-04-30 NA 4 IND2 2008-11-03 4205 5 IND2 2009-05-08 186 6 IND3 1984-01-17 NA 7 IND4 1996-

Re: [R] A question about data frame

2011-03-10 Thread Phil Spector
Gang - It sounds like you want your character variables to be stored as character values, not factor values. If that's the case, use df = data.frame(n, s,stringsAsFactors=FALSE) If you want them to be factors, but not to display as factors, others have provided usable solutions.

Re: [R] A question about data frame

2011-03-10 Thread jim holtman
try this: > n = c(2, 3, 5) > s = c("aa", "bb", "cc") > df = data.frame(n, s, stringsAsFactors = FALSE) > df n s 1 2 aa 2 3 bb 3 5 cc > str(df) 'data.frame': 3 obs. of 2 variables: $ n: num 2 3 5 $ s: chr "aa" "bb" "cc" > On Thu, Mar 10, 2011 at 4:35 PM, Gang Chen wrote: > A very simpl

[R] Is there an exact binomial k-sample test of equivalence?

2011-03-10 Thread Łukasz Ręcławowicz
Hi, I've got one silly question for evening. I don't know is this reasonable, but can test with two the most extreme proportions from the samples could be good enough evidence for testing equivalence, or should I have to look for something else...? -- Mi³ego dnia [[alternative HTML vers

[R] Sample or Probability Weights in LM4, NLME (and PLM) package

2011-03-10 Thread Arne Jonas Warnke
Dear all, First, I would like to thank you for your immense work. My question is about a frequent topic which I am not able to solve - even after hours of search in the mailing lisy. I would like to analyse random-effects (and fixed-effects)models of longitudinal / panel data with sampling wei

Re: [R] 3 dimensional MDS plots

2011-03-10 Thread Sarah Goslee
Hi Calla, On Thu, Mar 10, 2011 at 3:38 PM, Calla Carbone <6...@queensu.ca> wrote: > Hi, > > I am trying to create 3 mds plots: one with axis 1 vs axis 2, one with axis 2 > vs axis 3, and one with axis 1 vs axis 3. When inputting my code, I only end > up with one diagram and when inputting > mdsg

[R] vegan CCA I am Completely new to ordination analyses

2011-03-10 Thread kitty
Dear list, I am trying to predict species volume from bioclimatic data, I have various sites and I have a data frame with species volume and the corresponding bioclimatic data for each site. I read on a discussion forum that you can use ordination to predict species abundance (in my case volume)

[R] snp-chip table

2011-03-10 Thread shai uliel
Dear R helpers I have a table and i need to make new table table1: sire snp1 snp2 snp3 snp4 snp5 snp6 snp7 snp8 snp9 snp10 snp11 snp12 snp13 snp14 snp15 8877 -1 -1 -1 -1 0 0 -1 -1 -1 0 1 1 1 -1 -1 7765 1 1 1 0 0 0 -1 1 1 1 0 0 0 1 0 8766 1 1 -1 0 -1 -1 0 -1 0 -1 -1 -1 0 1 0 6756

Re: [R] identical values not so identical? newbie help please!

2011-03-10 Thread maiya
Quite fascinating, if annoying. Nice example Petr! Turns out my expected values are causing even more trouble because of this! I've even gotten negative chi square values (calculated using Cressie and Read's formula)! So instead of kludging the error measurement code, I think I'm going to have t

[R] 3 dimensional MDS plots

2011-03-10 Thread Calla Carbone
Hi, I am trying to create 3 mds plots: one with axis 1 vs axis 2, one with axis 2 vs axis 3, and one with axis 1 vs axis 3. When inputting my code, I only end up with one diagram and when inputting mdsg.mds$dims, the program returns 2 for 2 dimensions. How can I create the other two plots? An

Re: [R] A question about data frame

2011-03-10 Thread Gang Chen
Thanks! You mean something like: > print(df$s[1], max.levels=0) It seems I could also do > as.character(df$s[1]) Any other/better solutions? On Thu, Mar 10, 2011 at 4:40 PM, Rob Tirrell wrote: > See the max.levels argument in ?print. I think this is what you're looking > for. > -- > Robert Ti

Re: [R] Moving window per group

2011-03-10 Thread Gabor Grothendieck
On Thu, Mar 10, 2011 at 11:27 AM, mathijsdevaan wrote: > Hi, > > I have a data.frame of the following type: > > F = data.frame(read.table(textConnection("    A  B > 1 1  4 > 2 1  3 > 3 1  1 > 4 1  4 > 5 1  2 > 6 1  2 > 7 1  2 > 8 2  1 > 9 2  1 > 10 2  1 > 11 2  1 > 12 3  2 > 13 3  4 > 14 3  1 > 15

Re: [R] A question about data frame

2011-03-10 Thread Rob Tirrell
See the max.levels argument in ?print. I think this is what you're looking for. -- Robert Tirrell | r...@stanford.edu | (607) 437-6532 Program in Biomedical Informatics | Butte Lab | Stanford University On Thu, Mar 10, 2011 at 13:35, Gang Chen wrote: > n = c(2, 3, 5) > > s = c("aa", "bb", "cc"

[R] Main title in a multiple display of graphs

2011-03-10 Thread Marcos Prunello
Hello! I want to display four xyplots in the same window (sorry if I don't use the propers words, but my English is rude) I know that if I use plot(y~x) then x=(1:100) y=(1:100) par(mfrow=c(2,2)) plot(y~x) plot(y~x) plot(y~x) plot(y~x) wo

[R] A question about data frame

2011-03-10 Thread Gang Chen
A very simple question. With a data frame like this: > n = c(2, 3, 5) > s = c("aa", "bb", "cc") > df = data.frame(n, s) I want df$s[1] or df[1,2], but how can I get rid of the extra line in the output about the factor levels: > df$s[1] [1] aa Levels: aa bb cc Thanks, Gang _

Re: [R] ANOVA for stratified cox regression

2011-03-10 Thread Thomas Lumley
On Fri, Mar 11, 2011 at 8:25 AM, Brian McLoone wrote: > This is a follow-up to a query that was posted regarding some problems that > emerge when running anova analyses for cox models, posted by Mathias Gondan: > > Matthias Gondan wrote: > >>* Dear List,*>**>* I have tried a stratified Cox Regress

Re: [R] identical values not so identical? newbie help please!

2011-03-10 Thread maiya
Aaah, it truly is wonderful, this technology! I guess I'm going to have to override it a bit though.. Along the lines of tae <- ifesle(all.equal(obs, exp) == TRUE, 0, sum(abs(obs - exp))) Do I like doing this? No. But short of reading the vast literature that exists on calculation precision - wh

Re: [R] R beginner - Error in as.vector(x, mode)

2011-03-10 Thread Arne Henningsen
Dear Alex On 10 March 2011 20:31, Alex Olssen wrote: > I find it hard to provide a reproducible version of this error. > When I use the exact same procedure but get data from data() > everything works fine. > I.e., I do not think the startvals are the problem - in fact I copied > the syntax for t

[R] ANOVA for stratified cox regression

2011-03-10 Thread Brian McLoone
This is a follow-up to a query that was posted regarding some problems that emerge when running anova analyses for cox models, posted by Mathias Gondan: Matthias Gondan wrote: >* Dear List,*>**>* I have tried a stratified Cox Regression, it is working >fine, except for*>* the "Anova"-Tests:*>**>

Re: [R] identical values not so identical? newbie help please!

2011-03-10 Thread Petr Savicky
On Thu, Mar 10, 2011 at 10:34:21AM -0800, maiya wrote: > Thanks Josh and Dan! > > I did figure it had something to do with the machine epsilon... > > But so what do I do now? I'm calculating the total absolute error over > thousands of tables e.g.: > tae<-sum(abs(obs-exp)) > Is there any easy way

Re: [R] minimum distance between line segments

2011-03-10 Thread Thomas Lumley
On Fri, Mar 11, 2011 at 2:46 AM, Mike Marchywka wrote: > >> Date: Wed, 9 Mar 2011 10:55:46 +1300 >> From: darcy.web...@gmail.com >> To: r-help@r-project.org >> Subject: [R] minimum distance between line segments >> >> Dear R helpers, >> >> I think that thi

Re: [R] tobit regression model

2011-03-10 Thread Achim Zeileis
On Thu, 10 Mar 2011, Jen wrote: Hi, I'm trying to fit a tobit regression model to some data. When fitting the exact same data in Stata, I have no problems at all, however R won't converge. Its not a maxiters thing, since I've tried increasing this already. I need to be able to fit the model in R

[R] Adjust the distance between tick mark labels and axis

2011-03-10 Thread Al Roark
Hi all: I've been trying to figure out a way to move the tick mark labels in my lattice plots closer to the the axes. I've tinkered with a lot of the "buffer" parameters (those listed by trellis.par.get()), but haven't had any luck. Any ideas? Cheers.

Re: [R] power for repeated-measures ANOVA lacking sphericity

2011-03-10 Thread Thomas Lumley
On Fri, Mar 11, 2011 at 6:08 AM, Yuelin Li wrote: > Is there a function that calculates the power of a > repeated-measure ANOVA design, e.g., 2 groups, 4 > within-subject factors, an average 0.40 correlation between > the 4 within factors, etc. > > I don't think I can use power.anova.test() becaus

Re: [R] identical values not so identical? newbie help please!

2011-03-10 Thread Nordlund, Dan (DSHS/RDA)
Maja, Isn't modern technology wonderful? With computers we are able to do calculations that we could never do by hand, and we get to complain about the results not being exact. :-) More comments below > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@

Re: [R] identical values not so identical? newbie help please!

2011-03-10 Thread David A. Johnston
The function all.equal also might be helpful. See the help page. >help(all.equal) -David Johnston -- View this message in context: http://r.789695.n4.nabble.com/identical-values-not-so-identical-newbie-help-please-tp3346078p3346581.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] identical values not so identical? newbie help please!

2011-03-10 Thread Joshua Wiley
On Thu, Mar 10, 2011 at 10:34 AM, maiya wrote: > Thanks Josh and Dan! > > I did figure it had something to do with the machine epsilon... > > But so what do I do now? I'm calculating the total absolute error over > thousands of tables e.g.: > tae<-sum(abs(obs-exp)) > Is there any easy way to I kee

[R] lattice xscale.components: different ticks on top/bottom axis

2011-03-10 Thread Boris.Vasiliev
Good afternoon, I am trying to create a plot where the bottom and top axes have the same scale but different tick marks. I tried user-defined xscale.component function but it does not produce desired results. Can anybody suggest where my use of xscale.component function is incorrect? For exampl

Re: [R] No response after click the "show Rules" button on Tab "Associate".

2011-03-10 Thread Graham Williams
Did you scroll down the window to see the rules? Regards, Graham On 10 March 2011 02:07, Xiaobo Gu wrote: > Hi, > I am using Rattle 2.6.4 with R 2.12.2 on win64, is this a bug ? > > Following is the content after execute the associate analysis process: > > Summary of the Apriori Association R

Re: [R] identical values not so identical? newbie help please!

2011-03-10 Thread maiya
Thanks Josh and Dan! I did figure it had something to do with the machine epsilon... But so what do I do now? I'm calculating the total absolute error over thousands of tables e.g.: tae<-sum(abs(obs-exp)) Is there any easy way to I keep these ignorable errors from showing up? And furthermore, wh

Re: [R] sum of variables in function

2011-03-10 Thread Jonathan P Daily
How about: x <- rnorm(1000) fn <- function(k) sum(x[1:k]*(x[k+1] + x[k+2])) vals <- sapply(1:100, fn) vals -- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 "Is the room still a room when it

Re: [R] plot question, increasing Y-axis labels

2011-03-10 Thread Joshua Wiley
Hi Mike, You can use the ?axis function to add custom axes in. To prevent overwriting, you will want to suppress the default y axis in your call to plot. You can find details on the arguments and parameters in ?par (I recommend pulling it up in a way that you can search because the par documenta

Re: [R] within group sequential subtraction

2011-03-10 Thread Joshua Wiley
Dear Natalie, I am sure there are other ways, but one way you can do this is by applying diff() to each group using tapply() or by(). Because those return lists, if you want to add it back into your data frame, you can wrap the whole call in unlist(). Here is an example: dat <- structure(list(g

[R] plot question, increasing Y-axis labels

2011-03-10 Thread Mike Gibson
I want to increase the number of labels on my y-axis. Here is my code: plot(fish$species, fish$fl, ylim=c(5,25), xlab="Species", ylab="Fork Length (in)") The plot is great but it only has numerical y-labes every five values (i.e. labels at 5, 10, 15, and 25). I want R to give me the sa

[R] PDF & Hyperlink with "-" inside

2011-03-10 Thread Sascha41
Hello, I'm trying to create some pdf-File via R containing hyperlink, which has in the adress the "minus"-character used. Example: pdf(file="C:/R/test.pdf",width=11.69,height=8.27, onefile = TRUE) plot.new() mtext("http://www.sz-online.de";, side=1, line=-2, cex=0.7) dev.off() pdf-file will be cr

[R] sum of variables in function

2011-03-10 Thread beatleb
Dear R users, Probably, this is quite a simpe question, but I do not find the proper way to obtain want I need. To explain the problem, I constructed a simple example. Suppose I have the following function: try1<-function(x){ y<-x[1:2] z<-x[3:4] y[1]*(z[1]+z[2])+y[2]*(z[1]+z[2]) } This functio

Re: [R] identical values not so identical? newbie help please!

2011-03-10 Thread Joshua Wiley
Hi Maja, Values that are theoretically the same may not be exactly identical when using floating point arithmetic. Please read this FAQ page: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f If you need to test that they are "equal", you may add

Re: [R] aggregate by part of a field

2011-03-10 Thread Henrique Dallazuanna
Try this: rowsum(a$sales, gsub("(\\w*\\s\\w*\\s\\w*).*", "\\1", a$product)) On Thu, Mar 10, 2011 at 12:20 PM, Hui Du wrote: > > > Thank you for your reply. I didn't state my problem very clearly in my > previous post. The data could look like > > a = data.frame(date = c(20081201, 20081202, 2008

Re: [R] getting percentiles by factor

2011-03-10 Thread Paolo Cavatore
Hi David, thanks for your comment...I managed to sort it out. Below the final code...paolo # myExample <- data.frame(Ret=seq(-2, 2.5, by=0.5),PE=seq(10,19),Sectors=rep(c("Financial","Industrial"),5)) myExample <- na.omit(myExample) myecdf2 <- function(x, column, s

Re: [R] identical values not so identical? newbie help please!

2011-03-10 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of maiya > Sent: Thursday, March 10, 2011 7:19 AM > To: r-help@r-project.org > Subject: [R] identical values not so identical? newbie help please! > > Hi there! > I'm not sure I can

[R] Moving window per group

2011-03-10 Thread mathijsdevaan
Hi, I have a data.frame of the following type: F = data.frame(read.table(textConnection("A B 1 1 4 2 1 3 3 1 1 4 1 4 5 1 2 6 1 2 7 1 2 8 2 1 9 2 1 10 2 1 11 2 1 12 3 2 13 3 4 14 3 1 15 3 1 16 3 1"),head=TRUE,stringsAsFactors=FALSE)) F A B 1 1 4 2 1 3 3 1 1

[R] within group sequential subtraction

2011-03-10 Thread natalie.vanzuydam
Hi Everyone, I would like to do sequential subtractions within a group so that I know the time between separate observations for a group of individuals. My data: data <- structure(list(group = c("IND1", "IND1", "IND2", "IND2", "IND2", "IND3", "IND4", "IND5", "IND6", "IND6"), date_obs = struc

Re: [R] minimum distance between line segments

2011-03-10 Thread Mike Marchywka
> Date: Wed, 9 Mar 2011 10:55:46 +1300 > From: darcy.web...@gmail.com > To: r-help@r-project.org > Subject: [R] minimum distance between line segments > > Dear R helpers, > > I think that this may be a bit of a math question as the more I > consid

Re: [R] Selecting ranges of dates from a dataframe

2011-03-10 Thread Francisco Gochez
Benjamin, A more elegant "R-style" solution would be to use one of R's "apply"/aggregation routines, of which there are many. For example, the "by" function can split a data.frame by some factor/categorical variable(s), and then apply a function to each "slice". The result can then be pieced back

[R] identical values not so identical? newbie help please!

2011-03-10 Thread maiya
Hi there! I'm not sure I can create a minimal example of my problem, so I'm linking to a minimal .RData file that has only two objects: obs and exp, each is a 6x9 matrix. http://dl.dropbox.com/u/10364753/test.RData link to dropbox file (I hope this is acceptable mailing list etiquette!) Here's

Re: [R] aggregate by part of a field

2011-03-10 Thread Hui Du
Thank you for your reply. I didn't state my problem very clearly in my previous post. The data could look like a = data.frame(date = c(20081201, 20081202, 20081201), product = c("a b c d e", "a bdfd c g h t", "def e h a c e h g"), sales = c(1, 2, 3)). The first three items in "product" are th

[R] ERROR: gamm function (mgcv package). attempt to set an attribute on NULL

2011-03-10 Thread wang cheng
Hello:I run a gamm with following call :mode<-gamm(A~B,random=list(ID=~1),family=gaussian,na.action=na.omit,data=rs)an error happened:ERROR names(object$sp) <- names(G$sp) : attempt to set an attribute on NULLwith mgcv version 1.7-3What so? How can I correct the Error? Thanks very much for any

[R] Avoiding choosing parameters with mix[mixdist]

2011-03-10 Thread Anouk.Simard
Hi, I am working on a population of an invasive clam. The data are the size of each clam per station (2mm on average). Each station is found at a different distance from a power nuclear station, so at different water temperatures. The fist step I want to do is to identify cohort size at each st

Re: [R] using lapply

2011-03-10 Thread Phil Spector
To add to William's remarks, another advantage of the apply family of functions is that they avoid growing an object inside a loop, which is very inefficient in R. In other words, without the *apply functions, users might do something like this: answer = NULL for(i in 1:nrows) answer = rbind

Re: [R] using lapply

2011-03-10 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of > rex.dw...@syngenta.com > Sent: Thursday, March 10, 2011 8:47 AM > To: lig...@statistik.tu-dortmund.de; arun.kumar.s...@gmail.com > Cc: r-help@r-project.org > Subject: Re: [R] u

[R] power for repeated-measures ANOVA lacking sphericity

2011-03-10 Thread Yuelin Li
Is there a function that calculates the power of a repeated-measure ANOVA design, e.g., 2 groups, 4 within-subject factors, an average 0.40 correlation between the 4 within factors, etc. I don't think I can use power.anova.test() because it does not consider corr=0.40. I am hoping that someone

Re: [R] using lapply

2011-03-10 Thread rex.dwyer
But no one answered Kushan's question about performance implications of for-loop vs lapply. With apologies to George Orwell: "for-loops BAAD, no loops GOOD." -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Uwe Ligges Sent:

Re: [R] tryCatch - Continuing for/next loop after error

2011-03-10 Thread Jonathan P Daily
I did not know that. When reading the help topic for the first time myself, I think I assumed that it returned no value since it had no Value section, and I haven't used it in a way that it would return a value. -- Jonathan P. Daily Technician - USGS Leetown Sc

Re: [R] tryCatch - Continuing for/next loop after error

2011-03-10 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Jonathan P Daily > Sent: Thursday, March 10, 2011 7:49 AM > To: Nipesh Bajaj > Cc: r-help@r-project.org > Subject: Re: [R] tryCatch - Continuing for/next loop after error > > Wow

[R] Timezone issue with strftime/strptime and %z and %Z

2011-03-10 Thread Daniel Nüst
Hello! I've been trying to get this right for quite a while now and fear there is an easy solution I just don't see. I did not have this problem in Linux, and I searched r-help and Google but did not find a solution, but of course I am grateful for and resources I might not have found our not unde

[R] Error in predictor Variable Regression

2011-03-10 Thread Doran, Harold
Is there a package that does an EiV regression that uses the reliability of the measures which are provided by the user? I've searched RSiteSearch("error in variable regression") As well as various permutations of these terms in google. Though I say this with some trepidation, I am looking for

Re: [R] Reshape, melt and cast query

2011-03-10 Thread Muzna Alvi
yes..thats what i was also confused about..but thats what my column is named.. didnt know any other way of doing it. On Thu, Mar 10, 2011 at 9:23 PM, jdnew...@gmail.com < jdnew...@dcn.davis.ca.us> wrote: > I can't see the value of your first melt, which appears to result in a > column filled with

[R] rodbc error

2011-03-10 Thread Dr. Alireza Zolfaghari
Hi list, I have code which reads data from sql server using RODBC in R version 2.12.1. The code used to be ok, till today when I get the following error. The data does not have any problem, but if I run the code in differnt pc, it runs till different number of trial then it fails, for example on on

Re: [R] Reshape, melt and cast query

2011-03-10 Thread jdnew...@gmail.com
I can't see the value of your first melt, which appears to result in a column filled with identical values "crop_group". You really should read the posting guide and provide a reproducible example. I suspect that you would benefit from learning how to use the plyr library. -- Sent from my Andro

Re: [R] tryCatch - Continuing for/next loop after error

2011-03-10 Thread Jonathan P Daily
Wow, I had a major brain fart there. The function after error was supposed to accept an argument, and next won't do anything there because inside the function there is no loop. Also, the first argument of tryCatch is an expression, so do the assignment there. Corrections inline below: --

Re: [R] Reshape, melt and cast query

2011-03-10 Thread Muzna Alvi
thanks for that ista actually i want to break this into maybe three different data sets with each of the 3 kinds of sugarcane... it would be better if i could have this in one data set but if someone could tell me how i can run descriplitive statistics on each of the groups separately.. i would n

Re: [R] How to use conditional statement

2011-03-10 Thread peter dalgaard
On Mar 10, 2011, at 12:54 , Duncan Murdoch wrote: > On 11-03-10 5:54 AM, Ivan Calandra wrote: >> Try with double "== "instead: >> ifelse(val3 == "Monthly", val<- val1, val<- val2) > > That might work, but it is not how you should do it. (It should work if val3 > has a single entry, but will do

Re: [R] tryCatch - Continuing for/next loop after error

2011-03-10 Thread Nipesh Bajaj
Hi Jonathan, I was also trying to understand this tryCatch function on my own problem. Here is mine: fn1 <- function(x) { if(as.integer(x) == 5) { stop("stop") } return(x+5) } res <- matrix(

Re: [R] Reshape, melt and cast query

2011-03-10 Thread Ista Zahn
Hi Muzna, If I understand your question, it's not really about melting or casting, but about re-ordering. Try this: canefile <- canefile[order(canefile$value), ] see ?"[" and ?order HTH, Ista On Thu, Mar 10, 2011 at 2:20 PM, Muzna Alvi wrote: > I have a dataset that is based on crop output for

Re: [R] Help with read.csv

2011-03-10 Thread Giovanni Petris
Thanks to everybody who answered with suggestions (David Wolfskill, Stephen Sefick, Jim Holtman, Gabor Grothendieck, and Phil Spector). Beside the obvious end-of-the-day mixup ("int" in lieu of "integer"), I was not aware of the existence of a "NULL" class - which proved pretty useful in this cas

[R] expression at labels in contour function

2011-03-10 Thread Rogerio Porto
Hello, I'm stuck with the following code. p <- 0:100/100 a <- 0:200/100 beta <- matrix(a + p%x%(1-a), nrow=length(a), ncol=length(p)) lb <- c(expression(beta==0), expression(beta==0.2), expression(beta==0.4), expression(beta==0.6), expression(beta==0.8), expression(beta==1), expression(beta==1.2)

[R] Reshape, melt and cast query

2011-03-10 Thread Muzna Alvi
I have a dataset that is based on crop output for a single crop *sugarcane*...but each observation is further subdivided into 3 kinds of sugarcane i have read the file and have also used melt it to sort it on the basis of *crop group* using melt(sugarcane, m=c("Crop_group")) -> canefile this is

[R] Stress in metaMDS from vegam package

2011-03-10 Thread Ronaldo Reis Junior
Hi, I have a newbie doubt. I try to use metaMDS in R, it is OK, but the stress that I get is 16.32, in other programs stress is showed like 0.173. I don't find a good explanation about this calculations on books, I think that R show stress em a percentage data (0-100) and other software in a p

Re: [R] tryCatch - Continuing for/next loop after error

2011-03-10 Thread Jonathan P Daily
-- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 "Is the room still a room when its empty? Does the room, the thing itself have purpose? Or do we, what's the word... imbue it." - Jubal E

Re: [R] Install XML PACKAGE

2011-03-10 Thread Uwe Ligges
On 10.03.2011 13:33, David Winsemius wrote: On Mar 10, 2011, at 5:18 AM, wesley mathew wrote: Dear All I wanna install XML package, but it shows XML package is not available. install.packages("XML") *Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWi n/bin/win

[R] tobit regression model

2011-03-10 Thread Jen
Hi, I'm trying to fit a tobit regression model to some data. When fitting the exact same data in Stata, I have no problems at all, however R won't converge. Its not a maxiters thing, since I've tried increasing this already. I need to be able to fit the model in R since there are users of the code

Re: [R] Fw: random sampling steps in R with replacement

2011-03-10 Thread Dennis Murphy
Hi: To get the samples, here's one approach: df <- data.frame(gender = rep(c('F', 'M'), c(165, 42)), y = rpois(207, 20)) # Sampling function to take 20 F and 20 M with replacement # The sample function operates on the rows of df to get idx and then takes # the y's corresponding to those rows sfun

[R] Selecting ranges of dates from a dataframe

2011-03-10 Thread Benjamin Stier
Hello list! I have a data.frame which looks like this: > serv datum op.read op.write read write 1 2011-01-29 10:00:00 00 0 0 2 2011-01-29 10:00:01 00 0 0 3 2011-01-29 10:00:02 00 0 0 4 2011-01-29 10:00:03

  1   2   >