Re: [R] How to use contour plot?

2021-11-16 Thread Ivan Krylov
On Tue, 16 Nov 2021 09:45:34 +0100 Luigi Marongiu wrote: > contour(df$X, df$Y, df$Z) contour() works on matrices (sometimes called "wide format" data). Z must be a numeric matrix, X must be a numeric vector with length(X) == nrow(Z), and Y must be a numeric vector with length(Y) == ncol(Z).

Re: [R] How to use contour plot?

2021-11-16 Thread Duncan Murdoch
On 16/11/2021 3:45 a.m., Luigi Marongiu wrote: Hello, I have a dataframe with 3 values and that I would like to plot with contour: ``` head(df) Y X Z 1 0.0008094667 50 1 2 0.0012360955 50 1 3 0.0016627243 50 1 4 0.0020893531 50 1 5

Re: [R] How to use ifelse without invoking warnings

2021-10-09 Thread Leonard Mada via R-help
Dear Ravi, I have uploaded on GitHub a version which handles also constant values instead of functions. Regarding named arguments: this is actually handled automatically as well: eval.by.formula((x > 5 & x %% 2) ~ (x <= 5) ~ ., FUN, y=2, x) # [1]  1  4  9 16 25  6 14  8 18 10

Re: [R] How to use ifelse without invoking warnings

2021-10-09 Thread Leonard Mada via R-help
Dear Ravi, I wrote a small replacement for ifelse() which avoids such unnecessary evaluations (it bothered me a few times as well - so I decided to try a small replacement). ### Example: x = 1:10 FUN = list(); FUN[[1]] = function(x, y) x*y; FUN[[2]] = function(x, y) x^2; FUN[[3]] =

Re: [R] How to use ifelse without invoking warnings

2021-10-08 Thread Deepayan Sarkar
yes; tmp[!test] <- no[!test]; tmp) , possibly extended to handle missing values in 'test'. Best, -Deepayan > Thanks & Best regards, > Ravi > > From: John Fox > Sent: Thursday, October 7, 2021 2:00 PM > To: Ravi Varadhan > Cc:

Re: [R] How to use ifelse without invoking warnings

2021-10-08 Thread Jeff Newmiller
his behavior. > >Thanks & Best regards, >Ravi > >From: John Fox >Sent: Thursday, October 7, 2021 2:00 PM >To: Ravi Varadhan >Cc: R-Help >Subject: Re: [R] How to use ifelse without invoking warnings > > > External Email

Re: [R] How to use ifelse without invoking warnings

2021-10-08 Thread Avi Gross via R-help
i Varadhan via R-help Sent: Friday, October 8, 2021 8:22 AMiu To: John Fox l Cc: R-Help Subject: Re: [R] How to use ifelse without invoking warnings Thank you to Bert, Sarah, and John. I did consider suppressing warnings, but I felt that there must be a more principled approach. While John's so

Re: [R] How to use ifelse without invoking warnings

2021-10-08 Thread Ravi Varadhan via R-help
Ravi From: John Fox Sent: Thursday, October 7, 2021 2:00 PM To: Ravi Varadhan Cc: R-Help Subject: Re: [R] How to use ifelse without invoking warnings External Email - Use Caution Dear Ravi, It's already been suggested that you could disable warnings, but th

Re: [R] How to use ifelse without invoking warnings

2021-10-08 Thread John Fox
arguments. Best, John Thanks & Best regards, Ravi *From:* John Fox *Sent:* Thursday, October 7, 2021 2:00 PM *To:* Ravi Varadhan *Cc:* R-Help *Subject:* Re: [R] How to use ifelse without invoking warn

Re: [R] How to use ifelse without invoking warnings

2021-10-07 Thread John Fox
Dear Ravi, It's already been suggested that you could disable warnings, but that's risky in case there's a warning that you didn't anticipate. Here's a different approach: > kk <- k[k >= -1 & k <= n] > ans <- numeric(length(k)) > ans[k > n] <- 1 > ans[k >= -1 & k <= n] <- pbeta(p, kk + 1, n

Re: [R] How to use ifelse without invoking warnings

2021-10-07 Thread Sarah Goslee
Bert's approach is much less risky! On Thu, Oct 7, 2021 at 1:37 PM Bert Gunter wrote: > > ?suppressWarnings > > > p <- .05 > > k <- c(-1.2,-0.5, 1.5, 10.4) > > n <- 10 > > > > ans <- ifelse (k >= -1 & k <= n, pbeta(p,k+1,n-k,lower.tail=FALSE), > ifelse (k < -1, 0, 1) ) > Warning message: > In

Re: [R] How to use ifelse without invoking warnings

2021-10-07 Thread Sarah Goslee
If you are positive the warnings don't matter for your application, you can disable them: see ?options for details of warn. But that can be dangerous, so be careful! Sarah On Thu, Oct 7, 2021 at 1:21 PM Ravi Varadhan via R-help wrote: > > Hi, > I would like to execute the following vectorized

Re: [R] How to use ifelse without invoking warnings

2021-10-07 Thread Bert Gunter
?suppressWarnings > p <- .05 > k <- c(-1.2,-0.5, 1.5, 10.4) > n <- 10 > > ans <- ifelse (k >= -1 & k <= n, pbeta(p,k+1,n-k,lower.tail=FALSE), ifelse (k < -1, 0, 1) ) Warning message: In pbeta(p, k + 1, n - k, lower.tail = FALSE) : NaNs produced > > suppressWarnings(ans <- ifelse (k >= -1 & k <=

Re: [R] How to use R for Speech to text conversion

2020-10-07 Thread Jeff Newmiller
Whether you use RStudio is up to you... the heavy lifting would be done by R anyway. I am not a STT person, but TensorFlow was recently released on CRAN [1] so there may be more opportunities for R users to make headway in this area. [1] https://tensorflow.rstudio.com/installation/ On October

Re: [R] How to use R for Speech to text conversion

2020-10-07 Thread Bert Gunter
Have you checked here: https://cran.r-project.org/web/views/NaturalLanguageProcessing.html Speech to text is a very complex, specialized task requiring, I would expect, a lot of IP. It would not surprise me if you have to resort to big time, specialized software products with or without R.

Re: [R] How to use R for Speech to text conversion

2020-10-07 Thread Marc Roos
I am also interested in this. Maybe a start: https://voice.mozilla.org/ -Original Message- To: r-help@r-project.org Subject: *SPAM* [R] How to use R for Speech to text conversion Hi Iam a newbie to NLP and I would like to get some directions on how to convert speech

Re: [R] How to use mle2 function?

2020-07-01 Thread peter dalgaard
The basic problem is that holling() is not a (negative) loglikelihood function. nll() _is_ a negative loglikelihood, but it is not clear for what. You appear to be very confused as to what a likelihood even is (what is k? apparently your response variable? Then how can it be a scalar if X is a

Re: [R] How to use mle2 function?

2020-06-30 Thread Luigi Marongiu
Addendum: the optimization actually got a worse outcome than the original eyeball estimation: ``` actual <- c(8, 24, 39, 63, 89, 115, 153, 196, 242, 287, 344, 408, 473, 546, 619, 705, 794, 891, 999, 1096, 1242, 1363, 1506, 1648, 1753, 1851,

Re: [R] How to use mle2 function?

2020-06-30 Thread Luigi Marongiu
No, I got the same. I reckon the problem is with X: this was I scalar, I was providing a vector with the actual values. Ho can mle2 optimize without knowing what are the actual data? and what values should I give for X? Thank you On Tue, Jun 30, 2020 at 2:06 PM Eric Berger wrote: > > I have no

Re: [R] How to use mle2 function?

2020-06-30 Thread Eric Berger
I have no problem with the following code: library(bbmle) holling <- function( a, b, x ) { a*x^2 / (b^2 + x^2) } A=3261 B=10 X=30 foo <- mle2( minuslogl=holling, start=list(a=A,b=B,x=X) ) foo # Call: # mle2(minuslogl = holling, start = list(a = A, b = B, x = X)) # Coefficients: #a

Re: [R] How to use mle2 function?

2020-06-30 Thread Luigi Marongiu
Sorry for the typo, but I have the same error if using b instead of h: ``` > O = mle2(minuslogl = holling, start = list(a = A, b = B)) > Error in minuslogl(a = 3261, b = 10) : argument "x" is missing, with no default # let's add x X = c(8, 24, 39, 63, 89, 115, 153, 196, 242, 287,

Re: [R] How to use mle2 function?

2020-06-30 Thread Eric Berger
Hi Luigi, I took a quick look. First error: You wrote O = mle2(minuslogl = holling, start = list(a = A, h = B, x = X)) it should be b=B (h is not an argument of holling()) The error message gave very precise information! Second error: You wrote O = mle2(minuslogl = nll, start = list(a = A, h =

Re: [R] How to use R0 package?

2020-05-22 Thread Jeff Newmiller
Because the dates might not be consecutive. Or in ISO format. On May 22, 2020 7:38:17 PM PDT, Jim Lemon wrote: >So what if you treat a nuisance as a feature and import your dates as >factors? as.numeric(dates) would have the correct structure or am I, >as usual, missing something? > >Jim > >On

Re: [R] How to use R0 package?

2020-05-22 Thread Jim Lemon
So what if you treat a nuisance as a feature and import your dates as factors? as.numeric(dates) would have the correct structure or am I, as usual, missing something? Jim On Sat, May 23, 2020 at 1:00 AM Jeff Newmiller wrote: > > This is getting off-topic here but R0 is a mathematical parameter

Re: [R] How to use R0 package?

2020-05-22 Thread Jeff Newmiller
This is getting off-topic here but R0 is a mathematical parameter unrelated to calendar dates. It arises when analyzing case counts (integers) as a function of the numerical measure of time since some non-trivial number of cases has occurred (conventionally this measure is in days).. dta$days

Re: [R] How to use R0 package?

2020-05-22 Thread Olivier Crouzet
Hi, you should be able to convert your date variables to integers (usually viewed as the elapse between 1970/01/01 and today) by using date conversion to integers: TODAY="2020-05-22" as.Date(TODAY) [1] "2020-05-22" > as.integer(as.Date(TODAY)) [1] 18404 Doing the same with your reference dates

Re: [R] How to use R0 package?

2020-05-22 Thread Eric Berger
class(length(x1)) "integer" Your problem is thinking that begin=1 means you are passing begin as an integer. class(1) "numeric" class(1L) "integer" You should pass: begin=1L, end=length(x1) Best, Eric On Fri, May 22, 2020 at 3:31 PM Luigi Marongiu wrote: > > In theory, it works > ``` > > R0

Re: [R] How to use R0 package?

2020-05-22 Thread Luigi Marongiu
In theory, it works ``` > R0 = estimate.R(x1, t=d1, GT=mGT, begin=1, end=117, methods="EG",pop.size=pop, nsim=N) >R0 Reproduction number estimate using Exponential Growth method. R : 0.7425278[ 0.7409297 , 0.7441229 ] ``` but I am not happy because 1. I have to use numbers

Re: [R] How to use R0 package?

2020-05-22 Thread Eric Berger
Hi Luigi, I am not familiar with the R0 package but I took a quick look. The example in the documentation sets begin and end to integers. Try setting begin = 1, end = 121 and see if that works. HTH, Eric On Fri, May 22, 2020 at 1:17 PM Luigi Marongiu wrote: > > Hello, > I am trying ot get the

Re: [R] How to use pakcage R0

2020-05-05 Thread cpolwart
R0 = estimate.R(germany_vect, mGT, begin=germany_vect[1], end=germany_vect[length(germany_vect)], methods="EG", pop.size=pop_de, nsim=100) Error in begin.nb:end.nb : argument of length 0 germany_vect[1] 1 184 germany_vect[length(germany_vect)] 57 488 ``` What might be the problem

Re: [R] How to use preProcess in Caret?

2019-12-05 Thread Burak Kaymakci
Hello there, Yes, I'd tried scale as well. I mean, I could do my preprocessing separately and it was working fine. I was just wondering how preProcess argument in train function works. As far as I know, when preProcess argument is set, it normalizes inputs but not outputs. Then I've figured we

Re: [R] How to use preProcess in Caret?

2019-12-04 Thread William Michels via R-help
Hello, Have you tried alternative methods of pre-processing your data, such as simply calling scale()? What is the effect on convergence, for both the caret package and and the neuralnet package? There's an example using scale() with the neuralnet package at the link below:

Re: [R] how to use a matrix as an index to another matrix?

2019-10-28 Thread Bert Gunter
No loops necessary. Use array indexing (see ?"[", of course -- the section on matrices and arrays) set.seed(123) A <- matrix(sample(1:10), nrow = 5) B <- matrix(c(sample(1:5), sample(1:5)), nrow =5, byrow = FALSE) ## The following could be a 1-liner, but I broke it out for clarity. ix <-

Re: [R] how to use a matrix as an index to another matrix?

2019-10-28 Thread Linus Chen
Hi Jinsong, In such a case I think explicit loop IS the most elegant solution. for(i in 1:2) A[,i] <- A[,i][B[,i]] Linus On Fri, 11 Oct 2019 at 11:44, Jinsong Zhao wrote: > > Hi there, > > I have two matrices, A and B. The columns of B is the index of the > corresponding columns of A. I hope

Re: [R] how to use a matrix as an index to another matrix?

2019-10-11 Thread Martin Morgan
A matrix can be subset by another 2-column matrix, where the first column is the row index and the second column the column index. So idx = matrix(c(B, col(B)), ncol = 2) A[] <- A[idx] Martin Morgan On 10/11/19, 6:31 AM, "R-help on behalf of Eric Berger" wrote: Here is one way A <-

Re: [R] how to use a matrix as an index to another matrix?

2019-10-11 Thread Eric Berger
Here is one way A <- sapply(1:ncol(A), function(i) {A[,i][B[,i]]}) On Fri, Oct 11, 2019 at 12:44 PM Jinsong Zhao wrote: > Hi there, > > I have two matrices, A and B. The columns of B is the index of the > corresponding columns of A. I hope to rearrange of A by B. A minimal > example is

Re: [R] How to use Conda with R + RStudio Server

2019-10-07 Thread Juan Telleria Ruiz de Aguirre
Solution: https://github.com/grst/rstudio-server-conda It works. [[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

Re: [R] How to use breaks argument in hist() function correctly?

2019-09-18 Thread Stephen Ellison
> When I had breaks = 18, I get total number of cells as 16, which is > same when I put breaks = 20 > > In the 2nd case I was expecting total number of cells (i.e. bars) as > 20 i.e. if I understand the documentation correctly I should expect > total number of cells (bars) should be same as breaks

Re: [R] How to use breaks argument in hist() function correctly?

2019-09-18 Thread Jim Lemon
Hi Cristofer, If you just ask for a number of breaks, you will get what "hist" thinks you should. Try this or something similar: hist(x,breaks=seq(min(x),max(x),length.out=21)) Jim On Wed, Sep 18, 2019 at 8:55 PM Christofer Bogaso wrote: > > Hi, > > I have a numerical vector as below > > x =

Re: [R] How to use Conda with R + RStudio Server

2019-09-07 Thread Jeff Newmiller
You may get a response here (including my poorly-informed one) but this is off topic (_do read the Posting Guide_) so you are basically barking into the darkness here. You should be asking in the RStudio community forum. As far as I am aware you have to run your RSS in a single environment, so

Re: [R] How to use depmix for HMM with intial parameters

2017-09-20 Thread Ismail SEZEN
> On 20 Sep 2017, at 11:14, niharika singhal > wrote: > > Hello, > > I have initial parameters for HMM model and I want to use depmixS4 package. > The parameters are in the form > > intial_prob_matrix=matrix(c(0.07614213, 0.45177665, 0.47208122), nrow=1, >

Re: [R] How to use getSymbols() to get annual data

2017-09-02 Thread Duncan Murdoch
On 01/09/2017 7:37 PM, Yingrui Liu wrote: Dear Sir/Madam, How to use getSymbols() to get annual data? For example, I need the annual stock price of APPLE from the year 2000 to 2016. How to write the command? I only know how to get the daily data. It is:

Re: [R] How to use getSymbols() to get annual data

2017-09-01 Thread Bert Gunter
Reading ?getSymbols, why do think you can get yearly data if the src -- "yahoo" by default -- only contains daily data? And if you can get the daily data, why can't you just pick a day from each year to make it yearly? Note: I'm not a quantmod user, so apologies if I just don't get it. Cheers,

Re: [R] How to use getSymbols() to get annual data

2017-09-01 Thread Jeff Newmiller
I suppose that might depend what you mean by "annual data". ?yearlyReturn or ### library(quantmod) #> Loading required package: xts #> Loading required package: zoo #> #> Attaching package: 'zoo' #> The following objects are masked from 'package:base': #> #> as.Date, as.Date.numeric #>

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread Mike C
I was using OS X native R editor. I would imagine that editor is as simple and native as it gets. But, if it's truly native, why would Gmail think of my code chunk so differently. I'm just throwing it out there! I can always remove format in Gmail after pasting as a precaution. :) On Fri,

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread Jeff Newmiller
I am pretty sure it is not RStudio that is converting it to html... it is Gmail... but many email programs seem to do this these days so that people can send Wingdings symbols to their lolz pals, with no thought of the damage done to computer code examples. -- Sent from my phone. Please

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
Thanks for letting me know. That line does look familiar. It's interesting how I simply copy and paste from R editor can result in HTML format. On Fri, Feb 24, 2017 at 9:16 PM, Jeff Newmiller wrote: > There is a little button near the bottom of the Gmail editing box

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread Jeff Newmiller
There is a little button near the bottom of the Gmail editing box that switches to plain text. We can immediately tell because of the [[alternative HTML version deleted]] line when we receive it, and sometimes it loses all of the line breaks or has extra asterisks mixed in. You can look in the

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
I suppose for loop will suffice. I simply copy & paste the code from R editor. From my email, it looks plain. Is there a way to tell? On Fri, Feb 24, 2017 at 8:50 PM, Jeff Newmiller wrote: > The apply function is one of many alienate ways to write a loop. It is not >

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread Jeff Newmiller
The apply function is one of many alienate ways to write a loop. It is not appreciably more efficient in cpu time than a for loop. Your example creates the numbers in the loop... does your actual data get created in a loop? If so then your original code should be perfectly serviceable. If not

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread C W
In theory, I am generating from group 5 groups of random numbers, each group has 3 samples. Isn't apply() the replacement of loops? On Fri, Feb 24, 2017 at 8:23 PM, Jeff Newmiller wrote: > What is wrong with > > dat <- matrix(rnorm(15), nrow=5, ncol = 3) > > ? > > And

Re: [R] How to use apply() to fill matrix by rows or columns?

2017-02-24 Thread Jeff Newmiller
What is wrong with dat <- matrix(rnorm(15), nrow=5, ncol = 3) ? And what is this "no loop drama" you refer to? I use loops frequently to loop around large memory gobbling chunks of code. -- Sent from my phone. Please excuse my brevity. On February 24, 2017 5:02:46 PM PST, C W

Re: [R] how to use vector of values to change row order of a heatmap

2016-11-22 Thread PIKAL Petr
Hi Heatmap does not work with data frames (at least the version I have) > b=as.data.frame(matrix(c(3,4,5,8,9,10,13,14,15,27,19,20),3,4)) > heatmap(b) Error in heatmap(b) : 'x' must be a numeric matrix With matrix, heatmap works as expected. > b=matrix(c(3,4,5,8,9,10,13,14,15,27,19,20),3,4) >

Re: [R] How to use predict() so that one retains the rows that they're associated with?

2016-10-20 Thread David L Carlson
om: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Richard M. Heiberger Sent: Thursday, October 20, 2016 8:05 AM To: mviljamaa Cc: r-help Subject: Re: [R] How to use predict() so that one retains the rows that they're associated with? I believe you have missing values and therefore you n

Re: [R] How to use predict() so that one retains the rows that they're associated with?

2016-10-20 Thread Richard M. Heiberger
I believe you have missing values and therefore you need to use the argument glm(formula, data, na.action=na.exclude, ...) ?na.exclude The relevant line is when 'na.exclude' is used the residuals and predictions are padded to the correct length by inserting 'NA's for cases

Re: [R] How to use predict() so that one retains the rows that they're associated with?

2016-10-20 Thread PIKAL Petr
Hi. I am a bit puzzled. You do not get predicted values from variables but from estimated model. AFAIK order of predicted values is the same as order of original values. > x<-1:10 > y<-5*x+3+rnorm(10) > plot(x,y) > a<-sample(letters[1:3], 10, replace=T) > fit<-lm(y~x) > points(x, predict(fit),

Re: [R] How to use predict() so that one retains the rows that they're associated with?

2016-10-20 Thread Michael Dewey
Some more context would help here but here goes anyway. You should have a vector of predictions with length equal to the number of rows in your original data-set so you can just use cbind. If that is not true check the documentation for the correct setting of na.action. If you used newdata =

Re: [R] how to use 97.5%, 2.5% values of parameters for next calculation

2016-10-06 Thread David Winsemius
> On Oct 6, 2016, at 7:07 AM, abhishek pandey > wrote: > > Sent from RediffmailNG on Android > > From: abhishek pandeyabhishekpandey_1...@rediffmail.com > Sent:Thu, 06 Oct 2016 13:24:39 +0530 > To: r-help-ow...@r-project.org > Subject: how to use 97.5%,2.5%

Re: [R] how to use AND in grepl

2016-05-02 Thread Tom Wright
Please try to read my earlier comments. In the absence of a proper example with expected output I think what you are trying to achieve is: # create a sample dataframe df <- data.frame(Command=c("_localize_PD", "_localize_tre_t2", "_abdomen_t1_seq", "knee_pd_t1_localize", "pd_local_abdomen_t2"))

Re: [R] how to use AND in grepl

2016-05-02 Thread John McKown
On Mon, May 2, 2016 at 1:01 PM, ch.elahe via R-help wrote: > I just changed all the names in Command to lowercase, then this > str_extract works fine for "pd" and "t2", but not for "PDT2". Do you have > any idea how I can bring PDT2 also in str_extract? > Looking at

Re: [R] how to use AND in grepl

2016-05-02 Thread ch.elahe via R-help
I just changed all the names in Command to lowercase, then this str_extract works fine for "pd" and "t2", but not for "PDT2". Do you have any idea how I can bring PDT2 also in str_extract? On Monday, May 2, 2016 9:16 AM, Tom Wright wrote: The first thing I notice here

Re: [R] how to use AND in grepl

2016-05-02 Thread Tom Wright
The first thing I notice here is that your first two subset statements are searching in an object named Command, not the column df$Command. I'm not at all sure what you are trying to achieve with the str_extract process but it is looking for the exact string 'PDT2' the vectors / dataframe formed

Re: [R] how to use AND in grepl

2016-05-02 Thread ch.elahe via R-help
Yes it works, but let me explain what I am going to do. I extract all the names I want and then create a new column out of them for my plot. This is he whole thing I do: PD=subset(df,grepl("pd",Command)) //extract names in Command with only "pd" t2=subset(df,grepl("t2",Command)) //extract

Re: [R] how to use AND in grepl

2016-05-02 Thread Tom Wright
Sorry for the missed braces earlier. I was typing on a phone, not the best place to conjugate regular expressions. Using the example you provided: > df=data.frame(Command=c("_localize_PD", "_localize_tre_t2", "_abdomen_t1_seq", "knee_pd_t1_localize", "pd_local_abdomen_t2")) >

Re: [R] how to use AND in grepl

2016-05-02 Thread ch.elahe via R-help
Thanks Peter, you were right, the exact grepl is grepl("(.*t2.*pd.*)|(.*pd.*t2.*)",df$Command), but it does not change anything in Command, when I check the size of it by sum(grepl("(.*t2.*pd.*)|(.*pd.*t2.*)",df$Command)) the result is 0, but I am sure that the size is not 0. It seems that

Re: [R] how to use AND in grepl

2016-05-02 Thread peter dalgaard
On 02 May 2016, at 12:43 , ch.elahe via R-help wrote: > Thanks for your reply tom. After using > Subset(df,grepl("(.*t2.*pd.*)|(.*pd.*t2.*)"),df$Command) I get this error: > Argument "x" is missing, with no default. Actually I don't know how to fix > this. Do you have

Re: [R] how to use AND in grepl

2016-05-02 Thread ch.elahe via R-help
Thanks for your reply tom. After using Subset(df,grepl("(.*t2.*pd.*)|(.*pd.*t2.*)"),df$Command) I get this error: Argument "x" is missing, with no default. Actually I don't know how to fix this. Do you have any idea? Thanks, Elahe On Saturday, April 30, 2016 7:35 PM, Tom Wright

Re: [R] how to use AND in grepl

2016-04-30 Thread Tom Wright
Actually not sure my previous answer does what you wanted. Using your approach: t2pd=subset(df,grepl("t2",df$Command) & grepl("pd",df$Command)) Should work. I think the regex pattern you are looking for is: Subset(df,grepl("(.* t2.*pd.* )|(.* pd.* t2.*)",df$Command) On Sat, Apr 30, 2016,

Re: [R] how to use AND in grepl

2016-04-30 Thread Tom Wright
subset(df,grepl("t2|pd",x$Command)) On Sat, Apr 30, 2016 at 2:38 PM, ch.elahe via R-help wrote: > Hi all, > > I have one factor variable in my df and I want to extract the names from > it which contain both "t2" and "pd": > > 'data.frame': 36919 obs. of 162 variables >

Re: [R] how to use AND in grepl

2016-04-30 Thread William Dunlap via R-help
Your code looks fine to me. What did t2pd look like? I tried reproducing the problem in R-3.2.4(Revised) and everything worked (although the output of str() looked a bit different - perhaps you have an old version of R) > df <- data.frame(TE=1:10, TR=101:110,

Re: [R] how to use vectorization instead of for loop

2016-03-21 Thread Dalthorp, Daniel
> > > From: ruipbarra...@sapo.pt <ruipbarra...@sapo.pt> > > Sent: Monday, March 21, 2016 11:50 AM > > To: Stephen HK WONG > > Cc: r-help@r-project.org > > Subject: Re: [R] how to use vectorization instead of for loop &g

Re: [R] how to use vectorization instead of for loop

2016-03-21 Thread ruipbarradas
rom: ruipbarra...@sapo.pt <ruipbarra...@sapo.pt> > Sent: Monday, March 21, 2016 11:50 AM > To: Stephen HK WONG > Cc: r-help@r-project.org > Subject: Re: [R] how to use vectorization instead of for loop > > Hello, > > I've renamed your dataframe to 'dat'. Since ?ifelse i

Re: [R] how to use vectorization instead of for loop

2016-03-21 Thread Stephen HK WONG
ifelse ? Thanks. From: ruipbarra...@sapo.pt <ruipbarra...@sapo.pt> Sent: Monday, March 21, 2016 11:50 AM To: Stephen HK WONG Cc: r-help@r-project.org Subject: Re: [R] how to use vectorization instead of for loop Hello, I've renamed your dataframe to 'dat'. Since ?ifelse is vectorized, try

Re: [R] how to use vectorization instead of for loop

2016-03-21 Thread ruipbarradas
Hello, I've renamed your dataframe to 'dat'. Since ?ifelse is vectorized, try dat[, 4] <- ifelse(dat[, 2] > 0, 1 * (1/dat[,3]), -1* (1/dat[,3])) Oh, and why do you multiply by 1 and by -1? It would simply be 1/dat[,3] and -1/dat[,3]. Hope this helps, Rui Barradas Quoting Stephen HK WONG

Re: [R] How to use compare.linkage in RecordLinkage package -- unexpected output

2016-01-29 Thread Anders Alexandersson
Problem resolved. I confused the true matching status and the probabilistic record linkage results. Anders Alexandersson andersa...@gmail.com On Thu, Jan 28, 2016 at 9:48 AM, Anders Alexandersson wrote: > I am using the compare.linkage function in the RecordLinkage

Re: [R] How to use the options "usecommand" and "command" of tktable?

2015-12-18 Thread Cleber Borges
# only a update the R code (with strange behavior) library( tcltk ); tclRequire( "Tktable" ) top <- tktoplevel() tcl('variable', 'myarray') tcl('array', 'unset', 'myarray') x <- 0 tabCmd <- function() { x <<- x + 1 return( as.tclObj( paste(x) ) ) } tab <- tkwidget( top, 'table', rows=2,

Re: [R] how to use confusionMatrix function in solving multi-classes problem

2015-12-13 Thread Giorgio Garziano
You may use the "caret" package. At the following link 2-classes and 3-classes examples: http://www.inside-r.org/node/86995 -- GG [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

Re: [R] how to use confusionMatrix function in solving multi-classes problem

2015-12-13 Thread Boris Steipe
This looks like homework to me and this list has a No-Homework policy. Now, once you have done your homework (and that includes reading the documentation of the functions you are using), and you are still confused about details, you are welcome to ask again. Please keep the following in mind:

Re: [R] How to use curve() with two parameters in the function

2015-10-27 Thread C W
Never mind, I figured it out. You need to use sapply(), for instance, curve(sapply(x, p), from = 0, to =10) Thanks all! On Tue, Oct 27, 2015 at 11:14 AM, C W wrote: > Dear R list, > > I am trying to plot the curve of a function. > > Here's the R code: > > library(mvtnorm) >

Re: [R] How to use dwish in MCMCpack in R

2015-09-03 Thread Anamika Chaudhuri
I put in the matrix at which I want the density as S. I was wondering what is W then? Thanks Anamika On Thu, Sep 3, 2015 at 12:28 PM, Duncan Murdoch wrote: > On 03/09/2015 9:29 AM, Anamika Chaudhuri wrote: > > Hi All: > > > > I am trying to use the dwish function in

Re: [R] How to use dwish in MCMCpack in R

2015-09-03 Thread Duncan Murdoch
On 03/09/2015 9:29 AM, Anamika Chaudhuri wrote: > Hi All: > > I am trying to use the dwish function in the MCMCpack in R > > dwish(W, v, S) where > > Arguments > W-Positive definite matrix W > v-Degrees of freedom (scalar). > S-Inverse scale matrix > > How do I determine W, the positive

Re: [R] How to use dwish in MCMCpack in R

2015-09-03 Thread Duncan Murdoch
On 03/09/2015 12:41 PM, Anamika Chaudhuri wrote: > I put in the matrix at which I want the density as S. I was wondering > what is W then? You need to read the help page. The matrix at which you want the density is W. S is a parameter of the distribution. Duncan Murdoch > > Thanks > Anamika

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-31 Thread Ben Tupper
Hi Philippe, Ah! Thanks for pointing out the pesky ifelse() issue. I have only recently been learning (the hard way) that ifelse() is not a tool for the uninformed like me, but it is ever so tempting! I would like to offer another way to speed things up. findInterval() can be quite fast,

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-31 Thread Philippe Grosjean
Also note that ifelse() should be avoided as much as possible. To define a piecewise function you can use this trick: func - function (x, min, max) 1/(max-min) * (x = min x = max) The performances are much better. This has no impact here, but it is a good habit to take in case you manipulate

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-31 Thread peter dalgaard
On 31 Jan 2015, at 09:39 , Rolf Turner r.tur...@auckland.ac.nz wrote: On 31/01/15 21:10, C W wrote: Hi Bill, One quick question. What if I wanted to use curve() for a uniform distribution? Say, unif(0.5, 1.3), 0 elsewhere. My R code: func - function(min, max){ 1 / (max - min)

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-31 Thread C W
Hi Bill, One quick question. What if I wanted to use curve() for a uniform distribution? Say, unif(0.5, 1.3), 0 elsewhere. My R code: func - function(min, max){ 1 / (max - min) } curve(func(min = 0.5, max = 1.3), from = 0, to = 2) curve() wants an expression, but I have a constant. And I

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-31 Thread Rolf Turner
On 31/01/15 21:10, C W wrote: Hi Bill, One quick question. What if I wanted to use curve() for a uniform distribution? Say, unif(0.5, 1.3), 0 elsewhere. My R code: func - function(min, max){ 1 / (max - min) } curve(func(min = 0.5, max = 1.3), from = 0, to = 2) curve() wants an

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread Rui Barradas
Hello, The following will work, but I don't know if it's what you want. func2 will get x and y from the global environment. func2 - function(mu){ x + y + mu ^ 2 } curve(func2, from = 0, to = 10) Hope this helps, Rui Barradas Em 29-01-2015 21:02, C W escreveu: Hi all, I want to graph

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread C W
Hi Rui, Thank you for your help. That works for now, but eventually, I need to be pass in x and y. Is there a way to tell the curve() function, x is a fix vector, mu is a variable! Thanks, Mike On Thu, Jan 29, 2015 at 5:25 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, The following

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread William Dunlap
Does help(curve) talk about its 'xname' argument? Try curve(10*foofoo, from=0, to=17, xname=foofoo) You will have to modify your function, since curve() will call it once with a long vector for the independent variable and func(rnorm(10), rnorm(10), mu=seq(0,5,len=501)) won't work right.

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread C W
Hi Bill, You solved by problem. For some reason, I thought xname was only referring to name of the x-axis. I remember last time I fixed it, it was something about xname, couldn't get it right this time. Thanks! Saved me hours from frustration. Mike On Thu, Jan 29, 2015 at 9:04 PM, William

Re: [R] How to use ggplot2

2014-11-26 Thread John Kane
It is useful to have a reproducable example https://github.com/hadley/devtools/wiki/Reproducibility http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example However is this somethingl like what you want? Note I changed variable names and removed caps to make life

Re: [R] how to use the rpart model to predict new data frame?

2014-11-11 Thread David Winsemius
On Nov 11, 2014, at 7:47 PM, PO SU rhelpmaill...@163.com wrote: Dear expeRts, Now i have a train dataset a and test dataset b , i using the following codes: rp-rpart(y~.,data=a,method=class) plot(rp) text(rp) but how can i use the trained model to predict b? ?predict --

Re: [R] how to use the rpart model to predict new data frame?

2014-11-11 Thread Bharat Bargujar
HI, Try this: results - predict(rp,b,type = vector) Regards, Bharat On 12 November 2014 09:17, PO SU rhelpmaill...@163.com wrote: Dear expeRts, Now i have a train dataset a and test dataset b , i using the following codes: rp-rpart(y~.,data=a,method=class) plot(rp) text(rp)

Re: [R] how to use the rpart model to predict new data frame?

2014-11-11 Thread PO SU
OK , i tried predict(rp,b) but showed me a result which i can't understand, now it's the argument  type=vector worked. -- PO SU mail: desolato...@163.com Majored in Statistics from SJTU At 2014-11-12 11:55:08, Bharat Bargujar bharatbargu...@gmail.com wrote: HI,   Try this:   results -

Re: [R] How to use multi paragraph comment like /* and */ in cpp?

2014-09-10 Thread PO SU
Tks for all your help,  finally i choose the way in Rstudio ctrl+shift+C, and do twice to cancel those comments. It's enough for me now. BTW, I also like the way: if(FALSE) {}   :) -- PO SU mail: desolato...@163.com Majored in Statistics from SJTU At 2014-09-10 02:15:49, Gjalt-Jorn

Re: [R] How to use multi paragraph comment like /* and */ in cpp?

2014-09-09 Thread PO SU
I don't understand what's your meaning, do you mean that i should do some file processing,(like writing a script) ,so that i could add # in any line  i wanted. I think it is not convenient. And, it does seems that there is no way to multi line comment in R. But when i turn to using Rstudio,

Re: [R] How to use multi paragraph comment like /* and */ in cpp?

2014-09-09 Thread Berend Hasselman
On 09-09-2014, at 08:25, PO SU rhelpmaill...@163.com wrote: I don't understand what's your meaning, do you mean that i should do some file processing,(like writing a script) ,so that i could add # in any line i wanted. I think it is not convenient. And, it does seems that there is

Re: [R] How to use multi paragraph comment like /* and */ in cpp?

2014-09-09 Thread Pascal Oettli
No I don't mean this. Did you at least try the small example I provided? On Tue, Sep 9, 2014 at 3:25 PM, PO SU rhelpmaill...@163.com wrote: I don't understand what's your meaning, do you mean that i should do some file processing,(like writing a script) ,so that i could add # in any line i

Re: [R] How to use multi paragraph comment like /* and */ in cpp?

2014-09-09 Thread Duncan Murdoch
On 08/09/2014, 11:14 PM, Jeff Newmiller wrote: There are no multi line comment markers in R. However, since you are always referring to RStudio you might want to look into roxygen, since their editor supports that tool. RStudio has a command to comment a block: it's in the Code menu. (On

  1   2   3   4   5   >