similar to: Long model formulae

Displaying 20 results from an estimated 7000 matches similar to: "Long model formulae"

2010 Oct 31
3
extracting named vector from dataframe
Suppose df is a dataframe with one named row of numeric observations. I want to coerce df into a named vector. as.vector does not work as I expected: as.vector(df) returns the original dataframe, while as.vector(df,mode="numeric") returns an unnamed vector of NAs. This works: > v <- as.numeric(as.matrix(df)); names(v) <- names(df); I just wanted check if there
2010 Oct 04
3
read columns of quoted numbers as factors
Suppose I have a data file (possibly with a huge number of columns), where the columns with factors are coded as "1", "2", "3", etc ... The default behavior of read.table is to convert these columns to integer vectors. Is there a way to get read.table to recognize that columns of quoted numbers represent factors (while unquoted numbers are interpreted as
2010 Sep 19
2
working with eval and environments
I'm trying to get the following section of code to work, I think the problem is being caused by the assignment of data to the lm function not evaluating to "train" in the parent environment but I can't seem to figure out how to do this. fitmodel <- function(trial,data) { wrap.lm <- function(formula,data,...) { cat("in wrap lm",NROW(data),"\n");
2003 Jan 21
1
Orders of terms in formulae
Hi, Given that R reports Type I sums of squares, isn't it a bit anachronistic that it re-orders terms in formulae? > d <- expand.grid(y=rnorm(8), + A=factor(c(1,2)), + B=factor(c(1,2)), + C=factor(c(1,2))) > summary(aov(y ~ A+B+A:B+C,data=d)) Df Sum Sq Mean Sq F value Pr(>F) A 1 8.294e-34 8.294e-34 1.027e-33 1
2011 Jun 20
2
Model Formulae Evaluation
Hello All, I have searched but haven't been able to find an answer to this question. I'm writing a function that needs to be able evaluate the right-hand side of a general non-linear formula for different parameter values, similar to what nls() does. I looked through the nls() code but it isn't clear what is going on. Could someone point me to a reference or a way I might do this?
2010 Nov 23
2
Help with grouped barplot
Given the data structure below, how can I create a bar plot for the values of disc for each area grouped by year? bar <-structure(list(year = c(2003, 2003, 2003, 2003, 2003, 2003, 2003, 2007, 2007, 2007, 2007, 2007, 2007, 2007), area = structure(c(6L, 4L, 1L, 2L, 3L, 5L, 7L, 6L, 4L, 1L, 2L, 3L, 5L, 7L), .Label = c("AK", "ID", "MT", "NW",
2020 Aug 15
2
Tests failing on CentOS 6
Getting this when attempting to build 2.3.11.3 on CentOS 6: test-mail-cache.c:176: Assert failed: strcmp(str_c(str),"123\nfoo\n456\nbar\n") "" != "123 foo 456 bar " test-mail-cache.c:176: Assert failed: strcmp(str_c(str),"123\nfoo\n456\nbar\n") "" != "123 foo 456 bar " mail cache uncommitted lookups
2016 Apr 06
2
Is this a bug in quantmod::OpCl?
OpCl works on xts objects but not on quantmod.OHLC objects. Is this a bug? Example error: x.Date <- as.Date("2003-02-01") + c(1, 3, 7, 9, 14) - 1 set.seed(1) x <- zoo(matrix(runif(20, 0, 1), nrow=5, ncol=4), x.Date) q <- as.quantmod.OHLC(x,c("Open","High","Low","Close")) # error OpCl(q) #> Error in `colnames<-`(`*tmp*`, value =
2010 Nov 15
2
Extracting from data.frame
Can someone please explain the following behavior? df1 and df2 are data.frames. Suppose I want a subset of the rows (observations) using extraction, say just the first row. What I want to know is why if df1 has just one column then df1[1,] returns a vector, whereas if df2 has 2 or more columns then df2[1,] returns a data frame? Why is the single column case different? [[alternative HTML
2005 Jan 12
4
gbm
Hi, there: I am wondering if I can find some detailed explanation on gbm or explanation on examples of gbm. thanks, Ed
2011 Apr 22
3
Parametrized object name in Save statement
Greetings All, I am looking to write a parametrized Rscript that will accept a variable name(that also is the name of the flat file), transform the data into a data frame and preform various modeling on the structure and save the output and plot of the model. In this example i am using a rpart decision tree. The only problem i am having is integrating the parameter into the internal object name
2010 Sep 26
4
How to update an old unsupported package
Hi all, I have a package that is specific to a task I was repetitively using a few years ago. I now needed to run it again with new data. However I am told it was built with an older version or R and will not work. How can I tweak the package so it will run on 11.1? It was a one-off product and has not been maintained. Is there a way to "unpackage" it and repackage it to work? I
2007 Dec 16
1
paste dependent variable in formula (rpart)?
Hello, i'm trying to replace different target variables in rpart with a function. The data.frame getting always the target variable as last column. Try below, i get the target variable in the explained variables, too!? Have anybody an advice to avoid this. rp1 <- rpart(eval(parse(text=paste(names(train[length(train)])))) ~ . , data=train,cp=0.0001) regards & many thanks
2013 Feb 03
1
ggplot2 plotting errorbars.
Hi, i'm using this lines of code: dodge <-position_dodge(width=0.9) ggplot(dfm,aes(x = X,y = value)) + geom_bar(aes(fill = variable), position=dodge, stat="identity") + geom_errorbar(aes(ymin=value-er, ymax=value+er),width=0.25, position=dodge,stat="identity") to plot this data frame X variable value er 1 A X4 58.74 9.44 2 B X4
2010 Mar 12
1
simple plot in ggplot2, wrong error bars
I was wondering if anyone could help me with this, simple problem. I am essentially following the example on Hadley's webpage (http://had.co.nz/ggplot2/geom_errorbar.html), but it still doesn't make any sense to me. df <- data.frame(trt = factor(c("intact", "intact", "removed", "removed")), coon = c(0.093, 0.06, 0.057, 0.09), group =
2012 Jul 02
5
ggplot: dodge positions
Dear all, I want to get a series of boxplots (grouped by two factors) and I want to overlay the original observations and the following code does almost what I want: library(ggplot) ddf <- data.frame(x=factor(rep(LETTERS[1:4], each=30)), y = runif(120,0,10), grp = factor(rep(rep(1:3, 10), 4))) ggplot(ddf, aes(x, y, colour=grp)) + geom_boxplot() + geom_point() Yet the position of the points
2013 Mar 06
6
Ggplot2: Moving legend, change fill and removal of space between plots when using grid.arrange() possible use of facet_grid?
Hi, # For publications, I am not allowed to repeat the axes. I have tried to remove the axes using: # yaxt="n", but it did not work. I have not understood how to do this in ggplot2. Can you help me? # I also do not want loads of space between the graphs (see below script with Dummy Data). # If I could make it look like the examples on the (nice) examples page: #
2011 Dec 21
3
black and white in qplot? layout 4 graphs in one screen
Hello, I am trying to plot means and standard errors conditioned by a factor, using qplot. I am successful at getting the bar graph I want with a error bar, however I have tried many things and cannot get the bars to change colors. Currently showing as red and blue, but need it to be black and white for publication. Any suggestions please? Using a data set June, which is str:
2018 Jan 15
5
barplot that displays sums of values of 2 y colums grouped by different variables
I am trying to create a barplot displaying the sums of 2 columns of data grouped by a variable. the data is set up like this: "city" "n" "y" <br> mon 100 200 <br> tor 209 300 <br> edm 98 87 <br> mon 20 76 <br> tor 50 96 <br> edm 62 27 <br> the resulting plot should have city as the x-axis, 2 bars per city, 1 representing
2008 Jan 09
2
Two dependent variables in formula
Hello, I' m trying to change the formula in the rpart function. The format of a general formula is Answer ~ expression, where Answer is the dependent variable and expression is set of terms containing the independent variables and separated by operators. I want the response of the formula is more than one dependent variable. It is possible?