Displaying 20 results from an estimated 10000 matches similar to: "R/S compatibility in passing a formula"
2011 Apr 18
2
as.formula doesn't want to take a phrase
Hello!
I am trying to create a formula object using as.formula. But it's not working:
examplephraze<-"for.my.example"
myformula<-as.formula(paste(examplephraze,"~group, sum, data=mydata",sep=""))
What's the problem?
Thanks a lot!
--
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com
2009 Oct 11
3
passing field name parameter to function
Hi,
I am passing a data frame and field name to a function. I've figured out how
I can create the formula based on the passed in field name, but I'm
struggling to create a vector based in that field.
for example if I hard code with the actual field name
Y = df$Target, everything works fine.
but if I use the passed in parameter name, it doesn't give me what I want,
Y =
2007 Jun 15
2
model.frame: how does one use it?
Philipp Benner reported a Debian bug report against r-cran-rpart aka rpart.
In short, the issue has to do with how rpart evaluates a formula and
supporting arguments, in particular 'weights'.
A simple contrived example is
-----------------------------------------------------------------------------
library(rpart)
## using data from help(rpart), set up simple example
myformula <-
2005 Apr 02
4
factor to numeric in data.frame
Dear All,
Assume I have a data.frame that contains also factors and I would like to
get another data.frame containing the factors as numeric vectors, to apply
functions like sapply(..., median) on them.
I read the warning concerning as.numeric or unclass, but in my case this
makes sense, because the factor levels are properly ordered.
I can do it, if I write for each single column
2010 Jan 05
1
Is the Intercept Term always in First Position?
Dear All,
I have a question about formulas and model.matrix(). If one specifies a model via a formula, the corresponding design matrix can be obtained with the model.matrix() function. For example:
x1 <- c(1,4,2,3,5)
x2 <- c(1,1,2,2,2)
myformula <- ~ x1 + factor(x2)
model.matrix(myformula)
My question is: If an intercept term is in the model (like in the example above), is it always
2023 Apr 28
2
range() for Date and POSIXct could respect `finite = TRUE`
Hi all,
I noticed that `range.default()` has a nice `finite = TRUE` argument,
but it doesn't actually apply to Date or POSIXct due to how
`is.numeric()` works.
```
x <- .Date(c(0, Inf, 1, 2, Inf))
x
#> [1] "1970-01-01" "Inf" "1970-01-02" "1970-01-03" "Inf"
# Darn!
range(x, finite = TRUE)
#> [1] "1970-01-01"
2010 Jan 01
1
Questions bout SVM
Hi everyone,
Can someone please help me in these questions?:
1)if I use crossvalidation with svm, do I have to use this equation to calculate RMSE?:
mymodel <- svm(myformula,data=mydata,cross=10)
sqrt(mean(mymodel$MSE))
But if I don’t use crossvalidation, I have to use the following to calculate RMSE:
mymodel <- svm(myformula,data=mydata)
mytest
2009 Oct 10
1
field names as function parameters
Hi,
I am passing a data frame and field name to a function. I've figured out how
I can create the formula based on the passed in field name, but I'm
struggling to create a vector based in that field.
for example if I hard code with the actual field name
Y = df$Target, everything works fine.
but if I use the passed in parameter name, it doesn't give me what I want,
Y = df$mytarget
2023 Apr 28
1
range() for Date and POSIXct could respect `finite = TRUE`
A tiny nit-pick: Seems to me that end date = NA would mean the event has
not yet ended, whilst Inf would mean that the event is known to never
terminate, ie: an eternal fact, or physical law.
On Fri, Apr 28, 2023 at 10:12?AM Davis Vaughan via R-devel <
r-devel at r-project.org> wrote:
> Hi all,
>
> I noticed that `range.default()` has a nice `finite = TRUE` argument,
> but it
2007 Mar 23
1
objects of class "matrix" and mode "list"?
Hello everyone,
I cannot seem to find information about objects of class "matrix" and mode
"list", and how to handle them (apart from flattening the list). I get this
type of object from using sapply(). Sorry for the long example, but the code
below illustrates how I get this type of object. Is anyone aware of
documentation regarding this object?
Thanks very much,
Stephen
2011 Feb 01
1
dotchart {graphics} 2.11.1 vs. 2.12.1 [followed up from Rhelp]
Dear List,
With the R 2.12.0 addition of table methods for points(), dotchart()
struggles with tables. I found several possible solutions, but it is
beyond my skill to decide what is "best". Here is a small example:
#############################################
x <- table(infert$education)
y <- 1:3L
dotchart(x) # error about incorrect plot type
## moving closer to the cause,
2004 Dec 13
2
read attribute
How can I get a single attribute value of an object ?
I jhave the tiemSeries object
> ts1
Open
2003-10-09 02:00:00 1.27
2003-10-10 02:00:00 1.25
2003-10-13 02:00:00 1.27
2003-10-14 02:00:00 1.29
When I unclass ts1 I get:
> unclass(ts1)
list()
attr(,"Data")
Open
2003-10-09 02:00:00 1.27
2003-10-10 02:00:00 1.25
2003-10-13 02:00:00 1.27
1997 Sep 02
1
R-alpha: R interaction within ESS-4.9-b11: two small issues
1) I installed the latest ESS (Emacs Speaks Statistics) beta release
on a machine running Linux. Since there is no S-PLUS product for
Linux, I set the ess-site.el file for R, xlisp-stat, and S version 4.
I.e.,
;; (1.5) Require the needed dialects for your setup.
;;(require 'essd-s+3)
(require 'essd-r)
(require 'essd-xls)
;;(require 'essd-sas)
;;(require 'essd-s3) ;;
2010 Mar 14
1
Error in object$tables[[v]] : subscript out of bounds
Hi,
Could you please tell me how I correct the following error message?
“Error in object$tables[[v]] : subscript out of bounds”
This is the code:
library(e1071)
data(iris)
attach(iris)
class_label <- names(iris)[1]
myformula <- formula(paste(class_label,"~ ."))
mymodel<-naiveBayes(myformula, iris,cross=3)
predict(mymodel,iris) ##Error in object$tables[[v]] :
2001 Aug 12
1
Creating a Model Matrix - keeping NAs
I am wanting to create a model matrix and keep the NAs.
stratmat <- model.matrix(myformula,mydata)
Is there any way to do this? model.matrix doesn't have na.action as a
parameter. Elsewhere I have made use of na.keep <- function(x){x}.
Many thanks,
Rachel Cunliffe
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read
2006 Sep 22
2
behavior of [<-.foo
Can someone help me understand the following behavior of "[<-" ?
If I define a simple class based on a matrix, the [<- operation only
inserts into the first column:
> x <- matrix(rnorm(10),nrow=5,ncol=2)
> class(x) <- "foo"
> "[<-.foo" <- function(x, i, j, value) {
+ if(missing(i)) i <- 1:nrow(x)
+ if(missing(j)) j <-
2005 Oct 17
2
Insightful Announces: "R and S-PLUS- Panel Discussion" at 9th Annual 2005 User Conference
Event: 2005 Insightful User Conference
Dates: Oct 26-27, 2005
Location: Princeton, NJ
URL: http://www.insightful.com/news_events/2005uc/ for details on pricing,
hotel accommodations and to register for this event.
The Insightful 2005 User Conference is being held October 26th-27th in
Princeton, NJ. This year's conference focuses on the techniques and
methodologies pivotal to the
2008 Feb 16
3
Arithmetic bug? (found when use POSIXct) (PR#10776)
Full_Name: Bo Zhou
Version: 2.6.1 (2007-11-26)
OS: Windows XP
Submission from: (NULL) (207.237.54.242)
Hi,
I found an arithmetic problem when I'm doing something with POSIXct
The code to reproduce it is as follows (This is the recommended way of finding
out time zone difference on R News 2004-1 Page 32 URL
http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf)
a=Sys.time()
2012 Dec 21
2
Why can't I "unclass" an array?
In a real example I was trying to remove the class from the result of table, just because
it was to be used as a building block for other things and a simple integer vector seemed
likely to be most efficient.
I'm puzzled as to why unclass doesn't work.
> zed <- table(1:5)
> class(zed)
[1] "table"
> class(unclass(zed))
[1] "array"
>
2012 Dec 21
2
Why can't I "unclass" an array?
In a real example I was trying to remove the class from the result of table, just because
it was to be used as a building block for other things and a simple integer vector seemed
likely to be most efficient.
I'm puzzled as to why unclass doesn't work.
> zed <- table(1:5)
> class(zed)
[1] "table"
> class(unclass(zed))
[1] "array"
>