[R] Selecting rows and columns of a data frame using relational operators

2017-02-27 Thread Tunga Kantarcı
Consider a data frame named data. data contains 4 columns and 1000 rows. Say the aim is to bring together columns 1, 2, and 4, if the values in column 4 is equal to 1. We could use the syntax data(data[,4] == 1, c(1 2 4)) for this purpose. Suppose now that the aim is to bring together columns 1,

Re: [R] Selecting rows and columns of a data frame using relational operators

2017-02-27 Thread Erich Subscriptions
The answer is simple data[,4] == 1 produces a logical vector of length nrow(data) and the subsetting mechanism for data frames in R needs a vector of the same length as the data frame has rows. data[1:20,4] == 1 produces a data frame of length 20, and if this is not the length of data. So R

Re: [R] How to prune using a validation set

2017-02-27 Thread Therneau, Terry M., Ph.D.
You will need to give more detail of exactly what you mean by "prune using a validation set". THe prune.rpart function will prune at any value you want, what I suspect you are looking for is to compute the error of each possible tree, using a validation data set, then find the best one, and

Re: [R] Selecting rows and columns of a data frame using relational operators

2017-02-27 Thread Ulrik Stervbo
Hi Tunga, The function subset() is probably what you are looking for. You might also want to look at a tutorial to understand the R syntax. In addition, calling your data data is not a good idea because of the name clash with the function data(). Hope this helps, Ulrik On Mon, 27 Feb 2017 at

[R] concurvity

2017-02-27 Thread Eva Maria Leunissen
Hi, I'm using the concurvity function to check for concurvity in my model. The output I get when comparing to the rest of the model (ie full=TRUE) many of the variables have concurvity values higher than 0.9. However when comparing the terms pairwise most values are very small, less than 0.1

Re: [R] [FORGED] if and

2017-02-27 Thread Rolf Turner
On 28/02/17 14:47, Val wrote: Currently I have about six or more scripts that do the same job. I thought it might be possible and more efficient to use one script by using IF ELSE statements. Here is an example but this will be expandable for several countries ans year-months Year-month =

Re: [R] [FORGED] if and

2017-02-27 Thread Val
Thank you Rolf and Bert! I found the problem and this if(country="USA" & year-month = "FEB2015" | "FEB2012" ){ has be changed to this if(country="USA" & year-month == "FEB2015" | year-month == "FEB2012" ){ On Mon, Feb 27, 2017 at 8:45 PM, Bert Gunter wrote:

Re: [R] [FORGED] if and

2017-02-27 Thread Jeff Newmiller
Really? That seems unlikely, given that * = is used for moving values, not comparing them, * - is not a legal symbol for a variable name, it is subtraction, and year-month can hardly end up as a character string like "FEB2015" * (possible problem) & and | compare vectors one at a time, so are

Re: [R] order.by requires an appropriate time-based object

2017-02-27 Thread Allan Tanaka
Jesus!! even a small mistake like that can make me a headache.Thanks, this works like charm :) :) On Tuesday, 28 February 2017, 4:12, Joshua Ulrich wrote: On Sun, Feb 26, 2017 at 11:37 PM, Allan Tanaka wrote: > Here is the screenshoot

Re: [R] [FORGED] if and

2017-02-27 Thread Bert Gunter
I note that you have "Year-month" (capital 'Y') and "year-month" in your code; case matters in R. Otherwise, Rolf's advice applies. 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 Breathed in

[R] if and

2017-02-27 Thread Val
Currently I have about six or more scripts that do the same job. I thought it might be possible and more efficient to use one script by using IF ELSE statements. Here is an example but this will be expandable for several countries ans year-months Year-month = FEB2015, FEB2012, Feb2010

Re: [R] concurvity

2017-02-27 Thread Bert Gunter
Eva: Yours is a statistical question, which is generally off topic here. While you may get a reply, I think you would do better to post on a statistics list like stats.stackexchange.com. Even better, I think, would be to consult a local statistical expert, as it sounds like you are fairly

