Displaying 20 results from an estimated 241 matches for "idvars".
Did you mean:
indvars
2007 Sep 07
2
R first.id last.id function error
Hi R users,
I have a test dataframe ("file1," shown below) for which I am trying
to create a flag for the first and last ID record (equivalent to SAS
first.id and last.id variables.
Dump of file1:
> file1
id rx week dv1
1 1 1 1 1
2 1 1 2 1
3 1 1 3 2
4 2 1 1 3
5 2 1 2 4
6 2 1 3 1
7 3 1 1 2
8 3 1 2 3
9 3 1 3
2009 Oct 21
1
formula and model.frame
Suppose I have the following function
myFun <- function(formula, data){
f <- formula(formula)
dat <- model.frame(f, data)
dat
}
Applying it with this sample data yields a new dataframe:
qqq <- data.frame(grade = c(3, NA, 3,4,5,5,4,3), score = rnorm(8), idVar = c(1:8))
dat <- myFun(score ~ grade, qqq)
However, what I would like is for the resulting dataframe (dat) to include
2005 Oct 31
0
Problem using reshape with missing values in idvar
Hello everybody,
I have been recently using reshape to convert "long" data to "wide"
data. Everything was going well until I reached some problematic
datasets. It has taken me a couple of weeks to finally figure out
what might be happening.
The problem is reproducible with test cases, and on two versions of R
(Windows 2.2.0 and x86-64 Fedora Core 3 R 2.2.0).
The data
2009 Feb 08
0
Modifying forestplot function in rmeta
All,
I am using the forestplot function in rmeta.
I was able to modify the x axis range by commenting out one line and
feeding it two new parameters (I wanted to set zero as the axis start point).
#xrange <- c(max(min(lower, na.rm = TRUE), clip[1]),
min(max(upper, na.rm = TRUE), clip[2]))
#new line
xrange <- c(xlow,xhigh)
Now I am trying to modify the text font size for
2001 Dec 27
3
reshape error in 1.4 (PR#1231)
Full_Name: Kevin Wright
Version: 1.4
OS: Windows 95
Submission from: (NULL) (170.54.59.160)
Note: This was the 1.4 build for Windows that Brian Ripley made available.
The first example in the help for reshape doesn't work for me. When I cut and
paste, this is what happens:
> data(Indometh,package="nls")
> summary(Indometh)
Subject time conc
2009 Sep 14
2
problems with reshape
Hello *
I would like to reshape wide the following dataset:
> rl <- read.dta("intermedi/rapporti_lavoro.dta") [c("id_rl","prog","sil_pi","sil_cf","sil_dat_avv")]
> dim(rl)
[1] 12964 5
> object.size(rl)
1194728 bytes
> head(rl)
id_rl prog sil_pi sil_cf sil_dat_avv
1 638 1 04567XXXXXX
2005 Mar 26
1
Function Arguments
Hello,
I am trying to wrap some code that I repeatedly use into a function for efficiency. The following is a toy example simply to illustrate the problem.
foobar.fun<-function(data,idvar,dv){
id.list<-unique(idvar)
result<-numeric(0)
for (i in id.list){
tmp1<-subset(data, idvar == i)
result[i]<-mean(get("tmp1")[[dv]])
}
return(result)
}
The
2012 Dec 06
1
scope, lme, ns, nlme, splines
I want to fit a series of lme() regression models that differ only in the
degrees of freedom of a ns() spline. I want to use a wrapper function to do
this. The models will be of the form
y ~ ns(x, df=splineDF)
where splineDF is passed as an argument to a wrapper function.
This works fine if the regression function is lm(). But with lme(),
I get an error. fitfunction() below demonstrates this.
2000 Sep 29
0
Is it R or I?
Salutations:
I have been trying to translate a S-PLUS/ArcInfo (GIS software) application
that I wrote on a SGI (IRIX) platform to public domain R and GrassGIS on
a Linux platform. I am almost on the verge of abandoning it as I find R to
be
rather unstable, slow and frustrating.
I enclose a section of my code for R experts to examine
hoping that they'll point out that all the above three are
2006 Jan 22
6
Making a markov transition matrix
Folks,
I am holding a dataset where firms are observed for a fixed (and
small) set of years. The data is in "long" format - one record for one
firm for one point in time. A state variable is observed (a factor).
I wish to make a markov transition matrix about the time-series
evolution of that state variable. The code below does this. But it's
hardcoded to the specific years that I
2009 Oct 04
2
Row to Column help
Dear R Community,
I am attempting to transpose a dataset from rows to columns but am stuck. I
have tried using reshape() with little luck, possibly due to the categorical
nature of the data. For example:
id<-c(1,2,2,3,3,3)
author<-c("j","k","k","l","l","l")
2003 Oct 30
1
Trouble reshaping some data
I would appreciate some advice on the following task. I have
some data that currently looks like this:
t1 <- data.frame(id=c(1,1,2,2),
aspect=c("A","B","A","B"), score=c(10,9,11,12))
I'd like it to look like this:
id A B
1 10 9
2 11 12
reshape() looks like a good candidate for this job but I'm
not really sure about the roles of
2011 Jan 11
1
sorting question
...CET"). Now, I want to sort the data frame in
ascending order by a, b, c and then in descending order by t.
Here's what I've got, but I'm not sure how to put the 'descending' bit in the
code. The trick with the minus sign doesn't work as the var isn't numeric.
idvars <-- c("a", "b", "c")
myData["t"] <- as.POSIXct(myData[,"t"])
result <- myData[ do.call(order, myData[c(idvars, "t")]), ]
This should be simple, I guess, but I've been staring at this a bit too long
now. Suggestions anyone? T...
2006 Jan 23
0
Making a markov transition matrix - more progress
I solved the problem in one more (and more elegant) way. So here's the
program again.
Where does R stand on the Anderson-Goodman test of 1957? I hunted
around and nobody seems to be doing this in R. Is it that there has
been much progress after 1957 and nobody uses it anymore?
# Problem statement:
#
# You are holding a dataset where firms are observed for a fixed
# (and small) set of years.
2013 Apr 08
1
remove duplicates in data frame
Hi,
Try ?unique()
You haven't provided reproducible data or information about the package.? So, this may or may not work.
dat1<- data.frame(idvar=c(rep(1,2),2,4),col2=c(7,7,8,9))
?dat1
#? idvar col2
#1???? 1??? 7
#2???? 1??? 7
#3???? 2??? 8
#4???? 4??? 9
?unique(dat1)
#? idvar col2
#1???? 1??? 7
#3???? 2??? 8
#4???? 4??? 9
A.K.
I got the following message when trying to use Google
2009 Dec 09
1
reshape() makes R run out of memory (PR#14121)
Full_Name: Alexander L. Belikoff
Version: 2.8.1
OS: Ubuntu 9.04 (x86_64)
Submission from: (NULL) (67.244.71.200)
I'm trying to reshape the following data frame:
ID DATE1 DATE2 VALUE_TYPE VALUE
'abcd1233' 2009-11-12 2009-12-23 'TYPE1' 123.45
...
VALUE_TYPE is a string and is a factor with only 2 values
2012 Dec 11
1
Debian packaging and openblas related crash when profiling in R
...but only
when openblas stuff is in the picture. I wondered what you think?
Here's the code to reproduce this:
datM <- read.csv("http://pj.freefaculty.org/scraps/profile/missingDat.csv")
library(Amelia)
set.seed(12345)
Rprof("Amelia-1.out")
impA <- amelia(datM, m = 5, idvars="group")
Rprof(NULL)
summaryRprof("Amelia-1.out")
Here's the crashed session
> datM <- read.csv("http://pj.freefaculty.org/scraps/profile/missingDat.csv")
> library(Amelia)
Loading required package: foreign
##
## Amelia II: Multiple Imputation
## (Versi...
2004 Aug 06
1
reshape (was: Comparing rows in a dataframe)
Hi all:
I solved the previous stated problem in something of a brute force way
(but it works). I seem to now be running into one little hiccup using
reshape. Here is a quick snip of the data in long format:
grade stability year schid
6 Grade 4 3 2001 100005
7 Grade 4 3 2002 100005
8 Grade 4 2 2003 100005
10 Grade 5 2 2001 100005
11 Grade 5
2008 Nov 18
1
reshape question
Hi,
It's probably a simple issue but I'm struggling with that. I'll use the
example shown in the help page.
head(Indometh)
wide <- reshape(Indometh, v.names="conc", idvar="Subject",
timevar="time", direction="wide")
head(wide)
reshape(wide, idvar="Subject", varying=list(2:12),
v.names="conc",
2011 Jul 22
0
Using package amelia
...nth, measurements, standard deviation of the
measurement). Of course, there are some random missing values on columns 3
and 4. The measurements are an almost periodic time-series contaminated by
noise.
I did some tests such as:
a.out <- amelia(x, m = 5, ts = "YEAR", p2s = 0, idvars=c("DEV"));
> a.out <- amelia(x, m = 5, ts = "YEAR", p2s = 0, idvars=c("MON","DEV"));
Error in matrix(1, AMn, 1) : non-numeric matrix extent
a.out <- amelia(x, m = 5, ts = "YEAR", p2s = 0);
a.out <- amelia(x, m = 5, p2s = 0, idv...