[R] probability of occurrence of an event and the probability of an event upon the occurrence of another event
how can i calculate the probability of occurrence of an event and the probability of an event upon the occurrence of another event. P (A) and P (A | B) .. [[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] probability of occurrence of an event and the probabilityof anevent upon the occurrence of another event
Hello, Francesco, these could be considered as two of the central questions in statistics in general ... but they do not necessarily have anything to do with R. Regards -- Gerrit On Fri, 6 Sep 2013, Francesco Miranda wrote: how can i calculate the probability of occurrence of an event and the probability of an event upon the occurrence of another event. P (A) and P (A | B) .. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] read.dta()
It should work. I've used it several times with 3.01 in Linux. Just make sure you load the library: library(foreign) day-read.dta(filelocation/abc.dta) Carlos On Thursday, September 5, 2013, Debasish Roy wrote: I've been using R 3.0.1 version. I tried to read a file named abc.dta() I used the command X - read.dta(abc.dta) and it gave me Error: could not find function read.dta Can anyone help me what could be the problem and how to fix it ? Thanks, Deb. [[alternative HTML version deleted]] -- Sent from Gmail Mobile [[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] probability of occurrence of an event and the probabilityof anevent upon the occurrence of another event
On Sep 6, 2013, at 12:34 , Gerrit Eichner wrote: Hello, Francesco, these could be considered as two of the central questions in statistics in general ... but they do not necessarily have anything to do with R. Regards -- Gerrit Yes. However, since it is Friday and my brain is fried from the morning lecture anyway: If you can represent the (finite) sample space in R, you can also do probability calculations in R. Conditioning corresponds to subsetting the sample space. E.g., for a double dice throw (D1,D2) you can find twodice - expand.grid(d1=1:6,d2=1:6) with(twodice, mean(d1==5)) [1] 0.167 with(subset(twodice,d1+d2==8), mean(d1==5)) [1] 0.2 with(subset(twodice,d1+d2==11), mean(d1==5)) [1] 0.5 I.e. P(D1=5) = 1/6 P(D1=5 | D1+D2=8) = 1/5 P(D1=5 | D1+D2=11) = 1/2 The above works for symmetric probability spaces. For general finite spaces, include a vector of probabilities and do something like this: twodice$p - 1/nrow(twodice) with(subset(twodice,d1+d2==11), sum(p[d1==5])/sum(p)) [1] 0.5 - Peter D. On Fri, 6 Sep 2013, Francesco Miranda wrote: how can i calculate the probability of occurrence of an event and the probability of an event upon the occurrence of another event. P (A) and P (A | B) .. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@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] xyplot() with discontinuous x-axis variable
My xyplot() with superposed multiple condiions looks better with lines than with points (it's easier to see changes over time with the lines). But, there are gaps in the years (the x axis) for which there are data to be plotted. For example, there are data for years 2004-2006 and 2010-2012, but not for 2007-2009. I would like to have the lines for only the two groups with data. Reading ?xyplot suggests that the group attribute might do the job but I do not see how to write the equation. #Test data ym -as.data.frame(expand.grid(Y=c(2004:2006, 2010:2012), A=1:4)) #A is an arbitrary variable to give us some panels. ym$x - runif(nrow(ym)) library(lattice) #Plots without, andf with, a groups argument xyplot(x~Y|A, data=ym, type=l) xyplot(x~Y|A, data=ym, type=l, groups=ym$Y2007) Is that what you had in mind? S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] plot densities outside axis
That's perfect. Thanks! On Fri, Sep 6, 2013 at 12:45 AM, Pascal Oettli kri...@ymail.com wrote: Hello, Using a web search engine, I found, for example: http://www.unt.edu/benchmarks/archives/2003/february03/rss.htm http://sas-and-r.blogspot.jp/2012_09_01_archive.html Hope this helps, Pascal 2013/9/5 Dustin Fife df...@ou.edu I've been working on a way to visualize a spearman correlation. That seemed pretty simple: generate skewed data x = rnorm(100)^2 y = .6*x + rnorm(100, 0, sqrt(1-.6^2)) plot(x,y) regular plot plot(rank(x),rank(y), xaxt=n, yaxt=n) ### spearman-like plot make axis labels axis(1, at=quantile(rank(x)), labels=round(quantile(x), digits=2)) axis(2, at=quantile(rank(y)), labels=round(quantile(y), digits=2)) However, transforming the data into ranks eliminates any information we have about the distributions of the data. My solution to this problem is to plot the densities outside the x/y axis with the mode of the distribution pointing away from the plot. I've seen plots like this in textbooks, but can't think of a way to do this in R. Any ideas? [[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.
[R] calculate the probability
How to calculate the probability P (xt q | yt q) where xt and yt are two time series and q is a conditional quantile. thankFrancesco Miranda [[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] calculate the probability
On Sep 6, 2013, at 9:36 AM, Francesco Miranda kicco1...@hotmail.it wrote: How to calculate the probability P (xt q | yt q) where xt and yt are two time series and q is a conditional quantile. thankFrancesco Miranda You were told previously, directly and indirectly, that this is not the proper place to post general statistics and probability questions and especially not homework questions, if that is the case here. Peter kindly took the time to reply to your first post, but that should not be an indication that you have tacit approval to continue to post such questions here. If these are indeed homework questions, seek assistance from your professor or other academic support resources. If they are not, seek out other more general online resources such as StackExchange/CrossValidated (http://stats.stackexchange.com/questions). Regards, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Y-axis labels as decimal numbers
Does this modification work for you: par(mar=c(10,4,4,2)) plot(set1$duration,set1$duration.1,type=b,col = blue, ylab=, xaxt = 'n', xlab=,las=2,lwd=2.5, lty=1,cex.axis=2.5) # now plot you times axis(1 , at = set1$duration , labels = format(set1$duration, format = %H:%M) , las = 2 ,cex.axis=2.5 ) Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Fri, Sep 6, 2013 at 1:42 AM, mohan.radhakrish...@polarisft.com wrote: Hi, set1$duration.2- as.POSIXct(paste('2013-08-24', set1$duration)) plot(set1$duration.2,set1$duration.1,type=b,col = blue, ylab=, xaxt = 'n', xlab=,las=2,lwd=2.5, lty=1,cex.axis=2.5) # now plot you times axis(1, at = set1$duration.2, labels = set1$duration, las = 2,cex.axis=2.5) text(set1$duration,set1$duration.1, set1$duration.1, 2, cex=1.45) I think this is the correct code. The graphs is attached. y-axis is not accurately shown. Thanks. From:jim holtman jholt...@gmail.com To:mohan.radhakrish...@polarisft.com Cc:R mailing list r-help@r-project.org Date:09/05/2013 10:01 PM Subject:Re: [R] Y-axis labels as decimal numbers So what is wrong with the y-axis? When I run your script, things seem right. Can you explain what it is that you want. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Thu, Sep 5, 2013 at 9:22 AM, mohan.radhakrish...@polarisft.com wrote: Hi, I am able to create a graph with this code but the decimal numbers are not plotted accurately because the ylim values are not set properly. x-axis is proper. How do I accurately set the ylim for duration.1 column ? Thanks, Mohan set1$duration- as.POSIXct(paste('2013-08-24', set1$duration)) plot(set1$duration,set1$duration.1,type=b,col = blue, ylab=, xaxt = 'n', xlab=,las=2,lwd=2.5, lty=1,cex.axis=2.5) # now plot you times axis(1, at = set1$duration, labels = set1$duration, las = 2,cex.axis=2.5) duration duration.1 2 16:03:41 0.05 3 17:03:41 0.27 4 18:03:43 1.22 5 19:03:45 1.51 6 20:03:47 1.27 7 21:03:48 1.15 8 22:03:50 1.22 9 23:03:52 1.27 10 00:03:54 1.27 11 01:03:55 1.22 12 02:03:57 1.26 13 03:03:59 1.57 14 04:04:01 1.31 15 05:04:03 1.24 This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.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. This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.com attachment: r-help.png__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error with RNetLogo on a mac
gist with code and respective errors: http://goo.gl/r6VrHl would appreciate any input on how to get around the java vm problem. btw, the very idea of connecting R and netlogo is superb copying Jan in case he might have some input many thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] melt error that I don't understand.
I'm stumped. I have a dataset I want to melt to create a temporal sequence of events for each subject, but in each row, I would like to retain the baseline characteristics. D - structure(list(ID = c(A, B, C, D, E, F, G, H, I, J), AGE = structure(c(68L, 63L, 55L, 64L, 60L, 78L, 60L, 62L, 60L, 75L), label = Age, class = labelled), BMI = structure(c(25L, 27L, 27L, 28L, 32L, NA, 36L, 27L, 31L, 25L), label = BMI (kg/m2), class = labelled), EventDays = structure(c(722L, 738L, 707L, 751L, 735L, 728L, 731L, 717L, 728L, 735L), label = Time to first ACM/censor (days), class = labelled), ImplantDays = c(NA, NA, 575, NA, NA, NA, 490, 643, NA, NA)), .Names = c(ID, AGE, BMI, EventDays, InterventionDays), row.names = c(NA, 10L), class = data.frame) melt(D, c(ID, AGE, BMI)) # produces the following error Error in data.frame(ids, variable, value, stringsAsFactors = FALSE) : arguments imply differing number of rows: 10, 20 Now, I know AGE and BMI aren't exactly identifying variables, but my hope would be that, since ID uniquely identifies the subjects, I could use this as a short cut to getting the data set I want. I can get the data I want if I go about it a little differently. #* What I would like it to look like. Timeline - melt(D[, c(ID, EventDays, InterventionDays)], ID, na.rm=TRUE) Timeline - arrange(Timeline, ID, value) Timeline - merge(D[, c(ID, AGE, BMI)], Timeline, by=ID, all.x=TRUE) At first I thought it might be the mixture of character and numeric variables as IDs, but the following example works A - data.frame(id = LETTERS[1:10], age = c(50, NA, 51, 52, 53, 54, 55, 56, 57, 58), meas1 = rnorm(10), meas2 = rnorm(10, 5), stringsAsFactors=FALSE) melt(A, c(id, age)) I'm sure I'm missing something really obvious (kind of like how I can stare at the dry goods aisle for 10 minutes and still not find the chocolate chips). If anyone could help me understand why this error is occurring, I'd greatly appreciate it. sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] C attached base packages: [1] splines stats graphics grDevices utils datasets methods base other attached packages: [1] lazyWeave_2.2.3 Hmisc_3.10-1 survival_2.36-14 plyr_1.7.1 reshape2_1.2.2 loaded via a namespace (and not attached): [1] cluster_1.14.3 grid_2.15.2 lattice_0.20-10 stringr_0.6.1 tools_2.15.2 Benjamin Nutter | Biostatistician | Quantitative Health Sciences Cleveland Clinic | 9500 Euclid Ave. | Cleveland, OH 44195 | (216) 445-1365 === Please consider the environment before printing this e-mail Cleveland Clinic is ranked as one of the top hospitals in America by U.S.News World Report (2013). Visit us online at http://www.clevelandclinic.org for a complete listing of our services, staff and locations. Confidentiality Note: This message is intended for use ...{{dropped:18}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Impute missing data by regression in R
i dont think it works. is there any function in any package? -- View this message in context: http://r.789695.n4.nabble.com/Impute-missing-data-by-regression-in-R-tp2996520p4675516.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fwd:
On 06-09-2013, at 19:32, Waqas Shafqat waqas1...@gmail.com wrote: -- Forwarded message -- From: Waqas Shafqat waqas1...@gmail.com Date: Fri, Sep 6, 2013 at 10:31 PM Subject: To: rosy...@msu.edu sorry sir i have istalled plantbreeding libraray..but when i give command require(plantbreeding) then following message appear require(plantbreeding) Loading required package: plantbreeding Loading required package: qtl Failed with error: ‘package ‘qtl’ could not be loaded’ In addition: Warning message: In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) : there is no package called ‘qtl’ Well, just install package qtl. Berend further any anlysis i.e dialle or stability not to be done please guide me sorry to disturb for so many times.. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to define ordinal, nominal and scale type variables?
On 06/09/2013 5:29 AM, Markus Gschwind wrote: Hello, I am a beginner of R but knowing SPSS and matlab. I need to analyse my data with a mixed type cluster analysis, that's why I am looking into R. I have a datasheet with 45 subjects (rows) and 30 variables of each subjet (columns) in Excel (datasheet.csv) or SPSS (datasheet.sav). In SPSS I can define if the variable is ordinal (e.g. low - intermediate - high), nominal (e.g. type of hobby) or scale (e.g. age). The variables are all numerical (as SPSS needs them in numbers coding the ordinal or nominal qualities). However, when using data importing like mydata-read.spss(datasheet.sav) or mydata-read.table(datasheet.csv, sep=,,na=,stringsAsFactors=F) this produces a 'list' and not a 'data frame' with factors. My question: How can I import the measure (i.e. nominal, ordinal, scale) form SPSS? Or how can I define variables in mydata as nominal or ordinal, even if they consist of numbers? Actually, the read.table() function will produce a dataframe, but you asked for no factors, so you'll get no factors. To convert a variable x to a nominal factor, use f - factor(x, levels = c( . )) where the levels are chosen to list all possible values that x could take. If x is a column of a dataframe d, use d$f - factor(d$x, levels = c( )) to create a new column named f in the dataframe. For an ordinal factor, do the same, but use ordered() instead of factor(). (You can do some of this automatically using read.table, e.g. by specifying colClasses, but you have more flexibility if you do it as shown above.) Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] melt error that I don't understand.
Hi Benjamin, This looks like a bug, whereby melt fails when numeric id.vars have attributes. Consider: D - structure(list(ID = c(A, B, C, D, E, F, G, H, I, J), AGE = structure(c(68L, 63L, 55L, 64L, 60L, 78L, 60L, 62L, 60L, 75L), label = Age, class = labelled), BMI = structure(c(25L, 27L, 27L, 28L, 32L, NA, 36L, 27L, 31L, 25L), label = BMI (kg/m2), class = labelled), EventDays = structure(c(722L, 738L, 707L, 751L, 735L, 728L, 731L, 717L, 728L, 735L), label = Time to first ACM/censor (days), class = labelled), ImplantDays = c(NA, NA, 575, NA, NA, NA, 490, 643, NA, NA)), .Names = c(ID, AGE, BMI, EventDays, InterventionDays), row.names = c(NA, 10L), class = data.frame) melt(D, c(ID, AGE, BMI)) ## does not work D - as.data.frame(lapply(D, as.vector)) ## strip attributes melt(D, c(ID, AGE, BMI)) ## works attr(D$ID, label) - ID number ## add attribute to factor melt(D, c(ID, AGE, BMI)) ## works attr(D$AGE, label) - Age ## add attribute to numeric variable melt(D, c(ID, AGE, BMI)) ## does not work I've reported the bug at https://github.com/hadley/reshape/issues/36 Best, Ista On Fri, Sep 6, 2013 at 11:59 AM, Nutter, Benjamin nutt...@ccf.org wrote: I'm stumped. I have a dataset I want to melt to create a temporal sequence of events for each subject, but in each row, I would like to retain the baseline characteristics. D - structure(list(ID = c(A, B, C, D, E, F, G, H, I, J), AGE = structure(c(68L, 63L, 55L, 64L, 60L, 78L, 60L, 62L, 60L, 75L), label = Age, class = labelled), BMI = structure(c(25L, 27L, 27L, 28L, 32L, NA, 36L, 27L, 31L, 25L), label = BMI (kg/m2), class = labelled), EventDays = structure(c(722L, 738L, 707L, 751L, 735L, 728L, 731L, 717L, 728L, 735L), label = Time to first ACM/censor (days), class = labelled), ImplantDays = c(NA, NA, 575, NA, NA, NA, 490, 643, NA, NA)), .Names = c(ID, AGE, BMI, EventDays, InterventionDays), row.names = c(NA, 10L), class = data.frame) melt(D, c(ID, AGE, BMI)) # produces the following error Error in data.frame(ids, variable, value, stringsAsFactors = FALSE) : arguments imply differing number of rows: 10, 20 Now, I know AGE and BMI aren't exactly identifying variables, but my hope would be that, since ID uniquely identifies the subjects, I could use this as a short cut to getting the data set I want. I can get the data I want if I go about it a little differently. #* What I would like it to look like. Timeline - melt(D[, c(ID, EventDays, InterventionDays)], ID, na.rm=TRUE) Timeline - arrange(Timeline, ID, value) Timeline - merge(D[, c(ID, AGE, BMI)], Timeline, by=ID, all.x=TRUE) At first I thought it might be the mixture of character and numeric variables as IDs, but the following example works A - data.frame(id = LETTERS[1:10], age = c(50, NA, 51, 52, 53, 54, 55, 56, 57, 58), meas1 = rnorm(10), meas2 = rnorm(10, 5), stringsAsFactors=FALSE) melt(A, c(id, age)) I'm sure I'm missing something really obvious (kind of like how I can stare at the dry goods aisle for 10 minutes and still not find the chocolate chips). If anyone could help me understand why this error is occurring, I'd greatly appreciate it. sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] C attached base packages: [1] splines stats graphics grDevices utils datasets methods base other attached packages: [1] lazyWeave_2.2.3 Hmisc_3.10-1 survival_2.36-14 plyr_1.7.1 reshape2_1.2.2 loaded via a namespace (and not attached): [1] cluster_1.14.3 grid_2.15.2 lattice_0.20-10 stringr_0.6.1 tools_2.15.2 Benjamin Nutter | Biostatistician | Quantitative Health Sciences Cleveland Clinic| 9500 Euclid Ave. | Cleveland, OH 44195 | (216) 445-1365 === Please consider the environment before printing this e-mail Cleveland Clinic is ranked as one of the top hospitals in America by U.S.News World Report (2013). Visit us online at http://www.clevelandclinic.org for a complete listing of our services, staff and locations. Confidentiality Note: This message is intended for use ...{{dropped:18}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and
Re: [R] Fwd:
It looks like all of your problem are associated with failing to installing dependencies of the plantbreeding package. install.packages(qtl) install.packages(ggplot2) install.packages (onemap) install.packages(grid) install.packages (agricolae) install.packages (reshape) install.packages (lme4) install.packages (boot) install.packages (plyr) install.packages (pvclust) Details on installation are provided in: http://rplantbreeding.blogspot.com/ Once you have installed all dependencies then you can use require(plantbreeding) On Fri, Sep 6, 2013 at 1:32 PM, Waqas Shafqat waqas1...@gmail.com wrote: -- Forwarded message -- From: Waqas Shafqat waqas1...@gmail.com Date: Fri, Sep 6, 2013 at 10:31 PM Subject: To: rosy...@msu.edu sorry sir i have istalled plantbreeding libraray..but when i give command require(plantbreeding) then following message appear require(plantbreeding) Loading required package: plantbreeding Loading required package: qtl Failed with error: package qtl could not be loaded In addition: Warning message: In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) : there is no package called qtl further any anlysis i.e dialle or stability not to be done please guide me sorry to disturb for so many times.. [[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.
Re: [R] Fwd: calculating dissimilarity index of islands (vegan and betapart)
Elaine: You would do better posting this on the R-sig-ecology list, I believe. THE r-help list is mostly for general R programming questions, while the ecology list readers will have expertise more closely related to your specific issues. Cheers, Bert On Fri, Sep 6, 2013 at 3:25 PM, Elaine Kuo elaine.kuo...@gmail.com wrote: Dear List, This is Elaine, a postgraduate studying in bird distributions in East Asia. I want to calculate Simpson dissimilarity index, based on a presence/absence matrix of bird species in islands in East Asia. (matrix row: 36 islands/matrix column: species ID) (R package vegan to make NMDS and R package betapart) In most papers using vegan for NMDS and betapart for dissimilarity index, the dissimilarity index is generated by grid data in continents. The calculation of this index is done by comparing species presence/absence between a pair of grids adjacent to each other. However, in my case, the dissimilarity index needs to be generated per island, and it is difficult for islands to find continuous landmass nearby. I would like ask if the calculation of dissimilarity index using metaMDS and beta.pair in continents can work as well as in islands. If so, please kindly advice how the mechanisim behind the code generates the dissimilarity index for island. (Does it compare species presence/absence between a pair of island? Should the two islands be specifically located or close to each other?) Thank you Elaine Code # NMDS library(MASS) library(vegan) island.NMDS - metaMDS(island,k=2, distfun = betadiver, distance = sim,trymax=100,zerodist=add) plot(island.NMDS, type = n) #Simpson Dissimilarity Index library(betapart) island.dist-beta.pair(island, index.family=sor) class(island.dist) [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] using correlation compound correlation structure with nlme; how to incorporate multple random effects?
You would do better to post this on the R-sig-mixed-models or R-sig-ecology list. Cheers, Bert On Fri, Sep 6, 2013 at 9:57 AM, Meredith, Christy S -FS csmered...@fs.fed.us wrote: Hello, I have developed this model to test change in PTFines6 over time. I have random effects of watershed (HUC3) and management type (mgmt3), and then I have the YrC/SiteID random effect which is the longitudinal time effect. But I recently found out that I need to incorporate a compound correlation structure. I found examples of this where there is just one random effect, but not my case where I have multiple. I am not sure if I just include YrC|SiteID or the entire random effect. I have tried both, and get error messages: Original code: model5.15_e=lme(PTFines6~HUC3 + YrC*mgmt3 + Bf* mgmt3 + LnGrad * mgmt3+ Precip ,random=list( ~1|HUC3,~1|mgmt3,1~(YrC)|SiteID),na.action=na.omit, data=habitat2,method=REML,control=control1) #22835 no precip interaction I have tried: model5.15_e=lme(PTFines6~HUC3 + YrC*mgmt3 + Bf* mgmt3 + LnGrad * mgmt3+ Precip ,random=list( ~1|HUC3,~1|mgmt3,1~(YrC)|SiteID),na.action=na.omit, data=habitat2, correlation=corCompSymm(form=1~(YrC)|SiteID),method=REML,control=control1) #22835 no precip interaction I get the message: incompatible formulas for groups in random and correlation I have tried: model5.15_e=lme(PTFines6~HUC3 + YrC*mgmt3 + Bf* mgmt3 + LnGrad * mgmt3+ Precip ,random=list( ~1|HUC3,~1|mgmt3,1~(YrC)|SiteID),na.action=na.omit, data=habitat2, correlation=corCompSymm(form=~1|HUC3,~1|mgmt3,1~(YrC)|SiteID),method=REML,control=control1) #22835 no precip interaction I get the error message non-numeric argument to mathematical function Thanks for any help. Christy Meredith This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately. [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] While using R CMD check: LaTex error: File `inconsolata.sty' not found
I have been struggling to try many ways with old version of R tools, MikTex, and R versions including R-patached and R-devel, os version (windows 7 and 8), but no luck to pass R CMD check at all. It seems that the missing inconsolata.sty is a key issue to bother so many R users, especially for those R users without much experience of latex. Even I renamed zi4.sty to inconsolata.sty, it did not work at all. I am wondering if any experienced R tools developers can fix this issue. Thanks. For reference, here is an example of a testing package with errors I had: * using log directory 'E:/Dropbox/RGenMod/data.Rcheck' * using R version 3.0.1 (2013-05-16) * using platform: x86_64-w64-mingw32 (64-bit) * using session charset: ISO8859-1 * checking for file 'data/DESCRIPTION' ... OK * checking extension type ... Package * this is package 'data' version '1.0' * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for executable files ... OK * checking for hidden files and directories ... OK * checking for portable file names ... OK * checking whether package 'data' can be installed ... WARNING Found the following significant warnings: Warning: E:/Dropbox/RGenMod/data/man/data-package.Rd:31: All text must be in a section Warning: E:/Dropbox/RGenMod/data/man/data-package.Rd:32: All text must be in a section See 'E:/Dropbox/RGenMod/data.Rcheck/00install.out' for details. * checking installed package size ... OK * checking package directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the package can be unloaded cleanly ... OK * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking Rd files ... WARNING prepare_Rd: data-package.Rd:31: All text must be in a section prepare_Rd: data-package.Rd:32: All text must be in a section * checking Rd metadata ... OK * checking Rd cross-references ... WARNING Unknown package 'pkg' in Rd xrefs * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking contents of 'data' directory ... OK * checking data for non-ASCII characters ... OK * checking data for ASCII and uncompressed saves ... OK * checking examples ... OK * checking PDF version of manual ... WARNING LaTeX errors when creating PDF version. This typically indicates Rd problems. LaTeX errors found: ! LaTeX Error: File `inconsolata.sty' not found. Type X to quit or RETURN to proceed, or enter new name. (Default extension: sty) ! Emergency stop. read * l.281 ! == Fatal error occurred, no output PDF file produced! * checking PDF version of manual without hyperrefs or index ... OK WARNING: There were 4 warnings. See 'E:/Dropbox/RGenMod/data.Rcheck/00check.log' for details. On Fri, Jul 12, 2013 at 12:49 PM, Berend Hasselman b...@xs4all.nl wrote: On 12-07-2013, at 18:04, Ravi Varadhan ravi.varad...@jhu.edu wrote: Hi, While using R CMD check I get the following Latex error message which occurs when creating PDF version of manual: LaTex error: File `inconsolata.sty' not found I am using Windows 7 (64-bit) and R 3.0.1. I have MikTex 2.9. I see that the incosolata.sty is present under \doc\fonts folder. How can I eliminate this problem? See http://r.789695.n4.nabble.com/inconsolata-sty-is-liable-to-disappear-texinfo-5-1-td4669976.html Get R-patched. Berend __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Looping an lapply linear regression function
HI, Using the example dataset (Test_data.csv): dat1- read.csv(Test_data.csv,header=TRUE,sep=\t,row.names=1) indx2-expand.grid(names(dat1),names(dat1),stringsAsFactors=FALSE) indx2New- indx2[indx2[,1]!=indx2[,2],] res2-t(sapply(seq_len(nrow(indx2New)),function(i) {x1- indx2New[i,]; x2-cbind(dat1[x1[,1]],dat1[x1[,2]]);summary(lm(x2[,1]~x2[,2]))$coef[,4]})) dat2- cbind(indx2New,value=res2[,2]) library(reshape2) res2New- dcast(dat2,Var1~Var2,value.var=value) row.names(res2New)- res2New[,1] res2New- as.matrix(res2New[,-1]) dim(res2New) #[1] 28 28 head(res2New,3) # AgriEmi AgriMach AgriValAd AgrVaGDP AIL ALAre #AgriEmi NA 0.23401895 0.45697412 4.644877e-01 0.6398030 0.4039855 #AgriMach 0.2340189 NA 0.01449519 4.922558e-06 0.3890046 0.9279044 #AgriValAd 0.4569741 0.01449519 NA 5.135269e-02 0.5325943 0.4872555 # ALPer ANS AraLa AraLaPer CombusRen ForArea #AgriEmi 0.4039855 2.507257e-01 0.2303275 0.2303275 0.9438409125 0.0004473563 #AgriMach 0.9279044 6.072123e-05 0.3154370 0.3154370 0.0040254771 0.2590309747 #AgriValAd 0.4872555 2.060412e-01 0.8449600 0.8449600 0.0008077264 0.5152352072 # ForArePer ForProTon ForProTonSKm ForRen GDP #AgriEmi 0.0004473563 0.01714768 0.0007089448 0.900222038 0.6022470671 #AgriMach 0.2590309748 0.20170800 0.2305335762 0.005584703 0.4199684378 #AgriValAd 0.5152352071 0.80983446 0.4368256400 0.208975126 0.0003534226 # GEF GroAgriProVal PermaCrop RoadDens RoadTot RurPopGro #AgriEmi 0.0008580856 0.01078593 0.6863110 0.6398030 0.6398030 0.40734903 #AgriMach 0.1315182244 0.14074612 0.2530378 0.3064186 0.3064186 0.33705434 #AgriValAd 0.7520803684 0.31556633 0.1151395 0.4374599 0.4374599 0.04837586 # RurPopPerc TerrPA Trac Vehi WaterWith #AgriEmi 0.4835676 0.4504239 2.279566e-01 0.6398030 0.3056195 #AgriMach 0.6401556 0.1707857 4.730759e-33 0.3064186 0.9502553 #AgriValAd 0.2383507 0.0223124 1.513169e-02 0.1251843 0.3307148 #or res3-xtabs(value~Var1+Var2,data=dat2) #here the diagonals are 0s attr(res3,class)- NULL attr(res3,call)-NULL names(dimnames(res3))-NULL #You can change it in the first solution also. res2New- dcast(dat2,Var1~Var2,value.var=value,fill=0) row.names(res2New)- res2New[,1] res2New- as.matrix(res2New[,-1]) identical(res2New,res3) #[1] TRUE A.K. Arun, That does exactly what I wanted to do, but how would I manipulate into a matrix where the indepedent variable was on the x and dependent on y, or vice versa, rather than a 736, 2 matrix V1 V2 V3 V4 V5...Vn V1 - V2 - V3 - V4 - V5 - Vn - - Original Message - From: arun smartpink...@yahoo.com To: R help r-help@r-project.org Cc: Sent: Thursday, September 5, 2013 12:49 PM Subject: Re: Looping an lapply linear regression function HI, May be this helps: set.seed(28) dat1- setNames(as.data.frame(matrix(sample(1:40,10*5,replace=TRUE),ncol=5)),letters[1:5]) indx-as.data.frame(combn(names(dat1),2),stringsAsFactors=FALSE) res-t(sapply(indx,function(x) {x1-cbind(dat1[x[1]],dat1[x[2]]);summary(lm(x1[,1]~x1[,2]))$coef[,4]})) rownames(res)-apply(indx,2,paste,collapse=_) colnames(res)[2]- Coef1 head(res,3) # (Intercept) Coef1 #a_b 0.39862676 0.8365606 #a_c 0.02427885 0.6094141 #a_d 0.37521423 0.7578723 #permutation indx2-expand.grid(names(dat1),names(dat1),stringsAsFactors=FALSE) #or indx2- expand.grid(rep(list(names(dat1)),2),stringsAsFactors=FALSE) indx2New- indx2[indx2[,1]!=indx2[,2],] res2-t(sapply(seq_len(nrow(indx2New)),function(i) {x1- indx2New[i,]; x2-cbind(dat1[x1[,1]],dat1[x1[,2]]);summary(lm(x2[,1]~x2[,2]))$coef[,4]})) row.names(res2)-apply(indx2New,1,paste,collapse=_) colnames(res2)- colnames(res) A.K. Hi everyone, First off just like to say thanks to everyone´s contributions. Up until now, I´ve never had to post as I´ve always found the answers from trawling through the database. I´ve finally managed to stump myself, and although for someone out there, I´m sure the answer to my problem is fairly simple, I, however have spent the whole day infront of my computer struggling. I know I´ll probably get an absolute ribbing for making a basic mistake, or not understanding something fully, but I´m blind to the mistake now after looking so long at it. What I´m looking to do, is formulate a matrix ([28,28]) of p-values produced from running linear regressions of 28 variables against themselves (eg a~b, a~c, a~d.b~a, b~c etc...), if that makes sense. I´ve managed to get this to work if I just input each variable by hand, but this isn´t going to help when I have to make 20 matrices. My script is as follows; for (j in [1:28]) { ##This section works perfectly, if I don´t try to loop it, I know this wont work at the moment, because I haven´t designated what j
Re: [R] Assessing temporal correlation in GAM with irregular time steps
Dear Gavin I got the code to work by setting the 'bar' to DOY as this was the measured time step. I stumbled across another problem, on some days I have multiple measurements which isn't allowed in corCAR1, therefore I've had to take the average of the replicates as suggested in another R help post. Taking the average has meant adding the autocorrelation structure now doesn't improve the model, although I now appear to have heterogeneity in the residuals (as you suggested in your initial post). I will look at variance structures or moving to the GLM GAM Thanks again, Tom -Original Message- From: Gavin Simpson [mailto:ucfa...@gmail.com] Sent: Thursday, September 05, 2013 6:35 PM To: Worthington, Thomas A Cc: r-help@r-project.org Subject: Re: [R] Assessing temporal correlation in GAM with irregular time steps On 3 September 2013 16:10, Worthington, Thomas A thomas.worthing...@okstate.edu wrote: Dear Gavin Thank you for the very detailed response. I had started to go down the route of fitting a correlation structure via gamm. I tried applying your code to my data but returned the error Error in corCAR1(~ID | SiteCode1971) : parameter in CAR(1) structure must be between 0 and 1 Sorry, that is my fault, I keep forgetting that you need to specify the formula argument, the first argument of corCAR1() is the value of the correlation parameter if you want to specify it. So try: corCAR1(form = ~ID | SiteCode1971) I do this (get that error) all the time myself. I set the 'bar' in your code to the sample ID (basically a number between 1 and 192) but I wasn't sure if this was what you meant in relation to 'ordering of the samples' That is not that useful as you need to give the software something about when the samples occur in time, otherwise it doesn't have the information needed to properly model the decay in correlation with time. You need to give it the observation time, however you measured it. HTH G Best wishes Tom -Original Message- From: Gavin Simpson [mailto:ucfa...@gmail.com] Sent: Tuesday, September 03, 2013 3:17 PM To: Worthington, Thomas A Cc: r-help@r-project.org Subject: Re: [R] Assessing temporal correlation in GAM with irregular time steps It is possible, but you can't use the discrete time or classical stochastic trend models (or evaluate using the ACF). Also, why do you care to do this with regard to DoY? The assumption of the model relates to the residuals, so you should check those for residual autocorrelation. As you are using `mgcv::gam` you could also use `mgcv::gamm` which can then leverage the correlation structures from the nlme package, which has spatial correlation structures (and you can think of time as a 1-d spatial direction). The package also has a `corCAR1()` correlation structure which is the continuous-time analogue of the AR(1). Fitting via `gamm()` will also allow you to use the `Variogram()` function from the nlme package to assess the model residuals for residual autocorrelation. For example you could compare the two fits m0 - gamm(Length ~ s(DOY, by = SiteCode) + SiteCode, data = foo, method = REML) m1 - gamm(Length ~ s(DOY, by = SiteCode) + SiteCode, data = foo, method = REML, correlation = corCAR1( ~ bar | SiteCode)) where `foo` is the object that contains the variables mentioned in the call, and `bar` is the variable (in `foo)` that indicates the ordering of the samples. Notice that I nest the CAR(1) within the two respective Sites, but do note IIRC that this fits the same residual correlation structure to both sites' residuals (i.e. there is 1 CAR(1) process, not two separate ones). require(nlme) anova(m0$lme, m1$lme) will perform a likelihood ratio test on the two models. If you have residual autocorrelation, do note that the smooth for DoY may be chosen to be more complex than is appropriate (it might be fitting the autocorrleated noise), so you may want to fix the degrees of freedom for the smoother at some a priori chosen value and use this same value when fitting both m0 and m1, or at the very least set an upper limit on the complexity of the DoY smooth, say via s(DoY, by = SiteCode, k = 5). Finally, as a length = 0 insect makes no sense, the assumption of Gaussian (Normal) errors may be in trouble with your data; apart from their strictly positive nature, the mean-variance relationship of the data may not follow that of the assumptions for the errors. You can move to a GLM (GAM) to account for this but things get very tricky with the correlation structures (you can use gamm() still but fitting then goes via glmmPQL() in the MASS package a thence to lme()). If you just want to fit a variogram to something, there are a large number of spatial packages available for R, several of which can fit variograms to data, though you will need to study their respective help files for how to use them. As
Re: [R] binary symmetric matrix combination
HI, No problem. Suppose you have many matrices and you want to sum up the repeated variables, may be this helps: #Creating one more matrix which has some repeated variables. m6- as.matrix(read.table(text=y1 e5 s2 y1 0 1 1 e5 1 0 1 s2 1 1 0,sep=,header=TRUE)) #m1:m5 same as previous dat-do.call(rbind,lapply(paste0(m,1:6),function(x) {x1- get(x);cbind(expand.grid(rep(list(colnames(x1)),2),stringsAsFactors=FALSE),value=as.vector(x1))})) library(reshape2) res- dcast(dat,Var1~Var2,value.var=value,sum) row.names(res)- res[,1] res- as.matrix(res[,-1]) res # c1 c2 e5 e6 g24 h4 l15 l16 l17 s2 s30 y1 #c1 0 1 0 0 0 0 0 0 1 0 0 1 #c2 1 0 0 0 0 0 0 0 1 0 0 1 #e5 0 0 0 0 0 0 1 0 0 1 0 2 #e6 0 0 0 0 0 0 0 1 0 0 0 1 #g24 0 0 0 0 0 0 0 0 0 0 0 1 #h4 0 0 0 0 0 0 0 0 0 1 1 1 #l15 0 0 1 0 0 0 0 0 0 0 0 1 #l16 0 0 0 1 0 0 0 0 0 0 0 1 #l17 1 1 0 0 0 0 0 0 0 0 0 1 #s2 0 0 1 0 0 1 0 0 0 0 1 2 #s30 0 0 0 0 0 1 0 0 0 1 0 1 #y1 1 1 2 1 1 1 1 1 1 2 1 0 #If you want it in a particular order, say: names1-unique(unlist(lapply(paste0(m,1:6),function(x) colnames(get(x) names1 #[1] y1 g24 c1 c2 l17 h4 s2 s30 e5 l15 e6 l16 dat1- datdat1$Var1- factor(dat1$Var1,levels=names1) dat1$Var2- factor(dat1$Var2,levels=names1) dat2-dat1[order(dat1$Var1,dat1$Var2),] res1- dcast(dat2,Var1~Var2,value.var=value,sum)row.names(res1)- res1[,1] res1- as.matrix(res1[,-1]) res1 # y1 g24 c1 c2 l17 h4 s2 s30 e5 l15 e6 l16 #y1 0 1 1 1 1 1 2 1 2 1 1 1 #g24 1 0 0 0 0 0 0 0 0 0 0 0 #c1 1 0 0 1 1 0 0 0 0 0 0 0 #c2 1 0 1 0 1 0 0 0 0 0 0 0 #l17 1 0 1 1 0 0 0 0 0 0 0 0 #h4 1 0 0 0 0 0 1 1 0 0 0 0 #s2 2 0 0 0 0 1 0 1 1 0 0 0 #s30 1 0 0 0 0 1 1 0 0 0 0 0 #e5 2 0 0 0 0 0 1 0 0 1 0 0 #l15 1 0 0 0 0 0 0 0 1 0 0 0 #e6 1 0 0 0 0 0 0 0 0 0 0 1 #l16 1 0 0 0 0 0 0 0 0 0 1 0 #or res2- xtabs(value~Var1+Var2,data=dat2) attr(res2,class)- NULL attr(res2,call)-NULL names(dimnames(res2))-NULL all.equal(res1,res2) #[1] TRUE A.K. Very many thanks once again...does the code work for many matrices? I have around 200 small matrices. Another question, is there a similar code to merge the matrices by summing up the 1 values for repeated variables (row/colnames)? - Original Message - From: arun smartpink...@yahoo.com To: R help r-help@r-project.org Cc: Sent: Thursday, September 5, 2013 6:54 PM Subject: Re: binary symmetric matrix combination HI, No problem. I think you didn't run the `vecOut` after adding the new matrix. `lst1` is based on `vecOut` For example: m5- as.matrix(read.table(text=y1 e6 l16 y1 0 1 1 e6 1 0 1 l16 1 1 0,sep=,header=TRUE)) names1-unique(c(colnames(m1),colnames(m2),colnames(m3),colnames(m4), colnames(m5))) Out3-matrix(0,length(names1),length(names1),dimnames=list(names1,names1)) lst1-sapply(paste0(m,1:5),function(x) {x1- get(x); x2-paste0(colnames(x1)[col(x1)],rownames(x1)[row(x1)]); match(x2,vecOut)}) lst1 #$m1 #[1] 1 2 11 12 # #$m2 #[1] 1 3 4 5 21 23 24 25 31 33 34 35 41 43 44 45 # #$m3 #[1] 1 6 7 8 51 56 57 58 61 66 67 68 71 76 77 78 # #$m4 #[1] 1 9 10 81 89 90 91 99 100 # #$m5 #[1] 1 NA NA NA NA NA NA NA NA ###Here vecOut was based on Out2 lst2- list(m1,m2,m3,m4,m5) N- length(lst1) fn1- function(N,Out){ i=1 while(i=N){ Out[lst1[[i]]]-lst2[[i]] i-i+1 } Out } fn1(N,Out3) #Error in Out[lst1[[i]]] - lst2[[i]] : # NAs are not allowed in subscripted assignments ###Running vecOut using Out3 vecOut-paste0(colnames(Out3)[col(Out3)],rownames(Out3)[row(Out3)]) lst1-sapply(paste0(m,1:5),function(x) {x1- get(x); x2-paste0(colnames(x1)[col(x1)],rownames(x1)[row(x1)]); match(x2,vecOut)}) fn1(N,Out3) # y1 g24 c1 c2 l17 h4 s2 s30 e5 l15 e6 l16 #y1 0 1 1 1 1 1 1 1 1 1 1 1 #g24 1 0 0 0 0 0 0 0 0 0 0 0 #c1 1 0 0 1 1 0 0 0 0 0 0 0 #c2 1 0 1 0 1 0 0 0 0 0 0 0 #l17 1 0 1 1 0 0 0 0 0 0 0 0 #h4 1 0 0 0 0 0 1 1 0 0 0 0 #s2 1 0 0 0 0 1 0 1 0 0 0 0 #s30 1 0 0 0 0 1 1 0 0 0 0 0 #e5 1 0 0 0 0 0 0 0 0 1 0 0 #l15 1 0 0 0 0 0 0 0 1 0 0 0 #e6 1 0 0 0 0 0 0 0 0 0 0 1 #l16 1 0 0 0 0 0 0 0 0 0 1 0 A.K. Thanks a lot, all the codes worked perfectly. I have an additional question on the last steps you mentioned. I wanted to add another matrix to the ones I gave as an example, inputing m5 worked well, however when I type the code (added colnames (m5), changed 1:4 with 1:5 and added m5 to list2 I get the following error: Error in Out[lst1[[i]]] -
[R] using correlation compound correlation structure with nlme; how to incorporate multple random effects?
Hello, I have developed this model to test change in PTFines6 over time. I have random effects of watershed (HUC3) and management type (mgmt3), and then I have the YrC/SiteID random effect which is the longitudinal time effect. But I recently found out that I need to incorporate a compound correlation structure. I found examples of this where there is just one random effect, but not my case where I have multiple. I am not sure if I just include YrC|SiteID or the entire random effect. I have tried both, and get error messages: Original code: model5.15_e=lme(PTFines6~HUC3 + YrC*mgmt3 + Bf* mgmt3 + LnGrad * mgmt3+ Precip ,random=list( ~1|HUC3,~1|mgmt3,1~(YrC)|SiteID),na.action=na.omit, data=habitat2,method=REML,control=control1) #22835 no precip interaction I have tried: model5.15_e=lme(PTFines6~HUC3 + YrC*mgmt3 + Bf* mgmt3 + LnGrad * mgmt3+ Precip ,random=list( ~1|HUC3,~1|mgmt3,1~(YrC)|SiteID),na.action=na.omit, data=habitat2, correlation=corCompSymm(form=1~(YrC)|SiteID),method=REML,control=control1) #22835 no precip interaction I get the message: incompatible formulas for groups in random and correlation I have tried: model5.15_e=lme(PTFines6~HUC3 + YrC*mgmt3 + Bf* mgmt3 + LnGrad * mgmt3+ Precip ,random=list( ~1|HUC3,~1|mgmt3,1~(YrC)|SiteID),na.action=na.omit, data=habitat2, correlation=corCompSymm(form=~1|HUC3,~1|mgmt3,1~(YrC)|SiteID),method=REML,control=control1) #22835 no precip interaction I get the error message non-numeric argument to mathematical function Thanks for any help. Christy Meredith This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately. [[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] Combining rasters
[Probably an R-Sig-geo question...] On Fri, Sep 6, 2013 at 3:57 PM, philippe massicotte pmassico...@hotmail.com wrote: Hi everyone. I would like to know if it is possible to combine rasters in R to form a collage. For example, I would like to place 2 copies of the R logo side by side. r = raster(system.file(external/rlogo.grd, package = raster)) Convert to matrix, cbind, convert to raster: r2 = raster(cbind(as.matrix(r),as.matrix(r))) plot(r2) If you want to preserve the x and y scale somehow then you need to think about exactly where you are putting the second r and set xmx, ymx xmn, ymn when you construct the new raster. Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Combining rasters
Hi everyone. I would like to know if it is possible to combine rasters in R to form a collage. For example, I would like to place 2 copies of the R logo side by side. r = raster(system.file(external/rlogo.grd, package = raster)) After reading the help file (maybe I missed it) I did not find a way to do it. Any help would be appreciated. Sincerely, Phil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How do I parse text?
I have a data frame with a character field of the form ACUTE URI NOS, OPEN WOUND OF FOREHEAD, CROUP, STREP SORE THROAT, How can I get counts of all the words and their co-occurences? I've spent a long time searching on google, but it just takes me on a wild goose chase of dozens of modules involving advanced natural language processing theory. All I want is word counts and co-occurences. Thanks CONFIDENTIALITY NOTICE:\ This email message and any acco...{{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.
[R] How do I parse text?
I have a data frame with a character field of the form ACUTE URI NOS, OPEN WOUND OF FOREHEAD, CROUP, STREP SORE THROAT, How can I get counts of all the words and their co-occurences? I've spent a long time searching on google, but it just takes me on a wild goose chase of dozens of modules involving advanced natural language processing theory. All I want is word counts and co-occurences. Thanks CONFIDENTIALITY NOTICE:\ This email message and any acco...{{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.
[R] Alignment of data sets
Hi all; I have a data set with the format below: Year, Day, Hour, Value 2010, 001,0,15.9 2010, 001,1,7.3 2010, 001,2,5.2 2010, 001,3,8.0 2010, 001,4,0.0 2010, 001,5,12.1 2010, 001,6,11.6 2010, 001,7,13.9 2010, 001,8,11.9 2010, 001,9,13.6 2010, 001,10,16.1 2010, 001,11,18.5 That should be converted to this format: 2010, 001,0,15.9 2010, 001,1, 7.3 2010, 001,2, 5.2 2010, 001,3, 8.0 2010, 001,4, 0.0 2010, 001,5,12.1 2010, 001,6,11.6 2010, 001,7,13.9 2010, 001,8,11.9 2010, 001,9,13.6 2010, 001, 10,16.1 2010, 001, 11,18.5 The number of spaces is important. I have tried justify, but it produces spaces at the end or at the beginning of the rows depending on the choice of right, left alignment. Also I need 3 significant digits for the second column, when I use read.csv it gives me 1 instead of 001. So I use read.table, and one of the problems with read.table is that it produces row names that I don't want. Also I need commas in my output file. So far this is the best I could do: mydata = read.table(C:/ozone3.txt, sep = ) capture.output( print(mydata, sep = ,, print.gap=3), file=capture2.txt ) and the output has all the unwanted row names and also there are no commas. Any suggestions? Thank you Nasrin [[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] Java exception error (Jcheck) while running an R script
Dear all, I am facing a problem with running a script that i have written in R and i hope you can help me spot which exactly is the problem and how i can solve it. The error I get is the following: Error in .jcheck(silent = FALSE) : Java Exception no description because toString() failed.jcall(row[[ir]], Lorg/apache/poi/ss/usermodel/Cell;, createCell, as.integer(colIndex[ic] - 1))S4 object of class jobjRef As I am not a programmer, i don't really understand the error message. I did a search to try to understand what is wrong and if i am correct the problem is related with the 'rjava' package. I am not using directly this package but i am using the 'xlsx' package that is calling the 'rjava' one. I have made a search on the available resources online for tips/solutions. I found some similar errors on these reports: http://r.789695.n4.nabble.com/Java-Exception-error-while-reading-large-data-in-R-from-DB-using-RJDBC-td4647844.html but it is not really similar with my problem, as i don't read any data online. On http://stackoverflow.com/questions/12476044/r-how-to-clear-memory-used-by-rjava the problem seems similar but there is no reply. Since it mentions a memory problem, based on this post http://www.bramschoenmakers.nl/en/node/726 i tried to change the available java memory by using options(java.parameters = -Xmx4g ) It didn't work out. (Possibly is not related, but i had to try something). I would like to point out that i am loading to the script an excel file (through xlsx), making some calculations with the use of 'data.table' and 'sqldf' packages and then writing the results to a new excel file. We have tested the script with a file of 3120 lines and it works without any problem but when i try to run the script and load the excel file of interest that has 47000 lines, i get the error that i reported above. I would be more than grateful if anyone can help me on this. I am running R on Windows 7, with R version 3.0.1 and Java 7 update 10, all 64-bit. Thank you very much in advance, Panos -- Panagiotis Isigonis PhD student Department of Environmental Sciences, Informatics and Statistics Ca Foscari University Venice email: isigo...@unive.it tel: (+39) 041 509 3190 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 do I parse text?
Henry, Have look at the qdap package's termco, wfm, adjacency_matrix, and (possibly) word_associate functions. I'm not sure if they'll work as you really don't give much in the way of what the data is and the desired output (an example of the output). Cheers, Tyler Rinker From: htrobert...@seton.org To: r-help@r-project.org Date: Fri, 6 Sep 2013 21:14:42 + Subject: [R] How do I parse text? I have a data frame with a character field of the form ACUTE URI NOS, OPEN WOUND OF FOREHEAD, CROUP, STREP SORE THROAT, How can I get counts of all the words and their co-occurences? I've spent a long time searching on google, but it just takes me on a wild goose chase of dozens of modules involving advanced natural language processing theory. All I want is word counts and co-occurences. Thanks CONFIDENTIALITY NOTICE:\ This email message and any acco...{{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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Alignment of data sets
HI, The question is not clear. Lines1- readLines(textConnection(Year, Day, Hour, Value 2010, 001, 0, 15.9 2010, 001, 1, 7.3 2010, 001, 2, 5.2 2010, 001, 3, 8.0 2010, 001, 4, 0.0 2010, 001, 5, 12.1 2010, 001, 6, 11.6 2010, 001, 7, 13.9 2010, 001, 8, 11.9 2010, 001, 9, 13.6 2010, 001, 10, 16.1 2010, 001, 11, 18.5)) library(stringr) #Looking at the spaces between each comma. str_count(gsub((\\d+,\\s+\\d+).*,\\1,Lines1[-1]), ) # [1] 2 2 2 2 2 2 2 2 2 2 2 2 str_count(gsub(^\\d+,\\s+(\\d+,\\s+\\d+).*,\\1,Lines1[-1]), ) # [1] 4 4 4 4 4 4 4 4 4 4 4 4 str_count(gsub(\\d+,\\s+\\d+,\\s+(\\d+,\\s+\\d+),\\1,Lines1[-1]), ) # [1] 4 4 4 4 4 4 4 4 4 4 4 4 Lines2- gsub(,,, ,gsub( ,,Lines1))[-1] str_count(Lines2, ) # [1] 9 9 9 9 9 9 9 9 9 9 9 9 str_count(gsub((\\d+,\\s+\\d+).*,\\1,Lines2), ) # [1] 3 3 3 3 3 3 3 3 3 3 3 3 str_count(gsub(^\\d+,\\s+(\\d+,\\s+\\d+).*,\\1,Lines2), ) # [1] 3 3 3 3 3 3 3 3 3 3 3 3 str_count(gsub(\\d+,\\s+\\d+,\\s+(\\d+,\\s+\\d+),\\1,Lines2), ) # [1] 3 3 3 3 3 3 3 3 3 3 3 3 write(Lines2,capture2.txt) A.K. - Original Message - From: Mostafavipak, Nasrin nasrin.mostafavi...@stantec.com To: r-help@R-project.org r-help@r-project.org Cc: Sent: Friday, September 6, 2013 3:42 PM Subject: [R] Alignment of data sets Hi all; I have a data set with the format below: Year, Day, Hour, Value 2010, 001, 0, 15.9 2010, 001, 1, 7.3 2010, 001, 2, 5.2 2010, 001, 3, 8.0 2010, 001, 4, 0.0 2010, 001, 5, 12.1 2010, 001, 6, 11.6 2010, 001, 7, 13.9 2010, 001, 8, 11.9 2010, 001, 9, 13.6 2010, 001, 10, 16.1 2010, 001, 11, 18.5 That should be converted to this format: 2010, 001, 0, 15.9 2010, 001, 1, 7.3 2010, 001, 2, 5.2 2010, 001, 3, 8.0 2010, 001, 4, 0.0 2010, 001, 5, 12.1 2010, 001, 6, 11.6 2010, 001, 7, 13.9 2010, 001, 8, 11.9 2010, 001, 9, 13.6 2010, 001, 10, 16.1 2010, 001, 11, 18.5 The number of spaces is important. I have tried justify, but it produces spaces at the end or at the beginning of the rows depending on the choice of right, left alignment. Also I need 3 significant digits for the second column, when I use read.csv it gives me 1 instead of 001. So I use read.table, and one of the problems with read.table is that it produces row names that I don't want. Also I need commas in my output file. So far this is the best I could do: mydata = read.table(C:/ozone3.txt, sep = ) capture.output( print(mydata, sep = ,, print.gap=3), file=capture2.txt ) and the output has all the unwanted row names and also there are no commas. Any suggestions? Thank you Nasrin [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.