Re: [R] Reading S-plus data in R

2017-02-27 Thread roslinazairimah zakaria
Hi Willianm, Thank you. However, still null: > library(foreign) > dt <- data.restore4("C:/Users/FTSI/Desktop/2 ICGPA/1ACTIVITY.sdd", verbose=TRUE, print=TRUE, env = SplusDataEnv <- new.env()) > SplusDataEnv[["dt"]] NULL On Mon, Feb 27, 2017 at 10:41 AM, William Dunlap

[R] plotting dates in x axis

2017-02-27 Thread Maria Lathouri via R-help
Dear all,  I have an excel file of 180 observations with dates and one variable, from 1998 to 2012 by random months (there are some years that I might not have all the months or I might have two observations in one month). I am trying to plot the dates in x axis and the variable in y axis. I

Re: [R] Reading S-plus data in R

2017-02-27 Thread Martin Maechler
> Richard M Heiberger > on Sun, 26 Feb 2017 15:46:07 -0500 writes: > Bill, > this looks good. Can you add it to the splus2R package? Well, the natural place would rather be the foreign package, and some of use R core members would be happy with maintaining

[R] R: How to prune using holdout data

2017-02-27 Thread Alfredo
Thank you, Terry, for your answer. I'll try to explain better my question. When you create a classification or regression tree you first grow a tree based on a splitting criteria: this usually results in a large tree that provides a good fit to the training data. The problem with this tree is

Re: [R] Selecting rows and columns of a data frame using relational operators

2017-02-27 Thread PIKAL Petr
Hi Above what was said data(data[,4] == 1, c(1 2 4)) Error: unexpected numeric constant in "data(data[,4] == 1, c(1 2" is not valid syntax as it assume that data is a function and c(1 2 4) is also not correct syntax (I wonder if commands in MATLAB are such free form). And I am a little

Re: [R] Reading S-plus data in R

2017-02-27 Thread roslinazairimah zakaria
Hi William, I read again your message. Yes, finally, it works beautifully! Thank you so much. ## Import Data from S-Plus to R library(foreign) data.restore4("C:/Users/FTSI/Desktop/2 ICGPA/1ACTIVITY.sdd", verbose=TRUE, print=TRUE, env = SplusDataEnv <- new.env()) objects(SplusDataEnv) dt <-

[R] Baddperiods and other functions

2017-02-27 Thread Piyush Roy
Is there a way to use baddperiods and other Bloomberg API functions in R through package Rblpapi or any other packages ? Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

[R] Help with GENETICS package

2017-02-27 Thread Giulia Valvassori
Dear all, I am writing you this email because i need your help and I will really appreciate if you can dedicate some minutes of your time in helping me. I'm trying to use the R genetics package for a Linkage Disequilibrium analysis of data matrix obtained from a RADseq protocol (Stacks

[R] [R-pkgs] usmap v 0.1.0 released

