similar to: passing parameters to functions

Displaying 20 results from an estimated 3000 matches similar to: "passing parameters to functions"

2007 May 03
2
Package contrast error
Trying to use contrast to look at differences within an lme lme.fnl.REML <- lme(Max ~ S + Tr + Yr + Tr:Yr, random = ~1 |TID, method = "REML") I have three levels of Tr I'm trying to contrast among different years (R, T97, T98), years = 1997-1999, so I'm interested in contrasts of the interaction term. > anova(lme.fnl.REML) numDF denDF F-value
2002 Mar 18
1
line breaks
I have a question about the function of line feeds/carriage returns in an all linux (R, vi to write scripts) environment. In my scripts I have a few functions, using { or ( to wrap commands on the next line. Usually this is fine, but sometimes R appears confused by line wrappings (more likely of course it is me who is confused). I tried ';' to explictly break the line, but no dice. An
2007 Apr 30
2
Independent contrasts from lme with interactions
Hi All, I've been searching the help archives but haven't found a workable solution to this problem. I'm running an lme model with the following call: >lme.fnl <- lme(Max ~ S + Tr + Yr + Tr:Yr, random = ~1 |TID) > anova(lme.fnl) numDF denDF F-value p-value (Intercept) 1 168 19255.389 <.0001 S 1 168 5.912 0.0161 Tr
2009 Apr 13
2
weighted mean and by() with two index
Hi expeRts, I would like to calculate weighted mean by two factors. My code is as follows: R> tmp <- by(re$meta.sales.lkm[, c("pc", "sales")], re$meta.sales.lkm[, c("size", "yr")], function(x) weighted.mean(x[,1], x[,2])) The result is as follows: R> tmp size: micro yr: 1994 [1] 1.090
2013 Jun 12
1
Question on Simple Repeated Loops
Dear R-User, Appreciate any helps. It looks simple, but I don't have a clue. Given that I have a dataframe of tree population with three variables: sp=species , d0=initial_size grow=growth increment from initial size per year How can I calculate the future growth increment of each tree for the next 3 years. The following Rscript was written, #---------- a0 <-
2010 Dec 10
1
WriteXLS error:Error in get(x, envir = envir) : variable names are limited to 256 bytes
Hello all, I don't understand why this won't work. I have entered: WriteXLS(alldata,'test.xls') and I get this error message: Error in get(x, envir = envir) : variable names are limited to 256 bytes. My variable names are not very long, and are accepted by write.csv. alldata is a list containing 4 dataframes, with each dataframe having the the same variable names, which are:
2005 Apr 30
2
formula in fixed-effects part of GLMM
Can GLMM take formula derived from another object? foo <- glm (OVEN ~ h + h2, poisson, dataset) # ok bar <- GLMM (OVEN ~ h + h2, poisson, dataset, random = list (yr = ~1)) #error bar <- GLMM (foo$formula, poisson, dataset, random = list (yr = ~1)) #Error in foo$("formula" + yr + 1) : invalid subscript type I am using R2.1.0, lme4 0.8-2, windows xp. Below is a dataset if you
2007 Jul 19
4
Help with Dates
R I am taking an excel dataset and reading it into R using read.table. (actually I am dumping the data into a .txt file first and then reading data in to R). Here is snippet: > head(data); Date Price Open.Int. Comm.Long Comm.Short net.comm 1 15-Jan-86 673.25 175645 65910 28425 37485 2 31-Jan-86 677.00 167350 54060 27120 26940 3 14-Feb-86 680.25
2023 Jan 14
2
Removing variables from data frame with a wile card
Thanks to all. Very helpful. Steven from iPhone > On Jan 14, 2023, at 3:08 PM, Andrew Simmons <akwsimmo at gmail.com> wrote: > > ?You'll want to use grep() or grepl(). By default, grep() uses extended > regular expressions to find matches, but you can also use perl regular > expressions and globbing (after converting to a regular expression). > For example: >
2023 Jan 14
1
Removing variables from data frame with a wile card
You'll want to use grep() or grepl(). By default, grep() uses extended regular expressions to find matches, but you can also use perl regular expressions and globbing (after converting to a regular expression). For example: grepl("^yr", colnames(mydata)) will tell you which 'colnames' start with "yr". If you'd rather you use globbing:
2011 Nov 29
1
Sum matrix by rows, conditional on value
I'd like to sum a matrix only where the matrix meets a specific condition. The matrix has 365 rows and about 50,000 columns. str(cdem.mat.yr) num [1:365, 1:41772] -43.5 -48.4 -45.9 -38.4 -32 ... I'm having trouble replicating this because it is not working out for me, so I'm unsure I can provide an solid working example (apologies). I would like to subset my matrix where the values
2010 Nov 19
3
Sweave Dynamic Graph Question
i have a time Series of IBM closing px from 1/1/2000 to today I want to graph the time serie by dividing the graph by year and month all the monthly graphs with the same year will go to one page. so from 1/1/2000 to 11/19/2010. i will have 11 pages, and each page will have 12 graphs (jan to dec) except for 2010. I am able to do it in R, but when i use sweave, I can only print the last page.
2008 Jun 21
1
Coloring Stripchart Points, or Better, Lattice Equivalent
Hi All. I have the commands below to create a stripchart/plot. I was hoping to color the points in the plot by yr, and use a symbol that varied with resp. However, the outcome makes it appear as though the point by point col and pch data is not being passed properly. Any suggestions? And truthfully, I?d rather be doing this with Lattice, but I?ve tried several variations of stripplot and can?t
2005 Dec 08
3
Reshaping data
Dear all, given I have data in a data.frame which indicate the number of people in a specific year at a specific age: n <- 10 mydf <- data.frame(yr=sample(1:10, size=n, replace=FALSE), age=sample(1:12, size=n, replace=FALSE), no=sample(1:10, size=n, replace=FALSE)) Now I would like to make a matrix with (in this simple example) 10 columns (for the
2006 Jun 12
3
Group averages
Hello: I hope none of you will mind helping a newbie. I'm a student research assistant working with a large data set in which observations are categorized according to two factors. I'm trying to calculate the group mean and variance of a variable (called 'hsgpa' in the example data presented below) to each observation , excluding that observation. For example, if there are
2010 May 24
1
Fixed Effects Estimations (in Panel Data)
dear readers---I struggled with how to do nice fixed-effects regressions in large economic samples for a while. Eventually, I realized that nlme is not really what I needed (too complex), and all I really wanted is the plm package. so, I thought I would share a quick example. ################ sample code to show fixed-effects models? in R # create a sample panel data set with firms and years
2023 Jan 14
1
Removing variables from data frame with a wile card
You rang sir? library(tidyverse) xx = 1:10 yr1 = yr2 = yr3 = rnorm(10) dat1 <- data.frame(xx , yr1, yr2, y3) dat1 %>% select(!starts_with("yr")) or for something a bit more exotic as I have been trying to learn a bit about the "data.table package library(data.table) xx = 1:10 yr1 = yr2 = yr3 = rnorm(10) dat2 <- data.table(xx , yr1, yr2, yr3) dat2[, !names(dat2)
2023 Feb 12
2
Removing variables from data frame with a wile card
x["V2"] is more efficient than using drop=FALSE, and perfectly normal syntax (data frames are lists of columns). I would ignore the naysayers, or put a comment in if you want to accelerate their uptake. As I understand it, one of the main reasons tibbles exist is because of drop=TRUE. List-slice (single-dimension) indexing works equally well with both standard and tibble types of data
2008 Dec 03
1
GLMM using lme4
Dear R-experts, I am running R version 2.7.1 on Windows Vista. I have a small dataset which consists of ?chick ID?, ?year (0, 1)?, ?hatching order [HO, defined as first, second and third-hatched chick]?, and the binary outcome of interest ?death (0, 1)?. So a subset of my dataset looks like this on a txt file: y ID Yr HO 1 1 1 First 0 2 1 First 0 3 1 Second 0 4 1 First 1 5 1 First 0 6 1 Third
2011 Jul 14
1
glm() scale parameters and predicted Values
In glm() you can use the summary() function to recover the shape parameter (the reciprocal of the dispersion parameter). How do you recover the scale parameter? Also, in the given example, how I estimate and save the geometric mean of the predicted values? For a simple model you can use fitted() or predicted() functions. I will appreciate any help. ? ? ? #Call required R packages require(plyr)?