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).
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
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
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]] =
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:
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
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
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
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
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
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
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
?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 <=
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
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.
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
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
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,
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
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
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,
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 =
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
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
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
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
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
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
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
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
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
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:
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 <-
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
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 <-
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
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
> 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
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 =
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
> 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,
>
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:
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,
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
#>
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,
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
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
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
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
>
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
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
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
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)
>
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
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
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),
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 =
> 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%
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"))
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
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
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
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
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"))
>
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
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
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
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,
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
>
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,
>
> > 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
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
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
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
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
# 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,
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
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:
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)
>
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
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
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
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,
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
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)
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
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
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
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
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.
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
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
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
--
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)
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 -
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
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,
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
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
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 - 100 of 401 matches
Mail list logo