Re: [R] as.Date() function
You loaded "lubridate" so using Erin's approach library(lubridate) st <- c("1961-01","1961-04","1983-02") dat1 <- ymd(paste( st, "01", sep ="-")) On Monday, August 20, 2018, 1:15:56 a.m. EDT, wrote: Thanks Erin and Jim. You have indeed solved my problem. Philip Quoting Erin Hodgess : > Hi Philip: > > Here is something to consider: > >> #potential solution: >> sta <- paste(st,"-01",sep="") >> st1 <- as.Date(sta, format=("%Y-%m-%d")) >> print(st1) > [1] "1961-01-01" "1961-04-01" "1983-02-01" > > > Hope this helps! > Erin > > Erin Hodgess, PhD > mailto: erinm.hodg...@gmail.com > > > On Sun, Aug 19, 2018 at 3:25 PM wrote: > >> I am having trouble with what must be a very simple problem. Here is a >> reproducible example: >> >> library(lubridate) >> st <- c("1961-01","1961-04","1983-02") >> print(st) >> #[1] "1961-01" "1961-04" "1983-02" >> st1 <- as.Date(st, format=("%Y-%m")) >> print(st1) >> #[1] NA NA NA >> >> Why the heck am I getting three NAs instead of three Dates?I have >> studied the R documentation for as.Date() and it has not turned on the >> light bulb for me. >> >> __ >> 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-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. [[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] How to manually color specific bars
Please disregard I simply added a highlight variable and added scale_fill_manual(values = c("Yes"="red", "No"="grey")) -Original Message- From: R-help On Behalf Of Jeff Reichman Sent: Tuesday, August 21, 2018 8:44 PM To: r-help@r-project.org Subject: [R] How to manually color specific bars R-Help Forum While the following code works fine I need to change (highlight) specific "bars" within plot 2 (p2). For example I want the bars to be (lets say) red, on 1 Aug 2016 and 1 Aug 2017 . What do I need to do? library(ggplot2) library(reshape2) library(scales) library(egg) #data <- dataset data <- read.csv("~/R/Data_Files/AreaPlotData.csv", stringsAsFactors=FALSE) data$Serial <- seq.int(nrow(data)) data$min <- pmin(data$Melbourne,data$Sydney) data <- melt(data, id.vars=c("Serial","min","Timeline"), value.name="Price") data$Timeline <- as.Date(data$Timeline, format="%m/%d/%Y") p1 <- ggplot(data, aes(x = Timeline, y = Price)) + geom_line(aes(col = variable)) + geom_ribbon(aes(ymin = min, ymax = Price, fill = variable), alpha = 0.3) + scale_color_manual(values = c("#144A90","#D81F26")) + scale_fill_manual(values = c("#F7A396","#88CADD")) + theme_get() + theme(legend.position="top", legend.title=element_blank()) + scale_x_date(labels=date_format("%b%y")) data2 <- read.csv("~/R/Data_Files/AreaPlotData2.csv", stringsAsFactors=FALSE) data2$Timeline <- as.Date(data2$Timeline, format="%m/%d/%Y") p2 <- ggplot(data2, aes(x = Timeline, y=Port)) + geom_bar(stat = "identity", width = 0.1, color = "blue") + scale_y_continuous(name="Port Holdings", limits=c(0, 40)) ggarrange(p1, p2, heights = c(2, 0.6),ncol = 1, nrow = 2) Jeff [[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-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] How to manually color specific bars
R-Help Forum While the following code works fine I need to change (highlight) specific "bars" within plot 2 (p2). For example I want the bars to be (lets say) red, on 1 Aug 2016 and 1 Aug 2017 . What do I need to do? library(ggplot2) library(reshape2) library(scales) library(egg) #data <- dataset data <- read.csv("~/R/Data_Files/AreaPlotData.csv", stringsAsFactors=FALSE) data$Serial <- seq.int(nrow(data)) data$min <- pmin(data$Melbourne,data$Sydney) data <- melt(data, id.vars=c("Serial","min","Timeline"), value.name="Price") data$Timeline <- as.Date(data$Timeline, format="%m/%d/%Y") p1 <- ggplot(data, aes(x = Timeline, y = Price)) + geom_line(aes(col = variable)) + geom_ribbon(aes(ymin = min, ymax = Price, fill = variable), alpha = 0.3) + scale_color_manual(values = c("#144A90","#D81F26")) + scale_fill_manual(values = c("#F7A396","#88CADD")) + theme_get() + theme(legend.position="top", legend.title=element_blank()) + scale_x_date(labels=date_format("%b%y")) data2 <- read.csv("~/R/Data_Files/AreaPlotData2.csv", stringsAsFactors=FALSE) data2$Timeline <- as.Date(data2$Timeline, format="%m/%d/%Y") p2 <- ggplot(data2, aes(x = Timeline, y=Port)) + geom_bar(stat = "identity", width = 0.1, color = "blue") + scale_y_continuous(name="Port Holdings", limits=c(0, 40)) ggarrange(p1, p2, heights = c(2, 0.6),ncol = 1, nrow = 2) Jeff [[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] as.Date() function
Nice one! On Tue, Aug 21, 2018 at 6:14 PM John Kane wrote: > You loaded "lubridate" so using Erin's approach > > library(lubridate) > st <- c("1961-01","1961-04","1983-02") > dat1 <- ymd(paste( st, "01", sep ="-")) > > > On Monday, August 20, 2018, 1:15:56 a.m. EDT, < > phili...@cpanel1.stormweb.net> wrote: > > > Thanks Erin and Jim. You have indeed solved my problem. > > Philip > > > Quoting Erin Hodgess : > > > Hi Philip: > > > > Here is something to consider: > > > >> #potential solution: > >> sta <- paste(st,"-01",sep="") > >> st1 <- as.Date(sta, format=("%Y-%m-%d")) > >> print(st1) > > [1] "1961-01-01" "1961-04-01" "1983-02-01" > > > > > > Hope this helps! > > Erin > > > > Erin Hodgess, PhD > > mailto: erinm.hodg...@gmail.com > > > > > > On Sun, Aug 19, 2018 at 3:25 PM wrote: > > > >> I am having trouble with what must be a very simple problem. Here is a > >> reproducible example: > >> > >> library(lubridate) > >> st <- c("1961-01","1961-04","1983-02") > >> print(st) > >> #[1] "1961-01" "1961-04" "1983-02" > >> st1 <- as.Date(st, format=("%Y-%m")) > >> print(st1) > >> #[1] NA NA NA > >> > >> Why the heck am I getting three NAs instead of three Dates?I have > >> studied the R documentation for as.Date() and it has not turned on the > >> light bulb for me. > >> > >> __ > >> 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-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. > -- Erin Hodgess, PhD mailto: erinm.hodg...@gmail.com [[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] (no subject)
hi R https://goo.gl/G8X41r __ 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] looking for formula parser that allows coefficients
Dear Paul, Is it possible that you're overthinking this? That is, to you really need an R model formula or just want to evaluate an arithmetic expression using the columns of X? If the latter, the following approach may work for you: > evalFormula <- function(X, expr){ + if (is.null(colnames(X))) colnames(X) <- paste0("x", 1:ncol(X)) + with(as.data.frame(X), eval(parse(text=expr))) + } > X <- matrix(1:20, 5, 4) > X [,1] [,2] [,3] [,4] [1,]16 11 16 [2,]27 12 17 [3,]38 13 18 [4,]49 14 19 [5,]5 10 15 20 > evalFormula(X, '2 + 3*x1 + 4*x2 + 5*x3 + 6*x1*x2') [1] 120 180 252 336 432 I hope that this helps, John - John Fox Professor Emeritus McMaster University Hamilton, Ontario, Canada Web: https://socialsciences.mcmaster.ca/jfox/ > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Paul > Johnson > Sent: Tuesday, August 21, 2018 6:46 PM > To: R-help > Subject: [R] looking for formula parser that allows coefficients > > Can you point me at any packages that allow users to write a formula with > coefficients? > > I want to write a data simulator that has a matrix X with lots of columns, and > then users can generate predictive models by entering a formula that uses > some of the variables, allowing interactions, like > > y ~ 2 + 1.1 * x1 + 3 * x3 + 0.1 * x1:x3 + 0.2 * x2:x2 > > Currently, in the rockchalk package, I have a function simulates data > (genCorrelatedData2), but my interface to enter the beta coefficients is poor. > I assumed user would always enter 0's as place holder for the unused > coefficients, and the intercept is always first. The unnamed vector is too > confusing. I have them specify: > > c(2, 1.1, 0, 3, 0, 0, 0.2, ...) > > I the documentation I say (ridiculously) it is easy to figure out from the > examples, but it really isnt. > It function prints out the equation it thinks you intended, thats minimum > protection against user error, but still not very good: > > dat <- genCorrelatedData2(N = 10, rho = 0.0, > beta = c(1, 2, 1, 1, 0, 0.2, 0, 0, 0), > means = c(0,0,0), sds = c(1,1,1), stde = 0) [1] "The equation that > was > calculated was" > y = 1 + 2*x1 + 1*x2 + 1*x3 > + 0*x1*x1 + 0.2*x2*x1 + 0*x3*x1 > + 0*x1*x2 + 0*x2*x2 + 0*x3*x2 > + 0*x1*x3 + 0*x2*x3 + 0*x3*x3 > + N(0,0) random error > > But still, it is not very good. > > As I look at this now, I realize expect just the vech, not the whole vector > of all > interaction terms, so it is even more difficult than I thought to get the > correct > input.Hence, I'd like to let the user write a formula. > > The alternative for the user interface is to have named coefficients. > I can more or less easily allow a named vector for beta > > beta = c("(Intercept)" = 1, "x1" = 2, "x2" = 1, "x3" = 1, "x2:x1" = 0.1) > > I could build a formula from that. That's not too bad. But I still think it > would > be cool to allow formula input. > > Have you ever seen it done? > pj > -- > Paul E. Johnson http://pj.freefaculty.org > Director, Center for Research Methods and Data Analysis http://crmda.ku.edu > > To write to me directly, please address me at pauljohn at ku.edu. > > __ > 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-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] looking for formula parser that allows coefficients
Can you point me at any packages that allow users to write a formula with coefficients? I want to write a data simulator that has a matrix X with lots of columns, and then users can generate predictive models by entering a formula that uses some of the variables, allowing interactions, like y ~ 2 + 1.1 * x1 + 3 * x3 + 0.1 * x1:x3 + 0.2 * x2:x2 Currently, in the rockchalk package, I have a function simulates data (genCorrelatedData2), but my interface to enter the beta coefficients is poor. I assumed user would always enter 0's as place holder for the unused coefficients, and the intercept is always first. The unnamed vector is too confusing. I have them specify: c(2, 1.1, 0, 3, 0, 0, 0.2, ...) I the documentation I say (ridiculously) it is easy to figure out from the examples, but it really isnt. It function prints out the equation it thinks you intended, thats minimum protection against user error, but still not very good: dat <- genCorrelatedData2(N = 10, rho = 0.0, beta = c(1, 2, 1, 1, 0, 0.2, 0, 0, 0), means = c(0,0,0), sds = c(1,1,1), stde = 0) [1] "The equation that was calculated was" y = 1 + 2*x1 + 1*x2 + 1*x3 + 0*x1*x1 + 0.2*x2*x1 + 0*x3*x1 + 0*x1*x2 + 0*x2*x2 + 0*x3*x2 + 0*x1*x3 + 0*x2*x3 + 0*x3*x3 + N(0,0) random error But still, it is not very good. As I look at this now, I realize expect just the vech, not the whole vector of all interaction terms, so it is even more difficult than I thought to get the correct input.Hence, I'd like to let the user write a formula. The alternative for the user interface is to have named coefficients. I can more or less easily allow a named vector for beta beta = c("(Intercept)" = 1, "x1" = 2, "x2" = 1, "x3" = 1, "x2:x1" = 0.1) I could build a formula from that. That's not too bad. But I still think it would be cool to allow formula input. Have you ever seen it done? pj -- Paul E. Johnson http://pj.freefaculty.org Director, Center for Research Methods and Data Analysis http://crmda.ku.edu To write to me directly, please address me at pauljohn at ku.edu. __ 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] Transforming data for nice output table
On Mon, Aug 20, 2018 at 2:17 PM David Doyle wrote: > > Hello everyone, > > I'm trying to generate tables of my data out of R for my report. > > My data is setup in the format as follows and the example can be found at: > http://doylesdartden.com/R/ExampleData.csv > > LocationDateYear GW_Elevation > 127(I)5/14/2006 2006 752.46 > 119(I)5/14/2006 2006 774.67 > 127(I)6/11/2007 2007 752.06 > 119(I)6/11/2007 2007 775.57 > > I would like to generate a table that showed > > LocationGW_Elevation 2006GW_Elevation 2007GW_Elevation xxx. > > 119(I)774.67 775.57 > > 127(I)752.46 752.06 > > XX XX > > Any thoughts on how to transform the data so it would be in this format?? > > Thank you for your time > > David Doyle Dear David I'd consider studying R's reshape function, it was intended exactly for this purpose. No reason to adventure into any user-contributed tidy places to get this done. dta <- read.csv("http://doylesdartden.com/R/ExampleData.csv;) dta <- dta[c("Location", "Year", "GW_Elevation")] dta.wide <- reshape(dta, direction = "wide", idvar = "Location", v.names = "GW_Elevation", timevar = "Year") head(dta.wide) Location GW_Elevation.2006 GW_Elevation.2007 GW_Elevation.2008 1 127(I)752.46NA757.50 2 119(S)774.67778.76776.40 3 132(I)759.45761.68764.27 4 132(S)761.77761.04765.44 5 111(I)753.52763.24764.24 6 111(S)766.18772.84767.41 GW_Elevation.2009 GW_Elevation.2010 GW_Elevation.2011 GW_Elevation.2012 1759.90756.40759.05759.31 2777.59777.45778.21778.13 3761.90764.03763.63763.99 4761.21763.12762.69759.57 5750.85764.37762.99763.90 6769.77767.88767.95767.19 GW_Elevation.2013 GW_Elevation.2014 GW_Elevation.2015 GW_Elevation.2016 1756.07756.66757.72757.66 2778.88778.28775.16778.28 3761.22762.81762.36764.46 4763.19763.87761.94763.90 5764.42761.65764.02762.93 6770.20767.25767.74766.87 The main difference between this and your stated target is that your target column names have spaces in them, which are forbidden in column names of data frames. Here R used a period for joining strings. You can override that if you want to with the reshape function, but usually I'd let the periods happen. If you do want to replace period with spaces, it can be done, but you break the warranty on other uses of a data frame. (Could get rid of underscore after GW in same way) colnames(dta.wide) <- sub("Elevation.", "Elevation ", colnames(dta.wide), fixed = TRUE) I'd not try to use that wide frame for many other purposes because of the spaces, but it works well if you want to make a pleasant table out of it. For example, xtable is my favorite: library(xtable) xt <- xtable(dta.wide) print(xt) The latex from that prints out beautifully in a document. The print method for xtable has a file parameter if you want to save the file. Good Luck pj > > [[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. -- Paul E. Johnson http://pj.freefaculty.org Director, Center for Research Methods and Data Analysis http://crmda.ku.edu To write to me directly, please address me at pauljohn at ku.edu. __ 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] R Codes for Introduction to Data Mining
Dear David: Thank you very much abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* On Tue, Aug 21, 2018 at 12:07 PM David L Carlson wrote: > There are some materials at > > https://www-users.cs.umn.edu/~kumar001/dmbook/index.php > > Michael Hahsler has code examples at > > https://mhahsler.github.io/Introduction_to_Data_Mining_R_Examples/ > https://github.com/mhahsler/Introduction_to_Data_Mining_R_Examples > > > David L. Carlson > Department of Anthropology > Texas A University > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > AbouEl-Makarim Aboueissa > Sent: Tuesday, August 21, 2018 10:48 AM > To: R mailing list > Subject: [R] R Codes for Introduction to Data Mining > > Dear All: good morning > > > I am going to teach a course title "Introduction to Statistical Data > Mining", and I am using the book titled "*Introduction to Data Mining > (Second Edition)*" by Kumar and etal. > > I am wondering if someone have R codes/functions for examples and exercises > given in this textbook. > > I thank you all in advance. > > > with many thanks > abou > __ > > > *AbouEl-Makarim Aboueissa, PhD* > > *Professor of Statistics* > > *Department of Mathematics and Statistics* > *University of Southern Maine* > > [[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. > [[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] Transforming data for nice output table
Another approach to adding GW_Elevation to the year value, but the table is more compact with just the year. dta <- read.csv("http://doylesdartden.com/R/ExampleData.csv;) Years <- paste("GW_Elevation", dta$Year) xtabs(GW_Elevation~Location+Years, dta) David L. Carlson Department of Anthropology Texas A University -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rui Barradas Sent: Monday, August 20, 2018 11:39 PM To: David Doyle ; r-help@r-project.org Subject: Re: [R] Transforming data for nice output table Sorry, there is no need to subset the data frame, reshape2::dcast(dta, etc) will do the same. Rui Barradas On 21/08/2018 05:10, Rui Barradas wrote: > Hello, > > One of those would be with package reshape2. > > > > dta <- read.csv( "http://doylesdartden.com/R/ExampleData.csv;) > > subdta <- dta[, c("Location", "Year", "GW_Elevation")] > > res <- reshape2::dcast(subdta, Location ~ Year, value.var = "GW_Elevation") > names(res)[-1] <- paste("GW_Elevation", names(res)[-1], sep = "_") > head(res) > > > Hope this helps, > > Rui Barradas > > On 20/08/2018 21:37, Rui Barradas wrote: >> Hello, >> >> This is a very frequent question. >> I could rewrite one or two answers taken from StackOverflow: >> >> https://stackoverflow.com/questions/5890584/how-to-reshape-data-from-long-to-wide-format >> >> >> >> >> But there you will have more options. >> >> >> Hope this helps, >> >> Rui Barradas >> >> On 20/08/2018 20:17, David Doyle wrote: >>> Hello everyone, >>> >>> I'm trying to generate tables of my data out of R for my report. >>> >>> My data is setup in the format as follows and the example can be >>> found at: >>> http://doylesdartden.com/R/ExampleData.csv >>> >>> Location Date Year GW_Elevation >>> 127(I) 5/14/2006 2006 752.46 >>> 119(I) 5/14/2006 2006 774.67 >>> 127(I) 6/11/2007 2007 752.06 >>> 119(I) 6/11/2007 2007 775.57 >>> >>> I would like to generate a table that showed >>> >>> Location GW_Elevation 2006 GW_Elevation 2007 GW_Elevation >>> xxx. >>> >>> 119(I) 774.67 775.57 >>> >>> 127(I) 752.46 752.06 >>> >>> XX XX >>> >>> Any thoughts on how to transform the data so it would be in this >>> format?? >>> >>> Thank you for your time >>> >>> David Doyle >>> >>> [[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. >>> >> >> --- >> This email has been checked for viruses by AVG. >> https://www.avg.com >> >> __ >> 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-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-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-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] R Codes for Introduction to Data Mining
There are some materials at https://www-users.cs.umn.edu/~kumar001/dmbook/index.php Michael Hahsler has code examples at https://mhahsler.github.io/Introduction_to_Data_Mining_R_Examples/ https://github.com/mhahsler/Introduction_to_Data_Mining_R_Examples David L. Carlson Department of Anthropology Texas A University -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of AbouEl-Makarim Aboueissa Sent: Tuesday, August 21, 2018 10:48 AM To: R mailing list Subject: [R] R Codes for Introduction to Data Mining Dear All: good morning I am going to teach a course title "Introduction to Statistical Data Mining", and I am using the book titled "*Introduction to Data Mining (Second Edition)*" by Kumar and etal. I am wondering if someone have R codes/functions for examples and exercises given in this textbook. I thank you all in advance. with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* [[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-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] R Codes for Introduction to Data Mining
Dear All: good morning I am going to teach a course title "Introduction to Statistical Data Mining", and I am using the book titled "*Introduction to Data Mining (Second Edition)*" by Kumar and etal. I am wondering if someone have R codes/functions for examples and exercises given in this textbook. I thank you all in advance. with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor of Statistics* *Department of Mathematics and Statistics* *University of Southern Maine* [[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] Seeking nomination for the Statistical Computing and Graphics Award
(apologies for cross posting) The Statistical Computing and Graphics Award of the ASA Sections of Statistical Computing and Statistical Graphics recognizes an individual or team for innovation in computing, software, or graphics that has had a great impact on statistical practice or research. The past awardees include Bill Cleveland (2016) and Robert Gentleman and Ross Ihaka (2010). The prize carries with it a cash award of $5,000 plus an allowance of up to $1,000 for travel to the next Joint Statistical Meetings (JSM) where the award will be presented. Qualifications The prize-winning contribution will have had significant and lasting impacts on statistical computing, software or graphics. The Awards Committee depends on the American Statistical Association membership to submit nominations. Committee members will review the nominations and make the final determination of who, if any, should receive the award. The award may not be given to a sitting member of the Awards Committee or a sitting member of the Executive Committee of the Section of Statistical Computing or the Section of Statistical Graphics. Nomination and Award Dates Nominations are due by November 15, 2018 for an award to be presented at the JSM in the following year. Nominations should be submitted as a complete packet, consisting of: - a nomination letter, no longer than four pages, addressing points in the selection criteria - nominee's curriculum vita(e) - a minimum of 3 (and no more than 4) supporting letters, each no longer than two pages Selection Process The Awards Committee will consist of the Chairs and Past Chairs of the Sections on Statistical Computing and Statistical Graphics. The selection process will be handled by the Awards Chair of the Statistical Computing Section and the Statistical Graphics Section. Nominations and questions are to be sent to the e-mail address below. Jun Yan Professor University of Connecticut jun@uconn.edu __ 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] plotmath and logical operators?
Try this: plot(1) tmp <- x >= 3 ~ "&" ~ y <= 3 mtext(tmp) On Mon, Aug 20, 2018 at 5:00 PM MacQueen, Don via R-help wrote: > > I would like to use plotmath to annotate a plot with an expression that > includes a logical operator. > > ## works well > tmp <- expression(x >= 3) > plot(1) > mtext(tmp) > > ## not so well > tmp <- expression(x >= 3 & y <= 3) > plot(1) > mtext(tmp) > > Although the text that's displayed makes sense, it won't be obvious to my > non-mathematical audience. > > I'd appreciate suggestions. > > > I've found a work-around that gets the annotation to look right > tmpw <- expression(paste( x >= 3, " & ", y <= 3) ) > plot(1) > mtext(tmpw) > > > But it breaks my original purpose, illustrated by this example: > > df <- data.frame(x=1:5, y=1:5) > tmp <- expression(x >= 3 & y <= 3) > tmpw <- expression(paste( x >= 3, " & ", y <= 3) ) > with(df, eval(tmp)) > [1] FALSE FALSE TRUE FALSE FALSE > with(df, eval(tmpw)) > [1] "FALSE & TRUE" "FALSE & TRUE" "TRUE & TRUE" "TRUE & FALSE" "TRUE > & FALSE" > > Thanks > -Don > > -- > Don MacQueen > Lawrence Livermore National Laboratory > 7000 East Ave., L-627 > Livermore, CA 94550 > 925-423-1062 > Lab cell 925-724-7509 > > > > __ > 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. -- 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 -- 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] Time series analysis: Granger causality with error-correction term
Hi, Which package/function do you recommend for Granger causality between x and y with an error correction term? In my problem, economic theory maintains that x~ I(1); y~I(1), x-y ~I(0) \begin{eqnarray} \Delta x_t = g_0 + \lambda_{x}(x_{t-1}-y_{t-1})+\sum_{k=1}^{n}g_{1k}\Delta x_{t-s}+\sum_{k=1}^{n}g_{2k}\Delta y_{t-s}+\epsilon_{1t} \\ \Delta y_t = g_0 + \lambda_{y}(x_{t-1}-y_{t-1})+\sum_{k=1}^{n}g_{3k}\Delta x_{t-s}+\sum_{k=1}^{n}g_{4k}\Delta y_{t-s}+\epsilon_{2t} \end{eqnarray} I am not sure if it would work if I run Granger causality between \Delta x and \Delta y, treating the error correction term (x_{t-1}-y_{t-1}) and exogenous variable. Thank you very much!! John [[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] (no subject)
Hello, I have a list of lists. The lists in the list of lists are file names. I use lapply to read and merge the contents of each list in the list of lists (3 merged contents in this case which will be the content of 3 files). Then, I have to change the name of the 3 resulting files and finally I have to write the contents of the files to each file. lc <- list("test.txt", "test.txt", "test.txt", "test.txt") lc1 <- list("test.txt", "test.txt", "test.txt") lc2 <- list("test.txt", "test.txt") #list of lists. The lists contain file names lc <- list(lc, lc1, lc2) #new names for the three lists in the list of lists new_dataFns <- list("name1", "name2", "name3") file_paths <- NULL new_path <- NULL #add the file names to the path and read and merge the contents of each list in the list of lists lapply( lc, function(lc) { filenames <- file.path(dataFnsDir, lc) dataList= lapply(filenames, function (x) read.table(file=x, header=TRUE)) Reduce(function(x,y) merge(x,y), dataList) # print(dataList) } ) #add the new name of the file to the path total will be 3 paths/fille_newname.tsv. lapply(new_path, function(new_path){new_path <- file.path(getwd(), new_dataFns) The statements above work because lc and new_dataFns are global and I can pass them to the lapply function #Finally, I need to write the merged contents to the corresponding file (path/name.tsv). I tried the following statement, but this does not work. How can I write the content to each file? I was trying to use list <- cbind(dataList, new_path) so that afterwards I can get the merged contents and the file_name from the list and that way write each merged content to the corresponding file, but it seems that the dataList and the newPath are not global and the cbind() function does not work. [[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.