Re: [R] Help with R script

2017-07-13 Thread Ulrik Stervbo
@Don your solution does not solve Vijayan's scenario 2. I used spread and gather for that. An alternative solution to insert mising Fval - picking up with Don's newtst - is newtst <- c("FName: fname1", "Fval: Fval1.name1", "FName: fname2", "Fval: Fval2.name2", "FName: fname3", "FName: fname4", "F

[R] Conduct Network Analysis

2017-07-13 Thread SEB140004 Student
Greeting. Dear Mr/Mrs/Miss, I want to create a network by using R but I only have a table that contain OTU ID and the abundance value of two samples ONLY. Isn't possible? If can, which package can be used? Greatly appreciated to any suggestions and helps. Thank you. Best regards, Kang Chin Yi

Re: [R] Quadratic function with interaction terms for the PLS fitting model?

2017-07-13 Thread Bert Gunter
David et.al.: It's a problem with poly (or rather with how it is being misused) > mx <- as.matrix(gasoline[1:50,"NIR"]) > str(mx) AsIs [1:50, 1:401] -0.0502 -0.0442 -0.0469 -0.0467 -0.0509 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:50] "1" "2" "3" "4" ... ..$ : chr [1:401] "900 nm" "9

Re: [R] Quadratic function with interaction terms for the PLS fitting model?

2017-07-13 Thread David Winsemius
> On Jul 13, 2017, at 10:43 AM, Bert Gunter wrote: > > poly(NIR, degree = 2) will work if NIR is a matrix, not a data.frame. > The degree argument apparently *must* be explicitly named if NIR is > not a numeric vector. AFAICS, this is unclear or unstated in ?poly. I still get the same error wi

Re: [R] How to make a figure plotting p-values by range of different adjustment values?

2017-07-13 Thread Jim Lemon
Hi Kirsten, Yes, the adjustment in the "car" package is different from the p.adjust function in the "stats" package. I used the latter as I thought you only needed a way to plot different p-values against the various adjustment methods. Just create a vector of method names that you have used and pa

Re: [R] Extracting sentences with combinations of target words/terms from cancer patient text medical records

2017-07-13 Thread Paul Miller via R-help
Hi Robert, Thank you for your reply. An attempt to solve this via a regular expression query is particularly helpful. Unfortunately, I don't have much time to play around with this just now. Ultimately though, I think I would like to implement a solution something along the lines of what you ha

[R] R Consortium R Users Survey

2017-07-13 Thread Joseph Rickert
Hello All, The R Consortium is attempting to survey R users worldwide. We would like to know some basic information: How people use R, What they think of the way R is developing, What other languages they use, etc. You can read more about its purpose in a recent post

Re: [R] Quadratic function with interaction terms for the PLS fitting model?

2017-07-13 Thread Bert Gunter
> It would seem reasonable that the help for poly() could make it explicitly > clear that if 'x' is not a vector, but is a matrix, that 'degree' must be > explicitly named. > > Regards, > > Marc > Exactly. As written, there is no reason to believe that the stated exception to the ... argument m

Re: [R] Extracting sentences with combinations of target words/terms from cancer patient text medical records

2017-07-13 Thread Robert McGehee
Hi Paul, No need to collapse the information into a single text string, gregexpr() can take a vector of strings (sentences in your case). You can split your sentences up, number them how you want, then search for your pattern either via regex or via these extra packages you use which probably us

Re: [R] Quadratic function with interaction terms for the PLS fitting model?

2017-07-13 Thread Marc Schwartz
Hi Bert, Ok, to your initial point, the key nuance is that if 'x' is a vector, you can leave the 'degree' argument unnamed, however, if 'x' is a matrix, you cannot. That aspect of the behavior does not seem to change if poly() is called stand alone or, as suggested in ?poly, within a formula to

Re: [R] Quadratic function with interaction terms for the PLS fitting model?

2017-07-13 Thread Bert Gunter
Marc: 1. I am aware of the need to explicitly name arguments after ... -- see the R Language definition where this can be inferred from the argument matching rules. 2. I am aware of the stated exception for poly(). However: > x1 <- runif(20) > x2 <- runif(20) > mx <- cbind(x1,x2) > poly(mx,2) Er

Re: [R] Quadratic function with interaction terms for the PLS fitting model?

2017-07-13 Thread Marc Schwartz
Bert, The 'degree' argument follows the "..." argument in the function declaration: poly(x, ..., degree = 1, coefs = NULL, raw = FALSE, simple = FALSE) Generally, any arguments after the "..." must be explicitly named, but as per the Details section of ?poly: "Although formally degree should

Re: [R] Quadratic function with interaction terms for the PLS fitting model?

2017-07-13 Thread Bert Gunter
poly(NIR, degree = 2) will work if NIR is a matrix, not a data.frame. The degree argument apparently *must* be explicitly named if NIR is not a numeric vector. AFAICS, this is unclear or unstated in ?poly. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming alo

Re: [R] Quadratic function with interaction terms for the PLS fitting model?

2017-07-13 Thread David Winsemius
> On Jul 12, 2017, at 6:58 PM, Ng, Kelvin Sai-cheong > wrote: > > Dear all, > > I am using the pls package of R to perform partial least square on a set of > multivariate data. Instead of fitting a linear model, I want to fit my > data with a quadratic function with interaction terms. But I

Re: [R] How to make a figure plotting p-values by range of different adjustment values?

2017-07-13 Thread Kirsten Morehouse
Hi Jim, Thanks for your help, I really appreciate it. Perhaps I'm misunderstanding, but does this formula run different ajustment values for this function? logit(p = doc$value, adjust = 0.025) I'm looking to plot the p-values of different adjustment values. Thanks so much, Kirsten On Wed,

Re: [R] Help with R script

2017-07-13 Thread MacQueen, Don
Using Ulrik’s example data (and assuming I understand what is wanted), here is what I would do: ex.dat <- c("FName: fname1", "Fval: Fval1.name1", "Fval: ", "FName: fname2", "Fval: Fval2.name2", "FName: fname3") tst <- data.frame(x = ex.dat, stringsAsFactors=FALSE) sp <- strsplit(tst$x, ':', fix

Re: [R] How to formulate quadratic function with interaction terms for the PLS fitting model?

2017-07-13 Thread Bert Gunter
Below. -- Bert Bert Gunter On Thu, Jul 13, 2017 at 3:07 AM, Luigi Biagini wrote: > I have two ideas about it. > > 1- > i) Entering variables in quadratic form is done with the command I > (variable ^ 2) - > plsr (octane ~ NIR + I (nir ^ 2), ncomp = 10, data = gasTrain, validation = > "LOO" > Y

Re: [R] Question on Simultaneous Equations & Forecasting

2017-07-13 Thread Bert Gunter
If you want to continue this discussion, I think you need to take it offlist, as it seems to be primarily about methodology, not R programming. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Bre

Re: [R] Help with R script

2017-07-13 Thread Ulrik Stervbo
Hi Vijayan, one way going about it *could* be this: library(dplyr) library(tidyr) library(purrr) ex_dat <- c("FName: fname1", "Fval: Fval1.name1", "Fval: ", "FName: fname2", "Fval: Fval2.name2", "FName: fname3") data.frame(x = ex_dat) %>% separate(x, c("F1", "F2"), sep = ": ") %>% filter(F2

Re: [R] How to formulate quadratic function with interaction terms for the PLS fitting model?

2017-07-13 Thread Luigi Biagini
I have two ideas about it. 1- i) Entering variables in quadratic form is done with the command I (variable ^ 2) - plsr (octane ~ NIR + I (nir ^ 2), ncomp = 10, data = gasTrain, validation = "LOO" You could also use a new variable NIR_sq <- (NIR) ^ 2 ii) To insert a square variable, use syntax I (

[R] [R-pkgs] New package: passport

2017-07-13 Thread Edward Visel
Hi! I'm happy to announce the debut of my first package on CRAN, `passport`, to help your country name and code data travel smoothly between formats. `passport` brings simple utilities for parsing irregular country names to standardized codes using local regex, or for anything geocodable, the Dat

[R] [R-pkgs] acs version 2.1.0 update: download and analyze data from the US Census in R

2017-07-13 Thread Ezra Haber Glenn
We are pleased to announce the release of version 2.1.0 of the "acs" package, now available on CRAN . The package allows users to download, manipulate, analyze, and present demographic data from the U.S. Census, with special tools and methods

Re: [R] metRology package

2017-07-13 Thread S Ellison
> I'm having trouble with a simple application with metRology. Well, what you probably need is to contact the maintainer of the metRology package. Fortunately that's me. An immediate problem that I have is that I don't quite understand what you're doing (in the measurement), so I may need to

Re: [R] Question on Simultaneous Equations & Forecasting

2017-07-13 Thread Berend Hasselman
> On 13 Jul 2017, at 12:55, Pfaff, Bernhard Dr. > wrote: > > Who was speaking about non-linear models in the first place??? > The Klein-Model(s) and pretty much all simultaneous equation models > encountered in macro-econometrics are linear That's really not true. Klein model is linear but Os

[R] Help with R script

2017-07-13 Thread Vijayan Padmanabhan
Dear R-help Group Scenario 1: I have a text file running to 1000 of lines...that is like as follows: [922] "FieldName: Wk3PackSubMonth" [923] "FieldValue: Apr" [924] "FieldName: Wk3PackSubYear" [925] "FieldValue: 2017" [926] "FieldName: Wk3Code1" [927] "FieldValue: " [928] "FieldVal

Re: [R] Question on Simultaneous Equations & Forecasting

2017-07-13 Thread Pfaff, Bernhard Dr.
Who was speaking about non-linear models in the first place??? The Klein-Model(s) and pretty much all simultaneous equation models encountered in macro-econometrics are linear and/or can contain linear approximations to non-linear relationships, e.g., production functions of the Cobb-Douglas type

Re: [R] bnlearn and cpquery

2017-07-13 Thread Marco Scutari
Dear Ross, This usually happen because you have parameters with a value of NaN in your network, because the data you estimate the network from are sparse and you are using maximum likelihood estimates. You should either 1) use simpler networks for which you can estimate all conditional distributio

Re: [R] Question on Simultaneous Equations & Forecasting

2017-07-13 Thread Berend Hasselman
Frances, I would not advise Gauss-Seidel for non linear models. Can be quite tricky, slow and diverge. You can write your model as a non linear system of equations and use one of the nonlinear solvers. See the section "Root Finding" in the task view NumericalMathematics suggesting three packag

Re: [R] about plotting a special case

2017-07-13 Thread Jim Lemon
If you want colors mapped to the _values_ in DF1$C, there are a number of ways to do it: Color_unq<-color.scale(DF1$C,c(1,0),c(0,0,c(0,1)) This will produce colors from the lowest values (red) through the highest (blue). See the help page for color.scale to get different colors. With this you can

Re: [R] Question on Simultaneous Equations & Forecasting

2017-07-13 Thread Pfaff, Bernhard Dr.
Hi Frances, I have not touched the system.fit package for quite some time, but to solve your problem the following two pointers might be helpful: 1) Recast your model in the revised form, i.e., include your identity directly into your reaction functions, if possible. 2) For solving your model,