2017-02-27 Thread Paolo Di Lorenzo
Hello useRs, I am announcing the release of my first package, usmap (http://cran.r-project.org/package=usmap). "usmap" is a package to aid in the creation of US choropleths that include Alaska and Hawaii. It is still in its early stages (v 0.1.0) but I hope to improve it with added

[R] Metafor multilevel metaregression: total variance increases when moderator added?

2017-02-27 Thread Duncan, Laura
Hi there, I am running a two level multilevel meta-regression of 170 estimates nested within 3 informants nested within 26 studies. I run the null model to get a pooled estimate with random effects at the informant level and study level. Then I test a series of potential moderators (one at a

[R] ASReml-R lack of documentation

2017-02-27 Thread Patrick Connolly
Has anyone had any success contacting VSNi, distributors of the non-free R package ASReml-R? I tried posting a question on their forum page but the forum software seems to have a bug too. So I tried emailing their support address but with no success. If anyone has had recent success with

Re: [R] plotting dates in x axis

2017-02-27 Thread Jim Lemon
Hi Maria, First, Excel files don't make it through the Mexican Wall. A CSV with the extension changed to .txt might. You can get all of the years like this: aa<-data.frame(var1=runif(180), SDATE=paste(sample(1998:2012,180,TRUE), sample(1:12,180,TRUE),sample(1:28,180,TRUE),sep="-"))

Re: [R] plotting dates in x axis

2017-02-27 Thread Jeff Newmiller
While humorous, the term "Mexican Wall" is unlikely to be clear to the OP. This is a reference to the mailing list anti-virus strategy of cutting out attachments that don't meet a very restrictive set of requirements outlined in the Posting Guide that all R-users are supposed to have read and

Re: [R] order.by requires an appropriate time-based object

2017-02-27 Thread Joshua Ulrich
On Sun, Feb 26, 2017 at 11:37 PM, Allan Tanaka wrote: > Here is the screenshoot to show what's happening entirely > > > > On Monday, 27 February 2017, 12:23, Allan Tanaka > wrote: > > > See attached for updated R script > > > On Monday, 27

Re: [R] Theta in Negative binomial GAM

2017-02-27 Thread Simon Wood
nb() will default to "REML" smoothing parameter estimation, while negbin() will default to "UBRE" unless you use the 'method="REML"' option to 'gam'. Using UBRE in place of REML may lead to differences in model fit, and will also mean that the AIC is not corrected for smoothing parameter

Re: [R] Impose Structure for Exogenous in vars Package

2017-02-27 Thread Pfaff, Bernhard Dr.
Hi Andrew, if I understand your question correctly, then you would like to place constraints for your exogenous variables in some VAR equations. If so, please have a look at ?restrict. As a toy example: library(vars) ?restrict data(Canada) N <- nrow(Canada) ExoVar <- matrix(runif(N))

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

2017-02-27 Thread Bob Rudis
Hey folks, I'm pleased to announce the inaugural release of my hrbrthemes (0.1.0) on CRAN: https://CRAN.R-project.org/package=hrbrthemes The primary goal of said package is to provide opinionated typographical and other aesthetic defaults for ggplot2 charts. Two core themes are included: -

[R-es] RStudio

2017-02-27 Thread Manuel Máquez
Guido: Mucho te (les) agradezco las atenciones que han tenido todos ustedes, para resolver el problema que tengo. *MANOLO MÁRQUEZ P.* [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org

Re: [R-es] Rstudio

2017-02-27 Thread Guido Corradi
Prueba ejecutando esto en la terminal: sudo apt-get install libxml2-dev sudo apt-get install libcurl4-openssl-dev libssl-dev El 25 de febrero de 2017, 20:27, Manuel David Jiménez Patiño < manueldavi...@gmail.com> escribió: > Hola Manuel Máquez, > > Recientemente yo instalé RStudio en Ubuntu

Re: [ESS] Ess in emacs on mac

2017-02-27 Thread Lionel Henry
Hi Luping, This is normal and part of ESS initialisation, but it has always bugged me as well. I think we should make this output silent. Lionel > On 27 févr. 2017, at 10:10, Luping Zhang wrote: > > To whom may concern > Sorry for bothering you. But I have a question

Re: [ESS] Ess in emacs on mac

2017-02-27 Thread Martin Maechler
On Mon, Feb 27, 2017 at 7:04 PM, Vitalie Spinu wrote: > > I would agree with that. I think it's pretty safe to make that silent. I don't think that safety is the issue here. Rather "transparency". If ESS changes relatively important options() in R, as an R user I'd rather

Re: [ESS] Ess in emacs on mac

2017-02-27 Thread Lionel Henry
It is implicit when you use an IDE that it will change the environment. Just like we are not giving any warning that the search path is altered by ESS or that we are pre-processing any input the user supplies. The number of users who care about these options is probably very small. I myself have