[R] MS-VAR Introduction
Dear R community, I'm starting to learn the MS-VAR methodology and I would like to know what I need to download (e.g. packages) to make MS-VAR estimations using R. Best, Henrique C. de Andrade Doutorando em Economia Aplicada Universidade Federal do Rio Grande do Sul www.ufrgs.br/ppge [[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] MS-VAR Introduction
Dear R community, I'm starting to learn the MS-VAR methodology and I would like to know what I need to download (e.g. packages) to make MS-VAR estimations using R. Best, Henrique C. de Andrade Doutorando em Economia Aplicada Universidade Federal do Rio Grande do Sul www.ufrgs.br/ppge __ 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] A MS-VAR Introduction
Dear R community, I'm starting to learn the MS-VAR methodology and I would like to know what I need to download (e.g. packages) to make MS-VAR estimations using R. Best, -- Henrique C. de Andrade Doutorando em Economia Aplicada Universidade Federal do Rio Grande do Sul www.ufrgs.br/ppge __ 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] MS-VAR
Dear R users, I would like to estimate a MS-VAR where the probabilities of regime shifts are dependent of an exogenous variable. Is it possible to do this using R? Best, Henrique C. de Andrade Doutorando em Economia Aplicada Universidade Federal do Rio Grande do Sul www.ufrgs.br/ppge __ 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] Cumsum with a max and min value
I have a vector of values -1, 0, 1, say a <- c(0, 1, 0, 1, 1, -1, -1, -1, 0, -1, -1) I want to create a vector of the cumulative sum of this, but I need to set a maximum and minimum value for the cumsum, for example: max_value <- 2 min_value <- -2 the expected result would be (0, 1, 1, 2, 2, 1, 0, -1, -1, -2, -2) The only way I managed to do It, was res <- vector(length=length(a)) res[1] <- a[1] for ( i in 2:length(a)) res[i] <- res[i-1] + a[i] * (( res[i-1] < max_value & a[i] > 0 ) | ( res[i-1] > min_value & a[i] < 0 )) This is certainly not the best way to do it, so any suggestions? Henrique [[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] RES: Cumsum with a max and min value
Worked fine Gabor, thanks! I just removed the init argument from the Reduce function and I got it without the first 0. Henrique -Mensagem original- De: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Enviada em: quinta-feira, 25 de novembro de 2010 22:13 Para: henrique Cc: r-help@r-project.org Assunto: Re: [R] Cumsum with a max and min value On Thu, Nov 25, 2010 at 3:44 PM, henrique wrote: > I have a vector of values -1, 0, 1, say > > a <- c(0, 1, 0, 1, 1, -1, -1, -1, 0, -1, -1) > > I want to create a vector of the cumulative sum of this, but I need to set a > maximum and minimum value for the cumsum, for example: > > max_value <- 2 > min_value <- -2 > the expected result would be (0, 1, 1, 2, 2, 1, 0, -1, -1, -2, -2) > Try this: f <- function(x, y) max(min(x + y, max_value), min_value) Reduce(f, a, 0, accumulate = TRUE)[-1] -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.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] replace NAs in each column of a matrix with 0 or 1 or 2 with specific proportion
Maybe you can use something like this In this way, almost your proportion of 0, 1 and 2 will be maintained m <- matrix(sample(c(NA, 0:2), size = 50*100, replace = TRUE), nrow = 50, ncol = 100) trunc(prop.table(apply(m, 2, table), 2) * colSums(is.na(m)), 0) m[is.na(m)] <- unlist(apply(trunc(prop.table(apply(m, 2, table), 2) * colSums(is.na(m)), 0), 2, rep, x = 0:2)) On Mon, Jun 6, 2016 at 5:38 PM, Lida Zeighami wrote: > Hello specialist, > > I have a matrix in which there are NA,0,1 and 2 in each columns. > I wanna replace NAs with special proportion of 0,1 or 2 ! > for example in df<- matric(df, nrow=50, ncol=100) > > If in one column the number of NAs = 10 , # of 0=50 , #of 1=25 and # of > 2=15 > I want to replace 5 of 10 NAs with 0 , 3 NAs with 1 and 2 NAs with 2! > > > I've already calculated the proportion of 0, 1 and 2 for each column, just > I don't know how to replace the number of NAs with these number (0,1,2) and > specific proportion? > > Thank you very much in advance > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] Web scraping - Having trouble figuring out how to approach this problem
Sometimes I need to get some data from the web organizing it into a dataframe and waste a lot of time doing it manually. I've been trying to figure out how to optimize this proccess, and I've tried with some R scraping approaches, but couldn't get to do it right and I thought there could be an easier way to do this, can anyone help me out with this? Fictional example: Here's a webpage with countries listed by continents: https://simple.wikipedia.org/wiki/List_of_countries_by_continents Each country name is also a link that leads to another webpage (specific of each country, e.g. https://simple.wikipedia.org/wiki/Angola). I would like as a final result to get a data frame with number of observations (rows) = number of countries listed and 4 variables (colums) as ID=Country Name, Continent=Continent it belongs to, Language=Official language (from the specific webpage of the Countries) and Population = most recent population count (from the specific webpage of the Countries). ... The main issue I'm trying to figure out is handling several webpages, like, would it be possible to scrape from the first link of the problem the countries as a list with the links of the countries webpages and then create and run a function to run a scraping command in each of those links from the list to get the specific data I'm looking for? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Output design question
I don't know, but you can change it by: out_sum <- summary(lm.D9 <- lm(weight ~ group)) rownames(out_sum$coefficients)[2] <- "group Trt" out_sum On Wed, Jul 16, 2008 at 12:51 PM, Michael Kubovy <[EMAIL PROTECTED]> wrote: > Dear R-helpers, > > I was curious why the output of summary (and many other functions in > R) does not add a separator between the name of a factor and the label > of a level (e.g., in the example below, 'group Trt'). If the user had > lower case labels (e.g., 'trt'), the output would be particularly hard > to read. > ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) > trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) > group <- gl(2,10,20, labels=c("Ctl","Trt")) > weight <- c(ctl, trt) > summary(lm.D9 <- lm(weight ~ group)) > gives > Call: > lm(formula = weight ~ group) > > Residuals: > Min 1Q Median 3Q Max > -1.0710 -0.4938 0.0685 0.2462 1.3690 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 5.0320 0.2202 22.850 9.55e-15 *** > groupTrt -0.3710 0.3114 -1.1910.249 > --- > Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > Residual standard error: 0.6964 on 18 degrees of freedom > Multiple R-squared: 0.07308,Adjusted R-squared: 0.02158 > F-statistic: 1.419 on 1 and 18 DF, p-value: 0.249 > Why not"group Trt"? > _ > Professor Michael Kubovy > University of Virginia > Department of Psychology > USPS: P.O.Box 400400Charlottesville, VA 22904-4400 > Parcels:Room 102Gilmer Hall > McCormick RoadCharlottesville, VA 22903 > Office:B011+1-434-982-4729 > Lab:B019+1-434-982-4751 > Fax:+1-434-982-4766 > WWW:http://www.people.virginia.edu/~mk9y/ > > > > > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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 data layout
Try this: #x <- read.csv('your_file.csv') x$Col1 <- rep(as.character(x$Col1[x$Col1!="" ]), each = unique(diff(which(x$Col1 != "" with(x, sapply(c(sd, mean), function(x)tapply(Col2, Col1, x))) On Thu, Jul 17, 2008 at 12:50 PM, Iain Gallagher <[EMAIL PROTECTED]> wrote: > Hello list > > I have been given some Excel sheets with data laid like this: > > Col1Col2 > A 3 > 2 > 3 > B 4 > 5 > 4 > C 1 > 4 > 3 > > I was hoping to import this into R as a csv and then get the mean and SD for > each letter in column 1. > > Could someone give me some guidance on best to approach this? > > Thanks > > Iain > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] only "T" becomes logical colum with read.table
Try this: x <- read.table('example.txt', colClasses = rep("character", 7)) On Fri, Jul 18, 2008 at 9:53 AM, Luis F <[EMAIL PROTECTED]> wrote: > Hello, > > I am a biologist and I am dealing with files composed of columns with T or A > or C or G (example below) > > Sometimes a column is composed of only "T" > and in that case, the columns becomes a logical column TRUE (example below) > > I know that the argument "as.is" controls the turns off turning a column > into a factor, instead becoming a character > Is there something similar for Iogical? (I could not find it) > > I can solve this problem by doing something like: > # > FUN.changeLogi <- function(df){ > if(identical(all.equal(all(df), T), T)) df <- 'T' > return(df) > } > xx <- do.call('cbind', lapply(xx, FUN.changeLogi)) > > but it seems very cumbersome… > > Thanks, > Tiago Magalhães > > produce a text file example.txt > > A C A T C G F > A A C T C G F > A C A T C G F > A G A T C G F > T A C T C G F > > xx <- read.table('example.txt') > str(xx) > xx <- read.table('~/Desktop/temp.txt') > $ V1: chr "A" "A" "A" "A" ... > $ V2: chr "C" "A" "C" "G" ... > $ V3: chr "A" "C" "A" "A" ... > $ V4: logi TRUE TRUE TRUE TRUE TRUE > $ V5: chr "C" "C" "C" "C" ... > $ V6: chr "G" "G" "G" "G" ... > $ V7: logi FALSE FALSE FALSE FALSE FALSE > >[[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. > > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] source code functions
This is a S3 method, then: methods("na.contiguous") getS3method("na.contiguous", "data.frame") getS3method("na.contiguous", "zoo") On Fri, Jul 18, 2008 at 10:37 AM, stephen sefick <[EMAIL PROTECTED]> wrote: >>na.contiguous > function (object, ...) > UseMethod("na.contiguous") > > > this is what I get when I look for the source code for some functions- Is > there a way to look at the source code? > > -- > 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 > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] creating names for lists
Try: foo <- list(3) names(foo) <- paste(a, b) On Fri, Jul 18, 2008 at 11:03 AM, <[EMAIL PROTECTED]> wrote: > Dear R Users, > How can I create names for lists within a function where the name itself > is a function of several variables ? > >> a<-1 >> b<-2 >> paste(a,b) > [1] "1 2" >> foo<-list(paste(a,b)=3) <<<= DOES NOT WORK > Error: unexpected '=' in "foo<-list(paste(a,b)=" >> eval(paste(a,b)) > [1] "1 2" >> foo<-list(eval(paste(a,b))=3) <<<= NEITHER DOES THIS > Error: unexpected '=' in "foo<-list(eval(paste(a,b))=" >> foo<-list("1 2"=3) >> foo > $`1 2` > [1] 3 > > The last example above is the desired outcome, but the a and the b > variable will of course take on different values through the execution of > the function. > > Thanks in advance, > Tolga > > > Generally, this communication is for informational purposes only > and it is not intended as an offer or solicitation for the purchase > or sale of any financial instrument or as an official confirmation > of any transaction. In the event you are receiving the offering > materials attached below related to your interest in hedge funds or > private equity, this communication may be intended as an offer or > solicitation for the purchase or sale of such fund(s). All market > prices, data and other information are not warranted as to > completeness or accuracy and are subject to change without notice. > Any comments or statements made herein do not necessarily reflect > those of JPMorgan Chase & Co., its subsidiaries and affiliates. > > This transmission may contain information that is privileged, > confidential, legally privileged, and/or exempt from disclosure > under applicable law. If you are not the intended recipient, you > are hereby notified that any disclosure, copying, distribution, or > use of the information contained herein (including any reliance > thereon) is STRICTLY PROHIBITED. Although this transmission and any > attachments are believed to be free of any virus or other defect > that might affect any computer system into which it is received and > opened, it is the responsibility of the recipient to ensure that it > is virus free and no responsibility is accepted by JPMorgan Chase & > Co., its subsidiaries and affiliates, as applicable, for any loss > or damage arising in any way from its use. If you received this > transmission in error, please immediately contact the sender and > destroy the material in its entirety, whether in electronic or hard > copy format. Thank you. > Please refer to http://www.jpmorgan.com/pages/disclosures for > disclosures relating to UK legal entities. >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] cbind help
Try: names(abc)[3] <- "w" On Fri, Jul 18, 2008 at 1:08 PM, Rajasekaramya <[EMAIL PROTECTED]> wrote: > > hi there, > > I need to change a column name in a dataframe.how do i do that > eg > abc<- dataframe > abc > x y z > > i wanna change the colum z to w. > > Ramya > -- > View this message in context: > http://www.nabble.com/cbind-help-tp18532609p18532609.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] re ad and check table
Maybe something like this: stopifnot(tail(unlist(strsplit("slides.pdf", "\\.")), 1) == "txt") On Fri, Jul 18, 2008 at 12:51 PM, mysimbaa <[EMAIL PROTECTED]> wrote: > > Dear R users, > I want to read a file like following : > > if it is a table then z <- read.table(pathname, dec=".", header=TRUE) > else if it's not a table (image,doc,...) then send an error or something > like that > > acually I have a read.table in the beginnig of my R code, and if my data is > not a table I become in my R console : fail in scan. > So the question is how to check the nature of the file? > something like : is.table? > I don't know the function. > > Thanks for any help > Adel > -- > View this message in context: > http://www.nabble.com/read-and-check-table-tp18532292p18532292.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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 cut data elements included in a text line
Try this: na.omit(as.numeric(unlist(strsplit("\talpha0\t-0.638\t0.4043\t0.4043\t-2.215\t-0.5765\t-0.137\t501\t2000", "\t" On Fri, Jul 18, 2008 at 1:44 PM, Christine A. <[EMAIL PROTECTED]> wrote: > > Hello, > > assume I have an "unstructured" text line from a connection. Unfortunately, > it is in string format: > > R> x > [1] "\talpha0\t-0.638\t0.4043\t0.4043\t-2.215\t-0.5765\t-0.137\t501\t2000" > > > How can I extract the data included in this string object "x" in order to > get the elements for the parameter vector called "alpha0", i.e. > -0.638 0.4043 0.0467 0.4043 -2.215 -0.5765 -0.137 501 > > > Any hints how to handle this would be appreciated. > Best regards, > Christine > > > -- > Christine Adrion, Dipl.-Stat., MPH > > Ludwig-Maximilians-Universitaet Muenchen > IBE - Institut fuer Medizinische Informations- > verarbeitung, Biometrie und Epidemiologie > Marchioninistr. 15 > D- 81377 Muenchen > > Tel.: +49 (0)89 7095 - 4483 > eMail:[EMAIL PROTECTED] > web: http://ibe.web.med.uni-muenchen.de > > > > > > > > > -- > View this message in context: > http://www.nabble.com/How-to-cut-data-elements-included-in-a-text-line-tp18533319p18533319.html > Sent from the R help mailing list archive at Nabble.com. > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] using which to identify a range of values
Try : which(a > 100 & a<= 120) On Fri, Jul 18, 2008 at 3:42 PM, sj <[EMAIL PROTECTED]> wrote: > Hello, I am trying to identify values that fall within a certain range. I > thought that I might be able to use the which function to do this but I have > been unable to figure out a way to do it. Perhaps a little code will > illustrate what i am trying to do. > > > a <- rnorm(1000, 100, 50) > which( 100 < a <= 200) > > > of course this doesn't work but illustrates what I ma trying to do, If > anyone has suggestions I would greatly appreciate it > > Best, > > Spencer > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] vector help
Try: paste(test, collapse='-') On Mon, Jul 21, 2008 at 3:49 PM, Rajasekaramya <[EMAIL PROTECTED]> wrote: > > hi > > I have vector test. It has 3 elements. I want to join the three into one > vector. > "Geneset=HSA04910_INSULIN_SIGNALING_PATHWAY-157- 20". > how can i do it. > > > >> class(test) > [1] "character" >> test > [1] "Geneset=HSA04910_INSULIN_SIGNALING_PATHWAY" "157" > [3] "20" > > Ramya > -- > View this message in context: > http://www.nabble.com/vector-help-tp18575055p18575055.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] lattice with bwplot
Maybe you can use split argument in plot.trellis. See ?print.trellis. On Mon, Jul 21, 2008 at 2:28 PM, Roberts, Kyle <[EMAIL PROTECTED]> wrote: > Dear All, > > How come par(mfrow=c(1,2)) works with boxplot, but not with bwplot? > > This works > par(mfrow=c(1,2)) > boxplot(dv~index, depend) > boxplot(dv~index, depend2) > > This does not work > par(mfrow=c(1,2)) > bwplot(index~dv, depend) > bwplot(index~dv, depend2) > > Thanks, > Kyle > > > Dr. J. Kyle Roberts > Department of Literacy, Language and Learning > School of Education and Human Development > Southern Methodist University > P.O. Box 750381 > Dallas, TX 75275 > 214-768-4494 > http://www.hlm-online.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] y-axis number format on plot, barplot etc.
Try this: barplot(x, yaxt="n") axis(2, axTicks(2), format(axTicks(2), scientific = F)) On 7/21/08, Bill Cunliffe <[EMAIL PROTECTED]> wrote: > I am trying to change the number format shown on the y-axis from scientific > 5e05, to 500,000 etc. Does anyone know how to do this? > > > > Is there something I can add as an argument to barplot, or would it be > through par? > > > > barplot(data$Value, names.arg = as.vector(data$Field), main=strTitle) > > > > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Reading the data from specific columns
See argument colClasses in ?read.table. On Tue, Jul 22, 2008 at 5:28 PM, Vidhu Choudhary <[EMAIL PROTECTED]> wrote: > Hi All, > I have a huge tab separated file which a many columns. I want to read only > few specific columns in R object. There are no column names/headers in the > file. Can someone please suggest how can I do that. I checked the help of > read.delim but wasnt able to find such option > Thank you > Reagards > Vidhu > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] par() function does not work
Perhaps you have a function called 'par' in your workspace. On Wed, Jul 23, 2008 at 6:56 AM, Fabio Sanchez <[EMAIL PROTECTED]> wrote: > Dear R-nautes, > > I installed the 2.7.1 version of R and found it is not possible to modify > graphical parameters with par(). > > for example; > >> par(mfrow=c(2,2)) > Error in c(2, 2) : unused argument(s) (2) > >> par$mfrow > NULL > Does any one know what is the cause of this problem? > > Regards, > > Fabio > -- > Fabio Sánchez, MD, MSc, PhD > Unit of Dermatology and Venereology > Department of Medicine > Karolinska Institute > SE-17176 Karolinska University Hospital > Phone: +46 8 51772158 > Fax: +46 8 51773620 > >[[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. > > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Combining 4th column from 30 files
Maybe: sapply(lapply(dir(pattern="data"), read.table), '[[', 4) On Wed, Jul 23, 2008 at 5:21 AM, Daren Tan <[EMAIL PROTECTED]> wrote: > > Better approach than this brute force ? > > mm <- NULL > for (i in dir(pattern="data")) { m <- readTable(i); mm <- cbind(mm, m[,4]) } > _ > > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Simple... but...
If I understand: sort(c(x,y)) or if you want combine the elements: as.vector(mapply(c, x, y)) On Wed, Jul 23, 2008 at 9:54 AM, Shubha Vishwanath Karanth <[EMAIL PROTECTED]> wrote: > Hi R, > > > > If > > x=c(1,3,5) > > y=c(2,4,6) > > > > I need a vector which is c(1,2,3,4,5,6) from x and y. > > > > How do I do it? I mean the best way > > > > Thanks, Shubha > > > > This e-mail may contain confidential and/or privileged i...{{dropped:13}} > > __ > 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 __ 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] Convert list of lists <--> data frame
Try this: pats.df <- do.call(rbind, pats) On Wed, Jul 23, 2008 at 10:23 AM, Michael Friendly <[EMAIL PROTECTED]> wrote: > For a function that takes an argument as a list of lists of parameters, I'd > like to be able to convert that > to a data.frame and vice versa, but can't quite figure out how. > > pats <- list(structure(list(shape = 0, shape.col = "black", shape.lty = 1, > cell.fill = "white", back.fill = "white", label = 1, label.size = 1, > ref.col = "gray80", ref.grid = "yes", scale.max = 100), .Names = > c("shape", > "shape.col", "shape.lty", "cell.fill", "back.fill", "label", > "label.size", "ref.col", "ref.grid", "scale.max")), structure(list( > shape = 0, shape.col = "black", shape.lty = 1, cell.fill = "pink", > back.fill = "white", label = 1, label.size = 1, ref.col = "gray80", > ref.grid = "yes", scale.max = 100), .Names = c("shape", "shape.col", > "shape.lty", "cell.fill", "back.fill", "label", "label.size", > "ref.col", "ref.grid", "scale.max")), structure(list(shape = 0, > shape.col = "black", shape.lty = 1, cell.fill = "red", back.fill = > "white", > label = 1, label.size = 1, ref.col = "gray80", ref.grid = "yes", > scale.max = 100), .Names = c("shape", "shape.col", "shape.lty", > "cell.fill", "back.fill", "label", "label.size", "ref.col", "ref.grid", > "scale.max"))) > > So, I want pats.df to have 10 columns, > c("shape", "shape.col", "shape.lty", "cell.fill", "back.fill", "label", > "label.size", "ref.col", "ref.grid", "scale.max"), and 3 rows for this > example. > > Given pats.df, I'd want to turn that back to pats. > > thanks for any help, > -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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] sequential sum of a vector...
Maybe: tapply(x, gl(10, 8), sum) or unlist(lapply(split(x, gl(10, 8)), sum)) On Wed, Jul 23, 2008 at 11:03 AM, Shubha Vishwanath Karanth <[EMAIL PROTECTED]> wrote: > Hi R, > > > > Let, > > > > x=1:80 > > > > I want to sum up first 8 elements of x, then again next 8 elements of x, > then again another 8 elements. So, my new vector should look like: > > c(36,100,164,228,292,356,420,484,548,612) > > > > I used: > > > > aggregate(x,list(rep(1:10,each=8)),sum)[-1] > > or > > rowsum(x,group=rep(1:10,each=8)) > > > > > > But without grouping, can I achieve the required? Any other ways of > doing this? > > > > Thanks, Shubha > > > > This e-mail may contain confidential and/or privileged i...{{dropped:13}} > > __ > 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 __ 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] Convert list of lists <--> data frame
Oh, you are rigth Marc, thanks. Another option is: pats.df <- do.call(rbind.data.frame, pats) On Wed, Jul 23, 2008 at 1:10 PM, Marc Schwartz <[EMAIL PROTECTED]> wrote: > on 07/23/2008 09:42 AM Henrique Dallazuanna wrote: >> >> Try this: >> >> pats.df <- do.call(rbind, pats) > > Henrique, > > Take note of the object that results from this: > >> do.call(rbind, pats) > shape shape.col shape.lty cell.fill back.fill label label.size > [1,] 0 "black" 1 "white" "white" 1 1 > [2,] 0 "black" 1 "pink""white" 1 1 > [3,] 0 "black" 1 "red" "white" 1 1 > ref.col ref.grid scale.max > [1,] "gray80" "yes"100 > [2,] "gray80" "yes"100 > [3,] "gray80" "yes"100 > > >> str(do.call(rbind, pats)) > List of 30 > $ : num 0 > $ : num 0 > $ : num 0 > $ : chr "black" > $ : chr "black" > $ : chr "black" > $ : num 1 > $ : num 1 > $ : num 1 > $ : chr "white" > $ : chr "pink" > $ : chr "red" > $ : chr "white" > $ : chr "white" > $ : chr "white" > $ : num 1 > $ : num 1 > $ : num 1 > $ : num 1 > $ : num 1 > $ : num 1 > $ : chr "gray80" > $ : chr "gray80" > $ : chr "gray80" > $ : chr "yes" > $ : chr "yes" > $ : chr "yes" > $ : num 100 > $ : num 100 > $ : num 100 > - attr(*, "dim")= int [1:2] 3 10 > - attr(*, "dimnames")=List of 2 > ..$ : NULL > ..$ : chr [1:10] "shape" "shape.col" "shape.lty" "cell.fill" ... > >> is.data.frame(do.call(rbind, pats)) > [1] FALSE > >> class(do.call(rbind, pats)) > [1] "matrix" > > > There is an extra level of manipulation required, as I noted in my reply: > >> str(do.call(rbind, lapply(pats, data.frame))) > 'data.frame': 3 obs. of 10 variables: > $ shape : num 0 0 0 > $ shape.col : Factor w/ 1 level "black": 1 1 1 > $ shape.lty : num 1 1 1 > $ cell.fill : Factor w/ 3 levels "white","pink",..: 1 2 3 > $ back.fill : Factor w/ 1 level "white": 1 1 1 > $ label : num 1 1 1 > $ label.size: num 1 1 1 > $ ref.col : Factor w/ 1 level "gray80": 1 1 1 > $ ref.grid : Factor w/ 1 level "yes": 1 1 1 > $ scale.max : num 100 100 100 > > > HTH, > > Marc > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] sum each row and output results
Try this: addmargins(as.matrix(my.df), 2) On Wed, Jul 23, 2008 at 2:43 PM, Rheannon <[EMAIL PROTECTED]> wrote: > > Hello, > > I have the following data frame (DF): > > V5V5.1V5.2 V5.3 V5.4 V5.5 > 2 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > 3 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > 4 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > 5 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > 6 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > 7 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > 8 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > 9 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > 10 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > 11 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 > > I would like to sum each row and output the results to another dataframe > (Results). > The resluts would be > Results[1] <- sum(DF[1]) > > When I try this i get: > Error in FUN(X[[1L]], ...) : > only defined on a data frame with all numeric variables > > I have also tried > apply(AFDDsec,1,sum) > Error in FUN(newX[, i], ...) : invalid 'type' (character) of argument > > What am I doing wrong? > Eventually I would like to do this with a dataframe that has 44 columns and > 5329 rows. > > Cheers, > R > -- > View this message in context: > http://www.nabble.com/sum-each-row-and-output-results-tp18616486p18616486.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Histogram
Try this: with(x, barplot(frequency, names.arg = class)) On Wed, Jul 23, 2008 at 3:29 PM, Angelo Scozzarella <[EMAIL PROTECTED]> wrote: > Hi, > > how can I treat data organised in classes and frequencies? > > Ex. > > class frequency > > 20-23 9 > 23-25 7 > 26-28 5 > 29-31 5 > 32-34 3 > > > > Thanks > > Angelo Scozzarella > > __ > 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 __ 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] convert a vector of words into a matrix
Try this: print(t(sapply(strings, '[', 1:max(sapply(strings, length, na=".") On 7/24/08, Daren Tan <[EMAIL PROTECTED]> wrote: > > I want the matrix to look like this: > > [,1] [,2] [,3] [,4] > [1,] "1" "2" "3" > [2,] "1" "2" [3,] "1" "2" "4" "5" > > I tried to use do.call(rbind, strings) but failed due to unequal row lengths. > > Date: Thu, 24 Jul 2008 09:35:21 +0100> From: [EMAIL PROTECTED]> To: [EMAIL > > PROTECTED]> CC: [EMAIL PROTECTED]> Subject: Re: [R] convert a vector of > > words into a matrix> > And what should the matrix look like?> > > Patrick > > Burns> [EMAIL PROTECTED]> +44 (0)20 8525 0696> http://www.burns-stat.com> > > (home of S Poetry and "A Guide for the Unwilling S User")> > Daren Tan > > wrote:> > How to convert the strings into matrix ?> > > > (strings <- > > strsplit(c("1 2 3", "1 2", "1 3 4 5"), " "))[[1]][1] "1" "2" "3"> > > > [[2]][1] "1" "2"> > [[3]][1] "1" "3" "4" "5"> > > > > > _> > Easily > > edit your photos like a pro with Photo Gallery.> >> > [[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.> >> >> > > _ > > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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 delete duplicate cases?
Try this: aggregate(x$rank, list(cno=x$cno), max) On 7/24/08, Daniel Wagner <[EMAIL PROTECTED]> wrote: > Dear R users, > > I have a dataframe with lot of duplicate cases and I want to delete duplicate > ones which have low rank and keep that case which has highest rank. > e.g > > > df1 > cno rank > 1 13420.23 > 2 13420.14 > 3 13420.56 > 4 25680.15 > 5 25680.89 > > so I want to keep 3rd and 5th cases with highest rank (0.56 & 0.89) and > delete rest of the duplicate cases. > Could somebody help me? > > Regards > > Daniel > Amsterdam > > > > > > > > > > Send instant messages to your online friends http://uk.messenger.yahoo.com >[[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. > > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] factor question
Try: fac1[3:9][drop=T] On Thu, Jul 24, 2008 at 4:19 PM, Edna Bell <[EMAIL PROTECTED]> wrote: > Hi! > > Suppose I have a factor: > >> fac1 <- factor(rep(c("dog","cat","tree"),c(2,3,4))) >> fac1 > [1] dog dog cat cat cat tree tree tree tree > Levels: cat dog tree >> length(fac1) > [1] 9 > > Now I want to get rid of the dogs: >> fac1 <- fac1[3:9] >> fac1 > [1] cat cat cat tree tree tree tree > Levels: cat dog tree >> > How should I remove the dog from the level, please? > > Thanks in advance, > Edna Bell > > __ > 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 __ 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] Building a data frame with missing data
Try: color<- c("red",NA,"orange","green",NA,NA,NA) size<- c(2,1,NA,3,NA,NA,8) data.frame(color, size) On Fri, Jul 25, 2008 at 7:33 AM, Natalia Quinteros <[EMAIL PROTECTED]> wrote: > Hi List, > > I'm trying to built a list where there are some missing data in some > columns, then I would like to know what I should put in these blank spaces > when building the vector. eg: > > color<- c("red",?,"orange","green",?,?,?) > size<- c(2,1,?,3,?,?,8) > > Thanks, > > Natalia > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Remove non-numerical columns from data frame
Try this: x <- data.frame(A=c(10,20), B = c("a", "b"), C = c(20,30)) x[sapply(x, is.numeric)] On Sat, Jul 26, 2008 at 11:19 AM, Markus Mühlbacher <[EMAIL PROTECTED]> wrote: > Hello, > > My question sounds simple, but as I am desperatly searchin for a solution I am > asking you all. :) > > I try to filter out all non-numeric columns of a data frame using a for loop > to go through all columns. My if clause looks like this: > > for(j in 1:length(data)) { > > ... > if(!is.numeric(data[j])) skip <- "not numeric") > ... > } > > When I do: is.numeric(data$vol) i get TRUE as result: > unfortunately this is not applicable in a for loop, because i need to go > through all of the columns using j. > I also tried to paste data$ and the name of the column , but this is always a > character. > > When I do: is.numeric(data[257]) i get FALSE as result > (257 is the corresponding column index to "vol") > > Help needed! Thanks! > Markus > > > > > >[[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. > > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] backslash in character string?
Try: file_dir <- "C:\\files\\data\\" On Mon, Aug 4, 2008 at 5:02 PM, zack holden <[EMAIL PROTECTED]> wrote: > > Dear list, > > After searching many old posts, I can't find the solution to a simple problem. > > can someone tell me how to create a character string with multiple > backslashes, as in: > > file_dir <- c("C:\files\data\") > > I need to create this string and then paste it to many files names for batch > processing in another software program. R won't accept the backslash and > removes it. > > Thanks for any suggestions, > > zack > > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] About Creating a List by Parsing Text
I think that you need: p <- scan(textConnection(p), what = "") On Tue, Aug 5, 2008 at 7:41 AM, Gundala Viswanath <[EMAIL PROTECTED]> wrote: > Thanks Jim, > > But how can I modify this line of yours > > y <- lapply(split(x, x$V3), "[[", 8) > > to suit my 'comp.ll' > > I tried this but fail: >> p <- "\tGene 11340 211952_at RANBP5 k= 1 LL= -970.692 " >> y <- lapply(split(p, p[3]), "[[", 8) >> y >> list() > > > - Gundala Viswanath > Jakarta - Indonesia > > > > On Tue, Aug 5, 2008 at 7:14 PM, jim holtman <[EMAIL PROTECTED]> wrote: >> Does this get you close to what you want: >> >>> x <- read.table(textConnection("Gene 11340 211952_at RANBP5 k= 1 LL= >>> -970.692 >> + Gene 11340 211952_at RANBP5 k= 2 LL= -965.35 >> + Gene 11340 211952_at RANBP5 k= 3 LL= -963.669 >> + Gene 12682 213301_x_at TRIM24 k= 1 LL= -948.527 >> + Gene 12682 213301_x_at TRIM24 k= 2 LL= -947.275 >> + Gene 12682 213301_x_at TRIM24 k= 3 LL= -947.379 >> + Gene 13764 214385_s_at AI521646 k= 1 LL= -827.86 >> + Gene 13764 214385_s_at AI521646 k= 2 LL= -777.756 >> + Gene 13764 214385_s_at AI521646 k= 3 LL= -812.083 ")) >>> y <- lapply(split(x, x$V3), "[[", 8) >>> >>> y >> $`211952_at` >> [1] -970.692 -965.350 -963.669 >> >> $`213301_x_at` >> [1] -948.527 -947.275 -947.379 >> >> $`214385_s_at` >> [1] -827.860 -777.756 -812.083 >> >> >> >> On Tue, Aug 5, 2008 at 3:09 AM, Gundala Viswanath <[EMAIL PROTECTED]> wrote: >>> Hi all, >>> >>> I have the following data in which I want to parse and >>> store them in a list >>> >>> __DATA__ >>>> print(comp.ll) >>> [1] "\tGene 11340 211952_at RANBP5 k= 1 LL= -970.692 " >>> [2] "\tGene 11340 211952_at RANBP5 k= 2 LL= -965.35 " >>> [3] "\tGene 11340 211952_at RANBP5 k= 3 LL= -963.669 " >>> [4] "\tGene 12682 213301_x_at TRIM24 k= 1 LL= -948.527 " >>> [5] "\tGene 12682 213301_x_at TRIM24 k= 2 LL= -947.275 " >>> [6] "\tGene 12682 213301_x_at TRIM24 k= 3 LL= -947.379 " >>> [7] "\tGene 13764 214385_s_at AI521646 k= 1 LL= -827.86 " >>> [8] "\tGene 13764 214385_s_at AI521646 k= 2 LL= -777.756 " >>> [9] "\tGene 13764 214385_s_at AI521646 k= 3 LL= -812.083 " >>> __END__ >>> >>> I expect to get this kind of data structure: >>> >>>> wanted_output >>> >>> [['211952_at']] >>> $ll.list >>> [1] -970.692 -965.35 -963.669 >>> >>> [['213301_x_at']] >>> $ll.list >>> [1] -948.527 -947.275 -947.379 >>> >>> etc. >>> >>> How can I achieve that? >>> >>> I am stuck with the following construct >>> >>> __BEGIN__ >>> comp.ll <- model_all[grep("Gene .* k=.*", model_all)] >>> print(comp.ll) >>> >>> patt <- "Gene \\d+ ([\\w-/]+) [\\w-]+ k= (\\d) LL= ([-]\\d+\.\\d+)" >>> nresk <- unlist(strsplit(sub(patt, "\\1 \\2 \\3",comp.ll,perl=TRUE)," ")) >>> __END__ >>> >>> >>> - Gundala Viswanath >>> Jakarta - Indonesia >>> >>> __ >>> 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Greek characters in plots
Try, expression(Delta) On Tue, Aug 5, 2008 at 8:14 AM, michael watson (IAH-C) <[EMAIL PROTECTED]> wrote: > Hi > > I am running an R script that creates 100s of graphs, and I need to use > the greek CAPITAL letter delta in the mtext() function. > > I got as far as expression(delta) but this gives me the lowercase > version. > > Can anyone help? I'm using R 2.7 on Windows XP > > Mick > > Head of Informatics > Institute for Animal Health > Compton > Berks > RG20 7NN > 01635 578411 > > http://www.iah.ac.uk/research/bioinformatics/bioinf.shtml > > The information contained in this message may be confide...{{dropped:14}} > > __ > 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 __ 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] Greek characters in plots
If I understand you need this: plot(rnorm(10), main = bquote(Delta == .(delt))) On Tue, Aug 5, 2008 at 8:20 AM, michael watson (IAH-C) <[EMAIL PROTECTED]> wrote: > Excellent! I even tried DELTA but not Delta > > Now, how do I go about pasting that with some text that I have in various > other variables? > > -Original Message- > From: Henrique Dallazuanna [mailto:[EMAIL PROTECTED] > Sent: 05 August 2008 12:17 > To: michael watson (IAH-C) > Cc: r-help@r-project.org > Subject: Re: [R] Greek characters in plots > > Try, > > expression(Delta) > > On Tue, Aug 5, 2008 at 8:14 AM, michael watson (IAH-C) > <[EMAIL PROTECTED]> wrote: >> Hi >> >> I am running an R script that creates 100s of graphs, and I need to use >> the greek CAPITAL letter delta in the mtext() function. >> >> I got as far as expression(delta) but this gives me the lowercase >> version. >> >> Can anyone help? I'm using R 2.7 on Windows XP >> >> Mick >> >> Head of Informatics >> Institute for Animal Health >> Compton >> Berks >> RG20 7NN >> 01635 578411 >> >> http://www.iah.ac.uk/research/bioinformatics/bioinf.shtml >> >> The information contained in this message may be confide...{{dropped:14}} >> >> __ >> 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 > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Greek characters in plots
Where delt should be your variable. On Tue, Aug 5, 2008 at 8:23 AM, Henrique Dallazuanna <[EMAIL PROTECTED]> wrote: > If I understand you need this: > > plot(rnorm(10), main = bquote(Delta == .(delt))) > > On Tue, Aug 5, 2008 at 8:20 AM, michael watson (IAH-C) > <[EMAIL PROTECTED]> wrote: >> Excellent! I even tried DELTA but not Delta >> >> Now, how do I go about pasting that with some text that I have in various >> other variables? >> >> -Original Message- >> From: Henrique Dallazuanna [mailto:[EMAIL PROTECTED] >> Sent: 05 August 2008 12:17 >> To: michael watson (IAH-C) >> Cc: r-help@r-project.org >> Subject: Re: [R] Greek characters in plots >> >> Try, >> >> expression(Delta) >> >> On Tue, Aug 5, 2008 at 8:14 AM, michael watson (IAH-C) >> <[EMAIL PROTECTED]> wrote: >>> Hi >>> >>> I am running an R script that creates 100s of graphs, and I need to use >>> the greek CAPITAL letter delta in the mtext() function. >>> >>> I got as far as expression(delta) but this gives me the lowercase >>> version. >>> >>> Can anyone help? I'm using R 2.7 on Windows XP >>> >>> Mick >>> >>> Head of Informatics >>> Institute for Animal Health >>> Compton >>> Berks >>> RG20 7NN >>> 01635 578411 >>> >>> http://www.iah.ac.uk/research/bioinformatics/bioinf.shtml >>> >>> The information contained in this message may be confide...{{dropped:14}} >>> >>> __ >>> 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 >> > > > > -- > Henrique Dallazuanna > Curitiba-Paraná-Brasil > 25° 25' 40" S 49° 16' 22" O > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Extracting Names of Named List (Index of Hash)
names(y) On Tue, Aug 5, 2008 at 10:14 AM, Gundala Viswanath <[EMAIL PROTECTED]> wrote: > Hi, > > How can I extract the names of the following > list: > >> str(y) > List of 815 > $ 200052_s_at : num [1:5] -1067 -1064 -1063 -1062 -1059 > $ 200071_at: num [1:5] -960 -954 -954 -949 -975 > $ 200084_at: num [1:5] -1136 -1133 -1128 -1129 -1126 > ... > > Thus in the end I want to get the array: > > [1] "200052_s_at" "200071_at" "200084_at" > > - Gundala Viswanath > Jakarta - Indonesia > > __ > 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 __ 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] Selecting Variables
Try this: data.frame(ID = x$ID, Max_Exposure = max(rowSums(x[,-1] == "y")), Unique_Exposure = rowSums(x[,-1] == "y")) On Tue, Aug 5, 2008 at 10:21 AM, Michael Pearmain <[EMAIL PROTECTED]> wrote: > Hi All, > > i have a dataset that i want to dynamically inspect for the number of > variables that start with "Exposure_" and then for these count the entries > across each case i.e > > ID Exposure_1 Exposure_2 Exposure_3 > 1y yy > 2y y- > 3y - - > > So the corresponding new variables that would be created are > > ID Max_Exposure Unique_Exposure > 1 3 3 > 2 3 2 > 3 3 1 > > I know this may seem fairly basic but it will give me the starting point to > develop more advanced things with loop and nat lang > > Thanks in advance > > Mike > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Merging two datasets
Try using: merge(df1, df2, all = TRUE) On Wed, Aug 6, 2008 at 11:15 AM, Shreyasee Pradhan <[EMAIL PROTECTED]> wrote: > I am facing a problem in merging two datasets. > I have given codes to the names which are common in both the datasets and > also to those which are uncommon. > When I gave gave the following command > > merge(df1,df2) > > only those rows and columns were merged which were having common codes. > When I viewed the results, only common codes are seen and the remaining > entries are not seen. > > Can anyone guide me in this regards? > How should I merge these two datasets completely without loss of any > information? > > 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] matching problem
One option is: strapply(mystring, "\\{[^\\}]+" , function(x)gsub("\\{", "", x), perl = F) On Wed, Aug 6, 2008 at 10:01 AM, Tom.O <[EMAIL PROTECTED]> wrote: > > I have a matching problem that I cant solve. > mystring = "xxx{XX}yy{YYY}zzz{Z}" where "x","X","y","Y","z","Z" basiclly can > be anything, letters, digits etc. I'm only interested in the content within > each "{}". > > I am close but not really there yet. > > library(gsubfn) > strapply(mystring,"\\{[^\\}]+",, perl=F) > > gives me > [[1]] > [1] "{XX" "{YYY" "{Z" > > but what should I add in the code to remove the "{" in the answer > > Regards Tom > -- > View this message in context: > http://www.nabble.com/matching-problem-tp18850718p18850718.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] using acf() for multiple columns
Try this: A <- matrix(rnorm(1500),nrow=500) do.call(cbind, lapply(apply(A, 2, acf, lag.max = 10), "[[", "acf")) On Thu, Aug 7, 2008 at 5:11 AM, rcoder <[EMAIL PROTECTED]> wrote: > > Hi Gary, > > Thanks for your reply. This works fine. Is there any way to send the ACF > data to a matrix, so I could analyse the data in excel for e.g.? > > Thanks, > > rcoder > > > > > > > > > > > > > Ling, Gary (Electronic Trading) wrote: >> >> Hi, here is one possible solution ... >> -gary >> >> ### example ### >> >> # create a 500x3 multi-ts >> A <- matrix(rnorm(1500),nrow=500) >> >> # misc. graphical setting >> par(mfrow=c(ncol(A),1)) >> >> # then our friend -- lapply(split(...)) >> lapply(split(A,col(A)), acf) >> #Or >> lapply(split(A,col(A)), function(ts) acf(ts, lag.max=10)) >> >> >> >> >> >> -Original Message- >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >> On Behalf Of rcoder >> Sent: Wednesday, August 06, 2008 4:13 PM >> To: r-help@r-project.org >> Subject: [R] using acf() for multiple columns >> >> >> >> Hi everyone, >> >> I'm trying to use the acf() function to calculate the autocorrelation of >> each column in a matrix. The trouble is that I can only seem to get the >> function to work if I extract the data in the column into a separate >> matrix >> and then apply the acf() function to this column. >> >> I have something like this: acf(mat,lag.max=10,na.action=na.pass) >> >> ...but I would really like to apply the function to 'mat' where 'mat' is >> a >> matrix as opposed to a vector. The function actually doesn't return an >> acf >> coefficient, but instead plots the data. So, in addition to handling >> matrices with multiple columns, would anyone know how to coerce the >> function >> to output the underlying data? >> >> Finally, when working with a matrix, is there a way I can specify how >> many >> plots I can display after the function executes? I managed to generate a >> multiple plot when I was experimenting, but the titles suggested the acf >> was >> calculated between adjacent columns in the matrix, which is something I >> was >> puzzled about. >> >> Thanks, >> >> rcoder >> -- >> View this message in context: >> http://www.nabble.com/using-acf%28%29-for-multiple-columns-tp18858672p18 >> 858672.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. >> >> >> This message w/attachments (message) may be privileged, confidential or >> proprietary, and if you are not an intended recipient, please notify the >> sender, do not use or share it and delete it. Unless specifically >> indicated, this message is not an offer to sell or a solicitation of any >> investment products or other financial product or service, an official >> confirmation of any transaction, or an official statement of Merrill >> Lynch. Subject to applicable law, Merrill Lynch may monitor, review and >> retain e-communications (EC) traveling through its networks/systems. The >> laws of the country of each sender/recipient may impact the handling of >> EC, and EC may be archived, supervised and produced in countries other >> than the country in which you are located. This message cannot be >> guaranteed to be secure or error-free. This message is subject to terms >> available at the following link: >> http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch >> you consent to the foregoing. >> >> __ >> 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. >> >> > > -- > View this message in context: > http://www.nabble.com/using-acf%28%29-for-multiple-columns-tp18858672p18865946.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] multiple tapply
Try this: aggregate(iris[,1:4], list(Species = iris[,5]), mean) On Thu, Aug 7, 2008 at 8:01 AM, glaporta <[EMAIL PROTECTED]> wrote: > > Hi folk, > I tried this and it works just perfectly > tapply(iris[,1],iris[5],mean) > but, how to obtain a single table from multiple variables? > In tapply x is an atomic object so this code doesn't work > tapply(iris[,1:4],iris[5],mean) > > Thanx and great summer holidays > Gianandrea > -- > View this message in context: > http://www.nabble.com/multiple-tapply-tp18868063p18868063.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Create new dataframes with dames from dataset...
You can do this: split(x, list(x$Product, x$Type), drop = TRUE) On Thu, Aug 7, 2008 at 8:21 AM, Lars Modig <[EMAIL PROTECTED]> wrote: > Hi > > I'm wondering if you could save new data frames with in a loop using the > names within the data frame... I.e. If you have a data frame as below > > Product TypeTest > A One 67 > A Two 55 > B One 42 > A One 55 > > I would like to generate new dataframes as follow... > > A.One (including) > A One 67 > A One 55 > > A.Two (including) > A Two 55 > > B.One (including) > B One 42 > > > I've so far has been able to store each data as an indexed eps picture. I > put a summary of my code below, and as you can see I'm not used to program > R, and actually it was a long time since I used C or some other software > also... > > Platforms <- sort(unique(data_variable[,3])) # find all platforms sorted > > length(Platforms) # no of platforms > > > for(j in 1: length(Platforms)){ # > row_vector <- which(data_variable[,3]==Platforms[j]) #Find the first > platform > cleaner_1 <- data_variable[row_vector,]#store it in > cleaner_1 > > > Motor <- sort(unique(cleaner_1[,5])) # find all motors for > platform 1 sorted > > for(i in 1: length(Motor)){ >row_vector <- which(cleaner_1[,5]==Motor[i]) # find the > first motor >cleaner_type_1 <- cleaner_1[row_vector,] # store it in > cleaner_type_1 > > > >Data_x <-cleaner_type_1[9] >Data_y <-cleaner_type_1[10] > > >hist(Data_x[,], probability=TRUE, breaks=5, main=data_header[9]) > > > savePlot(filename = paste(c("C:/pow",j,"_",i), collapse="") ,type = "eps") > # Save plot with order no i > > __ > 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 __ 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] re order vector in order given by another vector
Try this: xx[match(zz, xx)] On Thu, Aug 7, 2008 at 8:20 AM, jimineep <[EMAIL PROTECTED]> wrote: > > So imagine I have a vector: > > zz = c("a","c","d","b") > > and another vector: > > xx = c("d","c","a","b") > > I need to get xx in the same order as zz. I am sure this is very simple but > I can't figure it out from the help pages for order or sort. Perhaps I'm not > trying hard enough but its been bugging me for a while Can anyone help? > -- > View this message in context: > http://www.nabble.com/re-order-vector-in-order-given-by-another-vector-tp18868253p18868253.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Downloading Yahoo data
You are connecting to the internet trougth a proxy? On Thu, Aug 7, 2008 at 9:40 AM, Shubha Vishwanath Karanth <[EMAIL PROTECTED]> wrote: > Hi R, > > > > I am trying to download the data from R. I give the below command. > > > >> library(fImport) > >> yahooSeries("IBM") > > trying URL > 'http://chart.yahoo.com/table.csv?s=IBM&a=7&b=08&c=2007&d=7&e=07&f=2008&; > g=d&x=.csv' > > Error in download.file(url = url, destfile = file, method = method) : > > cannot open URL > 'http://chart.yahoo.com/table.csv?s=IBM&a=7&b=08&c=2007&d=7&e=07&f=2008&; > g=d&x=.csv' > > In addition: Warning message: > > In download.file(url = url, destfile = file, method = method) : > > unable to connect to 'chart.yahoo.com' on port 80. > > Error: cannot get a slot ("data") from an object of type "character" > > In addition: Warning message: > > trying to get slot "data" from an object of a basic class ("character") > with no slots > > > > > > The problem is related with connection of R with the internet. But my > port 80 is opened. Then also the error persists. > > > > And also, the link is accessible in my PC via the direct internet. How > do I make this work? > > > > Many Thanks, > > Shubha > > > > This e-mail may contain confidential and/or privileged i...{{dropped:13}} > > __ > 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 __ 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] Downloading Yahoo data
Then, start the R with --internet2 argument. On Thu, Aug 7, 2008 at 12:08 PM, Shubha Vishwanath Karanth <[EMAIL PROTECTED]> wrote: > Yes Henrique... we are connecting to the internet through a proxy... > > Thanks, Shubha > Shubha Karanth | Amba Research > Ph +91 80 3980 8031 | Mob +91 94 4886 4510 > Bangalore * Colombo * London * New York * San José * Singapore * > www.ambaresearch.com > > > -Original Message- > From: Henrique Dallazuanna [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 07, 2008 8:17 PM > To: Shubha Vishwanath Karanth > Cc: [EMAIL PROTECTED] > Subject: Re: [R] Downloading Yahoo data > > You are connecting to the internet trougth a proxy? > > On Thu, Aug 7, 2008 at 9:40 AM, Shubha Vishwanath Karanth > <[EMAIL PROTECTED]> wrote: >> Hi R, >> >> >> >> I am trying to download the data from R. I give the below command. >> >> >> >>> library(fImport) >> >>> yahooSeries("IBM") >> >> trying URL >> 'http://chart.yahoo.com/table.csv?s=IBM&a=7&b=08&c=2007&d=7&e=07&f=2008&; >> g=d&x=.csv' >> >> Error in download.file(url = url, destfile = file, method = method) : >> >> cannot open URL >> 'http://chart.yahoo.com/table.csv?s=IBM&a=7&b=08&c=2007&d=7&e=07&f=2008&; >> g=d&x=.csv' >> >> In addition: Warning message: >> >> In download.file(url = url, destfile = file, method = method) : >> >> unable to connect to 'chart.yahoo.com' on port 80. >> >> Error: cannot get a slot ("data") from an object of type "character" >> >> In addition: Warning message: >> >> trying to get slot "data" from an object of a basic class ("character") >> with no slots >> >> >> >> >> >> The problem is related with connection of R with the internet. But my >> port 80 is opened. Then also the error persists. >> >> >> >> And also, the link is accessible in my PC via the direct internet. How >> do I make this work? >> >> >> >> Many Thanks, >> >> Shubha >> >> >> >> This e-mail may contain confidential and/or privileged i...{{dropped:13}} >> >> __ >> 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 > This e-mail may contain confidential and/or privileged...{{dropped:19}} __ 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] Append to a vector?
Try this: append(a, 5) see ?append for more detail On Thu, Aug 7, 2008 at 1:38 PM, <[EMAIL PROTECTED]> wrote: > This is probably an extemly easy operation I just could not find out how to > do it. > > I simple want to append to a vector. > > a <- c(1,2,3,4) > a <- union(a, c(5)) > > I want to append the value 5 or even another vector. Or is the a "better" way? > > Kevin > > __ > 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 __ 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 save an R object selectively?
See ?save On Thu, Aug 7, 2008 at 5:39 PM, carol white <[EMAIL PROTECTED]> wrote: > Hi, > How to save an R object for example a matrix or vector and not all objects > created in a session (which is usually performed by save.image or q("yes"))? > > Best, > > Carol > > > > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] write.csv writing the "index"
write.table(..., row.names = FALSE) On Fri, Aug 8, 2008 at 3:23 PM, <[EMAIL PROTECTED]> wrote: > I have a simple command to export a data.frame: > > write.csv(output, "TotalPredicted2008.dat") > > The structure of the data.frame can be seen with: > >> head(output) > DayOfYear Sales > 1 1 1429 > 2 2 3952 > 3 3 3049 > 4 4 2844 > 5 5 2219 > 6 6 2340 > > But it seems that the index is getting written out to the file. The first few > lines look like: > > "","DayOfYear","Sales" > "1",1,1429 > "2",2,3952 > "3",3,3049 > "4",4,2844 > "5",5,2219 > "6",6,2340 > > I would like to not have this extra column in the output. Can it be filtered > out? > > Thank you. > > Kevin > > __ > 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 __ 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 create a vector of vector?
You can create a list of vector. x <- list(c(31,2,3), c(1,2,5,34,5656), c(211,3243,5,343,3)) x[[1]] x[[2]] x[[3]] On Fri, Aug 8, 2008 at 2:59 PM, Jim <[EMAIL PROTECTED]> wrote: > Dear All, > > How can I create a vector of vector in R? > for example, I would input the data as follows: > x[1] <- c(31,2,3) > x[2] <- c(1,2,5,34,5656) > x[3] <- c(211,3243,5,343,3) > > Jim Liu > > __ > 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 __ 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] number of an element in a matrix
Try this: mat <- matrix(sample(1:50, 100, rep = TRUE), 10) table(mat)[which(table(mat) == 2)] On 8/11/08, rostam shahname <[EMAIL PROTECTED]> wrote: > Hi, I wonder if there is any function which gives the number of times which > an element is repeated in the matrix. Let say there is a matrix, I would > like to find out how many times number 2 has been repeated in the matrix, or > in other words, how many elements of the matrix are equal 2. > Thanks for your help, > Rostam > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] tilde on a spanish keyboard?
You want the tilde on R? If yes, you want do this: plot(1, xlab = "\u0303") plot(1, xlab = "\u00c3") plot(1, xlab = "\u00D1") On 8/12/08, Martin Henry H. Stevens <[EMAIL PROTECTED]> wrote: > I was trying to help someone who used a spanish keyboard on a PC running > Windows. he discovered that he had no tilde key. Does anyone know of any > simple work-arounds? > Thanks, > Hank > > Dr. Hank Stevens, Associate Professor > 338 Pearson Hall > Botany Department > Miami University > Oxford, OH 45056 > > Office: (513) 529-4206 > Lab: (513) 529-4262 > FAX: (513) 529-4243 > http://www.cas.muohio.edu/~stevenmh/ > http://www.users.muohio.edu/harkesae/ > http://www.cas.muohio.edu/ecology > http://www.muohio.edu/botany/ > "E Pluribus Unum" > > "I love deadlines. I love the whooshing noise they make as they go by." >(Douglas Adams) > > > If you send an attachment, please try to send it in a format anyone can > read, such as PDF, text, Open Document Format, HTML, or RTF. > Why? See: > http://www.gnu.org/philosophy/no-word-attachments.html > > __ > 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 __ 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] tilde on a spanish keyboard?
The try this: form <- as.formula('x\u007ey') lm(form) On 8/12/08, Martin Henry H. Stevens <[EMAIL PROTECTED]> wrote: > Thanks Henrique. We need to use the tilde in formula statements as in, > lm(y ~ x) > > Any ideas? > > On Aug 12, 2008, at 7:02 AM, Henrique Dallazuanna wrote: > > You want the tilde on R? > > > > If yes, you want do this: > > > > plot(1, xlab = "\u0303") > > plot(1, xlab = "\u00c3") > > plot(1, xlab = "\u00D1") > > > > > > > > > > On 8/12/08, Martin Henry H. Stevens <[EMAIL PROTECTED]> wrote: > > > > > I was trying to help someone who used a spanish keyboard on a PC running > > > Windows. he discovered that he had no tilde key. Does anyone know of any > > > simple work-arounds? > > > Thanks, > > > Hank > > > > > > Dr. Hank Stevens, Associate Professor > > > 338 Pearson Hall > > > Botany Department > > > Miami University > > > Oxford, OH 45056 > > > > > > Office: (513) 529-4206 > > > Lab: (513) 529-4262 > > > FAX: (513) 529-4243 > > > http://www.cas.muohio.edu/~stevenmh/ > > > http://www.users.muohio.edu/harkesae/ > > > http://www.cas.muohio.edu/ecology > > > http://www.muohio.edu/botany/ > > > "E Pluribus Unum" > > > > > > "I love deadlines. I love the whooshing noise they make as they go by." > > > (Douglas Adams) > > > > > > > > > If you send an attachment, please try to send it in a format anyone can > > > read, such as PDF, text, Open Document Format, HTML, or RTF. > > > Why? See: > > > http://www.gnu.org/philosophy/no-word-attachments.html > > > > > > __ > > > 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 > > > > Dr. Hank Stevens, Associate Professor > 338 Pearson Hall > Botany Department > Miami University > Oxford, OH 45056 > > Office: (513) 529-4206 > Lab: (513) 529-4262 > FAX: (513) 529-4243 > http://www.cas.muohio.edu/~stevenmh/ > http://www.users.muohio.edu/harkesae/ > http://www.cas.muohio.edu/ecology > http://www.muohio.edu/botany/ > "E Pluribus Unum" > > "I love deadlines. I love the whooshing noise they make as they go by." >(Douglas Adams) > > > If you send an attachment, please try to send it in a format anyone can > read, such as PDF, text, Open Document Format, HTML, or RTF. > Why? See: > http://www.gnu.org/philosophy/no-word-attachments.html > > > > > > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] converting rgb() output to 0-255
Try this: col2rgb("#2C312C") On Tue, Aug 12, 2008 at 4:22 PM, rostam shahname <[EMAIL PROTECTED]> wrote: > Hi, > I have three matrices, Red, Green and Blue. I would like to produce a matrix > which is the combined values of Red, Green and Blue matrices. > I know rgb() does the job, but the values are not between 0-255, they are in > the following format: > "#2C312C" > I would like to have the values between 0-255. > I wonder if you could tell me what I can do... > > Thanks for your help, > Rostam > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] merging data sets to match data to date
Try this: x <- data.frame(Dates = seq(as.Date('2008-01-01'), as.Date('2008-01-31'), by = 'days'), Values = sample(31)) subset(x, Dates %in% as.Date(c('2008-01-05', '2008-01-20'))) On 8/13/08, rcoder <[EMAIL PROTECTED]> wrote: > > Hi everyone, > > I want to extract data from a data set according to dates specified in a > vector. I have created a blank matrix with row names (dates) that I want to > extract from the full data set. I have then performed a merge to try to o/p > rows corresponding to common dates to a results matrix, but the operation > did not fill the results matrix. Coulc anyone offer any advice to assist > with this operation? > > Thanks, > > rcoder > -- > View this message in context: > http://www.nabble.com/merging-data-sets-to-match-data-to-date-tp18962197p18962197.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Tiny help for tiny function
You can do this: ifelse(XY >= 0.8 | XY <= -0.8 | is.na(XY), XY, "low corr") On 8/13/08, Birgitle <[EMAIL PROTECTED]> wrote: > > I just started to write tiny functions and therefore I appologise in advance > if I am asking stupid question. > > I wrote a tiny function to give me back from the original matrix, a matrix > showing only the values smaller -0.8 and bigger 0.8. > > y<-c(0.1,0.2,0.3,-0.8,-0.4,0.9) > x<-c(0.5,0.3,0.9,-0.9,-0.7,0.3) > > XY<-rbind(x,y) > > extract.values<-function (x) > { > if(x>=0.8|x<=-0.8)x > else("low corr.") > >} > > works: > > Test<-sapply(XY,extract.values,simplify=FALSE) > > but now I try to solve the problem of having NA in the matrix. > I tried like that: > > extract.values<-function (x) > { > if(x>=0.8|x<=-0.8|x==NA)x > else("low corr.") > >} > > woks not: > > x<-c(0.5,0.3,0.9,-0.9,-0.7,0.3) > y<-c(0.1,0.2,NA,-0.8,-0.4,0.9) > > XY<-rbind(x,y) > > Testi<-sapply(XY,extract.values,simplify=FALSE) > > Fehler in if (x >= 0.8 | x <= -0.8 | x == NA) x else ("low corr.") : > Fehlender Wert, wo TRUE/FALSE nötig ist > > Error in if (x >= 0.8 | x <= -0.8 | x == NA) x else ("low corr.") : > Missing value, where TRUE/FALSE is needed > > How can I do this right. > > Thanks for help > > B. > > - > The art of living is more like wrestling than dancing. > (Marcus Aurelius) > -- > View this message in context: > http://www.nabble.com/Tiny-help-for-tiny-function-tp18963310p18963310.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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 matrix according to columns with character index
Try this: x V1 V2 V3 1 a1 c1 1 2 a1 c1 2 3 a2 c1 1 4 a1 c2 1 5 a1 c2 2 lis <- split(x, list(x$V1, x$V2), drop = TRUE) do.call(rbind, unname(lis[sapply(lis, function(x)all(1:2 %in% x[,3]))])) On Wed, Aug 13, 2008 at 3:00 PM, Ralph S. <[EMAIL PROTECTED]> wrote: > > Hi, > > I have a long matrix of the following form which I would like to subset > according to the third column: > > [x y z]: > > a1 c1 1 > a1 c1 2 > a2 c1 1 > a1 c2 1 > a1 c2 2 > . . . > > > The first two columns a characters ai and cj. > > I would like to keep all the rows where there are two entries for z, 1 and 2. > > That is, I want: > a1 c1 1 > a1 c1 2 > a1 c2 1 > a1 c2 2 > . . . > > I try to use something like df[by(df,c(df$x,df$y),sum(z)==3),] but that only > gives me one line of data per x y combination. > > Is there an easy way of coding to keep all rows for a and c combinations > where z has entries both 1 and 2? > > Many thanks, > > Ralph > > _ > > > LM_WLYIA_whichathlete_us > __ > 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 __ 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] conditional IF with AND
See: ?`&` On Wed, Aug 13, 2008 at 1:45 PM, rcoder <[EMAIL PROTECTED]> wrote: > > Hi everyone, > > I'm trying to create an "if" conditional statement with two conditions, > whereby the statement is true when condition 1 AND condition 2 are met: > > code structure: > if ?AND? (a[x,y] , a[x,y] ) > > I've trawled through the help files, but I cannot find an example of the > syntax for incorporating an AND in a conditional IF statement. > > Thanks, > > rcoder > -- > View this message in context: > http://www.nabble.com/conditional-IF-with-AND-tp18966890p18966890.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] re placing default labels in lattice
You can see the source code of demo script: file.show(system.file("demo/labels.R", package = "lattice")) On Wed, Aug 13, 2008 at 11:20 AM, Andrewjohnclose <[EMAIL PROTECTED]> wrote: > > Dear all, > > I am having a little trouble deciphering how to change the default x-axis > labels in a lattice xyplot (or any type of lattice plot for that matter). I > have tried using the "demo("labels") function but the code is truncated at > precisely the wrong moment! > > All I am trying to do is to add superscript to two of the labels for which i > tried using the expression function. It partly works, but it prints only the > first replacement label inside the plotting region and forgets the > rest...what am I missing? > > Thank you > > xyplot(resid(mod4)~factor(distance),aspect=1.0,cex=1.0,xlab="Distance",ylab="Residuals",data=meanAG, > span=1, > panel=function(x,y,span){ > panel.grid(h=0, v=-1) > panel.xyplot(x,y,cex=1.0,points="jitter") > panel.loess(x,y, span) > panel.axis(side="bottom",at=TRUE, > labels=c(expression(Bray-Curtis^{1}),expression(Bray-Curtis^{2}),expression(Canberra),expression(Gower),expression(Hellinger),expression(Kulczynski))) > }) > http://www.nabble.com/file/p18964008/meanAG.csv meanAG.csv > -- > View this message in context: > http://www.nabble.com/replacing-default-labels-in-lattice-tp18964008p18964008.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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] the name of the current running script.r
maybe you can do something about like this: #height.r script beg SourceFileDir <- "f:/documents/data & fits/THz Imaging Lab/r scripts" SourceFileName <- "height.r" source(file.path(SourceFileDir, SourceFileName)) # height.r script end savehistory() FileNameSourced <- gsub("source\\(|\\)|\"", "", tail(head(readLines(".Rhistory") , -1), 1)) On Thu, Aug 14, 2008 at 10:03 AM, Zroutik Zroutik <[EMAIL PROTECTED]> wrote: > Dear R users, > > is there a hack how to get the filename of the current script.r sourced/ran? > > My issue: I have a couple of scripts which were optimised and are placed in > tens of directories. (I have a height.r script in 30 directories, a lines.r > script in 25 directories and another flow.r script in 54 directories, > growing). The script runs in the directory and does its job: sources data > and creates plots. From time to time I realise there is a possible update to > a script and then I have to copy the new version over all my directories to > overwrite the old scripts. So, it is better to have a script height.r: > > # height.r script beg > SourceFileDir <- "f:/documents/data & fits/THz Imaging Lab/r scripts" > SourceFileName <- "height.r" > source(file.path(SourceFileDir, SourceFileName)) > # height.r script end > > placed in every directory and when running it, it sources the one and only > script height.r (this is the core script file) from a fix place. > > But, I need again three/more other scripts depending on the name (thus type) > of the script (note the third line of the script above). Anything which > would give me the name of the script currenlty running or last sourced or > anything. > I know getwd() gives me the working dir, but I need the working script > name. > > Any help appriciated. Thank you very much in advance. > Milan > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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 substitute special characters within a data frame?
Try this: gsub("345", "a", "H\\345rkan") But see: cat("H\345rkan\n") On Fri, Aug 15, 2008 at 6:54 AM, Yingfu Xie <[EMAIL PROTECTED]> wrote: > Hello all, > > I have a data frame in R, imported from an excel file in Swedish. The > original file contains several columns that have special characters, such as > \¨{a}, \¨{o}, and so on. After import such special characters are represented > in the data frame by "\\345", "\\366" etc (don't ask me why). For example, a > word "Hårkan" becomes ''H\\345rkan". > > Now my question is if it is possible to substitute those "H\\345rkan" by > "Haarkan" or simply "Harkan" in R, ideally by finding those "\\345" and then > replacing. > > Thanks in advance, > Yingfu > >[[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. > > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Opening a web browser from R?
Use browseURL: browseURL('about:blank') On Fri, Aug 15, 2008 at 7:55 AM, <[EMAIL PROTECTED]> wrote: > > Hi, > > I was wondering if there's a way in R to open a web browser (such as > Internet Explorer, or Firefox or whatever). > I'm doing some analyses that have associated urls, and it would be nice to > have the ability to directly open the relevant page from within R. > I was looking at the help for 'url' and I can see I can probably access the > information I need and display it in my own way, but can I somehow just open > the given url with my web browser of choice? > > many thanks for any help, > > Jose > > > -- > Dr. Jose I. de las Heras Email: [EMAIL PROTECTED] > The Wellcome Trust Centre for Cell BiologyPhone: +44 (0)131 6513374 > Institute for Cell & Molecular BiologyFax: +44 (0)131 6507360 > Swann Building, Mayfield Road > University of Edinburgh > Edinburgh EH9 3JR > UK > > -- > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > __ > 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 __ 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] ylab with an exponent
Try this: plot(1,2, ylab=expression(insects~m^2)) On Fri, Aug 15, 2008 at 1:26 PM, stephen sefick <[EMAIL PROTECTED]> wrote: > plot(1,2, ylab= paste("insects", expression(m^2), sep=" ")) > > I get insects m^2 > I would like m to the 2 > > what is the problem? > > -- > 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Question on default link directory
Try change the bugs.directory argument in bugs function: AR1bugs.sim <- bugs(data, inits, parameters, "D:AR1GammaModel.txt", n.chains=3, n.iter=1000,bugs.directory="c:/WinBUGS14/", working.directory=NULL, clearWD=TRUE, debug=TRUE) On Fri, Aug 15, 2008 at 1:54 PM, Yevhen Yankovskyy <[EMAIL PROTECTED]> wrote: > Hi, > > I have got a problem with running WinBugs from R. > Following WinBugs project recommendations for Vista Microcoft, I > installed my Winbugs software at C:\ (not at C:\Program Files). > However, when I run the attached code in R, R still looks for Winbugs > at C:\Program Files and ends up in numerous error messages. > > I wonder if it is possible to direct R to C:\WinBUGS14 instead of > default link to > C:\Program Files\WinBUGS14 > > Thanks, > Eugene > > __ > 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 __ 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] Extracting dataset from lm output
Try this: lm.out$model On Fri, Aug 15, 2008 at 4:48 PM, Roberts, Kyle <[EMAIL PROTECTED]> wrote: > Dear All, > > I want to extract the original dataset from a lm output. I know that I > can get most of it from > > model.matrix(lm.out) > > but I need the dependent variable to be in the first column. Any ideas? > > Thanks, > Kyle Roberts > > __ > 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 __ 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 no of pdf files in a particular directory
Try this: sapply(c("csv$", "pdf$"), function(x)length(dir(path=Dir, pattern = x))) On Mon, Aug 18, 2008 at 4:59 AM, Kurapati, Ravichandra (Ravichandra) <[EMAIL PROTECTED]> wrote: >> Let's say, > >> > >> Dir<-"/var/www/html/celnet/users/cxadmin/FlowDuration_DataVolume/fld_0 > >> 1_ > >> 08_18_08" > >> > >> There will be pdf and/or csv files. > >> I want to know how many *.pdf and/or csv files are there in that > directory. > >> > >> How can I get using R commands. > >> > > > > > > Thanks > > K.Ravichandra > > > > > > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] seq: specify *minimum* end value, more elegant solution
Hi, Maybe you can specify the length of vector: seq(from=0, by=4, l = 4) seq(from=0, by=4, l = 5) On Mon, Aug 18, 2008 at 3:38 PM, Timothy W. Hilton <[EMAIL PROTECTED]> wrote: > Hello, > > Using seq, I would like to specify a minumum end value, rather than a maximum > end value. For example, rather than > >> seq(from=0, to=10, by=4) > [1] 0 4 8 > > I would like to obtain > [1] 0 4 8 12 > > I can do that with >> by.value = 4 >> seq(from=0,by=by.value,to=ceiling(10 / by.value)*by.value) > [1] 0 4 8 12 > > That seems like a somewhat clunky solution, though, and requires an > additional variable (by.value) that shows up three times. Is there a more > elegant solution to this? > > 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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
See dmt function in csampling package. On Mon, Aug 18, 2008 at 3:15 PM, Andreia da Silva Meyer <[EMAIL PROTECTED]> wrote: > Hi, > > I am looking for an efficient way to compute the values of the density > function of a multivariate T distribution - something like "dmvnorm", but > for T distr. Does this exist somewhere? > > Many thanks, > > Andréia. > > __ > 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 __ 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] Calling a windows program
See shell command On Tue, Aug 19, 2008 at 3:48 PM, Benjamin E. Alexander-Eitzman <[EMAIL PROTECTED]> wrote: > Greetings, > > > > How do I make a call to a windows program from R? For example in > windows, I would run this in a shortcut: > > > > "C:\Program Files\WinBUGS14\WinBUGS14.exe" /PAR "myownscript.odc" > > > > Thanks, > > > > Ben Alexander-Eitzman > > >[[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Removing
Try this: Ill[Ill != "No"] On Wed, Aug 20, 2008 at 3:16 PM, <[EMAIL PROTECTED]> wrote: > I'm trying to remove the elements "No" from the character vector > > Ill=c("No","Yes","Yes","Yes","No","Yes","Yes","Yes","Yes","Yes","No","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","Yes","No","Yes","Yes","No","Yes","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","No","Yes","Yes","Yes","Yes","No","No","No","No","Yes","Yes","No","No","No","Yes","Yes","Yes","No","Yes","Yes") > > but cannot figure out how to do it. I appreciate any help you have to > offer. > > Brian > > __ > 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 __ 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] Removing
Try this also: Dt <- cbind(Age[o],Sex[o],Ill[o]) subset(as.data.frame(Dt), V3 != "No") On Wed, Aug 20, 2008 at 3:24 PM, <[EMAIL PROTECTED]> wrote: > I think I should be clearer. Given the matrix of column vectors Age, Sex, > and Ill > > Age=c(11,52,65,59,13,63,70,40,15,33,65,38,62,10,25,32,62,36,11,33,13,7,64,3,65,59,15,62,37,17,35,15,50,40,35,35,36,57,16,68,54,77,72,58,20,17,62,20,52,9,50,8,35,48,25,11,74,12,44,53,37,24,69,7,17,8,11,17,36,21,60,18,14,52,45) > Sex=c("Male","Female","Male","Female","Female","Female","Male","Female","Female","Female","Male","Female","Female","Male","Male","Female","Female","Male","Male","Female","Female","Male","Male","Male","Female","Female","Female","Male","Female","Male","Male","Male","Female","Male","Female","Female","Male","Female","Female","Male","Female","Male","Female","Male","Male","Male","Female","Female","Female","Female","Male","Male","Female","Female","Male","Female","Male","Female","Female","Female","Male","Female","Female","Male","Female","Female","Female","Male","Female","Female","Male","Female","Female","Male","Female") > Ill=c("No","Yes","Yes","Yes","No","Yes","Yes","Yes","Yes","Yes","No","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","Yes","No","Yes","Yes","No","Yes","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","Yes","No","Yes","Yes","Yes","No","No","Yes","Yes","Yes","No","No","Yes","No","Yes","Yes","No","Yes","Yes","Yes","Yes","No","No","No","No","Yes","Yes","No","No","No","Yes","Yes","Yes","No","Yes","Yes") > o=order(Ill) > cbind(Age[o],Sex[o],Ill[o]) > > I am trying to remove all rows of the matrix in which the element in the Ill > column vector is "No". I appreciate any help you have to offer. > > Brian > > __ > 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 __ 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] Jpg files in R
Is there the rimage package: if(!require(rimage))install.packages("rimage") x <- read.jpeg(system.file("data", "cat.jpg", package="rimage")) dim(x)[1:2] 2008/8/25 Leandro Marino <[EMAIL PROTECTED]>: > > > > If I have an file like an JPG, gif, png or other, exist any kind of function > in the R to see de dimension in pixels of this image? > > > Thanks > > > Atenciosamente, > Leandro Lins Marino > Centro de Avaliacao > Fundacao CESGRANRIO > Rua Santa Alexandrina, 1011 - 2o andar > Rio de Janeiro, RJ - CEP: 20261-903 > * (21) 2103-9600 R.:236 > * (21) 8777-7907 > * [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > > "Aquele que suporta o peso da sociedade >e precisamente aquele que obtem > as menores vantagens". (SMITH, Adam) > > P Antes de imprimir pense em sua responsabilidade e compromisso com o MEIO > AMBIENTE > > __ > 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 __ 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] Jpg files in R
Right Barry, I forget. Thanks On Mon, Aug 25, 2008 at 4:51 PM, Barry Rowlingson <[EMAIL PROTECTED]> wrote: > 2008/8/25 Henrique Dallazuanna <[EMAIL PROTECTED]>: >> Is there the rimage package: >> >> >> if(!require(rimage))install.packages("rimage") >> x <- read.jpeg(system.file("data", "cat.jpg", package="rimage")) > > Nice, but if the require() fails and the package installs via > install.packages, you still have to do the require() (or 'library()'), > so you need something like: > > if(!require(rimage)){ install.packages("rimage") ; require(rimage) } > > maybe we need a requireOrGet() function that goes and gets it from > CRAN if it can't find it :) > > Barry > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] paste: multiple collapse arguments?
Try this also: paste(apply(matrix(x, 2), 2, paste, collapse = ' '), collapse = "\n") On Mon, Aug 25, 2008 at 8:36 PM, remko duursma <[EMAIL PROTECTED]> wrote: > > Dear R-helpers, > > I have a numeric vector, like: > > x <- c(1,2,3,4,5,6) > > I make this into a string for output to a text file, separated by \n: > > paste(x, collapse="\n") > > Is there a way to alternate the collapse argument? So between the first two > elements of x, I want to separate by " ", then by "\n", and so forth. > The result should then look like: > "1 2\n3 4\n5 6" > > (This way I get 2 elements of x on each line using writeLines, instead of one > or all). > I could do this in some ugly loop, but surely there is a better way? > > thanks, > Remko > > > > > > > _ > Get thousands of games on your PC, your mobile phone, and the web with > Windows(R). > >[[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. > > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] environments
I think you need assign, see ?assign for more details. On Tue, Aug 26, 2008 at 6:02 AM, Antje <[EMAIL PROTECTED]> wrote: > Hi there, > > I try to understand the usage of environments but I'm not sure if I get it. > I wrote a test script like this: > > testenv <- new.env(environment()) > > myfun <- function(x) { >print(testvar) >testenv$testvar_2 <- 20 > } > environment(myfun) <- testenv > > testenv$testvar <- 10 > myfun("hello") > ls(envir = testenv) > > Now, I was wondering if there is any way to create new variables in my > environment without this "testenv$...". I know that I can access it that way > if I do an attach(testenv) before, but that does not help when creating new > ones... > Do I completely misunderstand the concept? > I'm just looking for an elegant way to access objects of a graphical > userinterface from each handler-function and so on. And I thought it might > be good to pack them into an environment... > > Antje > > __ > 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 __ 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] savePlot() does not save plot with format set
You need type the extension of the file: plot(rnorm(10)) savePlot("test.png", type="png") savePlot("test.bmp", type="bmp") On Tue, Aug 26, 2008 at 6:29 AM, Luis Ridao Cruz <[EMAIL PROTECTED]> wrote: > R-help, > > Whenever I try to save a plot with "savePlot" > the file is not stored in my hard disk with the selected > format. Several formats are set and none of them > works. I just get the file name with missing extension > and it can't be open with programs like Paint and Microsoft Photo > Editor > Th only one able to open it is "Windows Picture and Fax Viewer" > > > plot(rnorm(10)) > savePlot("test", type="png") > savePlot("test", type="bmp") > > > My platform is Windows XP SP3 > >> version > _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 2 > minor 7.0 > year 2008 > month 04 > day22 > svn rev45424 > language R > version.string R version 2.7.0 (2008-04-22) > > Thanks in advanced > > __ > 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 __ 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] coding rules
See http://www1.maths.lth.se/help/R/RCC/ On Wed, Aug 27, 2008 at 9:36 AM, Thomas LOUBRIEU <[EMAIL PROTECTED]> wrote: > Dear all, > > I am organizing a set of specific R code as package (to ease the > documentation and deployment of it to users). > Before doing so, I would like to know if there are written coding rules for > R (with functions, objects naming convention for example). > > Thanks a lot, > > Thomas > > -- > > > - > Thomas LOUBRIEU > IFREMER IDM/ISI > BP70 > 29280 Plouzane > FRANCE > email: [EMAIL PROTECTED] > WWW : http://www.coriolis.eu.org/cdc > Tel.: (+33) (0)2 98 22 48 53 > Fax: (+33) (0)2 98 22 46 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ 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] Closest value
Try this: x.axis[which.min(abs(x.axis - 3.2))] On Wed, Aug 27, 2008 at 10:12 AM, Dani Valverde <[EMAIL PROTECTED]> wrote: > Hello, > I have this command: > x.axis <- seq(from=0.5, to=4.5, length.out=13112) > How can I which of the x.axis components is the closest to a given value, > for example 3.2? > Best, > > Dani > > -- > Daniel Valverde Saubí > > Grup de Biologia Molecular de Llevats > Facultat de Veterinària de la Universitat Autònoma de Barcelona > Edifici V, Campus UAB > 08193 Cerdanyola del Vallès- SPAIN > > Centro de Investigación Biomédica en Red > en Bioingeniería, Biomateriales y > Nanomedicina (CIBER-BBN) > > Grup d'Aplicacions Biomèdiques de la RMN > Facultat de Biociències > Universitat Autònoma de Barcelona > Edifici Cs, Campus UAB > 08193 Cerdanyola del Vallès- SPAIN > +34 93 5814126 > > __ > 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 __ 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] Calculating total observations based on combinations of variable values
Try this: merge(aggregate(x$DAY, x[, c("YEAR", "MONTH")], length), data.frame(YEAR = unique(x$YEAR), MONTH = 1:12), all = T) On Wed, Aug 27, 2008 at 2:11 PM, Josip Dasovic <[EMAIL PROTECTED]> wrote: > Hello: > > As someone making the move from STATA to R, I'm finding it difficult at > times to perform basic tasks in R, so forgive me if I've missed an obvious > and easily obtained solution to my problem. I've searched the help guides > and the archives and have not been able to find a solution that works. > > I have a data frame with thousands of observations that looks something > like this: > > YEAR MONTH DAY COUNTRY REGION PROVINCE >CITY > 1994 1 22 Sri Lanka South Asia Northern (Province) > Pungudutivu > 1994 1 25 Sri Lanka South AsiaCentral (Province) > Kandy > 1994 2 26 Sri Lanka South AsiaCentral (Province) > Kandy > 1994 2 28 Sri Lanka South AsiaEastern (Province) > Wakianeri > 1994 6 28 Sri Lanka South AsiaEastern (Province) > Valachenai > 1994 6 31 Sri Lanka South AsiaCentral (Province) > Kandy > 1995 3 1 Sri Lanka South Asia North (Province) > Kilinochchi > 1995 3 6 Sri Lanka South AsiaWestern (Province) > Colombo > 1995 7 15 Sri Lanka South Asia Northern (Province) > Mankulam > 1995 7 23 Sri Lanka South Asia Northern (Province) > Point Pedro > 1995 9 25 Sri Lanka South Asia Northern (Province) > Kilali > ... > > What I would like to do is to calculate the total number of observations by > unique combinations of the values of (some of the) variables above. > > For example, I would like to know how many observations (i.e. rows) have > the values YEAR==1994 and MONTH==1. > > In the end, I'd like a table that looks like this: > > YEAR MONTH #OBS > 1994 1 2 > 1994 2 2 > 1994 3 0 > 1994 4 0 > 1994 5 0 > 1994 6 2 > 1994 7 0 > 1994 8 0 > 1994 9 0 > 1994 10 0 > 1994 11 0 > 1994 12 0 > 1995 1 0 > 1995 2 0 > 1995 3 2 > 1995 4 0 > ... > > I do need to fill out the table with all the possible combinations, even > where there are no observations with that combination in the data set. > At first, it seemed like this would not be think that aggregate is > probably the way to go, but there doesn't seem to be an appropriate summary > function (FUN) available. Thanks in advance for any help in this matter, > > Josip > > __ > 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] Plots spanning columns
Try this: l <- layout(matrix(c(1, 2, 1, 3), 2)) layout.show(l) On Thu, Aug 28, 2008 at 9:40 AM, Jose Luis Aznarte M. < [EMAIL PROTECTED]> wrote: > Hi! I want to plot three graphs (residuals, ACF and PACF of a model). > Ideally I would use a c(2,2) disposition where the residuals plot would > start at position 1,1 and span to position 1,2. Then I would plot the ACF in > position 2,1 and the PACF in position 2,2. Maybe is clearer like this: > > -- > || > | residuals| > || > -- > - > | | | | > |ACF | | PACF| > | | | | > - > > Does anyone know if that is possible at all? Cheers! > > -- > -- -- > Jose Luis Aznarte M. > http://decsai.ugr.es/~jlaznarte<http://decsai.ugr.es/%7Ejlaznarte> > Department of Computer Science and Artificial Intelligence > Universidad de Granada Tel. +34 - 958 - 24 04 67 > GRANADA (Spain) Fax: +34 - 958 - 24 00 79 > > __ > 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] Read a file
Try this: x <- readLines('clipboard') newx <- as.numeric(x[setdiff(seq(length(x)), grep("^#", x))]) comment(newx) <- grep("^#", x, value = TRUE) newx comment(newx) On Thu, Aug 28, 2008 at 12:41 PM, Dani Valverde <[EMAIL PROTECTED]>wrote: > Hello, > I have a text file with this structure: > > # File created = Thursday, August 28, 2008 3:33:02 PM GMT > # Data set = 373 2 1 C:\Bruker\TOPSPIN GABRMN > # Spectral Region: > # LEFT = 4.5 ppm. RIGHT = 0.5 ppm. > # > # SIZE = 13111 ( = number of points) > # > # In the following ordering is from the 'left' to the 'right' limits! > # Lines beginning with '#' must be considered as comment lines. > # > 1628.40625 > 1628.40625 > 1964.40625 > 2242.0625 > 2533.5 > 2937.90625 > 3448.0 > 3923.96875 > > Is it possible to read it with R, something like scan() but keeping the > structure? > Best, > > Dani > > -- > Daniel Valverde Saubí > > Grup de Biologia Molecular de Llevats > Facultat de Veterinària de la Universitat Autònoma de Barcelona > Edifici V, Campus UAB > 08193 Cerdanyola del Vallès- SPAIN > > Centro de Investigación Biomédica en Red > en Bioingeniería, Biomateriales y > Nanomedicina (CIBER-BBN) > > Grup d'Aplicacions Biomèdiques de la RMN > Facultat de Biociències > Universitat Autònoma de Barcelona > Edifici Cs, Campus UAB > 08193 Cerdanyola del Vallès- SPAIN > +34 93 5814126 > > __ > 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] Interaction between aggregate() and length()
One option is use this: aggregate(list(t=tt$t), list(idx=tt$idx), length) On Thu, Aug 28, 2008 at 4:36 PM, <[EMAIL PROTECTED]> wrote: > Folks, > > I've been running into an odd situation that occurs when I use length() > function with aggregate(), but not with either one separately. Together, > the results looks correct but is given an unexpected name. 'if > (stringsAsFactors) factor(x) else x' instead of just 'x'. > > # Numbers work ok > tt <- data.frame(idx=c(1,1,1,1,1,1,2,2,2,2,2,2) >,n=c(1,3,5,7,5,5,2,4,8,16,4,4) >,t=c(1,3,5,7,5,5,2,4,8,16,4,4) >,stringsAsFactors=FALSE) > > aggregate(tt$t, list('idx'=tt$idx), length) > aggregate(as.factor(tt$t), list('idx'=tt$idx), length) > > # Character data doesn't work right unless I convert the data to factors. > tt <- data.frame(idx=c(1,1,1,1,1,1,2,2,2,2,2,2) >,n=c('1','3','5','7','5','5','2','4','8','16','4','4') >,t=c('1','3','5','7','5','5','2','4','8','16','4','4') >,stringsAsFactors=FALSE) > > aggregate(tt$t, list('idx'=tt$idx), length) > aggregate(as.factor(tt$t), list('idx'=tt$idx), length) > > > Any idea what is going on here? For the record, this also happens with > the modalvalue() function defined at > http://wiki.r-project.org/rwiki/doku.php?id=tips:stats-basic:modalvalue > (which also relies on length() ). > > As a side note, this began as an attempt to determine sample size, for > which I've defined a function count <- function(x) { length(na.omit(x)) }. > No doubt there's a built in function to do just that, but as a newbie > I've yet to find it. > > Thank you for your help, > cur > -- > Curt Seeliger, Data Ranger > Raytheon Information Services - Contractor to ORD > [EMAIL PROTECTED] > 541/754-4638 > >[[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. > -- 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] how to calculate the mode of a continuous variable
Try: as.numeric(names(which.max(table(x On Fri, Aug 29, 2008 at 3:13 AM, Manuel Ramon <[EMAIL PROTECTED]> wrote: > > Is there any R funtion that allow the estimation of mode in a continuous > variable? > Thank you > -- > View this message in context: > http://www.nabble.com/how-to-calculate-the-mode-of-a-continuous-variable-tp19214243p19214243.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. > -- 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] how to calculate the mode of a continuous variable
Oh you are right Peter, thanks On Fri, Aug 29, 2008 at 8:37 AM, Peter Dalgaard <[EMAIL PROTECTED]>wrote: > Henrique Dallazuanna wrote: > > Try: > > > > as.numeric(names(which.max(table(x > > > > On Fri, Aug 29, 2008 at 3:13 AM, Manuel Ramon <[EMAIL PROTECTED]> wrote: > > > > You missed the word "continuous" there... > > x <- rnorm(10) > > table(x) > x > -1.64244637710945 -0.836534097622312 -0.810292826933485 -0.721008996586432 > 1 1 1 1 > -0.679702422788255 -0.667735659553467 -0.263432175981501 0.0795699932826675 > 1 1 1 1 > 0.387151850978792 0.761964511475389 > 1 1 > > as.numeric(names(which.max(table(x > [1] -1.642446 > > > Instead, how about > > > > dd <- density(x) > > which.max(dd$y) > [1] 227 > > dd$x[which.max(dd$y)] > [1] -0.6938049 > > plot(dd) > > rug(x) > > abline(v=dd$x[which.max(dd$y)]) > > > > >> Is there any R funtion that allow the estimation of mode in a continuous > >> variable? > >> Thank you > >> -- > >> View this message in context: > >> > http://www.nabble.com/how-to-calculate-the-mode-of-a-continuous-variable-tp19214243p19214243.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-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 > > > -- 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] another histogram question
You can do this: hh <- lapply(h, head, mh) hh$breaks <- head(h$breaks, mh + 1) class(hh) <- "histogram" plot(hh) On Mon, Sep 1, 2008 at 10:44 AM, Antje <[EMAIL PROTECTED]> wrote: > Hi there, > > I hope this question is not as stupid as the one before ... > I tried to shorten my histogram (because the distribution is quite skewed > and I simply don't want to see the long tail but still use the histogram > plot). How can I do something like this? (The example does not work but I > don't know why...) > > data <- rnorm(100) # as example, of course this is not skewed... > > h <- hist(data, plot=FALSE) > mh <- 5 > hh <- list(h$breaks[0:(mh+1)], > h$counts[0:mh],h$intensities[0:mh],h$density[0:mh],h$mids[0:mh],h$xname,h$equidist) > names(hh) <- names(h) > plot(hh) > > > Antje > > __ > 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] linebreak in mathematical anotation?
If I understand: tt <- c(expression(italic('First\nset')), expression(italic('Second\nset')), expression(italic('third\nset'))) barplot(1:3, names.arg=tt) On Mon, Sep 1, 2008 at 12:17 PM, Rainer M Krug <[EMAIL PROTECTED]> wrote: > Hi > > I am using mathematical anotation to make the labels in a barplot in > italics. as an example (adapted from > http://finzi.psych.upenn.edu/R/Rhelp02a/archive/129808.html): > > tt <- c("italic(First~~set)", "italic(Second~~set)", "italic(third~~set") > barplot(1:3, names.arg=parse(text=tt)) > > But I would like to have it with "set" in a second column, like > > tt <- c("First\nset", "Second\nset", "third\nset") > barplot(1:3, names.arg=tt) > > only in italics. Is this possible? > > Thanks > > Rainer > > -- > Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation > Biology, UCT), Dipl. Phys. (Germany) > > Centre of Excellence for Invasion Biology > Faculty of Science > Natural Sciences Building > Private Bag X1 > University of Stellenbosch > Matieland 7602 > South Africa > > __ > 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] how to read multiple lines per case
Try this: lines <- read.table(" http://www.math.yorku.ca/SCS/viscollin/data/linthall.dat";, fill = TRUE, header = TRUE) DF <- do.call(rbind, lapply(split(lines, rep(1:(nrow(lines)/2), each = 2)), function(x)cbind(x[1, 1:13], x[2, 1:4]))) names(DF) <- names(lines) On Mon, Sep 1, 2008 at 1:06 PM, Michael Friendly <[EMAIL PROTECTED]> wrote: > How can I read a space-delimited file, where the data values for each case > are folded before column 80, and so appear on two lines for each case? > > The first few cases look like this > > loc type bio H2S sal Eh7 pH buf P K Ca Mg Na Mn Zn Cu NH4 > OI DVEG 676 -610 33 -290 5.00 2.34 20.238 1441.67 2150.00 5169.05 35184.5 > 14.2857 16.4524 5.02381 59.524 > OI DVEG 516 -570 35 -268 4.75 2.66 15.591 1299.19 1844.76 4358.03 28170.4 > 7.7285 13.9852 4.19019 51.378 > OI DVEG 1052 -610 32 -282 4.20 4.18 18.716 1154.27 1750.36 4041.27 26455.0 > 17.8066 15.3276 4.79221 68.788 > OI DVEG 868 -560 30 -232 4.40 3.60 22.821 1045.15 1674.36 3966.08 25072.9 > 49.1538 17.3128 4.09487 82.256 > > The complete data is at: > > http://www.math.yorku.ca/SCS/viscollin/data/linthall.dat > > thanks, > -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. > -- 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] opening an external file
See ?browseURL On Mon, Sep 1, 2008 at 5:06 PM, Applejus <[EMAIL PROTECTED]> wrote: > > Hi, > > Is there a way to launch a file from an R command? > To be more precise: I am using windows, and I have an html file in the > working directory of R, and I would like my code in R to automatically > launch the html file in the browser (that is, open the file). Basically, i > would like to simulate a user double-clicking on the html file to open it > in > a browser... > > Thanks > -- > View this message in context: > http://www.nabble.com/opening-an-external-file-tp19260007p19260007.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. > -- 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] ftables package, zero rows
Try this: test[test == 0] <- '' test On Tue, Sep 2, 2008 at 1:03 PM, Marc Flockerzi <[EMAIL PROTECTED]>wrote: > dear all, > > i'm just about to do some straightforward contingency tables using ftables > (and ctab() for percents). > > the problem: > factor "a" are regions, factor "b" are subregions. > every region "a" consists of some subregions "b", but obviously not every > subregion "b" is part of every region "a". > if i use the ftable() function, the table contains a lot of zero rows which > i don't want in my output. > > minimal example: > > a <- c(1,1,1,1,1,2,2,2,2,2) > > b <- c(4,5,6,5,4,7,8,9,8,7) > > c <- c("a","b","c","d","a","b","b","a","d","d") > > A <- cbind(a,b,c) > > A > a b c > [1,] "1" "4" "a" > [2,] "1" "5" "b" > [3,] "1" "6" "c" > [4,] "1" "5" "d" > [5,] "1" "4" "a" > [6,] "2" "7" "b" > [7,] "2" "8" "b" > [8,] "2" "9" "a" > [9,] "2" "8" "d" > [10,] "2" "7" "d" > > test <- ftable(a,b,c) > > test >c a b c d > a b > 1 4 2 0 0 0 > 5 0 1 0 1 > 6 0 0 1 0 > 7 0 0 0 0 > 8 0 0 0 0 > 9 0 0 0 0 > 2 4 0 0 0 0 > 5 0 0 0 0 > 6 0 0 0 0 > 7 0 1 0 1 > 8 0 1 0 1 > 9 1 0 0 0 > > my question: how can i "delete" the zero rows and preserve the structure > and attributes of the original table? > simply doing something like: > test2 <- test[test>0] > obviously only returns the non-zero values, but not the nice structure and > attributes of the original table. > > to do it by hand is not an option as the original table has like 2000 rows, > 1500 of which are zero... > > thanks in advance > marc > __ > "Hostage" mit Bruce Willis kostenlos anschauen! > > __ > 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] graphics: per mil plus delta notation
Try this: plot(1, ylab=expression({delta}^13*C~'\211'~VPDB)) 2008/9/2 Nora Hanson <[EMAIL PROTECTED]> > Hello All, > > I am looking for some help with was is probably very simple: > > I want the y-axis title '¦Ä13C¡ë VPDB' and similarly for nitrogen on a > secondary axis. I am able to get the delta notation and per mil notation > separately but one messes up the other with the inclusion of quotations: > > ylab=expression("{delta}^13*C \211 VPDB") > gives the per mil just fine but not the delta > ylab=expression({delta}^13*C \211 VPDB) > gives an error message for the inclusion of the backslash, and > ylab=expression({delta}^13*C "\211 VPDB") > gives an error message for the inclustion of the quotation marks. > > Apologies for the simple question, any help is very much appreciated! > > Thank you in advance, > > Nora > > > > -- > Nora Hanson > Gatty Marine Institute > Sea Mammal Research Unit > University of St. Andrews > St. Andrews > Fife KY16 9AL > Scotland > Mobile: 07846140350 > [EMAIL PROTECTED] > >[[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. > -- 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] Read from many files into many object
You can read in a list: DF <- lapply(dir(patt="file.*\\.txt"), read.table, sep = ";", header = TRUE) names(DF) <- paste("data", seq_along(DF), sep = "") DF[["data1"]] On Wed, Sep 3, 2008 at 7:52 AM, Sigit B Wibowo <[EMAIL PROTECTED]> wrote: > Dear all, > > I am new in R. I want to read data which is vector from many files and > import to many object. > For example I have 10(ten) files. > file1.txt > file2.txt > : > : > file10.txt. > > I want to import each file into one object as follows. > data1 > data2 > : > : > data10 > > I want to import file1.txt into data1, file2.txt into data2, and so on. > How to do it quickly? > > Thanks in advance. > Sigit B. Wibowo > > __ > 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] boxplot - label outliers
Try this: set.seed(123) DF <- data.frame(fac = gl(5, 20), values = rnorm(100)) bp <- boxplot(values ~ fac, data = DF, range = 0.5) with(bp, text(x = unique(group), y = tapply(out, group, max), labels = round(tapply(out, group, max), 2), pos = 3)) On Tue, Sep 2, 2008 at 8:11 PM, Sherri Heck <[EMAIL PROTECTED]> wrote: > Hi Greg, > > I have the values of the outliers from the boxplot stats. I am just having > a difficult time adding the values to the plot in the appropriate places. > Hope this is clearer. > > Thanks! > > sherri > > > Greg Snow wrote: > >> Are you trying to find the values of the outliers? Or just how to add the >> text to the plot in the appropriate place? Or both? >> >> -- >> Gregory (Greg) L. Snow Ph.D. >> Statistical Data Center >> Intermountain Healthcare >> [EMAIL PROTECTED] >> (801) 408-8111 >> >> >> >> >> >>> -Original Message- >>> From: [EMAIL PROTECTED] >>> [mailto:[EMAIL PROTECTED] On Behalf Of Sherri Heck >>> Sent: Tuesday, September 02, 2008 3:38 PM >>> To: r-help@r-project.org >>> Subject: [R] boxplot - label outliers >>> >>> Hi All- >>> >>> I have 24 boxplots on one graph. I do not have the whiskers >>> extending to the outliers, but I would like to label the >>> maximum value of each outlier above the whiskers. I have the >>> stats but am having trouble figuring out how to label the whiskers. >>> >>> Any suggestions would be great! >>> >>> sherri >>> >>> __ >>> 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. > -- 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] request: How to get column name
Or: which(apply(x == 0, 2, all)) On Wed, Sep 3, 2008 at 12:46 PM, Marc Schwartz <[EMAIL PROTECTED]>wrote: > on 09/03/2008 10:34 AM Chuck Cleland wrote: > > On 9/3/2008 11:05 AM, Petr PIKAL wrote: > >> [EMAIL PROTECTED] napsal dne 03.09.2008 15:54:08: > >> > >>> try this: > >>> > >>> x <- c(3,3,3,3,0,0,0,0,5,5,5,5,8,8,8,8) > >>> x <- matrix(x, nrow=4) > >>> > >>> which(colSums(x == 0) == nrow(x)) > >> Isn't this the same? > >> > >> which(colSums(x)==0) > > > > No, because the column sum can be zero without each element being zero: > > > > x <- c(3,3,3,3,1,-1,1,-1,5,5,5,5,8,8,8,8) > > x <- matrix(x, nrow=4) > > > >> which(colSums(x == 0) == nrow(x)) > > integer(0) > > > >> which(colSums(x)==0) > > [1] 2 > > > > Another (column-wise) approach to this would be: > > x <- c(3,3,3,3,0,0,0,0,5,5,5,5,8,8,8,8) > x <- matrix(x, nrow=4) > > > which(apply(x, 2, function(i) all(i == 0))) > [1] 2 > > > x <- c(3,3,3,3,1,-1,1,-1,5,5,5,5,8,8,8,8) > x <- matrix(x, nrow=4) > > > which(apply(x, 2, function(i) all(i == 0))) > integer(0) > > > 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. > -- 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] create separate plots by factors
Try this: foo <- function(x, dir = getwd(), ...){ png(file.path(dir, sprintf("%s.png", x))) plot(DF.split[[x]], ...) dev.off() } DF.split <- split(DF[, c("year", "peak")], DF$site) sapply(DF.split, foo) On Fri, Aug 7, 2009 at 4:05 PM, Ingrid Tohver wrote: > Hello, > I am attempting to create several plots based on "site" (~300 total) and am > having trouble with the code. I simply want to create a plot using the code, > plot(year, peak), for the following dataset. I would like for each site to > be plotted on a separate page and the plots saved in a directory. Would a > "foreach" loop work? I tried a "by" statement, but it doesn't seem to work > with plotting functions. > I would really appreciate any leads. > Ingrid > > site year peak > ALBEN 5 101529.6 > ALBEN 10 117483.4 > ALBEN 20 132960.9 > ALBEN 50 153251.2 > ALBEN 100 168647.8 > ALBEN 200 184153.6 > ALBEN 500 204866.5 > ALDER 56561.3 > ALDER 107897.1 > ALDER 209208.1 > ALDER 50 10949.3 > ALDER 100 12287.6 > ALDER 200 13650.2 > ALDER 500 15493.6 > AMERI 5 43656.5 > AMERI 10 51475.3 > AMERI 20 58854.4 > AMERI 50 68233.3 > AMERI 100 75135.9 > AMERI 200 81908.3 > > > Ingrid M Tohver > Research Scientist, Climate Impacts Group > University of Washington > > __ > 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] strsplit a matrix
Try this: #1 gsub(".*-", "", zzz) #2 gsub("-.*", "", zzz) On Mon, Aug 10, 2009 at 1:56 PM, James Perkins wrote: > Dear all, > > I am trying to split a matrix into 2 as efficiently as possible. > > It is a character matrix: > > 1 2 3 1 "2-271" "2-367" "1-79" > 2 "2-282" "2-378" "1-90" > 3 "2-281" "2-377" "1-89" > > I want to make 2 matrices from this, as succinctly and efficiently as > possible. > > I've tried such things as sapply(matrix, strsplit, "-") and tried to go > from there, but I can't figure it out! So far I do it with a 2D for loop > which can't be efficient! > > firstPartM <- matrix(ncol= dim(zzz)[2], nrow= dim(zzz)[1]) > secondPartM <- matrix(ncol= dim(zzz)[2], nrow= dim(zzz)[1]) > for(i in 1:dim(zzz)[1]) { > for(j in 1:dim(zzz)[2]) { >splitS <- strsplit(zzz[i,j],"-") >firstPartM[i,j] <- splitS[[1]][1] >secondPartM[i,j] <- splitS[[1]][2] > } > } > > Cheers, > > Jim > > __ > 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] strsplit a matrix
Try this: #1 gsub(".*-", "", zzz) #2 gsub("-.*", "", zzz) #3) gsub(".*-(.*)-.*", "\\1", zzz) On Mon, Aug 10, 2009 at 4:20 PM, Jun Shen wrote: > Henrique, > > This is a very nice approach. I wonder what if I have data like 2-172-45 > and want to break it down into three parts 2, 172 and 45. How do we use your > method to achieve it? Thanks. > > Jun > > On Mon, Aug 10, 2009 at 12:34 PM, Henrique Dallazuanna > wrote: > >> Try this: >> >> #1 >> gsub(".*-", "", zzz) >> >> #2 >> gsub("-.*", "", zzz) >> >> >> On Mon, Aug 10, 2009 at 1:56 PM, James Perkins >> wrote: >> >> > Dear all, >> > >> > I am trying to split a matrix into 2 as efficiently as possible. >> > >> > It is a character matrix: >> > >> > 1 2 3 1 "2-271" "2-367" "1-79" >> > 2 "2-282" "2-378" "1-90" >> > 3 "2-281" "2-377" "1-89" >> > >> > I want to make 2 matrices from this, as succinctly and efficiently as >> > possible. >> > >> > I've tried such things as sapply(matrix, strsplit, "-") and tried to go >> > from there, but I can't figure it out! So far I do it with a 2D for loop >> > which can't be efficient! >> > >> > firstPartM <- matrix(ncol= dim(zzz)[2], nrow= dim(zzz)[1]) >> > secondPartM <- matrix(ncol= dim(zzz)[2], nrow= dim(zzz)[1]) >> > for(i in 1:dim(zzz)[1]) { >> > for(j in 1:dim(zzz)[2]) { >> >splitS <- strsplit(zzz[i,j],"-") >> >firstPartM[i,j] <- splitS[[1]][1] >> >secondPartM[i,j] <- splitS[[1]][2] >> > } >> > } >> > >> > Cheers, >> > >> > Jim >> > >> > __ >> > 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. >> >> > > > -- > Jun Shen PhD > PK/PD Scientist > BioPharma Services > Millipore Corporation > 15 Research Park Dr. > St Charles, MO 63304 > Direct: 636-720-1589 > > -- 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] Selecting/Accessing the last vector in a list of a list of data.frames
If I understand correctly your question, you can try something about like this: # Access all elements named 'V1' in your list lapply(test, lapply, '[', 'V1') On Tue, Aug 11, 2009 at 3:49 PM, Bryan Hanson wrote: > Hello Again R Folks: > > I¹m trying to clean up some code. Suppose I have an object like this: > > > str(test) > List of 2 > $ G:List of 2 > ..$ cls:'data.frame':101 obs. of 2 variables: > .. ..$ V1: num [1:101] -0.0019 -0.0019 -0.00189 -0.00188 -0.00186 ... > .. ..$ V2: num [1:101] 0.000206 0.000247 0.000288 0.000329 0.000371 ... > ..$ rob:'data.frame':101 obs. of 2 variables: > .. ..$ V1: num [1:101] -0.00142 -0.00141 -0.0014 -0.00139 -0.00137 ... > .. ..$ V2: num [1:101] 0.000424 0.000456 0.000487 0.000517 0.000546 ... > $ T:List of 2 > ..$ cls:'data.frame':101 obs. of 2 variables: > .. ..$ V1: num [1:101] -0.00222 -0.00222 -0.00221 -0.00219 -0.00216 ... > .. ..$ V2: num [1:101] -0.00077 -0.000742 -0.000712 -0.000681 -0.000648 > .. > ..$ rob:'data.frame':101 obs. of 2 variables: > .. ..$ V1: num [1:101] -0.000981 -0.000979 -0.000972 -0.000961 -0.000946 > .. > .. ..$ V2: num [1:101] -0.000332 -0.000303 -0.000274 -0.000245 -0.000216 > .. > > I need to perform some operations on each value of V1 in turn, then each > value of V2 in turn (so for instance I want test$G$cls$V1). The structure > of this object is nearly constant except the first elements of the list (G, > T in the example) may vary in number and name, so I need something that > accommodates this. > > I can do this with loops, but it seems like a job for lapply or rapply, but > these don't quite work. I've played with quite a few variations, searched > the help archives and found a number of useful ideas, but not quite what I > need. The only thing that nearly works is do.call(cbind, object) enough > times to bring V1 and V2 "to the surface" but then I've lost my carefully > constructed naming. > > Any suggestions appreciated. It seems like there might be a simple > approach, but I may be too tired right now to see it! > > Thanks, Bryan > * > Bryan Hanson > Professor of Chemistry & Biochemistry > DePauw University, Greencastle IN USA > > __ > 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.