Displaying 20 results from an estimated 8000 matches similar to: "Select the last rows of when specific conditions are met."
2005 Nov 16
2
Bug or a feature that I completely missed?
Dear all,
while looking at some R-code submitted by students in a unit that I
teach, I came across constructs that I thought would lead to an error.
Much to my surprise, the code is actually executed.
A boiled down version of the code is the following:
> tt <- function(x, i){
+ mean(x[i,2])/mean(x[i,1])
+ }
> dat <- matrix(rnorm(200), ncol=2)
> mean(dat[,2])/mean(dat[,1])
[1]
2013 Mar 08
2
Zoo Data
Hi Jakob,
dat1<-read.table(text="
TIME, Value1, Value2
01.08.2011 02:30:00, 4.4, 4.7
01.09.2011 03:00:00, 4.2, 4.3
01.11.2011 01:00:00, 3.5, 4.3
01.12.2011 01:40:00, 3.4, 4.5
01.01.2012 02:00:00, 4.8, 5.3
01.02.2012 02:30:00, 4.9, 5.2
01.08.2012 02:30:00, 4.1, 4.7
01.12.2012 03:00:00, 4.7, 4.3
01.01.2013 01:00:00, 3, 4.3
01.01.2013 01:30:00, 3.8, 4.1
01.01.2013 02:00:00, 3.8,
2009 Dec 30
3
rsync email notification on success and failure + Log
Hi,
I have a bash script for rsync that should tranfer all my filer from one drive to the other.
I would like to know how I can make the script sending me an email after the script is run and be able to know if it was a success or not and also if possible to include the log file.
This is my script:
!/bin/bash
rsync -av --delete --log-file=/home/duffed/RSyncLog/$(date
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
2013 Jul 02
2
Replacing strings to numbers
Hi guys,
I was wondering if any one is able to help me on a problem that I was stuck
with for a long time. It involves the replacement of character strings with
numbers. The character string can take on only 3 possible values, for
instance:
AA
AT
TT
I would want R to replace AT with 0. Between AA and TT, I want to compare
the frequency of either value, and then for the one which occurs more, I
2008 Sep 19
1
Type I SS and Type III SS problem
Dear all:
I m a newer on R.? I have some problem when I use?anova function.? I use anova function to get Type I SS results, but I also need to get Type III SS results.? However, in my code, there is some different between the result of Type I SS and Type III SS.? I don?t know why the ?seqe? factor disappeared in the result of Type III SS.? How can I do??
Here is my example and result.
2008 May 30
2
inconsistent output when using variable substitution
I am extremely puzzled by this behavior in R. I have a data frame called
Trials in which I have results from an experiment. I am trying to do a
subjects analysis, but getting weird results. Each row has 1 trial in it,
which includes a column for the subject number I get the list of subject
numbers like so:
> Subj=unique(sort(Trials$Subj))
Then I loop over them. But I get strange results. As
2013 Apr 18
1
select and do some calculations/manipulations on certain rows based on conditions in R
Hi,
May be this helps (Assuming that there are only '0's and '1's in the dataset)
dat1<-read.table(text="
??????? ID X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15
1?? 5184??? 0??? 0??? 0??? 0??? 0?? 0?? 0??? 0??? 0??? 1???? 0????? 0????? 0????? 0????? 0????? 0
2?? 6884??? 0??? 0??? 1??? 0??? 0?? 1?? 0??? 0??? 0??? 0???? 0????? 0????? 0????? 0????? 0????? 0
3?
2013 Jul 14
2
creating dummy variables based on conditions
Hello everyone,
I have a dataset which includes the first three variables from the demo
data below (year, id and var). I need to create the new variable ans as
follows
If var=1, then for each year (where var=1), i need to create a new dummy
ans which takes the value of 1 for all corresponding id's where an instance
of one was recorded. Sample data with the output is shown below.
year
2013 Jan 15
2
Need some help on Text manipulation.
Dear all,
Let say I have following data-frame:
Dat <- structure(list(dat = c(-0.387795842956327, -0.23270882099043,
-0.89528973290562, 0.95857175595512, 1.61680582493783, -1.17738110289352,
0.210601060411423, -0.827369747447338, -0.36896112964414, 0.440288648776096,
1.28018410608809, -0.897113649961341, 0.342216546981718, -1.17288066266219,
-1.57994101992621, -0.913655547602414,
2018 May 22
1
[SOLVED] [Nfs-ganesha-support] volume start: gv01: failed: Quorum not met. Volume operation not allowed.
Hey All,
Appears I solved this one and NFS mounts now work on all my clients. No
issues since fixing it a few hours back.
RESOLUTION
Auditd is to blame for the trouble. Noticed this in the logs on 2 of
the 3 NFS servers (nfs01, nfs02, nfs03):
type=AVC msg=audit(1526965320.850:4094): avc: denied { write } for
pid=8714 comm="ganesha.nfsd" name="nfs_0"
2005 Dec 01
1
LME & data with complicated random & correlational structures
Dear List,
This is my first post, and I'm a relatively new R user trying to work out a
mixed effects model using lme() with random effects, and a correlation
structure, and have looked over the archives, & R help on lme, corClasses, &
etc extensively for clues. My programming experience is minimal (1 semester
of C). My mentor, who has much more programming experience, but a comparable
2012 Aug 29
3
Help on calculating spearman rank correlation for a data frame with conditions
Dear all,
Suppose my data frame is as follows:
id price distance
1 2 4
1 3 5
...
2 4 8
2 5 9
...
n 3 7
n 8 9
I would like to calculate the rank-order correlation between price and
distance for each id.
cor(price,distance,method = "spearman") calculate a correlation for all.
Then I tried to use
apply(data,list='id',cor(price , distance , method =
2007 Nov 13
1
TRUNCATED error with data frame
Hi ,
I am new to R.
I am trying to run a simple R script as shown below:
aov.R
------
data1<-c(49,47,46,47,48,47,41,46,43,47,46,45,48,46,47,45,49,44,44,45,42,45,45,40
,49,46,47,45,49,45,41,43,44,46,45,40,45,43,44,45,48,46,40,45,40,45,47,40)
matrix(data1, ncol= 4, dimnames = list(paste("subj", 1:12),
c("Shape1.Color1",
"Shape2.Color1", "Shape1.Color2",
2009 Dec 08
6
conditionally merging adjacent rows in a data frame
Hi, I have a data frame and want to merge adjacent rows if some condition is
met. There's an obvious solution using a loop but it is prohibitively slow
because my data frame is large. Is there an efficient canonical solution for
that?
> head(d)
rt dur tid mood roi x
55 5523 200 4 subj 9 5
56 5523 52 4 subj 7 31
57 5523 209 4 subj 4 9
58 5523 188 4 subj 4 7
2012 Apr 23
2
plot function creating bars instead of lines
Hello,
I am having a problem where code that plots lines using a different data
frame plots bars with the current data frame (I am intended to plot lines).
The code specifies lines (see below), so I can't figure out why the results
are bars. I suspect that it may have something to do with the fact that in
the data frame where the code worked as intended, the both variables
specifying
2004 Mar 19
2
for loop or Hmisc library trap.rule function syntax error
Hello:
I am new R user stumped why the R code after this paragraph generates "Error:
syntax error" messages after each of the last 2 lines. I have tried searching
the manuals, Hmisc documentation, contributed manuals, help archives, and
Internet. I am running R 1.7.1 under Windows 2000 (I will upgrade when my
imminent OS upgrade happens). My data was successfully entered and
2007 May 16
1
lmer error confusion
Hi All.
I'm trying to run a simple model from Baayan, Davidson, & Bates and getting
a confusing error message. Any ideas what I'm doing wrong here?
# Here's the data.....
Subj <- factor(rep(1:3,each=6))
Item <- factor(rep(1:3,6))
SOA <- factor(rep(0:1,3,each=3))
RT <-
c(466,520,502,475,494,490,516,566,577,491,544,526,484,529,539,470,511,528)
priming
2013 Feb 21
1
remove rows in data frame by average
Dear all,
I have a data frame, which looks like this:
Subject | Block | Trial | Feature1 | Feature2 ....
1 | 1 | 1 | ... | ...
1 | 1 | 2 | ... | ...
1 | 2 | 1 | ... | ...
1 | 2 | 2 | ... | ...
1 | 3 | 1 | ... | ...
...| ...| ...| ... | ...
Can I remove the "Trial" column by averaging all the rows and without using
a "for loop"?
At the end my data frame should look like
2018 May 11
3
add one variable to a data frame
Hi Sarah,
Thank you so much!! I got your good ideas.
Ding
-----Original Message-----
From: Sarah Goslee [mailto:sarah.goslee at gmail.com]
Sent: Friday, May 11, 2018 11:40 AM
To: Ding, Yuan Chun
Cc: r-help mailing list
Subject: Re: [R] add one variable to a data frame
[Attention: This email came from an external source. Do not open attachments or click on links from unknown senders or