Displaying 20 results from an estimated 654 matches for "yr".
Did you mean:
yor
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 p-value...
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 2 116 15.919 <.0001
Yr 1 168 77.837 <.0001
Tr:Yr 2 168 47.5...
2002 Mar 18
1
line breaks
...ds 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 example (partial function).
inrange _ function(v,Y,s,z,mlv,met){
lower _ mean(v[data$yr==Y])-(var(v[data$yr==Y])^.5)
upper _ mean(v[data$yr==Y])+(var(v[data$yr==Y])^.5)
ML _ mlv[ML$yr==Y & ML$metcode==met]
diff _ 0
if (ML<lower) {diff <- lower-ML; # tried with and without ;
v <<- v-diff}
}
gives:
> inrange _ function(v,Y,s,z,mlv,met){
+ lower _ mean(v[da...
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
------------------------------------------------------------
size: small
yr: 1994
[1] 1.135
------------------------------------------------------------
size:...
2013 Jun 12
1
Question on Simple Repeated Loops
...ow can I calculate the future growth increment of each tree for the next 3 years.
The following Rscript was written,
#----------
a0 <- data.frame(d0=seq(5,50,5) , sp=gl(2,5,10),
grow=rep(0.5,10))
a2<- list()
for( i in 1:3){
a1 <- a0$d0+a0$grow
a2[[i]] <- cbind(sp=a0$sp,d0=a1+i,yr=i)
}
as.data.frame(do.call(cbind,a2))
> as.data.frame(do.call(cbind,a2))
sp d0 yr sp d0 yr sp d0 yr
1 1 6.5 1 1 7.5 2 1 8.5 3
2 1 11.5 1 1 12.5 2 1 13.5 3
3 1 16.5 1 1 17.5 2 1 18.5 3
4 1 21.5 1 1 22.5 2 1 23.5 3
5 1 26.5 1 1 27.5 2 1 28.5 3
6...
2007 Jul 19
4
Help with Dates
...24325
The dataset runs from 1986 to 2007.
I want to be able to take subsets of my data based on date e.g. data between
2000 - 2005.
As it stands, I can't work with the dates as they are not in correct format.
I tried successfully converting the dates to just the year using:
transform(data, Yr = format(as.Date(as.character(Date),format = '%d-%b-%y'),
"%y")))
This gives the following format:
Date Price Open.Int. Comm.Long Comm.Short net.comm Yr
1 15-Jan-86 673.25 175645 65910 28425 37485 86
2 31-Jan-86 677.00 167350 54060 27120 269...
2010 Dec 10
1
WriteXLS error:Error in get(x, envir = envir) : variable names are limited to 256 bytes
...le 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:
> names(avg8302)
[1] "ID" "cluster" "rec.unit" "int.hib"
"yr.hib" "yr0309.hib" "int.hib.se" "yr.hib.se" "
yr0309.hib.se" "int.cl"
[11] "yr.cl" "yr0309.cl" "int.cl.se" "yr.cl.se" "
yr0309.cl.se" "int.ru"...
2005 Oct 06
5
Interpolation in time
Can anybody help me write a code on the following data example, which
fills out all NA values by using a linear interpolation with the two
closest values?
Doy is day of year (%j).
Code example:
yr<-c(rep(2000,14))
doy<-c(16:29)
dat<-c(3.2,NA,NA,NA,NA,NA,NA,5.1,NA,NA,NA,NA,NA,4.6)
ta<-cbind(yr,doy,dat)
ta
yr doy dat
[1,] 2000 16 3.2
[2,] 2000 17 NA
[3,] 2000 18 NA
[4,] 2000 19 NA
[5,] 2000 20 NA
[6,] 2000 21 NA
[7,] 2000 22 NA
[8,] 2000 23 5.1
[9,] 2...
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 need (yr
is a factor).
> dataset
OVEN h h2 yr
1 2 30 900...
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 years) and 12 rows (for the ages). In each cell,
I would l...
2023 Jan 14
2
Removing variables from data frame with a wile card
...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:
>
> grepl("^yr", colnames(mydata))
>
> will tell you which 'colnames' start with "yr". If you'd rather you
> use globbing:
>
> grepl(glob2rx("yr*"), colnames(mydata))
>
> Then you might write something like this to remove the columns starting with yr:
&...
2006 Jun 12
3
Group averages
...r would try should help
me with my present task as well as future problems.
Below I've included some lines that will generate a sample data set
similar to the one I'm working with:
#
#Example data:
#
case <- sample(seq(1,10000,1),5000,replace=FALSE)
hsgpa <- rbeta(5000,7,1.5)*4.25
yr <- sample(seq(1993,2005,1),5000,replace=TRUE)
conf <- sample(letters[1:5],5000,replace=TRUE)
data <- data.frame(case=case,hsgpa=hsgpa,yr=yr,conf=conf)
data$conf <- as.character(data$conf)
s1 <- sample(seq(1,5000,1),500,replace=FALSE)
k <- data$hsgpa
k[row.names(data) %in% s1] <...
2002 Mar 18
3
function design
I have a, no doubt, simple question. I wish to write a function such
that
a <- 9
b <- 10
changer _ function(x,y) { if (y>x){ x <<- Y+1}}
Of course there are easier ways to accomplish the task above, but I am
more interested in how to have the "x <<- Y+1" part of the function to
change x in place for purposes of a much larger function.
I have been wrestling with
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:
grepl(glob2rx("yr*"), colnames(mydata))
Then you might write something like this to remove the columns starting with yr:
mydata <- mydata[, !grepl("...
2006 Jun 30
3
passing parameters to functions
...edule calendar to display
in the view. I''m just starting with this and am simply trying to
display the parameters I''m trying to pass in. Here''s what I''ve got so
far:
Controller:
class SchedulesController < ApplicationController
def index
show_cal(yr, mo)
render :action => ''show_cal''
end
#...other functions not listed
def show_cal(yr, mo)
# set up dates based on yr, and mo
end
end
View: show_cal.rhtml
<h2>Calendar</h2>
<%= yr %>
<%= mo %>
<%= link_to ''previous month&...
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 are greater than zero. I
can do this easily...
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 even get somet...
2010 Nov 19
3
Sweave Dynamic Graph Question
...le to do it in R, but when i use sweave, I can only print the last
page.
any help would be greatly appreciated
Thanks
Cameron
#R code
library(fImport)
IBM <- yahooSeries("IBM", from="2000-01-01")
IBM.Close <- IBM[,"IBM.Close"]
rng=range(time(IBM.Close))
Syr <- as.numeric(format(rng[1],"%Y"))
Eyr <- as.numeric(format(rng[2],"%Y"))
Smth <- as.numeric(format(rng[1],"%m"))
for( yr in Syr:Eyr){
par(mfrow=c(4,3))
Temp1 <- IBM.Close[which(format(time(IBM.Close),"%Y")==yr),]
Temp3 <- tapply(Temp1[...
2004 Nov 04
3
sub- and superscript in plot labels
Dear List,
I need to add a subscript and a superscript to some of the ions in the
labels on some plots.
I have got to here but now I'm stuck:
plot(1:10, xlab = expression(paste("nm SO"[4], " ", mu, "eq cm"^{-2}, "
yr"^{-1})))
Which gives almost what I require. No matter what I tried, however, I
could not get bot a sub script *and* a superscript attached to the SO in
the label.
In LaTeX I would just do $SO_4^{2-}$ but taking that to R produces a
syntax error:
plot(1:10, xlab = expression(paste("...
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 <- d...