[R] Creating Vignettes
Hi, I want to create a new vignette and include it in an already existing package. That package has already many vignettes which are related to the chapters from the book on which the package is built. It would be a great help if anyone could help to understand how to create vignette for a statistical test like Chi-Square test. Thanks, Shreyasee [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tklistbox selection
I solved this problem by adding "exportselection = 0" to the call to tklistbox. I.e. tb1 <- tklistbox(tt, listvariable = tcl1, exportselection = 0, selectmode = "multiple") Thanks, --sundar Sundar Dorai-Raj said the following on 10/29/2008 5:56 PM: Hi, I'm posting yet another question about tcltk since I'm still struggling with the package. I'm trying to create a tklistbox and a ttkcombobox on the same parent and am having a problem. Here's an example: library(tcltk) tt <- tktoplevel() tcl1 <- tclVar() tcl2 <- tclVar() tclObj(tcl1) <- letters[1:5] tclObj(tcl2) <- LETTERS[1] tb1 <- tklistbox(tt, listvariable = tcl1, selectmode = "multiple") tb2 <- ttkcombobox(tt, values = LETTERS[1:2], textvariable = tcl2) tkpack(tb1, tb2) First, I select some values in the list box. But when I select a value from the combo box, the selection from the list box is no longer highlighted. Is this a bug or am I missing something in the documentation? My goal is to allow highlighted text simultaneously in both widgets. Thanks, --sundar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Arrays of Trellis plots
2008/10/30 erwann rogard <[EMAIL PROTECTED]>: > hi, > > xyplot(y~x2|x1+which,data= >> >> make.groups(dataframe1, dataframe2)) >> >> > i'd like to replace the labels for dataframe1 and dataframe2 say with > c("A","B"). is there a way? I guess you mean make.groups(A = dataframe1, B = dataframe2) see ?make.groups > > thanks! > > On Mon, Oct 27, 2008 at 2:23 PM, Deepayan Sarkar > <[EMAIL PROTECTED]>wrote: > >> On 10/27/08, erwann rogard <[EMAIL PROTECTED]> wrote: >> > hello, >> > >> > the example below does not work. (i know it's not supposed, but it makes >> it >> > clear what i'm trying to achieve) >> > >> > par(mfrow=c(2,1)) >> > xyplot(y~x2|x1,data=dataframe1,pch=20) >> > xyplot(y~x2|x1,data=dataframe2,pch=20) >> > >> > i know i could probably merge the two datasets and do something like >> > xyplot(y~x2|x1+dataset,data=merged) >> > >> > any other suggestion? >> >> xyplot(y~x2|x1+which,data=make.groups(dataframe1, dataframe2)) >> >> -Deepayan >> > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Felix Andrews / 安福立 http://www.neurofractal.org/felix/ 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Arrays of Trellis plots
hi, xyplot(y~x2|x1+which,data= > > make.groups(dataframe1, dataframe2)) > > i'd like to replace the labels for dataframe1 and dataframe2 say with c("A","B"). is there a way? thanks! On Mon, Oct 27, 2008 at 2:23 PM, Deepayan Sarkar <[EMAIL PROTECTED]>wrote: > On 10/27/08, erwann rogard <[EMAIL PROTECTED]> wrote: > > hello, > > > > the example below does not work. (i know it's not supposed, but it makes > it > > clear what i'm trying to achieve) > > > > par(mfrow=c(2,1)) > > xyplot(y~x2|x1,data=dataframe1,pch=20) > > xyplot(y~x2|x1,data=dataframe2,pch=20) > > > > i know i could probably merge the two datasets and do something like > > xyplot(y~x2|x1+dataset,data=merged) > > > > any other suggestion? > > xyplot(y~x2|x1+which,data=make.groups(dataframe1, dataframe2)) > > -Deepayan > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Trying to "expand" some data - Newbie needs help
Each row of my dataframe has these data items: Stuff1 Stuff2 TripID StopID moreStuff1 moreStuff2 ... I might have 2 entries for TripID=9011890 and StopID=Reseda, while I know the "Universe" for that combination was 7. I'd like to set a new variable (Call it X1) with a value of 3.5 for the two entries with TripID=9011890 and StopID=Reseda. It gets messy when I have 0 entries for a combination. My "expanded" TripID/StopID X1 values don't add to the total for the TripID. If I sum "X1" for TripID=9011890 I'll get only say 23 when the sum of the targets was 34. I want to have another variable (call it X2) with a value 34/23. I've started by making a .csv file that's a "table" with each row listing a TripID and each column a StopID. I cannot combine the .csv file data with the dataframe data. Even though I'm using the same commands for each, I get different "data structure" results. My current script is as follows: SurveyData <- read.spss( {Snip} ) NewTargetData <- read.table( {Snip} ) # CurrentX1Sums <- as.matrix(xtabs(~TripID+StopID, data=SurveyData)) CurrentX2Sums <- apply(CurrentX1Sums, 1, sum) NewTargetX1Sums <- as.matrix(NewTargetData) NewTargetX2Sums <- apply(NewTargetX1Sums, 1, sum) Robert Farley Metro www.Metro.net -Original Message- From: Erik Iverson [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 29, 2008 19:58 To: Farley, Robert Subject: Re: [R] Trying to "expand" some data - Newbie needs help Farley, Robert wrote: > I want to calculate "expansion factors" for elements in my dataframe > based on a 2-d cross classification. Since I'll have "missing values" > (many combinations will have no record) I'll need a second "expansion > factor" for each "row". I've included my "work to date" below, but I'm > not very close to getting this right. > > Without looking too closely, would it be possible to submit this question to R-help again with a small example of what it is you are looking for? For instance, construct a small, simulated data.frame object like your 'real' one, and then show what you mean by "expansion factors" (i.e, the output you'd like based on your simulated data.frame). This usually helps get a quick, easy answer. Hope that helps! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reconstruct the Q matrix from the QR object
x <- matrix(rnorm(1:20), 5, 4) x.qr <- qr(x) Q <- qr.Q(x.qr) R <- qr.R(x.qr) X <- qr.X(x.qr) Q R X Q %*% R qr.Q(x.qr, complete=TRUE) ## orthogonal completion __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get the duplicated elements from a vector?
Erik Iverson wrote: ## BEGIN R CODE ## guarantees there is at least one level with exactly three elements, ## which your problem seems to require t1 <- data.frame(a = rnorm(10), b = c("D", "D", "D", sample(LETTERS[1:3], 7, replace = TRUE))) ## find which names have exactly three elements t2 <- subset(t1, b %in% names(which(table(t1$b) == 3))) ## note that the elements of the returned value depend on what was ## originally in your data set's 'b' column tapply(t2$a, t2$b, mean) ## END R CODE Hi, Thank you all for the kind help. Now I've learned much and solved my problem with your helpful information :) Cheers, Leon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Reconstruct the Q matrix from the QR object
Hi, Is it possible to construct a Q from qr() that some of the rows could be specified (to be fixed values)? Thanks, cruz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Trying to "expand" some data - Newbie needs help
I want to calculate "expansion factors" for elements in my dataframe based on a 2-d cross classification. Since I'll have "missing values" (many combinations will have no record) I'll need a second "expansion factor" for each "row". I've included my "work to date" below, but I'm not very close to getting this right. My first question is why CurrentX2Sums seems OK but NewTargetX2Sums has no totals? I've added the total to the "ID". How do I do this correctly? I expected CurrentX2Sums (and NewTargetX2Sums) to print in column form. How do I make it do so? t(CurrentX2Sums) doesn't seem to do the trick. How do I avoid getting e.g. "De.Soto" when I read "De Soto" into NewTargetData? How do I put this back into my dataframe? SurveyData$NewX1 = NewTargetX1Sums/CurrentX1Sums but how do I specify (tripid_nu lineon) the indices? If I'm only a ?LookHere or ??LookThere away I'd appreciate being pointed in the right direction. Thanks in advance. All the gory details: > sessionInfo()# List loaded packages R version 2.8.0 (2008-10-20) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] graphics grDevices utils datasets stats methods base other attached packages: [1] fortunes_1.3-5 prettyR_1.3-3 survey_3.9-1 foreign_0.8-29 > SurveyData <- read.spss("C:/Data/R/orange_delivery.sav", use.value.labels=TRUE, max.value.labels=Inf, to.data.frame=TRUE) > NewTargetData <- read.table("C:/Data/R/NewTarget.csv", header=TRUE, sep=",", na.strings="NA", dec=".", strip.white=TRUE) > #--- > temp <- sub(' +$', '', SurveyData$direction_) # Remove spaces from variable names > SurveyData$direction_ <- temp > #--- > SurveyData$StnNum=as.numeric(SurveyData$lineon) > CurrentX1Sums <- as.matrix(xtabs(~tripid_nu+lineon, data=SurveyData)) > CurrentX2Sums <- apply(CurrentX1Sums, 1, sum) > NewTargetX1Sums <- as.matrix(NewTargetData) > NewTargetX2Sums <- apply(NewTargetX1Sums, 1, sum) > > CurrentX1Sums lineon tripid_nu Warner Center De Soto Pierce College Tampa Reseda Balboa Woodley Sepulveda Van Nuys Woodman Valley College Laurel Canyon North Hollywood 9011880 1 0 2 1 0 2 1 00 0 1 0 0 9011890 0 0 0 0 0 0 1 00 0 0 1 0 9011960 1 1 2 0 1 1 0 13 2 1 0 0 .. {Snip} .. 9015640 0 0 0 0 0 0 0 00 0 0 0 1 9015650 0 0 0 0 0 0 0 01 0 0 0 5 9015840 0 5 0 0 0 0 0 00 0 0 0 0 > CurrentX2Sums 9011880 9011890 9011960 9011970 9012040 9012050 9012130 9012280 9012290 9012720 9012730 9012760 9012770 9012840 9012850 9012880 9012890 9013000 9013010 9013240 9013250 9013280 9013290 9013320 9013330 9013360 9013440 8 2 13 25 18 8 13 28 20 9 5 22 14 19 8 13 11 10 5 6 9 11 9 10 9 13 5 9013450 9013800 9013810 9013880 9013890 9013960 9013970 9014080 9014090 9014120 9014130 9014240 9014250 9014440 9014450 9014640 9014650 9014760 9014770 9014960 9014970 9015280 9015290 9015520 9015530 9015640 9015650 8 17 14 16 3 5 8 17 16 23 8 15 18 7 9 16 14 6 19 5 19 7 11 20 16 1 6 9015840 5 > NewTargetX1Sums TripID Warner.Center De.Soto Pierce.College Tampa Reseda Balboa Woodley Sepulveda Van.Nuys Woodman Valley.College Laurel.Canyon North.Hollywood [1,] 9011880 5 2 2 2 2 2 2 22 2 6 4 1 [2,] 9011890 1 1 1 1 1 1 2 11 1 1 2 1 [3,] 9011960 2 2 2 1 2 2 1 23 2 2 1 1 .. {Snip} .. [53,] 9015640 1 1 1 1 1 1 1 11 1 1 1 2 [54,] 9015650 1 1 1 1 1 1 1 12 1
Re: [R] Regression versus functional/structural relationship?
The two test outcomes will have correlated results, so you will need to look at either bivariate probit regression or seemingly unrelated regression. For either of these two methods, you will need to constrain all independent variable coefficients to be equal, or you will have difficulty making sense of the results. Stata has biprobit and sureg, and also a constraint command. (Also bivariate probit requires binary dependents, so you will need to apply a "clinically interesting" cutpoint of (+)/(-) test results. If you can't find anything like these in R you will likely need to perform quantile normalization of both dependents (x,y) before regression. Look at the qnorm package in bioconductor, by Bolstad. LP -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ravi Varadhan Sent: Wednesday, October 29, 2008 6:01 PM To: [EMAIL PROTECTED] Subject: [R] Regression versus functional/structural relationship? Hi, I am dealing with the following problem. There are two biochemical assays, say A and B, available for analyzing blood samples. Half the samples have been analyzed with A. Now, for some insurmountable logistic reasons, we have to use B to analyze the remaining samples. However, we can do a comparative study on a small number of samples where we can obtain concentrations using both A and B. This gives us the data of the form (x, y), where x are values from A and y from B. Now, my question: Can we simply use the regression equation from regressing y on x, to convert all the x values for which only method A was used? Or do we need to obtain the functional (or structural) relationship between X and Y (the true values without measurement error) and use that to do this conversion. It seems to me that since we can only observe error-prone x, and we should be predicting the expected value of error-prone y (i.e E[y | x]). Therefore, we can simply use the ordinary regression equation. However, I have seen papers using the Deming's orthogonal regression or something equivalent in the clinical chemistry literature to address this problem. Deming's method would make sense if I am interested in obtaining the functional relationship between X and Y (the true values of two assays), but I don't see why I should care about that. Am I right? I would appreciate any clarifying thoughts on this. I apologize for posting this methodological, non-R question. Thank you, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] tklistbox selection
Hi, I'm posting yet another question about tcltk since I'm still struggling with the package. I'm trying to create a tklistbox and a ttkcombobox on the same parent and am having a problem. Here's an example: library(tcltk) tt <- tktoplevel() tcl1 <- tclVar() tcl2 <- tclVar() tclObj(tcl1) <- letters[1:5] tclObj(tcl2) <- LETTERS[1] tb1 <- tklistbox(tt, listvariable = tcl1, selectmode = "multiple") tb2 <- ttkcombobox(tt, values = LETTERS[1:2], textvariable = tcl2) tkpack(tb1, tb2) First, I select some values in the list box. But when I select a value from the combo box, the selection from the list box is no longer highlighted. Is this a bug or am I missing something in the documentation? My goal is to allow highlighted text simultaneously in both widgets. Thanks, --sundar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Q: rbind problem in my code
I have a large matrix which is divided into several pieces, manipulated individually, and saved into RData in disc. After each pieces are done with operation, I load them into memory and use rbind to stack them back into matrix. however, the rbind is only give me the last two pieces. The following code illustrates the problem: 4 pieces of matrix (1000x1000) is created and stored in RData; then load them back and rbind them. I would expect mat is of 4000*1000; however, dim(mat) shows (2000 1000). Where is my code wrong? Thanks ## define a pathData directory pathData='C:'\\data'; points=1000; data.pfx='rnorm'; rname=paste('row',1:points,sep=''); cname=paste('col',1:points,sep=''); for (i in 1:4) { x=rnorm(points^2); mat=matrix(data=x,nrow=points,ncol=points); rname=paste('row',(points*(i-1)+1):(points*i),sep=''); rownames(mat)=rname; colnames(mat)=cname; file.rdata=paste(pathData,'\\',data.pfx,'_',i,'.RData', sep=''); save(list='mat',file=file.rdata,compress=T); } mat=NULL; for (i in 1:4) { file.rdata=paste(pathData,'\\',data.pfx,'_',i,'.RData', sep=''); x=load(file.rdata); mat=rbind(mat,get(x)); } ### code end here > dim(mat) [1] 2000 1000 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Functional pattern-matching in R
Using the list function defined here: http://tolstoy.newcastle.edu.au/R/help/04/06/1430.html list[m, n] <- as.list(dim(iris)) mylist <- as.list(1:5) list[Head, Tail] <- list(mylist[[1]], mylist[-1]) On Wed, Oct 29, 2008 at 4:39 PM, Alexy Khrabrov <[EMAIL PROTECTED]> wrote: > I found there's a very good functional set of operations in R, such as apply > family, Hadley Wickham's lovely plyr, etc. There's even a Reduce (a.k.a. > fold). Now I wonder how can we do pattern-matching? > > E.g., now I split dimensions like this: > >m <- dim(V)[1] # R >n <- dim(V)[2] # still R > > While even Matlab allows for > > [m,n] = size(V) % MATLAB! > > Ideally I'd be able to say, > > <> <- dim(V) > > -- where <<.,.>> is some magic needed. > > Similarly, to break lists, we'd need, in a MLish notation, > > match L with > | head::tail => ... > | () => ; > > What can be done in R now to simulate it, and/or how Rish is it to add > something like that? > > Cheers, > Alexy > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] substring/strsplit question
Assuming that by elements you mean characters ("2E" is the first element of x but "E" is the last character in x[1]) then this will create a character matrix of dimensions: length(x) by 2 such that each row corresponds to one component of x and the second column in that row holds its last character while the first column in that row holds a string of the prior characters. > x <- c("2E","5W","12H") > library(gsubfn) > strapply(x, "(.+)(.)$", c, simplify = rbind) [,1] [,2] [1,] "2" "E" [2,] "5" "W" [3,] "12" "H" The above assumes the latest version of gsubfn on CRAN. On Wed, Oct 29, 2008 at 4:57 PM, Erin Hodgess <[EMAIL PROTECTED]> wrote: > Dear R People: > > Here is a toy example: > >> x <- c("2E","5W","12H") >> substr(x,2,2) > [1] "E" "W" "2" >> > > Sometimes x has 3 elements, sometimes 2. I want to extract the last > element, and then extract the other 1 or 2 elements. > > How can I do this, please? > > TIA, > Sincerely, > Erin > > > -- > Erin Hodgess > Associate Professor > Department of Computer and Mathematical Sciences > University of Houston - Downtown > mailto: [EMAIL PROTECTED] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] License Question
Just remember that the Linux kernel is also licensed under GPL v2. I am not sure if you pay for your Linux distribution. But for many gov sites and for my copy of Linux, they just use Linux as a completely free product -- in the sense that no money needs to be paid to a company or anyone. However, if you want support for R, then you can get it on this list, or you can pay someone for it. --Chi On Mon, Oct 27, 2008 at 11:26 AM, Duncan Murdoch <[EMAIL PROTECTED]> wrote: > R is licensed under the GPL version 2, a pretty common license. You should > be able to get legal advice on it internally at your company. If you ask on > a forum like this, you'll get lots of advice, but some of it will likely be > wrong. I don't want to add to that, so I won't give any other than "ask > internally". > > Duncan Murdoch > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how can I access parts of yags output
On 30/10/2008, at 11:48 AM, Juliet Hannah wrote: Here is an example given from ?yags library(methods) data(stackloss) Y1 <- yags(stack.loss~Air.Flow,id=1:21, data=stackloss) How can I access parts of the output. I tried: str(Y1) Formal class 'yagsResult' [package "yags"] with 25 slots ..@ coefficients : num [1:2] -44.13 1.02 ..@ coefnames: chr(0) Y1$coefnames Error in Y1$coefnames : $ operator not defined for this S4 class Notice those ``@'' signs in the output of str(). These thingies (``coefficients'' and ``coefnames' are ``slots'', not components. This structure was introduced into S/R purely with the intent of totally bewildering people. It serves no genuinely useful purpose ... (Flame-bait! :-) ) You can get at them via a similar syntax: [EMAIL PROTECTED] The S4 control freaks would tell you that you are in severe danger of being condemned to eternal perdition for doing so however. They would say that you extract things from S4 objects *only* using the extractor functions provided. How one knows what extractor functions actually *are* provided remains a mystery to me, but there it is! :-) cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Regression versus functional/structural relationship?
Hi, I am dealing with the following problem. There are two biochemical assays, say A and B, available for analyzing blood samples. Half the samples have been analyzed with A. Now, for some insurmountable logistic reasons, we have to use B to analyze the remaining samples. However, we can do a comparative study on a small number of samples where we can obtain concentrations using both A and B. This gives us the data of the form (x, y), where x are values from A and y from B. Now, my question: Can we simply use the regression equation from regressing y on x, to convert all the x values for which only method A was used? Or do we need to obtain the functional (or structural) relationship between X and Y (the true values without measurement error) and use that to do this conversion. It seems to me that since we can only observe error-prone x, and we should be predicting the expected value of error-prone y (i.e E[y | x]). Therefore, we can simply use the ordinary regression equation. However, I have seen papers using the Deming's orthogonal regression or something equivalent in the clinical chemistry literature to address this problem. Deming's method would make sense if I am interested in obtaining the functional relationship between X and Y (the true values of two assays), but I don't see why I should care about that. Am I right? I would appreciate any clarifying thoughts on this. I apologize for posting this methodological, non-R question. Thank you, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting iregular time series
why not look at the zoo package it can deal with time irregular time series. I have used it and I have been very happy. On Wed, Oct 29, 2008 at 5:52 PM, Levy,Ilan [Ontario] <[EMAIL PROTECTED]> wrote: > Hi, > > I have several time series that I need to plot on the same plot. > There are 3 problems with these series: > 1. they do not start or end at the same times > 2. they have different time intervals (seconds, minutes or hours) > 3. they all have random missing time steps of a few step to longer > periods of several days > > The data is imported from a database as POSIXct so that the first column > holds the date-time format like: " 2007-09-05 15:42:00", and the rest of > the data is numeric. > > I am thinking of creating a new time series (ts) with the smallest time > interval (seconds) that will cover the max length of the time period, > and try to put the existing data I have onto that series, so that > missing data will be skiped. > > The question is how to match the time steps from the original series to > the new time series? > > Thanks, > Ilan > AQRD > Environment Canada > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy 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 up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plotting iregular time series
Hi, I have several time series that I need to plot on the same plot. There are 3 problems with these series: 1. they do not start or end at the same times 2. they have different time intervals (seconds, minutes or hours) 3. they all have random missing time steps of a few step to longer periods of several days The data is imported from a database as POSIXct so that the first column holds the date-time format like: " 2007-09-05 15:42:00", and the rest of the data is numeric. I am thinking of creating a new time series (ts) with the smallest time interval (seconds) that will cover the max length of the time period, and try to put the existing data I have onto that series, so that missing data will be skiped. The question is how to match the time steps from the original series to the new time series? Thanks, Ilan AQRD Environment Canada [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how can I access parts of yags output
Here is an example given from ?yags library(methods) data(stackloss) Y1 <- yags(stack.loss~Air.Flow,id=1:21, data=stackloss) How can I access parts of the output. I tried: > str(Y1) Formal class 'yagsResult' [package "yags"] with 25 slots ..@ coefficients : num [1:2] -44.13 1.02 ..@ coefnames: chr(0) > Y1$coefnames Error in Y1$coefnames : $ operator not defined for this S4 class Thanks, Juliet __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Macro stuff to work on up through august 2007
sorry guys. I have a cold and I am not thinking very clearly On Wed, Oct 29, 2008 at 5:50 PM, stephen sefick <[EMAIL PROTECTED]> wrote: > Title says it all remember cast() with sum as the aggregation function > > -- > Stephen Sefick > Research Scientist > Southeastern Natural Sciences Academy > > 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 up and > make us feel like gods. We are mammals, and have not exhausted the > annoying little problems of being mammals. > >-K. Mullis > -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy 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 up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] linux batch question
thanks Rolf. Yes, I meant temp.R. I was going to use test.R but then I realized that I already had a program named that. I think the R gods are really hating me !!! it's a very odd thing. I'll grep the file because maybe the output is in there somewhere and i'm missing it ? On Wed, Oct 29, 2008 at 5:01 PM, Rolf Turner wrote: On 30/10/2008, at 10:46 AM, [EMAIL PROTECTED] wrote: I usually just run my R programs at the R command prompt but for my latest one I want to save any output that gets written to the screen so I am trying to use R CMD BATCH and send the output to an output file. I realize I could use sink at the prompt but I'd rather try to do it this way because I know that I used to do this in S+. So, I wrote a simple one line program called test.R which is below. print("test of batch\n") Uh, you don't ack-chewally want that ``\n'' in there with a print() statement. (You'd want it with a cat() statement.) Then I did R CMD BATCH temp.R temp.out Did you mean ``test.R'' here, rather than ``temp.R''? If not, what's in ``temp.R''? temp.out which is shown below then ends up containing all my loading up messages and a proc.time statement at the very bottom but not the print statement itself ? Does someone know what I'm doing wrong. I've looked around but I can't find anything that answers my question. My sessionInfo() is at ther very bottom of this email. Thanks. Well, it works for *me*! I made a file temp.R containing the line ``print("test of batch") and then did: R CMD BATCH temp.R temp.out The resulting file temp.out contained the ``test of batch'' line as expected/required. No problema. Clearly the R gods don't like you. :-) cheers, Rolf ## Attention:This e-mail message is privileged and confidential. If you are not theintended recipient please delete the message and notify the sender.Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshalwww.marshalsoftware.com ## __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] FW: Re: linux batch question
Hi Phil: That's EXACTLY what it is. Thanks so much. It's nice to know that the R Gods don't hate me. I hope it's okay that I'm going to cc r-help in case this thread comes up in the future and also so that other people who might want to help know that it's solved. Thanks again. On Wed, Oct 29, 2008 at 5:01 PM, Phil Spector wrote: Mark: delete workspace? (y/n): print("test of batch\n") It looks like you've got something in your .Rprofile or .First that's causing R to prompt you about saving your workspace, and it's interpreting your program as that response. Try R --no-save --vanilla CMD BATCH test.r test.out - Phil On Wed, 29 Oct 2008, [EMAIL PROTECTED] wrote: I usually just run my R programs at the R command prompt but for my latest one I want to save any output that gets written to the screen so I am trying to use R CMD BATCH and send the output to an output file. I realize I could use sink at the prompt but I'd rather try to do it this way because I know that I used to do this in S+. So, I wrote a simple one line program called test.R which is below. print("test of batch\n") Then I did R CMD BATCH temp.R temp.out temp.out which is shown below then ends up containing all my loading up messages and a proc.time statement at the very bottom but not the print statement itself ? Does someone know what I'm doing wrong. I've looked around but I can't find anything that answers my question. My sessionInfo() is at ther very bottom of this email. Thanks. #=== R version 2.7.2 (2008-08-25) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [1] "LOADING MASS LIBRARY" Loading required package: graphics Loading required package: stats Loading required package: utils [Previously saved workspace restored] Welcome to R! delete workspace? (y/n): print("test of batch\n") [1] "LOADING LPSOLVE LIBRARY \n" [1] "LOADING RESHAPE LIBRARY \n" [1] "LOADING FILEHASH LIBRARY \n" filehash: Simple key-value database (2.0 2008-08-03) [1] "LOADING USINGR LIBRARY \n" [1] "LOADING CAR LIBRARY \n" [1] "LOADING EFFECTS LIBRARY \n" Loading required package: lattice Loading required package: grid Attaching package: 'effects' The following object(s) are masked from package:car : Cowles, Prestige [1] "LOADING NNET LIBRARY \n" [1] "LOADING LATTICE LIBRARY \n" [1] "LOADING ML FUTURES TOOLS LIBRARY" [1] "LOADING ML MISC TOOLS LIBRARY" [1] "LOADING ML TEST TOOLS LIBRARY" [1] "LOADING ML STOCK TOOLS LIBRARY" [1] "LOADING ML DECILE TOOLS LIBRARY" [1] "LOADING ML MULTINOM TOOLS LIBRARY" The following object(s) are masked from package:utils : memory.size Goodbye! proc.time() user system elapsed 3.061 0.087 3.252 # sessionInfo() R version 2.7.2 (2008-08-25) i686-redhat-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] datasets grid utils stats graphics grDevices methods base other attached packages: [1] nnet_7.2-44 effects_1.0-12 lattice_0.17-14 car_1.2-8 UsingR_0.1-8 filehash_2.0reshape_0.8.0 lpSolve_5.6.4 MASS_7.2-44 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Functional pattern-matching in R
On 29/10/2008 4:39 PM, Alexy Khrabrov wrote: I found there's a very good functional set of operations in R, such as apply family, Hadley Wickham's lovely plyr, etc. There's even a Reduce (a.k.a. fold). Now I wonder how can we do pattern-matching? E.g., now I split dimensions like this: m <- dim(V)[1] # R n <- dim(V)[2] # still R While even Matlab allows for [m,n] = size(V) % MATLAB! Ideally I'd be able to say, <> <- dim(V) -- where <<.,.>> is some magic needed. Similarly, to break lists, we'd need, in a MLish notation, match L with | head::tail => ... | () => ; What can be done in R now to simulate it, and/or how Rish is it to add something like that? You can do this: names <- c("m", "n") for (i in seq_along(names)) assign(names[i], dim(V)[i]) With some trickery, I think you could write a function that did this based on syntax like _(m, n) <- dim(V) I would call this quite non-Rish. It needs tricky evaluation (m and n are only there as names, not as bindings to objects). I don't know ML, so I don't understand your second example. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to restrict a parameter in optim()
Luis SAGAON TEYSSIER etumel.univmed.fr> writes: > > Dear all, > > I'm trying to estimate some parameters with the optim() function but I > need to restrict one parameter and I have not found how to do it. > Could you help me please? Thought someone else would answer by now. use the arguments method="L-BFGS-B", lower=c(-Inf,-Inf,-Inf,-Inf,0), upper=c(Inf,Inf,Inf,Inf,1) you may need to tweak these slightly (e.g. set the bounds slightly within the desired [0,1] range or set the lower/upper bounds for the unbounded parameters to large negative/positive numbers) if you get errors about NaNs etc. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with "simtest"
Susana Zuloaga wrote: Hello all I am working with the package multcomp but I have problems with the function simtest; the program say that can not find this function, nevertheless I doesn't have any problem with the function glht that it is in the same package. Someone knows what could be the problem? multcomp's `CHANGES' file says: CHANGES in `multcomp' VERSION 0.992-9 oremove deprecated functions simint and simtest (the files are still available from multcomp/inst/deprecated) HTH, Henric Thank you [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] linux batch question
On 30/10/2008, at 10:46 AM, [EMAIL PROTECTED] wrote: I usually just run my R programs at the R command prompt but for my latest one I want to save any output that gets written to the screen so I am trying to use R CMD BATCH and send the output to an output file. I realize I could use sink at the prompt but I'd rather try to do it this way because I know that I used to do this in S+. So, I wrote a simple one line program called test.R which is below. print("test of batch\n") Uh, you don't ack-chewally want that ``\n'' in there with a print() statement. (You'd want it with a cat() statement.) Then I did R CMD BATCH temp.R temp.out Did you mean ``test.R'' here, rather than ``temp.R''? If not, what's in ``temp.R''? temp.out which is shown below then ends up containing all my loading up messages and a proc.time statement at the very bottom but not the print statement itself ? Does someone know what I'm doing wrong. I've looked around but I can't find anything that answers my question. My sessionInfo() is at ther very bottom of this email. Thanks. Well, it works for *me*! I made a file temp.R containing the line ``print("test of batch") and then did: R CMD BATCH temp.R temp.out The resulting file temp.out contained the ``test of batch'' line as expected/required. No problema. Clearly the R gods don't like you. :-) cheers, Rolf ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Macro stuff to work on up through august 2007
Title says it all remember cast() with sum as the aggregation function -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy 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 up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] linux batch question
I usually just run my R programs at the R command prompt but for my latest one I want to save any output that gets written to the screen so I am trying to use R CMD BATCH and send the output to an output file. I realize I could use sink at the prompt but I'd rather try to do it this way because I know that I used to do this in S+. So, I wrote a simple one line program called test.R which is below. print("test of batch\n") Then I did R CMD BATCH temp.R temp.out temp.out which is shown below then ends up containing all my loading up messages and a proc.time statement at the very bottom but not the print statement itself ? Does someone know what I'm doing wrong. I've looked around but I can't find anything that answers my question. My sessionInfo() is at ther very bottom of this email. Thanks. #=== R version 2.7.2 (2008-08-25) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [1] "LOADING MASS LIBRARY" Loading required package: graphics Loading required package: stats Loading required package: utils [Previously saved workspace restored] Welcome to R! delete workspace? (y/n): print("test of batch\n") [1] "LOADING LPSOLVE LIBRARY \n" [1] "LOADING RESHAPE LIBRARY \n" [1] "LOADING FILEHASH LIBRARY \n" filehash: Simple key-value database (2.0 2008-08-03) [1] "LOADING USINGR LIBRARY \n" [1] "LOADING CAR LIBRARY \n" [1] "LOADING EFFECTS LIBRARY \n" Loading required package: lattice Loading required package: grid Attaching package: 'effects' The following object(s) are masked from package:car : Cowles, Prestige [1] "LOADING NNET LIBRARY \n" [1] "LOADING LATTICE LIBRARY \n" [1] "LOADING ML FUTURES TOOLS LIBRARY" [1] "LOADING ML MISC TOOLS LIBRARY" [1] "LOADING ML TEST TOOLS LIBRARY" [1] "LOADING ML STOCK TOOLS LIBRARY" [1] "LOADING ML DECILE TOOLS LIBRARY" [1] "LOADING ML MULTINOM TOOLS LIBRARY" The following object(s) are masked from package:utils : memory.size Goodbye! proc.time() user system elapsed 3.061 0.087 3.252 # sessionInfo() R version 2.7.2 (2008-08-25) i686-redhat-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] datasets grid utils stats graphics grDevices methods base other attached packages: [1] nnet_7.2-44 effects_1.0-12 lattice_0.17-14 car_1.2-8 UsingR_0.1-8filehash_2.0reshape_0.8.0 lpSolve_5.6.4 MASS_7.2-44 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] call works with gee and yags, but not geepack
On 30/10/2008, at 9:08 AM, Juliet Hannah wrote: I have included data at the bottom of this email. It can be read in by highlighting the data and then using this command: dat <- read.table("clipboard", header = TRUE,sep="\t") I can obtain solutions with both of these: library(gee) fit.gee<-gee(score ~ chem + time, id=id, family=gaussian,corstr="exchangeable",data=dat) and library(yags) fit.yags <- yags(score ~ chem + time, id=id, family=gaussian,corstr="exchangeable",data=dat,alphainit=0.05) However, I am making a mistake with: library(geepack) fit.geese <- geese(score ~ chem + time, id=id, family=gaussian,corstr="exch",data=dat) I obtain the following error: Error in geese.fit(x, y, id, offset, soffset, w, waves, zsca, zcor, corp, : nrow(zsca) and length(y) not match Could someone tell me what I have done incorrectly. Thanks for your time, Juliet. I'm pretty sure this is a bug in geese(), which should be reported to the maintainer of geepack. The problem is with the treatment of missing values. If looks at dim(na.omit(dat[,c("id","score","chem","time")])) one gets 44. In geese.fit() zsca is set equal to matrix(1,N,1) where N is set equal to length(id). But id has length 46 whereas the response y has been trimmed down to length 44 by eliminating any rows of the data where any of the variables involved are missing. Hence a problem. The solution of the problem requires some code re-writing by the maintainer of geepack. cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] substring/strsplit question
on 10/29/2008 03:57 PM Erin Hodgess wrote: > Dear R People: > > Here is a toy example: > >> x <- c("2E","5W","12H") >> substr(x,2,2) > [1] "E" "W" "2" > > Sometimes x has 3 elements, sometimes 2. I want to extract the last > element, and then extract the other 1 or 2 elements. > > How can I do this, please? > > TIA, > Sincerely, > Erin Hi Erin, Is this what you want? # Get the last character > gsub(".*(.)$", "\\1", x) [1] "E" "W" "H" # Get the others > gsub("(^.*).$", "\\1", x) [1] "2" "5" "12" See ?gsub HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] substring/strsplit question
How about > x <- c("2E","5W","12H") > substr(x, nchar(x), nchar(x)) [1] "E" "W" "H" > > substr(x, 1, nchar(x)-1) [1] "2" "5" "12" -- David -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erin Hodgess Sent: Wednesday, October 29, 2008 3:58 PM To: [EMAIL PROTECTED] Subject: [R] substring/strsplit question Dear R People: Here is a toy example: > x <- c("2E","5W","12H") > substr(x,2,2) [1] "E" "W" "2" > Sometimes x has 3 elements, sometimes 2. I want to extract the last element, and then extract the other 1 or 2 elements. How can I do this, please? TIA, Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] substring/strsplit question
Try this: library(gsubfn) ## The last character strapply(x, "(.)$", simplify = TRUE) ## The last two character strapply(x, "(..)$", simplify = TRUE) On Wed, Oct 29, 2008 at 6:57 PM, Erin Hodgess <[EMAIL PROTECTED]>wrote: > Dear R People: > > Here is a toy example: > > > x <- c("2E","5W","12H") > > substr(x,2,2) > [1] "E" "W" "2" > > > > Sometimes x has 3 elements, sometimes 2. I want to extract the last > element, and then extract the other 1 or 2 elements. > > How can I do this, please? > > TIA, > Sincerely, > Erin > > > -- > Erin Hodgess > Associate Professor > Department of Computer and Mathematical Sciences > University of Houston - Downtown > mailto: [EMAIL PROTECTED] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] substring/strsplit question
Upon re-reading your question, I did not provide what you wanted. In your example, 'x' is a character vector that has three elements. Each element of 'x' has two or three characters. Now I think I see what you want: ## untested, for the last character: substr(x, nchar(x), nchar(x)) ## untested, for the first character(s) substr(x, 1, ifelse(nchar(x) == 3, 2, 1)) Erin Hodgess wrote: Dear R People: Here is a toy example: x <- c("2E","5W","12H") substr(x,2,2) [1] "E" "W" "2" Sometimes x has 3 elements, sometimes 2. I want to extract the last element, and then extract the other 1 or 2 elements. How can I do this, please? TIA, Sincerely, Erin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] substring/strsplit question
## untested last <- tail(x, n = 1) first <- head(x, n = length(x) - 1) Erin Hodgess wrote: Dear R People: Here is a toy example: x <- c("2E","5W","12H") substr(x,2,2) [1] "E" "W" "2" Sometimes x has 3 elements, sometimes 2. I want to extract the last element, and then extract the other 1 or 2 elements. How can I do this, please? TIA, Sincerely, Erin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] substring/strsplit question
Dear R People: Here is a toy example: > x <- c("2E","5W","12H") > substr(x,2,2) [1] "E" "W" "2" > Sometimes x has 3 elements, sometimes 2. I want to extract the last element, and then extract the other 1 or 2 elements. How can I do this, please? TIA, Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Functional pattern-matching in R
I found there's a very good functional set of operations in R, such as apply family, Hadley Wickham's lovely plyr, etc. There's even a Reduce (a.k.a. fold). Now I wonder how can we do pattern-matching? E.g., now I split dimensions like this: m <- dim(V)[1] # R n <- dim(V)[2] # still R While even Matlab allows for [m,n] = size(V) % MATLAB! Ideally I'd be able to say, <> <- dim(V) -- where <<.,.>> is some magic needed. Similarly, to break lists, we'd need, in a MLish notation, match L with | head::tail => ... | () => ; What can be done in R now to simulate it, and/or how Rish is it to add something like that? Cheers, Alexy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] call works with gee and yags, but not geepack
Sorry. I did not output the NAs correctly. dat <- read.table("clipboard", header = TRUE) id treat time1 time2 time3 time4 chem1 chem2 chem3 chem4 time score chem 1 1 20 18 15 15 1000 1100 1200 1300 0 20 1000 1 1 20 18 15 15 1000 1100 1200 1300 2 18 1100 1 1 20 18 15 15 1000 1100 1200 1300 3 15 1200 1 1 20 18 15 15 1000 1100 1200 1300 6 15 1300 2 1 22 24 18 22 1000 1000 1055 950 0 22 1000 2 1 22 24 18 22 1000 1000 1055 950 2 24 1000 2 1 22 24 18 22 1000 1000 1055 950 3 18 1055 2 1 22 24 18 22 1000 1000 1055 950 6 22 950 3 1 14 10 24 10 1000 1999 800 1700 0 14 1000 3 1 14 10 24 10 1000 1999 800 1700 2 10 1999 3 1 14 10 24 10 1000 1999 800 1700 3 24 800 3 1 14 10 24 10 1000 1999 800 1700 6 10 1700 4 1 38 34 32 24 1000 1050 NA 1400 0 38 1000 4 1 38 34 32 24 1000 1050 NA 1400 2 34 1050 4 1 38 34 32 24 1000 1050 NA 1400 3 32 NA 4 1 38 34 32 24 1000 1050 NA 1400 6 24 1400 5 1 25 29 25 29 1000 1020 1040 1045 0 25 1000 5 1 25 29 25 29 1000 1020 1040 1045 2 29 1020 5 1 25 29 25 29 1000 1020 1040 1045 3 25 1040 5 1 25 29 25 29 1000 1020 1040 1045 6 29 1045 6 1 30 28 26 14 1000 1100 1180 1500 0 30 1000 6 1 30 28 26 14 1000 1100 1180 1500 2 28 1100 6 1 30 28 26 14 1000 1100 1180 1500 3 26 1180 6 1 30 28 26 14 1000 1100 1180 1500 6 14 1500 7 0 20 15 21 20 1000 1200 1200 1000 0 20 1000 7 0 20 15 21 20 1000 1200 1200 1000 2 15 1200 7 0 20 15 21 20 1000 1200 1200 1000 3 21 1200 7 0 20 15 21 20 1000 1200 1200 1000 6 20 1000 8 0 21 27 19 27 1000 900 1075 900 0 21 1000 8 0 21 27 19 27 1000 900 1075 900 2 27 900 8 0 21 27 19 27 1000 900 1075 900 3 19 1075 8 0 21 27 19 27 1000 900 1075 900 6 27 900 9 0 15 22 22 20 1000 NA 1000 700 0 15 1000 9 0 15 22 22 20 1000 NA 1000 700 2 22 NA 9 0 15 22 22 20 1000 NA 1000 700 3 22 1000 9 0 15 22 22 20 1000 NA 1000 700 6 20 700 10 0 39 NA 39 34 1000 950 1033 1025 0 39 1000 10 0 39 NA 39 34 1000 950 1033 1025 2 NA 950 10 0 39 NA 39 34 1000 950 1033 1025 3 39 1033 10 0 39 NA 39 34 1000 950 1033 1025 6 34 1025 11 0 27 27 31 22 1000 950 910 1050 0 27 1000 11 0 27 27 31 22 1000 950 910 1050 2 27 950 11 0 27 27 31 22 1000 950 910 1050 3 31 910 11 0 27 27 31 22 1000 950 910 1050 6 22 1050 12 0 28 24 33 NA 1000 1015 985 NA 0 28 1000 12 0 28 24 33 NA 1000 1015 985 NA 2 24 1015 12 0 28 24 33 NA 1000 1015 985 NA 3 33 985 12 0 28 24 33 NA 1000 1015 985 NA 6 NA NA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Subsetting data in a loop
?split. Hadley On Wed, Oct 29, 2008 at 3:22 PM, t c <[EMAIL PROTECTED]> wrote: > I need some help with sub-setting my data. I am trying to divide a data > frame into multiple data frames based on the year collected, and stored in a > list with each new data frame labeled with "year X" where X is the year the > data was collected. When I run my current code I get nine error messages > stating > "In one_year[name] <- myear : number of items to replace is not a multiple > of replacement length"What I have so far is: > Below is my code, the data frame mydat, and what I would like the final > product to look like. I would appreciate any help or suggestions on what I > am doing wrong. > Thanks, > Tim > > > one_year<-list() > for (i in min(mydat$Year):max(mydat$Year)) #Loops from first to last year in > dataset > { > myear<-mydat[mydat$Year==i,] > name<-paste("Year",i) > one_year[name]<-myear > } > > > mydat: > Year Month Day number other Ind1 Ind2 Ind3 Ind4 > 1985 8 13 1 1 0 0 0 0 > 1986 8 5 2 3 0 0 0 0 > 1991 4 24 3 0 0 0 0 0 > 1991 4 25 4 0 0 0 0 0 > 1991 8 2 5 0 0 0 0 0 > 1991 8 6 6 0 0 0 0 0 > 1991 9 4 7 2 0 0 0 0 > 1991 9 9 8 4 0 0 0 0 > 199112 16 9 0 0 0 0 0 > 1992 3 1810 1 0 0 0 0 > 1992 5 1311 0 0 0 0 0 > 1992 7 3112 1 0 0 0 0 > 1992 8 1913 0 0 0 0 0 > 199210 1414 2 0 0 0 0 > 199210 3015 4 0 0 0 0 > 199211 1116 2 0 0 0 0 > 199211 2017 0 0 0 0 0 > 199212 518 0 0 0 0 0 > 199212 919 3 0 0 0 0 > 1993 1 2420 5 0 0 0 0 > > > What I would like is: > Year1985 > 1985 8 13 1 1 0 0 0 0 > > Year 1986 > 1986 8 5 2 3 0 0 0 0 > > Year 1991 > 1991 4 24 3 0 0 0 0 0 > 1991 4 25 4 0 0 0 0 0 > 1991 8 2 5 0 0 0 0 0 > 1991 8 6 6 0 0 0 0 0 > 1991 9 4 7 2 0 0 0 0 > 1991 9 9 8 4 0 0 0 0 > 199112 16 9 0 0 0 0 0 > ect. > > > > > >[[alternative HTML version deleted]] > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Subsetting data in a loop
I need some help with sub-setting my data. I am trying to divide a data frame into multiple data frames based on the year collected, and stored in a list with each new data frame labeled with "year X" where X is the year the data was collected. When I run my current code I get nine error messages stating "In one_year[name] <- myear : number of items to replace is not a multiple of replacement length"What I have so far is: Below is my code, the data frame mydat, and what I would like the final product to look like. I would appreciate any help or suggestions on what I am doing wrong. Thanks, Tim one_year<-list() for (i in min(mydat$Year):max(mydat$Year)) #Loops from first to last year in dataset { myear<-mydat[mydat$Year==i,] name<-paste("Year",i) one_year[name]<-myear } mydat: Year Month Day number other Ind1 Ind2 Ind3 Ind4 1985 8 13 1 1 0 0 0 0 1986 8 5 2 3 0 0 0 0 1991 4 24 3 0 0 0 0 0 1991 4 25 4 0 0 0 0 0 1991 8 2 5 0 0 0 0 0 1991 8 6 6 0 0 0 0 0 1991 9 4 7 2 0 0 0 0 1991 9 9 8 4 0 0 0 0 1991 12 16 9 0 0 0 0 0 1992 3 18 10 1 0 0 0 0 1992 5 13 11 0 0 0 0 0 1992 7 31 12 1 0 0 0 0 1992 8 19 13 0 0 0 0 0 1992 10 14 14 2 0 0 0 0 1992 10 30 15 4 0 0 0 0 1992 11 11 16 2 0 0 0 0 1992 11 20 17 0 0 0 0 0 1992 12 5 18 0 0 0 0 0 1992 12 9 19 3 0 0 0 0 1993 1 24 20 5 0 0 0 0 What I would like is: Year1985 1985 8 13 1 1 0 0 0 0 Year 1986 1986 8 5 2 3 0 0 0 0 Year 1991 1991 4 24 3 0 0 0 0 0 1991 4 25 4 0 0 0 0 0 1991 8 2 5 0 0 0 0 0 1991 8 6 6 0 0 0 0 0 1991 9 4 7 2 0 0 0 0 1991 9 9 8 4 0 0 0 0 1991 12 16 9 0 0 0 0 0 ect. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] call works with gee and yags, but not geepack
I have included data at the bottom of this email. It can be read in by highlighting the data and then using this command: dat <- read.table("clipboard", header = TRUE,sep="\t") I can obtain solutions with both of these: library(gee) fit.gee<-gee(score ~ chem + time, id=id, family=gaussian,corstr="exchangeable",data=dat) and library(yags) fit.yags <- yags(score ~ chem + time, id=id, family=gaussian,corstr="exchangeable",data=dat,alphainit=0.05) However, I am making a mistake with: library(geepack) fit.geese <- geese(score ~ chem + time, id=id, family=gaussian,corstr="exch",data=dat) I obtain the following error: Error in geese.fit(x, y, id, offset, soffset, w, waves, zsca, zcor, corp, : nrow(zsca) and length(y) not match Could someone tell me what I have done incorrectly. Thanks for your time, Juliet. Data Below: id treat time1 time2 time3 time4 chem1 chem2 chem3 chem4 time score chem 1 1 20 18 15 15 1000 1100 1200 1300 0 20 1000 1 1 20 18 15 15 1000 1100 1200 1300 2 18 1100 1 1 20 18 15 15 1000 1100 1200 1300 3 15 1200 1 1 20 18 15 15 1000 1100 1200 1300 6 15 1300 2 1 22 24 18 22 1000 1000 1055 950 0 22 1000 2 1 22 24 18 22 1000 1000 1055 950 2 24 1000 2 1 22 24 18 22 1000 1000 1055 950 3 18 1055 2 1 22 24 18 22 1000 1000 1055 950 6 22 950 3 1 14 10 24 10 1000 1999 800 1700 0 14 1000 3 1 14 10 24 10 1000 1999 800 1700 2 10 1999 3 1 14 10 24 10 1000 1999 800 1700 3 24 800 3 1 14 10 24 10 1000 1999 800 1700 6 10 1700 4 1 38 34 32 24 1000 1050 1400 0 38 1000 4 1 38 34 32 24 1000 1050 1400 2 34 1050 4 1 38 34 32 24 1000 1050 1400 3 32 4 1 38 34 32 24 1000 1050 1400 6 24 1400 5 1 25 29 25 29 1000 1020 1040 1045 0 25 1000 5 1 25 29 25 29 1000 1020 1040 1045 2 29 1020 5 1 25 29 25 29 1000 1020 1040 1045 3 25 1040 5 1 25 29 25 29 1000 1020 1040 1045 6 29 1045 6 1 30 28 26 14 1000 1100 1180 1500 0 30 1000 6 1 30 28 26 14 1000 1100 1180 1500 2 28 1100 6 1 30 28 26 14 1000 1100 1180 1500 3 26 1180 6 1 30 28 26 14 1000 1100 1180 1500 6 14 1500 7 0 20 15 21 20 1000 1200 1200 1000 0 20 1000 7 0 20 15 21 20 1000 1200 1200 1000 2 15 1200 7 0 20 15 21 20 1000 1200 1200 1000 3 21 1200 7 0 20 15 21 20 1000 1200 1200 1000 6 20 1000 8 0 21 27 19 27 1000 900 1075 900 0 21 1000 8 0 21 27 19 27 1000 900 1075 900 2 27 900 8 0 21 27 19 27 1000 900 1075 900 3 19 1075 8 0 21 27 19 27 1000 900 1075 900 6 27 900 9 0 15 22 22 20 1000 1000 700 0 15 1000 9 0 15 22 22 20 1000 1000 700 2 22 9 0 15 22 22 20 1000 1000 700 3 22 1000 9 0 15 22 22 20 1000 1000 700 6 20 700 10 0 39 39 34 1000 950 1033 1025 0 39 1000 10 0 39 39 34 1000 950 1033 1025 2 950 10 0 39 39 34 1000 950 1033 1025 3 39 1033 10 0 39 39 34 1000 950 1033 1025 6 34 1025 11 0 27 27 31 22 1000 950 910 1050 0 27 1000 11 0 27 27 31 22 1000 950 910 1050 2 27 950 11 0 27 27 31 22 1000 950 910 1050 3 31 910 11 0 27 27 31 22 1000 950 910 1050 6 22 1050 12 0 28 24 33 1000 1015 985 0 28 1000 12 0 28 24 33 1000 1015 985 2 24 1015 12 0 28 24 33 1000 1015 985 3 33 985 12 0 28 24 33 1000 1015 985 6 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with Plots
#How about this? x1=6*(sin((0:100)*2*pi/100))+4 y1=6*(cos((0:100)*2*pi/100))+4 plot(x1,y1) x2=c(1,9,3,4,8,4,2,0) y2=c(3,6,8,2,4,1,9,6) lines(x2,y2,type="b") On Wed, Oct 29, 2008 at 2:48 PM, Alex99 <[EMAIL PROTECTED]> wrote: > > Hi there, > I am trying to have a connectivity graph (two plots at once) in R: > this is an example: > > x1=sin((0:100)*2*pi/100) > y1=cos((0:100)*2*pi/100) > plot(x1,y1) > > will draw a circle and > > x2=c(1,9,3,4,8,4,2,0) > y2=c(3,6,8,2,4,1,9,6) > plot(x2,y2,type="b") > > will draw a graph with corresponding x's and y's and connects the point. > > I want to have a circle with these points connected to each other inside the > circle. is it possible to do it in R? > > Thanks > -- > View this message in context: > http://www.nabble.com/Help-with-Plots-tp20233489p20233489.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy 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 up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] behavior of "by"
On Wed, 29 Oct 2008 10:49:03 -0700, Jeff Laake <[EMAIL PROTECTED]> wrote: > Again thanks for the input. I've been a recipient of this list for > quite a few years although I don't post often. It is an invaluable > resource and I appreciate the effort of all the contributors. I > support a lot of software so I know how much work it can be. > I've seen the "reproducible code" at the bottom of the messages but > until I got an off-list explanation I had no idea that it meant an > example in which the "code AND data can be copied and pasted directly > into R". I re-read the posting guide and it does suggest providing an > example. Adding a definition for "reproducible code" might help. The posting guide already has that (albeit implicitly): ---<---cut here---start-->--- Examples: Sometimes it helps to provide a small example that someone can actually run. For example: If I have a matrix x as follows: > x <- matrix(1:8, nrow=4, ncol=2, dimnames=list(c("A","B","C","D"), c("x","y")) > x x y A 1 5 B 2 6 C 3 7 D 4 8 > how can I turn it into a dataframe with 8 rows, and three columns named `row', `col', and `value', which have the dimension names as the values of `row' and `col', like this: > x.df row col value 1A x 1 ... (To which the answer might be: > x.df <- reshape(data.frame(row=rownames(x), x), direction="long", varying=list(colnames(x)), times=colnames(x), v.names="value", timevar="col", idvar="row") ) When providing examples, it is best to give an R command that constructs the data, as in the matrix() expression above. For more complicated data structures, dump("x", file=stdout()) will print an expression that will recreate the object x. ---<---cut here---end>--- Perhaps this should start with: Examples: It helps to provide reproducible code, i.e. a small example that someone can actually run. For example: to link the R-help banner with the posting guide more explicitly. -- Seb __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Barplot: Vertical bars with long labels
Thanks a lot, Henrique and Christos! It works fine Quoting Christos Hatzis <[EMAIL PROTECTED]>: > Udo, > > You can try inserting a newline where you need the break in your labels: > > > dd.names <- c('Conduct Disorders','Attention Deficit', 'Eating Disorders', > 'Substance Abuse','Developmental Disorders') > > dd.names.2 <- sapply(dd.names, function(x) gsub("\\s", "\\\n", x)) > > barplot(dd, names.arg=dd.names.2) > > -Christos > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Udo > > Sent: Wednesday, October 29, 2008 2:43 PM > > To: r-help@r-project.org > > Subject: [R] Barplot: Vertical bars with long labels > > > > Dear List, > > I need a barplot with vertical bars. Each bar should have a label. > > The problem is, that the labels are too long, so they > > overlap, or only every seccond label is displayed in the output. > > > > Here is a little syntax: > > > > dd <- c(100,110,90,105,95) > > barplot(dd,names.arg=c('Conduct Disorders','Attention Deficit', > >'Eating Disorders', > >'Substance Abuse','Developmental Disorders')) > > > > My question is, if there is a chance to force a line break in > > each label. > > > > The result shoud look like this: > > > > Bar1Bar2 Bar3 Bar4 Bar5 > > ConductAttentionEating Substance Developmental > > Disorders Disorders Disorders AbuseDisorders > > > > > > > > The result could also look like this: > > > > Bar1 Bar2 Bar3 Bar4 Bar5 > >|| || | > > Conduct Disorders |Eating Disordes| > > Developmental Disordes > > | | > > Attention deficit Substance Abuse > > > > > > > > > > Many thanks in advance > > Udo > > > > > > > > > > Udo KN G > > Ö I > > > > Clinic for Child an Adolescent Psychiatry Philipps University > > of Marburg / Germany > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > Udo KN G Ö I Clinic for Child an Adolescent Psychiatry Philipps University of Marburg / Germany __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Barplot: Vertical bars with long labels
Udo, You can try inserting a newline where you need the break in your labels: > dd.names <- c('Conduct Disorders','Attention Deficit', 'Eating Disorders', 'Substance Abuse','Developmental Disorders') > dd.names.2 <- sapply(dd.names, function(x) gsub("\\s", "\\\n", x)) > barplot(dd, names.arg=dd.names.2) -Christos > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Udo > Sent: Wednesday, October 29, 2008 2:43 PM > To: r-help@r-project.org > Subject: [R] Barplot: Vertical bars with long labels > > Dear List, > I need a barplot with vertical bars. Each bar should have a label. > The problem is, that the labels are too long, so they > overlap, or only every seccond label is displayed in the output. > > Here is a little syntax: > > dd <- c(100,110,90,105,95) > barplot(dd,names.arg=c('Conduct Disorders','Attention Deficit', >'Eating Disorders', >'Substance Abuse','Developmental Disorders')) > > My question is, if there is a chance to force a line break in > each label. > > The result shoud look like this: > > Bar1Bar2 Bar3 Bar4 Bar5 > ConductAttentionEating Substance Developmental > Disorders Disorders Disorders AbuseDisorders > > > > The result could also look like this: > > Bar1 Bar2 Bar3 Bar4 Bar5 >|| || | > Conduct Disorders |Eating Disordes| > Developmental Disordes > | | > Attention deficit Substance Abuse > > > > > Many thanks in advance > Udo > > > > > Udo KN G > Ö I > > Clinic for Child an Adolescent Psychiatry Philipps University > of Marburg / Germany > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Barplot: Vertical bars with long labels
Try this: nm <- c('Conduct Disorders','Attention Deficit', 'Eating Disorders','Substance Abuse','Developmental Disorders') barplot(dd, names.arg = gsub(" ", "\n", nm)) On Wed, Oct 29, 2008 at 4:43 PM, Udo <[EMAIL PROTECTED]> wrote: > Dear List, > I need a barplot with vertical bars. Each bar should have a label. > The problem is, that the labels are too long, so they overlap, or > only every seccond label is displayed in the output. > > Here is a little syntax: > > dd <- c(100,110,90,105,95) > barplot(dd,names.arg=c('Conduct Disorders','Attention Deficit', > 'Eating Disorders', > 'Substance Abuse','Developmental Disorders')) > > My question is, if there is a chance to force a line break in each label. > > The result shoud look like this: > > Bar1Bar2 Bar3 Bar4 Bar5 > ConductAttentionEating Substance Developmental > Disorders Disorders Disorders AbuseDisorders > > > > The result could also look like this: > > Bar1 Bar2 Bar3 Bar4 Bar5 > || || | > Conduct Disorders |Eating Disordes|Developmental Disordes >| | > Attention deficit Substance Abuse > > > > > Many thanks in advance > Udo > > > > > Udo KN G > Ö I > > Clinic for Child an Adolescent Psychiatry > Philipps University of Marburg / Germany > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with Plots
Hi there, I am trying to have a connectivity graph (two plots at once) in R: this is an example: x1=sin((0:100)*2*pi/100) y1=cos((0:100)*2*pi/100) plot(x1,y1) will draw a circle and x2=c(1,9,3,4,8,4,2,0) y2=c(3,6,8,2,4,1,9,6) plot(x2,y2,type="b") will draw a graph with corresponding x's and y's and connects the point. I want to have a circle with these points connected to each other inside the circle. is it possible to do it in R? Thanks -- View this message in context: http://www.nabble.com/Help-with-Plots-tp20233489p20233489.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Barplot: Vertical bars with long labels
Dear List, I need a barplot with vertical bars. Each bar should have a label. The problem is, that the labels are too long, so they overlap, or only every seccond label is displayed in the output. Here is a little syntax: dd <- c(100,110,90,105,95) barplot(dd,names.arg=c('Conduct Disorders','Attention Deficit', 'Eating Disorders', 'Substance Abuse','Developmental Disorders')) My question is, if there is a chance to force a line break in each label. The result shoud look like this: Bar1Bar2 Bar3 Bar4 Bar5 ConductAttentionEating Substance Developmental Disorders Disorders Disorders AbuseDisorders The result could also look like this: Bar1 Bar2 Bar3 Bar4 Bar5 || || | Conduct Disorders |Eating Disordes|Developmental Disordes | | Attention deficit Substance Abuse Many thanks in advance Udo Udo KN G Ö I Clinic for Child an Adolescent Psychiatry Philipps University of Marburg / Germany __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Suppressing internal grid in filled.contour
Ok, I've placed the input files and the PDF on a website (I apologize for attaching the PDF -- the readme guide for this listserv indicated that PDFs were fine): http://www.cstars.ucdavis.edu/~jongreen/temp/ The full suite of commands I used are: tahoecontourdata<-read.csv("tahoedata02.csv",header=TRUE) x=tahoecontourdata$Elevation_Bin y=tahoecontourdata$PRR z=tahoecontourdata$MaxStems tahoelinedata<-read.csv("tahoelines02.csv",header=TRUE) xline=tahoelinedata$Elevation yline=tahoelinedata$PRR filled.contour(interp(x,y,z,duplicate="strip",xo=seq(1800,3200,length=57),yo=seq(120,280,length=65)),col=grey.colors(33,start=0,end=1,gamma=1),nlevels=33,zlim=0:650,plot.axes={axis(1);axis(2);points(xline,yline,type="l")}) As you can see in the PDF, there is a faint internal grid that I can't seem to disable. Thanks again! --j Dieter Menne wrote: Jonathan Greenberg ucdavis.edu> writes: ..faint internal grid when running the following command to make a filled contour plot of some data I have (x,y,z being the inputs): filled.contour(interp(x,y,z,duplicate="strip", xo=seq(1800,3200,length=57), yo=seq(120,280,length=65)), col=grey.colors(33,start=0,end=1,gamma=1),nlevels=33,zlim=0:650, plot.axes={axis(1);axis(2);points(xline,yline,type="l")}) The output is attached to this email via pdf -- I'm using R 2.8.0 on MacOS X. Thanks for any help you all can give me! Please do not send attachments, most people cannot see this. Instead, better use self-running code, including simulated data. The above line does not run (probably because of bad formatting?) For a similar case, check http://finzi.psych.upenn.edu/R/Rhelp02a/archive/90744.html Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jonathan A. Greenberg, PhD Postdoctoral Scholar Center for Spatial Technologies and Remote Sensing (CSTARS) University of California, Davis One Shields Avenue The Barn, Room 250N Davis, CA 95616 Cell: 415-794-5043 AIM: jgrn307, MSN: [EMAIL PROTECTED], Gchat: jgrn307 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ANOVA and T-test with means and SEs as imput
Dear friends I am analysing the leaf expansion of a grass species and am interested in the speed of expansion. I produced exponential models for each of the treatments and got the equation for leaf size in function of time. I want to compare the coeficients that gives the initial inclination of the exponential curve, but as they are result of the previous modelling, I have them as means and SE. Is it possible tu run an ANOVA or a T-test in R using the means and SEs as imputs instead of the raw data? Thanks a lot for the help. Best Wishes -- MSc José Alberto F. Monteiro Botanisches Institut Universität Basel [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] reporting interactions of factors in linear mixed effects models
Hi, I have a question about how I should report the results for a linear mixed effects model where the model includes as predictors three factors (facA, facB and facC), one of which (facA) interacts with the other two. facA and facB have two levels and facC has 3 levels. There are also several other continuous predictors (e.g. varA, varB, varC). My mixed model is specified with the following formula: model <- lmer(RT~ facA*facB*facC - facA:facB:facC - facB:facC ++ varA + varB + varC + ... + (1|subject) + (1| item), data=alldata) Here are the estimates of the fixed effects: Estimate Std.Err t.valuepMCMC (Intercept)0.896 0.038 23.3460.000 facA2 -0.011 0.054 -0.2040.811 facB2 -0.024 0.007 -3.6560.000 facC2 0.099 0.012 8.0400.000 facC3 0.160 0.011 14.4280.000 var1 0.025 0.004 5.9500.000 var2 0.022 0.004 5.1700.000 var3 -0.010 0.004 -2.4460.014 ... facA2:facB20.018 0.008 2.1630.031 facA2:facC20.035 0.011 3.2680.001 facA2:facC30.045 0.010 4.7080.000 And here is the analysis of variance table, obtained with aovlmer.fnc in the languageR package: DfSum Sq Mean Sq F valueFDf2 p facA 1 1.469e-02 1.469e-02 0.3841 0.3841 9225.0 0.5 facB 1 0.7 0.7 18.1221 18.1221 9225.0 2.092e-05 facC 2 14.4 7.2 188.8753 188.8753 9225.0 0.0 varA 1 1.4 1.4 36.7171 36.7171 9225.0 1.419e-09 varB 1 1.1 1.1 28.5398 28.5398 9225.0 9.398e-08 varC 1 0.2 0.2 5.2951 5.2951 9225.0 2.141e-02 ... facA:facB 1 0.1 0.1 3.8429 3.8429 9225.0 4.552e-15 facA:facC 2 0.9 0.4 11.5971 11.5971 9225.0 1.419e-09 For simpler models with no interactions and one 2-level factor, I am only reporting the estimates, t-values and p-values. However, since in this model there are two coefficients associated with the facA x facC interaction, I believe I should report the F-statistic in this case as this tells us whether the interaction overall is significant (e.g. as in Section 7.2.2 in Baayen's textbook). However, since the anova table is calculated stepwise, how do I decide whether facB should appear before facC in the model specification (the F values depends on the order)? Also, the contrast coefficients for facA, facB and facC in the model above are dependent on what the reference levels of those factors are. Is it meaningful to explore the simple effects of the factors by using relevel() to change the reference level of the factors? Finally, why does aovlmer.fnc only give p-vales with one significant digit in some cases (e.g. the p-value for facA is 0.5)? Thanks in advance for any advice you can give me, it will be appreciated greatly. Barry. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Constrained panel linear regression
Hi, I would like to impose an inequality constraint on one of the regression parameters of a panel linear model. How can I do that? Thanks for your help, Sara _ [[elided Hotmail spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Installation: not creating necessary directories
I have tried installing R on a web server on which I have a user account but not root access. I checked and the PERL, Fortran, etc. prerequisites all seem in order. The compiling of R with: % ./configure --with-x=no This works fine without errors. I try a "make check", however, and soon get an error as it cannot find files which should have been made. Most of the files seem to have come through though. ... collecting examples for package 'base' ... make[5]: Entering directory `/home/USERACCOUNT/mybin/R-2.8.0/src/library' /bin/sh: ../../bin/R: No such file or directory make[5]: *** [Rdfiles] Error 127 make[5]: Leaving directory `/home/USERACCOUNT/mybin/R-2.8.0/src/library' file ../../library/base/R-ex cannot be opened at ../../share/perl/massage-Examples.pl line 136. ... Is there any advice on what might be happening or on what I might need to do? Thanks, Tim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] behavior of "by"
Again thanks for the input. I've been a recipient of this list for quite a few years although I don't post often. It is an invaluable resource and I appreciate the effort of all the contributors. I support a lot of software so I know how much work it can be. I've seen the "reproducible code" at the bottom of the messages but until I got an off-list explanation I had no idea that it meant an example in which the "code AND data can be copied and pasted directly into R". I re-read the posting guide and it does suggest providing an example. Adding a definition for "reproducible code" might help. I've always interpreted "reproducible" to mean an example that can be used to "reproduce" the error. However, that is a bit of a catch-22 because in my case I couldn't reproduce it with a simple example because I didn't know what to reproduce. I could demonstrate it within my own code. It didn't make sense until I used str() on the dataframe. Sometimes what is needed is some insight about what to look for. Now that I understand the problem, below is the "reproducible code and data" df=data.frame(x=rep(1,3),y=tapply(1:9,factor(c(rep("A",3),rep("B",3),rep("C",3))),sum)) df by(df$y,df$x,length) tapply(df$y,df$x,length) As suggested table(df$x) would have been the more tidy solution for what I wanted to do. regards --jeff Sebastian P. Luque wrote: On Tue, 28 Oct 2008 18:04:57 -0700, Jeff Laake <[EMAIL PROTECTED]> wrote: Any insight into the behavior of "by" in the following case would be appreciated. There is a note in the help details for "by" about documenting behavior since v2.7 but I don't entirely understand what it is saying. I'm using R2.7.2 Windows. I'm interested if the following behavior was a change or whether it has always worked this way. I looked at RSiteSearch and read through version changes but found nothing. Take a dataframe as follows: samples Region.Label Area Sample.Label Effort Label 1 1 1 1 100 11 2 1 1 2 100 12 3 1 1 3 100 13 4 1 1 4 100 14 5 1 1 5 100 15 6 1 1 6 100 16 7 1 1 7 100 17 8 1 1 8 100 18 9 1 1 9 100 19 10 1 1 10 100 110 I cannot reproduce your results (please provide reproducible code), but: table(samples$Region.Label) is simpler for this purpose. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] SAS - surveyselect in R?
Hi Markus, is there a R function or package containing a similar functionality then the SAS PROC SURVEYSELECT? I think you need the sampling package http://cran.r-project.org/web/packages/sampling/index.html It is a package accompanying the book Tillé, Y. (2006). Sampling Algorithms, New York: Springer. Kind regards, Tobias P.S. for the analysis itself, your best choice is the survey package by Thomas Lumley: http://cran.r-project.org/web/packages/survey/index.html Thanks Markus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error using fitting weibull distribution to some data
Dear R-users, Using Maximum-likelihood Fitting (fitdistr function) I've got the next error: > fitdistr(datos,"weibull",lower=0) Error in optim(x = c(1.4625e-06, 0.257854, 0.0001217545, 0.11421005, 0.028721576, : L-BFGS-B *needs finite values of 'fn' * where "datos" is a vector of length=1000 between 1.4625e-06 and 0.8867114 I add the lower argument in order to avoid dweibull produce "NaNs".If I don't add the lower argument, the call to fitdistr returns the parameter estimates with the warning messages below: Warning message: In dweibull(x, shape, scale, log) : Se han producido NaNs Does anyone know how to use fitdistr using the lower parameter to avoid warnings and avoid the error in optim? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] difficulties in reading a .prn file
jim holtman wrote: > I would guess that your separator is not really a tab like you think > it is. Take a small subset of the data, bring it up in a text editor, > check the contents and then try to read it. Always start small to see > if it is working the way you think it should. Also it seem to have a > header, so why are you ignoring it? It may make your numeric columns > look like factors which is probably not want you want. Also, there seems to be 38 columns, not 29... Does it not work with plain whitespace separation?, i.e.: read.table("file.prn", header=T, na.strings="*") > On Wed, Oct 29, 2008 at 12:19 PM, <[EMAIL PROTECTED]> wrote: >> Hello, >> >> I am having problems in reading appropriately a huge .prn file of almost >> 450.000 rows and 29 columns. >> The variables are consisted of characters, dates, time, numeric values. >> I use read.table("file.prn", header=F, sep="\t", na.strings="*"), where the >> missing values are declared as "*". >> The R engine is reading it like it, but when I am asking for the dimensions >> of the data frame I get the right number of rows but only 1 column... >> dim(file) >> [1] 422344 1 >> >> It is somehow as it reads the whole row as one column. >> When I am asking for the first 3 lines for example I got the message that R >> is reading everything as factors and I get something like this below: >> >> data12L[1:3,] >> ID DATETime RRR VEl Leng Weig Sub >> var1 var2 var3 var4 var5 var6 var7 var8 >> var9var10var11var12var13var14var15VAR1VAR2 >> VAR3VAR4VAR5VAR6VAR7VAR8VAR9 VAR10 VAR11 >> VAR12 VAR13 VAR14 VAR15 >> [2] 54678611 39356 0.1572569RW 892014 >> 21400 V11A11 4500 7200 4700 5000 * >>* * * * * * * >> * * * 0 527 594 567 * >>* * * * * * * * >> * * >> [3] 54678612 39356 0.158RW 811716 >> 33000 T11O3 7100 9100 5700 5600 5500 >> * * * * * * * >> * * * 0 397 605 133 133 >> * * * * * * * * >>* * >> >> 422344 Levels:ID DATETime RRR VEl >> LengWeig Sub var1 var2 var3 var4 var5 >> var6 var7 var8 var9var10var11var12var13 >> var14var15VAR1VAR2VAR3VAR4VAR5VAR6VAR7 >> VAR8VAR9 VAR10 VAR11 VAR12 VAR13 VAR14 VAR15 .. >> >> Is there any solution? Any suggestion? >> And what is going on with the "*"? Is there any suggestion for this as >> well??? >> Thanks for your time! >> >> Ismini >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > > -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] difficulties in reading a .prn file
On Wed, Oct 29, 2008 at 06:19:51PM +0200, [EMAIL PROTECTED] wrote: > I am having problems in reading appropriately a huge .prn file of almost > 450.000 rows and 29 columns. The variables are consisted of characters, > dates, time, numeric values. I use read.table("file.prn", header=F, > sep="\t", na.strings="*"), where the missing values are declared as "*". The > R engine is reading it like it, but when I am asking for the dimensions of > the data frame I get the right number of rows but only 1 column... > dim(file) > [1] 422344 1 The most likely explanation is that your file is not tab separated. > And what is going on with the "*"? Is there any suggestion for this as well??? That should work fine as soon as you figure out the correct value for sep. BTW: your outpu looks like you want to use header=T. cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://mips.gsf.de/staff/pagel __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] difficulties in reading a .prn file
I would guess that your separator is not really a tab like you think it is. Take a small subset of the data, bring it up in a text editor, check the contents and then try to read it. Always start small to see if it is working the way you think it should. Also it seem to have a header, so why are you ignoring it? It may make your numeric columns look like factors which is probably not want you want. On Wed, Oct 29, 2008 at 12:19 PM, <[EMAIL PROTECTED]> wrote: > > Hello, > > I am having problems in reading appropriately a huge .prn file of almost > 450.000 rows and 29 columns. > The variables are consisted of characters, dates, time, numeric values. > I use read.table("file.prn", header=F, sep="\t", na.strings="*"), where the > missing values are declared as "*". > The R engine is reading it like it, but when I am asking for the dimensions > of the data frame I get the right number of rows but only 1 column... > dim(file) > [1] 422344 1 > > It is somehow as it reads the whole row as one column. > When I am asking for the first 3 lines for example I got the message that R > is reading everything as factors and I get something like this below: > > data12L[1:3,] > ID DATETime RRR VEl Leng Weig Sub > var1 var2 var3 var4 var5 var6 var7 var8 var9 >var10var11var12var13var14var15VAR1VAR2VAR3 >VAR4VAR5VAR6VAR7VAR8VAR9 VAR10 VAR11 VAR12 > VAR13 VAR14 VAR15 > [2] 54678611 39356 0.1572569RW 892014 > 21400 V11A11 4500 7200 4700 5000 * > * * * * * * * * > * * 0 527 594 567 * > * * * * * * * * > * * > [3] 54678612 39356 0.158RW 811716 > 33000 T11O3 7100 9100 5700 5600 5500 > * * * * * * * * > * * 0 397 605 133 133 > * * * * * * * * > * * > > 422344 Levels:ID DATETime RRR VEl > LengWeig Sub var1 var2 var3 var4 var5 > var6 var7 var8 var9var10var11var12var13var14 > var15VAR1VAR2VAR3VAR4VAR5VAR6VAR7VAR8 > VAR9 VAR10 VAR11 VAR12 VAR13 VAR14 VAR15 .. > > Is there any solution? Any suggestion? > And what is going on with the "*"? Is there any suggestion for this as well??? > Thanks for your time! > > Ismini > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] SAS - surveyselect in R?
Hello, is there a R function or package containing a similar functionality then the SAS PROC SURVEYSELECT? Thanks Markus __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] difficulties in reading a .prn file
Hello, I am having problems in reading appropriately a huge .prn file of almost 450.000 rows and 29 columns. The variables are consisted of characters, dates, time, numeric values. I use read.table("file.prn", header=F, sep="\t", na.strings="*"), where the missing values are declared as "*". The R engine is reading it like it, but when I am asking for the dimensions of the data frame I get the right number of rows but only 1 column... dim(file) [1] 422344 1 It is somehow as it reads the whole row as one column. When I am asking for the first 3 lines for example I got the message that R is reading everything as factors and I get something like this below: data12L[1:3,] ID DATETime RRR VEl Leng Weig Sub var1 var2 var3 var4 var5 var6 var7 var8 var9 var10var11var12var13var14var15VAR1VAR2VAR3 VAR4VAR5VAR6VAR7VAR8VAR9 VAR10 VAR11 VAR12 VAR13 VAR14 VAR15 [2] 54678611 39356 0.1572569RW 892014 21400 V11A11 4500 7200 4700 5000 * * * * * * * * * * * 0 527 594 567 * * * * * * * * * * * [3] 54678612 39356 0.158RW 811716 33000 T11O3 7100 9100 5700 5600 5500 * * * * * * * * * * 0 397 605 133 133 * * * * * * * * * * 422344 Levels:ID DATETime RRR VElLeng Weig Sub var1 var2 var3 var4 var5 var6 var7 var8 var9var10var11var12var13var14var15 VAR1VAR2VAR3VAR4VAR5VAR6VAR7VAR8VAR9 VAR10 VAR11 VAR12 VAR13 VAR14 VAR15 .. Is there any solution? Any suggestion? And what is going on with the "*"? Is there any suggestion for this as well??? Thanks for your time! Ismini __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problem with "simtest"
Hello all I am working with the package multcomp but I have problems with the function simtest; the program say that can not find this function, nevertheless I doesn't have any problem with the function glht that it is in the same package. Someone knows what could be the problem? Thank you [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Propagate vector attributes to data frame
Hello, I've got a function that takes a numeric vector (x), computes a transformation value (myAttr) for x, transforms x according to myAttr and then sets myAttr as an attribute of x before returning x, so I can easily know what myAttr was used (basically it's a power transformation and myAttr is the lambda). myFunction.numeric <- function(x, ...) { myAttr <- calcMyAttr(x, ...) x <- myTransform(x, myAttr, ...) attr(x, "myAttr") <- myAttr return(x) } To apply it over several columns of a data.frame, I have the following function: myFunction.data.frame <- function(df, ...) { df <- apply(df, 2, myFunction , ...) } myDataFrame[cols] <- myFunction(myDataFrame[cols]) Unfortunately, it seems to me that the attributes set in myFunction are not transferred into the data frame. At least I can't figure out how to extract them. attributes(myDataFrame$myColum) is NULL and there is nothing in attributes(myDataFrame) that looks like a possible myAttr. Is there a way so that attributes of numeric vectors could be kept in the data.frame? Thanks in advance, Xavier Robin -- Xavier Robin Biomedical Proteomics Research Group (BPRG) Department of Structural Biology and Bioinformatics (DBSB) Geneva University Medical Center (CMU) 1, rue Michel Servet - CH-1211 Genève 4 - Switzerland Tel: (+41 22) 379 53 21 Fax: (+41 22) 379 59 84 [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] strptime and strftime
?strptime gives the percent codes and R News 4/1 has an article on dates with a table at its end containing many examples. On Wed, Oct 29, 2008 at 11:03 AM, Santosh <[EMAIL PROTECTED]> wrote: > Dear R experts.. > > I am trying to understand what exactly strptime and strftime do... > Where can I look for the detailed notes on these two functions? In addition, > how POSIX functions like POSIXct and POSIXlt are used in these functions? > > Regards, > Santosh > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] strptime and strftime
Dear R experts.. I am trying to understand what exactly strptime and strftime do... Where can I look for the detailed notes on these two functions? In addition, how POSIX functions like POSIXct and POSIXlt are used in these functions? Regards, Santosh [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Distributions Comparison REFORMULATED
Dear all, Yes, indeed my knowledge in statistics is rather limited, but let me reformulate my question. I have two samples (V1 and V2) of measurements of observed physical values( v1_i and v2_i). Each value in the samples is measured with an error (err_i), so it is in interval (v1_i-err_i, v1_i+err_i) for V1 sample, (v2_i-err_i, v2_i+err_i) for V2 sample. I need to know the probability of that these two samples have been drawn from the same distribution . I have already applied KS test (realized in CERN ROOT), but in the standard case it deals only with the values themselves (v1_i and v2_i) measuring the distance between their cumulatives. I would like to know if there a coded routine in any R package that could take into account errors (err_i) of EACH separate measurement (v1_i and v2_i) in my samples (V1 and V2). If there is no such routine, maybe you have an idea what algorithm (method) to apply for my problem. Thank you and regards, Igor. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get the duplicated elements from a vector?
On Wed, Oct 29, 2008 at 3:45 PM, Erik Iverson <[EMAIL PROTECTED]> wrote: > > > Leon Yee wrote: >> >> Gustaf Rydevik wrote: >>> Hi Leon, >>> >>> unique(x) >>> >>> or >>> >>> duplicated(x) >>> >>> should work, depending on what you want. >>> >>> Best, >>> >>> Gustaf >>> >> >> Hi, >>Thank you all. Actually, I have a data frame or matrix, whose first >> column is numerical values, and whose 2nd column is names. > > Then you have a data.frame, as matrices in R are of homogeneous type. > >>I need those >> whose names repeated 3 times and get the mean of the 3 values for each >> repeated names. >> >>It sounds that I need some programming work. > > Yes, but not much > > ## BEGIN R CODE > ## guarantees there is at least one level with exactly three elements, > ## which your problem seems to require > t1 <- data.frame(a = rnorm(10), b = c("D", "D", "D", sample(LETTERS[1:3], 7, > replace = TRUE))) > > ## find which names have exactly three elements > t2 <- subset(t1, b %in% names(which(table(t1$b) == 3))) > > ## note that the elements of the returned value depend on what was > ## originally in your data set's 'b' column > tapply(t2$a, t2$b, mean) > > ## END R CODE > I'm always forgetting about the "ave" function. Using that one, here's another way: temp<-data.frame(Num=sample(1:1000,100),Names=sample(letters[1:25],100,replace=T)) temp$count<-ave(rep(1,nrow(temp)),temp$Names,FUN=sum) temp$MeanOfThree[temp$count==3]<- ave(temp$Num[temp$count==3],temp$Names[temp$count==3]) /Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with impute.knn
ear all, This is my first time using this listserv and I am seeking help from the expert. OK, here is my question, I am trying to use impute.knn function in impute library and when I tested the sample code, I got the error as followingt: Here is the sample code: library(impute) data(khanmiss) khan.expr <- khanmiss[-1, -(1:2)] ## ## First example ## if(exists(".Random.seed")) rm(.Random.seed) khan.imputed <- impute.knn(as.matrix(khan.expr)) ## ## khan.imputed$data should now contain the imputed data matrix x<-khan.imputed$data Here are the results: > library(impute) > data(khanmiss) > khan.expr <- khanmiss[-1, -(1:2)] > ## ## First example > ## if(exists(".Random.seed")) rm(.Random.seed) > khan.imputed <- impute.knn(as.matrix(khan.expr)) Cluster size 2308 broken into 1448 860 Done cluster 1448 Done cluster 860 > ## ## khan.imputed$data should now contain the imputed data matrix > x<-khan.imputed$data Error in khan.imputed$data : $ operator is invalid for atomic vectors It seems that khan.imputed$data is empty!! Why is that?? Any help is appreciated, Jianying Li __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get the duplicated elements from a vector?
Leon Yee wrote: > > Gustaf Rydevik wrote: >> Hi Leon, >> >> unique(x) >> >> or >> >> duplicated(x) >> >> should work, depending on what you want. >> >> Best, >> >> Gustaf >> > > Hi, >Thank you all. Actually, I have a data frame or matrix, whose first > column is numerical values, and whose 2nd column is names. Then you have a data.frame, as matrices in R are of homogeneous type. >I need those > whose names repeated 3 times and get the mean of the 3 values for each > repeated names. > >It sounds that I need some programming work. Yes, but not much ## BEGIN R CODE ## guarantees there is at least one level with exactly three elements, ## which your problem seems to require t1 <- data.frame(a = rnorm(10), b = c("D", "D", "D", sample(LETTERS[1:3], 7, replace = TRUE))) ## find which names have exactly three elements t2 <- subset(t1, b %in% names(which(table(t1$b) == 3))) ## note that the elements of the returned value depend on what was ## originally in your data set's 'b' column tapply(t2$a, t2$b, mean) ## END R CODE > > Regards, > Leon > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get the duplicated elements from a vector?
Dear Leon, It's not the most efficient way but it works. Hopefully someone else will come up with another approach. Here a toy example: 1. calculate the mean for each name in your second column by using tapply or others, 2. determinate which names are repeated >= 2 times, 3. match the names of the mean you estimated in number 1 with the names in number 2 and 4. extract the elements: # Data set set.seed(123) mydata=data.frame(value=rnorm(6), Names= c("yes", "no", "yes", "yes", "no", "not sure")) # mean Mean=tapply(mydata$value,mydata$Names,mean) # which names have frequencies >= 2 and match index=names(Mean)%in%names(table(mydata$Names))[table(mydata$Names)>=2] # extracting the elements Mean[index] no yes -0.05044488 0.35624702 HTH, Jorge On Wed, Oct 29, 2008 at 10:19 AM, Leon Yee <[EMAIL PROTECTED]> wrote: > > Gustaf Rydevik wrote: > >> Hi Leon, >> >> unique(x) >> >> or >> >> duplicated(x) >> >> should work, depending on what you want. >> >> Best, >> >> Gustaf >> >> > Hi, > Thank you all. Actually, I have a data frame or matrix, whose first > column is numerical values, and whose 2nd column is names. I need those > whose names repeated 3 times and get the mean of the 3 values for each > repeated names. > > It sounds that I need some programming work. > > Regards, > Leon > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get the duplicated elements from a vector?
Gustaf Rydevik wrote: Hi Leon, unique(x) or duplicated(x) should work, depending on what you want. Best, Gustaf Hi, Thank you all. Actually, I have a data frame or matrix, whose first column is numerical values, and whose 2nd column is names. I need those whose names repeated 3 times and get the mean of the 3 values for each repeated names. It sounds that I need some programming work. Regards, Leon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get the duplicated elements from a vector?
On Wed, Oct 29, 2008 at 2:47 PM, Leon Yee <[EMAIL PROTECTED]> wrote: > Dear all, > >How can I get the duplicated elements from a vector? For example, > x <- c("yes", "no", "yes", "yes", "no", "not sure"), how can I filter out > all the elements which occured >=2 times? > >Thanks for any help! > > Regards, > Leon > Hi Leon, unique(x) or duplicated(x) should work, depending on what you want. Best, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get the duplicated elements from a vector?
check duplicated(), e.g., x <- c("yes", "no", "yes", "yes", "no", "not sure") x[duplicated(x)] I hope it helps. Best, Dimitris Leon Yee wrote: Dear all, How can I get the duplicated elements from a vector? For example, x <- c("yes", "no", "yes", "yes", "no", "not sure"), how can I filter out all the elements which occured >=2 times? Thanks for any help! Regards, Leon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] builtin to filter a list?
?Filter ... how did I miss that one? Thanks, Gabor. -Whit On Wed, Oct 29, 2008 at 9:37 AM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Try: > > ?Filter > > e.g. > > Filter(function(x) x > 0, x1) > > or using gsubfn's fn > > library(gsubfn) > fn$Filter(~ x > 0, x1) > > > On Wed, Oct 29, 2008 at 9:06 AM, Whit Armstrong > <[EMAIL PROTECTED]> wrote: >> I know it's easy to write a simple loop to do this, but in the spirit >> of lapply, I thought I would ask if there is a builtin to filter or >> take a subset of a list based on a predicate in a similar way to the >> Erlang lists:filter/2 function: >> >> http://www.erlang.org/doc/man/lists.html#filter-2 >> >> filter(Pred, List1) -> List2 >> Types: >> >> Pred = fun(Elem) -> bool() >> Elem = term() >> List1 = List2 = [term()] >> List2 is a list of all elements Elem in List1 for which Pred(Elem) returns >> true. >> >> I've tried the simple case in R already: >> >>> x <- rnorm(10) >>> xl <- as.list(x) >>> xl[[ x > 0]] >> Error in xl[[x > 0]] : attempt to select less than one element >>> >> >> Thanks, >> Whit >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get the duplicated elements from a vector?
Dear Leon, Perhaps: x <- c("yes", "no", "yes", "yes", "no", "not sure") names(table(x))[table(x)>=2] HTH, Jorge On Wed, Oct 29, 2008 at 9:47 AM, Leon Yee <[EMAIL PROTECTED]> wrote: > Dear all, > >How can I get the duplicated elements from a vector? For example, > x <- c("yes", "no", "yes", "yes", "no", "not sure"), how can I filter out > all the elements which occured >=2 times? > >Thanks for any help! > > Regards, > Leon > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to get the duplicated elements from a vector?
Dear all, How can I get the duplicated elements from a vector? For example, x <- c("yes", "no", "yes", "yes", "no", "not sure"), how can I filter out all the elements which occured >=2 times? Thanks for any help! Regards, Leon __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Recommended R books by XLSolutions Corporation
Peter Dalgaard wrote: >> Drats!! I almost thought that you had gotten a hold on the elusive >> problem of estimating the population of R users I suspect that the Higgs Boson will be observed well before we get reasonable estimates on that figure...just need to get the LHC back online... ;-) Regards, Marc __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] builtin to filter a list?
Try: ?Filter e.g. Filter(function(x) x > 0, x1) or using gsubfn's fn library(gsubfn) fn$Filter(~ x > 0, x1) On Wed, Oct 29, 2008 at 9:06 AM, Whit Armstrong <[EMAIL PROTECTED]> wrote: > I know it's easy to write a simple loop to do this, but in the spirit > of lapply, I thought I would ask if there is a builtin to filter or > take a subset of a list based on a predicate in a similar way to the > Erlang lists:filter/2 function: > > http://www.erlang.org/doc/man/lists.html#filter-2 > > filter(Pred, List1) -> List2 > Types: > > Pred = fun(Elem) -> bool() > Elem = term() > List1 = List2 = [term()] > List2 is a list of all elements Elem in List1 for which Pred(Elem) returns > true. > > I've tried the simple case in R already: > >> x <- rnorm(10) >> xl <- as.list(x) >> xl[[ x > 0]] > Error in xl[[x > 0]] : attempt to select less than one element >> > > Thanks, > Whit > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to restrict a parameter in optim()
Dear all, I'm trying to estimate some parameters with the optim() function but I need to restrict one parameter and I have not found how to do it. Could you help me please? my program is basically fn<-function(s) initial<-function(r) { cst<-r[1] cst1<-r[2] beta<-r[3] rho<-r[4] p1<-r[5] return(-sum()) } parms<-c() m0<-optim() I need to specify 0<=p1<=1. Thank you very much Luis SAGAON __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Selecting cases for a grouping value to refill x and y vectors
The variable "iter" from read.table takes on values of 0,5,10,15, and 20. I am trying to pick off values of iter by assigning it to "grp", and e.g. iter<-5, then fill the x and y vectors and make plots of x,y for each value of iter (>0) For some reason all of the plots are the same, so I am not changing x and y. Any sugestions on how to refill vectors x and y when iter takes on certain values? thx LP > > mydata<-read.table("C:/refvecs_iters_5.csv", header=TRUE, sep=",", na.strings="NA", dec=".", strip.white=TRUE, row.names=1) > > x <- runif(1000) > y <- runif(1000) > > summary(mydata) iter xinyin Min. : 0 Min. : 0.01792 Min. : 0.03055 1st Qu.: 5 1st Qu.: 3.10674 1st Qu.: 3.13284 Median :10 Median : 5.46899 Median : 5.43446 Mean :10 Mean : 5.43360 Mean : 5.39696 3rd Qu.:15 3rd Qu.: 7.70127 3rd Qu.: 7.70780 Max. :20 Max. :10.0 Max. :10.0 > > #plot(mydata$xin,mydata$yin) > > split.screen(c(2,2)) [1] 1 2 3 4 > > for (k in 1:4){ + + screen(k) + cnt <- 0 + grp<- mydata$iter * 5 + for (i in 1:5000 ) { + if (grp<-k*5) { + cnt = cnt + 1 + x[cnt] <- mydata$xin[i] + y[cnt] <- mydata$yin[i] + } + } + #p = cbind(x=rnorm(300), y=rnorm(300)) + #p = cbind(x, y) + #tt = delaunayn(p) + #trimesh(tt,p,axis=TRUE,box=TRUE) + plot(x,y) + } > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problem with impute.knn
Dear all, This is my first time using this listserv and I am seeking help from the expert. OK, here is my question, I am trying to use impute.knn function in impute library and when I tested the sample code, I got the error as followingt: Here is the sample code: library(impute) data(khanmiss) khan.expr <- khanmiss[-1, -(1:2)] ## ## First example ## if(exists(".Random.seed")) rm(.Random.seed) khan.imputed <- impute.knn(as.matrix(khan.expr)) ## ## khan.imputed$data should now contain the imputed data matrix x<-khan.imputed$data Here are the results: > library(impute) > data(khanmiss) > khan.expr <- khanmiss[-1, -(1:2)] > ## ## First example > ## if(exists(".Random.seed")) rm(.Random.seed) > khan.imputed <- impute.knn(as.matrix(khan.expr)) Cluster size 2308 broken into 1448 860 Done cluster 1448 Done cluster 860 > ## ## khan.imputed$data should now contain the imputed data matrix > x<-khan.imputed$data Error in khan.imputed$data : $ operator is invalid for atomic vectors It seems that khan.imputed$data is empty!! Why is that?? Any help is appreciated, Jianying Li __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Pkg rgl: installation fails because of x11
Dear Duncan, Ben and Megha Thank you for your help! I tried sudo apt-get build-dep r-cran-rgl And so all necessitated package were installed and I could install rgl.. nice! Mat I believe the correct incantation is: sudo apt-get build-dep r-cran-rgl If that doesn't work, get back to us Ben Bolker 2008/10/27 Duncan Murdoch <[EMAIL PROTECTED]> > Matthieu Stigler wrote: > >> Hello >> >> Im trying to install package rgl in a freshly installed Ubuntu 8.04 >> system. I have a problem (actually is has been reported three times on >> the R-list but the answers were too complicated for me) when >> installing: >> >> configure: using libpng dynamic linkage >> checking for X... no >> configure: error: X11 not found but required, configure aborted. >> ERROR: configuration failed for package 'rgl' >> ** Removing '/usr/local/lib/R/site-library/rgl' >> >> The downloaded packages are in >>/tmp/RtmpcnTzdW/downloaded_packages >> Warning message: >> In install.packages("rgl", dep = TRUE) : >> installation of package 'rgl' had non-zero exit status >> >> >> I see two potential explanations: >> -to use rgl I should install some OpenGl package... is it right? which one >> then? >> >> > > No, it's some X11 package you need to install, whichever one contains the > includes and development libraries. I'm not an Ubuntu user so I can't tell > you which one. BTW, rgl is now on R-forge, so you could post questions > there. > > > Duncan Murdoch > >> -rgl only needs x11 but does not find it. I see actually that there is >> no x11 in /usr/ but X11R6 does the problem come from that? >> >> PS: Im cross posting on R and rgl list >> >> Thank you for your help! >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >> > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Incorrect order
Hi, I believe Bart answered to your question. What is the solution you are expecting? If you don't give us more explanations we cannot understand what is wrong for you. > help(sort) |order| returns a permutation which rearranges its first argument into ascending or descending order, breaking ties by further arguments. |sort.list| is the same, using only one argument. See the examples for how to use these functions to sort data frames, etc. In the section "see also" of the help about sort there are the two functions sort and rank! > a<-c(20,30,15,40) > sort(a) [1] 15 20 30 40 > order(a) [1] 3 1 2 4 > rank(a) [1] 2 3 1 4 Alain lll73 wrote: > I am using the order function and the result seems to be incorrect: > > >> a<-c(20,30,15,40) >> order(a) >> > [1] 3 1 2 4 > > Any suggestions? > > Thanks, > Laura > > -- Alain Guillet Statistician and Computer Scientist Institut de statistique - Université catholique de Louvain Bureau d.126 Voie du Roman Pays, 20 B-1348 Louvain-la-Neuve Belgium tel: +32 10 47 30 50 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Incorrect order
Laura, Order works fine. The output tells you that the third element of a is the smallest, the first element is a second smallest, ... Try a[order(a)] that should be equal to sort(a). HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens lll73 Verzonden: woensdag 29 oktober 2008 12:18 Aan: r-help@r-project.org Onderwerp: [R] Incorrect order I am using the order function and the result seems to be incorrect: > a<-c(20,30,15,40) > order(a) [1] 3 1 2 4 Any suggestions? Thanks, Laura -- View this message in context: http://www.nabble.com/Incorrect-order-tp20224993p20224993.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Recommended R books by XLSolutions Corporation
I thought R users were measured in fractal dimensions...or is that fractious? On Wed, Oct 29, 2008 at 4:06 AM, Detlef Steuer <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > >> > >> > This is the bit where I get stuck. >> >> Drats!! I almost thought that you had gotten a hold on the elusive >> problem of estimating the population of R users >> > > We are legion! :-) > I admit: that doesn't help with calculations ... > \ -- Due to the recession, requests for instant gratification will be deferred until arrears in scheduled gratification have been satisfied. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Incorrect order
I am using the order function and the result seems to be incorrect: > a<-c(20,30,15,40) > order(a) [1] 3 1 2 4 Any suggestions? Thanks, Laura -- View this message in context: http://www.nabble.com/Incorrect-order-tp20224993p20224993.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Recommended R books by XLSolutions Corporation
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > > > > This is the bit where I get stuck. > > Drats!! I almost thought that you had gotten a hold on the elusive > problem of estimating the population of R users > We are legion! :-) I admit: that doesn't help with calculations ... Detlef > [] > > > > # David M Smith > > > > > -- >O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B > c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K > (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 > ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkIGaAACgkQ0g+Q+yDyuZg8pgCeJFlODWVLJm8AnDm4hLTRKtka zx0AnRmZFnZZp5I2m1APgBxqsY1L/Tqf =RC53 -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] builtin to filter a list?
I know it's easy to write a simple loop to do this, but in the spirit of lapply, I thought I would ask if there is a builtin to filter or take a subset of a list based on a predicate in a similar way to the Erlang lists:filter/2 function: http://www.erlang.org/doc/man/lists.html#filter-2 filter(Pred, List1) -> List2 Types: Pred = fun(Elem) -> bool() Elem = term() List1 = List2 = [term()] List2 is a list of all elements Elem in List1 for which Pred(Elem) returns true. I've tried the simple case in R already: > x <- rnorm(10) > xl <- as.list(x) > xl[[ x > 0]] Error in xl[[x > 0]] : attempt to select less than one element > Thanks, Whit __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] maximum device size
Hi, I would like to know how to get the maximum possible values that can be used for the dimensions of a device, For example windows(h=,w=), what are the maximum values that I can pass as parameters for w and h. environment info: platform: Windows XP SP2 R version: 2.7.1 Thanks Nishan Sugathadasa Indian Ocean Tuna Commission P.O.Box 1011 Victoria Mahe Seychelles www.iotc.org Tel: +(248) 225494 Fax : +248.224.364 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sessionInfo() error
[Using R 2.7.2 on Windows XP] After re-building our heplots package, I've begun to get the following error from sessionInfo(), even though it passes R CMD check and builds without errors: > sessionInfo() Error in x$Priority : $ operator is invalid for atomic vectors In addition: Warning message: In FUN(c("MASS", "heplots", "car", "rgl", "stats", "graphics", "grDevices", : DESCRIPTION file of package 'heplots' is missing or broken The DESCRIPTION file is as follows: Package: heplots Type: Package Title: Visualizing Tests in Multivariate Linear Models Version: 0.8-3 Date: 2008-10-28 Author: John Fox, Michael Friendly, and Georges Monette Maintainer: John Fox <[EMAIL PROTECTED]> Depends: car, graphics, stats Suggests: rgl, candisc LazyLoad: yes LazyData: yes Description: Represents sums-of-squares-and-products matrices for linear hypotheses and for error using ellipses (in two dimensions) and ellipsoids (in three dimensions). License: GPL version 2 or newer Packaged: Wed Jan 31 09:23:10 2007; John Fox What is wrong here? -Michael -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R rockie
For a good, extemely basic, tutorial see http://www.math.ilstu.edu/dhkim/Rstuff/Rtutor.html You might also want to have a look at http://zoonek2.free.fr/UNIX/48_R/all.html If you are familiar with SPSS or SAS then Bob Muenchen's paper in PDF form http://oit.utk.edu/scc/RforSAS&SPSSusers.pdf (or his new book) is very helpful. There are all kinds of good documentation available on the R site. Try the Books and Other links on the left side of the main R page. In the Books page there is a link to "other publications". Under the R documentation page ( link Other) you may want to try the "other documention" link. I personally find that Introduction to R is very useful but it is better read after you have read some of the really basic tutorial stuff. --- On Wed, 10/29/08, paul murima <[EMAIL PROTECTED]> wrote: > From: paul murima <[EMAIL PROTECTED]> > Subject: [R] R rockie > To: r-help@r-project.org > >- Is there a beginner's manual for R? >- How do i analyse gene expression data using R, to > generate a >dendrogram. > > I would greatlyy appreciate every bit of input. > -- > BEST > > Paul __ [[elided Yahoo spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with doing a manipulation on a column of a data frame based on another column
> #this is my stab at - I am sure that I am missing something. If this > doesn't make sense then please ask for more details. #This may show > my low level of programing knowledge > > hester. <- c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4) > value <- rnorm(16) > x <- data.frame(value, hester.) > > z <- > (if(x[,"hester."]==1){ > x[,"value"]*6.250} > else > if(x[,"hester."]==2){ > x[,"value"]*3.125} > else > if(x[,"hester."]==3){ > x[,"value"]*2.100} > else > if(x[,"hester."]==4){ > x[,"value"]*1.600}) Does this do what you want? > h <- rep(1:4,each=4) > z <- c(6.25,3.125,2.1,1.6)[match(h,1:4)] > x <- data.frame(hester.=h,value=z) cheers, Rolf Turner - I suspect some random values should be included, making the code : > h <- rep(1:4,each=4) > z <- c(6.25,3.125,2.1,1.6)[match(h,1:4)] > x <- data.frame(hester.=h,value=z*rnorm(16)) Kind regards Joris __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help using tapply with multiple variables
try this: lapply(split(dat, dat$country), function (x) { pres.test(x$pop1995, x$pop2000) }) I hope it helps. Best, Dimitris Corey Sparks wrote: Dear list, I have the function (as a simple example, which is actually part of a larger function) pres.test<-function(N0=N0, N1=N1) { dt<-5 r<-log(N1/N0)/dt r } which calculates the annual growth rates in a population Where N0 is the population classified into age intervals, say 5 years, at time=1995, and N1 is the population by 5 year age classes at time=2000. For example some data like this are: country pop1995 pop2000 1 17121940 1 13291535 1 11011268 1 9111048 1 758 859 2 627 710 2 513 584 2 420 475 2 754 965 2 638 741 I want to use the tapply function to apply the pres.test function over all countries in my data table (the real data have ~150 countries and 10 age classes), but I can't seem to get tapply to take as input to FUN more than one variable, for example I tried: popdat<-cbind(dat2.sub$pop1995, dat2.sub$pop2000) #try to force the two time points into a vector form tapply(popdat, dat2.sub$country, pres.test, ...=list(N0=popdat[,1], N1=popdat[,2])) #tried to pass the other arguments that pres.test needs via ... And got the error: Error in tapply(popdat, dat2.sub$Country, pres.test, ... = list(N0 = popdat[, : arguments must have same length I see that the function mapply will take multiple arguements, but I don't think it will use an INDEX like tapply. Any comments or clarification would be most appreciated. Corey -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help using tapply with multiple variables
Try this: split(mapply(function(x, y)pres.test(x, y), DF$pop1995, DF$pop2000), DF$country) On Wed, Oct 29, 2008 at 10:19 AM, Corey Sparks <[EMAIL PROTECTED]>wrote: > Dear list, > I have the function (as a simple example, which is actually part of a > larger function) > > pres.test<-function(N0=N0, N1=N1) > { >dt<-5 >r<-log(N1/N0)/dt >r > } > > which calculates the annual growth rates in a population > > Where N0 is the population classified into age intervals, say 5 years, at > time=1995, and N1 is the population by 5 year age classes at time=2000. > > For example some data like this are: > country pop1995 pop2000 > 1 17121940 > 1 13291535 > 1 11011268 > 1 9111048 > 1 758 859 > 2 627 710 > 2 513 584 > 2 420 475 > 2 754 965 > 2 638 741 > > I want to use the tapply function to apply the pres.test function over all > countries in my data table (the real data have ~150 countries and 10 age > classes), but I can't seem to get tapply to take as input to FUN more than > one variable, for example I tried: > > popdat<-cbind(dat2.sub$pop1995, dat2.sub$pop2000) #try to force the two > time points into a vector form > > tapply(popdat, dat2.sub$country, pres.test, ...=list(N0=popdat[,1], > N1=popdat[,2])) #tried to pass the other arguments that pres.test needs via > ... > > And got the error: > Error in tapply(popdat, dat2.sub$Country, pres.test, ... = list(N0 = > popdat[, : > arguments must have same length > > I see that the function mapply will take multiple arguements, but I don't > think it will use an INDEX like tapply. > > Any comments or clarification would be most appreciated. > > Corey > > -- > Corey Sparks > Assistant Professor > Department of Demography and Organization Studies > University of Texas at San Antonio > One UTSA Circle > San Antonio, TX 78249 > 210-458-6858 > [EMAIL PROTECTED] > https://rowdyspace.utsa.edu/users/ozd504/www/index.htm > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problem with tune.rpart()
Dear useRs, I am using the function tune.rpart() implemented in the e1071 package under R 2.7.1 on Windows XP. Sometimes, i.e., for some datasets, I get the following error: > tune.rpart(dataset, data = dataset, cp = c(.005,.01,.02)) > Error in table(pred, true.y) : all arguments must have the same length I am not able to understand the reason of it! Thanks in advance for any help! Regards, claudio [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help using tapply with multiple variables
Dear list, I have the function (as a simple example, which is actually part of a larger function) pres.test<-function(N0=N0, N1=N1) { dt<-5 r<-log(N1/N0)/dt r } which calculates the annual growth rates in a population Where N0 is the population classified into age intervals, say 5 years, at time=1995, and N1 is the population by 5 year age classes at time=2000. For example some data like this are: country pop1995 pop2000 1 17121940 1 13291535 1 11011268 1 9111048 1 758 859 2 627 710 2 513 584 2 420 475 2 754 965 2 638 741 I want to use the tapply function to apply the pres.test function over all countries in my data table (the real data have ~150 countries and 10 age classes), but I can't seem to get tapply to take as input to FUN more than one variable, for example I tried: popdat<-cbind(dat2.sub$pop1995, dat2.sub$pop2000) #try to force the two time points into a vector form tapply(popdat, dat2.sub$country, pres.test, ...=list(N0=popdat[,1], N1=popdat[,2])) #tried to pass the other arguments that pres.test needs via ... And got the error: Error in tapply(popdat, dat2.sub$Country, pres.test, ... = list(N0 = popdat[, : arguments must have same length I see that the function mapply will take multiple arguements, but I don't think it will use an INDEX like tapply. Any comments or clarification would be most appreciated. Corey -- Corey Sparks Assistant Professor Department of Demography and Organization Studies University of Texas at San Antonio One UTSA Circle San Antonio, TX 78249 210-458-6858 [EMAIL PROTECTED] https://rowdyspace.utsa.edu/users/ozd504/www/index.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R rockie
Paul, Look for the An Introduction to R on the CRAN - R web site. The latest version, as far as I know, is Version 2.7.2 (2008-08-25). You might also want to examine the R Data Import/Export doc Both can be found here : http://cran.r-project.org/doc/manuals.html Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 Office (305) 224 - 4282 [EMAIL PROTECTED] "paul murima" <[EMAIL PROTECTED] l.com> To Sent by: r-help@r-project.org [EMAIL PROTECTED] cc project.org Subject [R] R rockie 10/29/2008 04:57 PM ZE8 Help. - Is there a beginner's manual for R? - How do i analyse gene expression data using R, to generate a dendrogram. I would greatlyy appreciate every bit of input. -- BEST Paul [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to set read.table variables to vectors?
'xin' is an element of a dataframe and you must explicity reference it as such. See the Intro to R. plot(mydata$xin, mydata$yin) On Wed, Oct 29, 2008 at 4:29 AM, Leif Peterson <[EMAIL PROTECTED]> wrote: > The summary stats for the xin and yin variables below are correct. However, > if I use plot(xin,yin), an exception is thrown saying that "object xin is > not found." > > Also, it is apparent that I can't successfully replace the x and y vectors > with values from xin and yin. > > The four plots on one panel are showing but the range of x and y is only > [0,1], and therefore, it seems like an integer vs. real issue. Please help. > > Thanks, > > LP > > > >> >> mydata<-read.table("C:/refvecs_iters_5.csv", header=TRUE, sep=",", > na.strings="NA", dec=".", strip.white=TRUE, row.names=1) >> >> x <- runif(1000) >> y <- runif(1000) >> >> summary(mydata) > iter xinyin > Min. : 0 Min. : 0.01792 Min. : 0.03055 > 1st Qu.: 5 1st Qu.: 3.10674 1st Qu.: 3.13284 > Median :10 Median : 5.46899 Median : 5.43446 > Mean :10 Mean : 5.43360 Mean : 5.39696 > 3rd Qu.:15 3rd Qu.: 7.70127 3rd Qu.: 7.70780 > Max. :20 Max. :10.0 Max. :10.0 >> >> plot(xin,yin) > Error in plot(xin, yin) : object "xin" not found >> >> split.screen(c(2,2)) > [1] 1 2 3 4 >> >> for (k in 0:3){ > + > + screen(k+1) > + cnt <- 0 > + #grp<- iter * 5 > + for (i in 1:5000 ) { > + if (iter<-k*5) { > + cnt = cnt + 1 > + x[cnt] <- myx[i] > + y[cnt] <- myy[i] > + } > + } > + #p = cbind(x=rnorm(300), y=rnorm(300)) > + #p = cbind(x, y) > + #tt = delaunayn(p) > + #trimesh(tt,p,axis=TRUE,box=TRUE) > + plot(myx,myy) > + } >> >> > > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Incorrect order
What's wrong with that result? you should look at the result as: first take the 3th element of a, then the first one, than the second one and then the fourth. if you do a[order(a)] then you get 15,20,30,40. I suppose you expected: rank(a) [1] 2 3 1 4 Good luck Bart lll73 wrote: > > > I am using the order function and the result seems to be incorrect: > >> a<-c(20,30,15,40) >> order(a) > [1] 3 1 2 4 > > Any suggestions? > > Thanks, > Laura > > -- View this message in context: http://www.nabble.com/Incorrect-order-tp20224993p20225235.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Suppressing internal grid in filled.contour
Jonathan Greenberg ucdavis.edu> writes: > ..faint internal grid when running the following command to make a > filled contour plot of some data I have (x,y,z being the inputs): > > filled.contour(interp(x,y,z,duplicate="strip", xo=seq(1800,3200,length=57), yo=seq(120,280,length=65)), col=grey.colors(33,start=0,end=1,gamma=1),nlevels=33,zlim=0:650, plot.axes={axis(1);axis(2);points(xline,yline,type="l")}) > > The output is attached to this email via pdf -- I'm using R 2.8.0 on > MacOS X. Thanks for any help you all can give me! > Please do not send attachments, most people cannot see this. Instead, better use self-running code, including simulated data. The above line does not run (probably because of bad formatting?) For a similar case, check http://finzi.psych.upenn.edu/R/Rhelp02a/archive/90744.html Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.