Displaying 20 results from an estimated 3000 matches similar to: "conditionally merging adjacent rows in a data frame"
2009 Nov 25
2
order of panels in xyplots
I'd like do a simple xyplot with customized order of panels and try to
understand how to use index.cond for that. Several attempts didn't
deliver the correct results. Now, I noticed the following:
> p <- xyplot(dur~roi|trial, data)
> p$index.cond
[[1]]
[1] 1 2 3 4 5 6 7 8 9 10
These numbers are "valid indexing vector for the integer vector
2009 Feb 11
1
Variables captured in closures get copied?
Hi list! I have a data frame called fix and a list of index vectors
called rois:
> head(rois, 3)
[[1]]
[1] 2 1
[[2]]
[1] 3
[[3]]
[1] 6 7 28 26 27 24 25
The part that's causing the issue is the following line:
lapply(rois, function(roi) fix$x[roi] <- 100)
So for every index vector I'd like to set the respective entries in the
data frame (fix) to 100.
I
2010 Sep 27
7
Regular expressions: offsets of groups
Dear list!
> gregexpr("a+(b+)", "abcdaabbc")
[[1]]
[1] 1 5
attr(,"match.length")
[1] 2 4
What I want is the offsets of the matches for the group (b+), i.e. 2
and 7, not the offsets of the complete matches. Is there a way in R
to get that?
I know about gsubgn and strapply, but they only give me the strings
matched by groups not their offsets.
I could write
2009 Feb 16
3
Applying functions to partitions
Hi list! I have a large matrix which I'd like to partition into blocks
and for each block I'd like to compute the mean. Following a example
where each letter marks a block of the partition:
a a a d g g
a a a d g g
a a a d g g
b b b e h h
b b b e h h
c c c f i i
I'm only interested in the resulting matrix of means. How can this be
done efficiently?
2009 Jun 09
3
Splicing factors without losing levels
Hi list!
An operation that I often need is splicing two vectors:
> splice(1:3, 4:6)
[1] 1 4 2 5 3 6
For numeric vectors I use this hack:
splice <- function(x, y) {
xy <- cbind(x, y)
xy <- t(xy)
dim(xy) <- length(x) * 2
return(xy)
}
So far, so good (?). But I also need splicing for factors and I tried
this:
splice <- function(x, y) {
xy <-
2009 May 12
3
What's the best way to tell a function about relevant fields in data frames
Hi list,
I have a function that detects saccadic eye movements in a time series
of eye positions sampled at a rate of 250Hz. This function needs
three vectors: x-coordinate, y-coordinate, trial-id. This information
is usually contained in a data frame that also has some other fields.
The names of the fields are not standardized.
> head(eyemovements)
time x y trial
51
2010 Feb 06
3
melt on OSX ignores na.rm=T
Hi list,
I run R on Linux and OSX. On both systems I use R version 2.9.2 (2009-08-24)
and reshape version: 0.8.2 (2008-11-04). When I do a melt with
na.rm=T on a data frame I get different results on these systems:
library(reshape)
x <- read.table(textConnection("char trial wn
p E10I13D0 4
r E10I13D0 4
a E10I13D0 4
c E10I13D0 4
t E10I13D0 4
i E10I13D0 4
c E10I13D0 4
e E10I13D0
2012 Feb 10
3
Creating XML document extremely slow
Hi list,
I'm using the package XML to create a simple XML document.
Unfortunately constructing the XML tree is extremely slow. My code
(see below) adds only about 100 nodes per second on an Intel i5
machine. There's clearly something wrong but I don't see what.
Here's a sample of the XML document:
<?xml version="1.0" encoding="utf-8"?>
2009 Jan 31
1
Splitting a data frame with break points where factor changes value
I have a data frame called s3. This data frame has a column called
saccade which has two levels 1 and -1.
> head(s3$saccade, 100)
[1] NA NA NA NA -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
[26] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1
[51] 1 1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
[76] -1 -1 -1 -1 -1
2012 Feb 03
1
Resume processing after warning handler.
Dear list!
I have a script that processes a large number of data files. When one
file fails to process correctly, I want the script to write a message
and to continue with the next file. I achieved this with tryCatch:
for (f in files)
tryCatch({heavy.lifting(f)}, error=function(e) log.error.to.file(e))
I also want to log warning messages and tried something like this:
for (f in
2009 Jan 22
1
melt stumbles over deleted columns
I have a data frame that is the result of a cast (reshape) operation. I
deleted the variable column and tried to melt the resulting data frame.
Depending on which method I use to delete the column I get different
error messages when melting:
> head(tinfos)
vpn group trial_no item relation trial_type rt variable #
1 102 2 1 4351 diag1 distractor 8471 fix_d 27
2006 May 11
1
model formulation for the following ANOVA
Hallo!
I have run a EEG experiment and got the following data
group: 1 2 1 2 1 2 1 2 ... as factor, 2 levels between subjects fixed effect (patient vs control)
subj: 1 2 ... 14 1 2 ... 14 as factor 7 patients 7 control random effect
condition: 1 1 ... 2 2 ... 1 1 ... 2 2 as factor, 2 levels within subjects, ie every subject worked on every cond fixed effect
roi: 1 ... 2 ... 3 ... 4 ... as factor,
2009 Dec 07
1
Sweave and license message when loading mclust package
When loading mclust, it shows a license agreement message. This
message shows up in my document when I use Sweave. I did the
following:
<<echo=FALSE,include=FALSE>>=
library(mclust)
@
Is this a problem with mclust, Sweave or with me? How can it be fixed?
Thanks for any suggestions!
Titus
2009 Jun 18
1
"Normal" plot and xyplot side by side in one figure?
Hi list,
I want to place a plot (eg "plot(1:10)") and a xyplot side by side in
one figure. The two columns should have different widths. If I'm not
missing something, this rules out the standard way: par(mfcol=n).
I tried layout(), but it doesn't seem to like it when grid scribbles
into its views (the plot works but the view for the xyplot is left empty).
I would
2004 Aug 06
1
icecast-1.3.12 on SunOS
Thomas,
unfortunately it does slow down the machine. I am working in a chroot
enviroment and there are other users on the same box. Therefore it's of
special importance that I don't consume the cpu by myself.
Titus
Am Sonntag den, 15. September 2002, um 23:37, schrieb Thomas Vander
Stichele:
> Apart from what probably is a bad assumption in the code, does it
> actually
2005 Feb 18
1
Two-factorial Huynh-Feldt-Test
Hi,
I'm currently working on porting some SAS scripts to R, and hence need
to do the same calculation (and get the same results) as SAS in order to
make the transition easier for users of the script.
In the script, I'm dealing with a two-factorial repeated-measures anova.
I'll try to give you a short overview of the setup:
- two between-cell factors: facBetweenROI (numbering
2019 May 30
2
Problem joining domain [SEC=UNOFFICIAL]
UNOFFICIAL
Firstly thanks for the help with my previous problem building SAMBA. The UNOFFICIAL in the subject heading is added automatically by our email system.
I'm getting the following error when trying to join a 2003 server domain.
...
Adding CN=TITUS,OU=Domain Controllers,DC=SSUNIT050,DC=local
Adding
2007 Mar 25
1
for loop help
Hello-
I have a script which steps through a series of subjects, and for the
subjects I remove outlying values. After removing these outliers, I
specify a cutoff, keeping only values over a certain value (e.g., 1.96).
I want to populate a matrix with a statistic of the values that make the
cutoff (for example, the mean). However, in some subjects, after
outliers and the cutoff are specified,
2003 Mar 06
1
Virtual servers for 2 workgroup
Hi
My config: Samba 2.2.3 & Linux Debian Testing kernel 2.4.20
There are two network cards on my pc :
-one links to the network R1 (138.231.121.12)
-one links to the network R2 (192.168.0.1)
I would like to open two shares:
-the first one on R1 in the workgroup wkgrp1
-the second one on R2 in the workgroup wkgrp2
I read that, thanks to the directives "netbios
2014 Sep 01
3
Unable to compile R 3.1.3 under GCC 4.1.2 (Red Hat 4.1.2-51)
Hi all,
I'm unable to compile R under an HPC system (which like many HPC systems
doesn't always have the latest and greatest software). The version of
GCC is 4.1.2 under CentOS 5.7. Running ./configure gives the following
output:
R is now configured for x86_64-unknown-linux-gnu
Source directory: .
Installation directory: /home/tbarik
C compiler: gcc