Try
y - x[ -( 30596:678013 ), ]
Please note that I have replaced 30595 with 30596 which is I think what you
mean.
You can add a new column with
y$new - new_column # this is your vector of length 30595
Good luck,
Rainer
On Friday 03 July 2015 07:23:28 Charles Thuo wrote:
I have a data
In my experience package dplyr has all functions to deal with this kind
of problems in a simple and compact way
Sergio
Il 03/lug/2015 07:26, Charles Thuo tcmui...@gmail.com ha scritto:
I have a data frame whose rows are 678013 . I would like to remove rows
from 30696 to 678013 and then attach
I have a data frame whose rows are 678013 . I would like to remove rows
from 30696 to 678013 and then attach a new column with a length of 30595.
I tried
Y- X[-30595:678013,] and its not working
In addition how do i add a new column
Kindly assist.
Charles
[[alternative HTML version
?precedence
-5:10 is (-5):10
-- Bert
Bert Gunter
Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom.
-- Clifford Stoll
On Thu, Jul 2, 2015 at 10:23 PM, Charles Thuo tcmui...@gmail.com wrote:
I have a data frame whose rows are 678013 . I would
I like to remove from a data frame rows with labels containing
certain string, e.g., sex and rating. Below is a list of the data
frame and my failed attempt to the rows. Any clues? Thanks.
out
est se t p disc
p.(Intercept) 26.430 13.605 1.943 0.053
p.sex
Try grepl() to do pattern matching in strings. (%in% checks for
equality.) E.g., using your original 'out' do
out[ !grepl(sex|rating, rownames(out), ]
to get all but the rows whose names contain the character sequences
sex or rating.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Sun, Nov
Thank you Bill and Dennis. grepl worked great.
However, for reason I am not figuring out, the
code worked as I included the procedure
(subroutine) with a source command, viz.,
source(z:\\R\\mylib\\me.R)
Compiling the routine into a library/package, as
I always do, then the command got
Not clear what you did. Is this an example of FAQ 7.16?
---
Jeff NewmillerThe . . Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go...
Hello,
I have a column called max_date in my data frame and I only want to keep the
bigger values for the same activity. How can I do that?
data frame:
activitymax_dt
A2013-03-05
B 2013-03-28
A 2013-03-28
C 2013-03-28
B 2013-03-01
-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of ramoss
Sent: Thursday, May 23, 2013 4:24 PM
To: r-help@r-project.org
Subject: [R] Removing rows w/ smaller value from data frame
Hello,
I have a column called max_date in my data frame and I only want to
keep
, max_dt=tail(sort(max_dt),1))
# activity max_dt
#1 A 2013-03-28
#2 B 2013-03-28
#3 C 2013-03-28
A.K.
- Original Message -
From: ramoss ramine.mossad...@finra.org
To: r-help@r-project.org
Cc:
Sent: Thursday, May 23, 2013 10:23 AM
Subject: [R] Removing rows w
, Ramine N. ramine.mossad...@finra.org
To: arun smartpink...@yahoo.com
Cc:
Sent: Thursday, May 23, 2013 10:44 AM
Subject: RE: [R] Removing rows w/ smaller value from data frame
Thank but I get : Error in is.list(by) : 'by' is missing
When I tried ddply(datNew,.(activity),summarize, max_dt=max
Hi,
From your example data,
dat1- read.table(text=
id1 id2 value
a b 10
c d 11
b a 10
c e 12
,sep=,header=TRUE,stringsAsFactors=FALSE)
#it is easier to get the output you wanted
dat1[!duplicated(dat1$value),]
# id1 id2 value
#1 a b 10
Thanks very much for your rapid help Arun.
Vince
On Apr 12, 2013, at 4:10 PM, arun kirshna [via R] wrote:
Hi,
From your example data,
dat1- read.table(text=
id1 id2 value
a b 10
c d11
b a 10
c e 12
,sep=,header=TRUE,stringsAsFactors=FALSE)
Perhaps I've missed something, but if it's really true that the goal is to
remove rows if the first non-zero element is D or d, then how about
this:
tmp - gsub('0','',df$ch)
first - substr(tmp,1,1)
subset(df, tolower(first) != 'd')
and of course it could be rolled up into a single expression,
Hello,
Inline.
Em 03-07-2012 01:15, jim holtman escreveu:
You will have to change the 'i1' expression as follows:
i1 - grepl(^([0D]|[0d])*$, dd$ch)
i1 # matches strings with d D in them
[1] TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
# second string had 'd' 'D' in it
Thank you Rui and Jim, both 'i1' and 'i1new' worked perfectly because there
are no instances of 'Dd' or 'dD' in the data set (that I would/not want to
include/exclude)... but I understand that 'i1new' targets precisely what I
want.
Why isn't a leader of zero's required for either 'i1' or 'i1new',
Hello,
I'm glad it helped. See answer inline.
Em 03-07-2012 17:09, Claudia Penaloza escreveu:
Thank you Rui and Jim, both 'i1' and 'i1new' worked perfectly
because there are no instances of 'Dd' or 'dD' in the data set (that I
would/not want to include/exclude)... but I understand that 'i1new'
Got it! Thank you Rui!
cp
On Tue, Jul 3, 2012 at 10:14 AM, Rui Barradas ruipbarra...@sapo.pt wrote:
Hello,
I'm glad it helped. See answer inline.
Em 03-07-2012 17:09, Claudia Penaloza escreveu:
Thank you Rui and Jim, both 'i1' and 'i1new' worked perfectly
because there are no instances
I would like to remove rows from the following data frame (df) if there are
only two specific elements found in the df$ch character string (I want to
remove rows with only 0 D or 0 d). Alternatively, I would like
to remove rows if the first non-zero element is D or d.
Hello,
Try regular expressions instead.
In this data.frame, I've changed row nr.4 to have a row with 'D' as
first non-zero character.
dd - read.table(text=
ch count
1 00D0 0.007368
2 00d0 0.002456
3
You will have to change the 'i1' expression as follows:
i1 - grepl(^([0D]|[0d])*$, dd$ch)
i1 # matches strings with d D in them
[1] TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
# second string had 'd' 'D' in it so it was TRUE above and FALSE below
i1new -
On Jul 2, 2012, at 6:48 PM, Claudia Penaloza wrote:
I would like to remove rows from the following data frame (df) if
there are
only two specific elements found in the df$ch character string (I
want to
remove rows with only 0 D or 0 d). Alternatively, I
would like
to remove rows if the
-
From: Claudia Penaloza claudiapenal...@gmail.com
To: r-help@r-project.org
Cc:
Sent: Monday, July 2, 2012 6:48 PM
Subject: [R] Removing rows if certain elements are found in character string
I would like to remove rows from the following data frame (df) if there are
only two specific elements
: r-help@r-project.org
Sent: Monday, July 2, 2012 7:24 PM
Subject: Re: [R] Removing rows if certain elements are found in character string
Hello,
Try regular expressions instead.
In this data.frame, I've changed row nr.4 to have a row with 'D' as
first non-zero character.
dd - read.table(text=
ch
Hi,
Is there an easy way to remove dataframe rows without duplicated values of
a specified column ('id')? e.g.,
dat - data.frame(id = c(1,1,1,2,3,3), value = c(5,6,7,4,5,4), value2 =
c(1,4,3,3,4,3))
dat
id value value2
1 1 5 1
2 1 6 4
3 1 7 3
4 2 4 3
5
This is ugly, but it gets what you want.
dat[which(dat[,1] %in% unique((dat[duplicated(dat[,1], fromLast = T),
1]))),]
AC Del Re wrote
Hi,
Is there an easy way to remove dataframe rows without duplicated values of
a specified column ('id')? e.g.,
dat - data.frame(id =
Hi:
Here's one way:
do.call(rbind, lapply(L, function(d) if(nrow(d) 1) return(d)))
id value value2
1.1 1 5 1
1.2 1 6 4
1.3 1 7 3
3.5 3 5 4
3.6 3 4 3
HTH,
Dennis
On Tue, Nov 22, 2011 at 9:43 AM, AC Del Re de...@wisc.edu wrote:
Hi,
Is
Sorry, you need this first:
L - split(dat, dat$id)
do.call(rbind, lapply(L, function(d) if(nrow(d) 1) return(d)))
D.
On Tue, Nov 22, 2011 at 10:38 AM, Dennis Murphy djmu...@gmail.com wrote:
Hi:
Here's one way:
do.call(rbind, lapply(L, function(d) if(nrow(d) 1) return(d)))
id value
one approach is the following:
dat - data.frame(id = c(1,1,1,2,3,3), value = c(5,6,7,4,5,4),
value2 = c(1,4,3,3,4,3))
ind - ave(dat$id, dat$id, FUN = length) 1
dat[ind, ]
I hope it helps.
Best,
Dimitris
On 11/22/2011 6:43 PM, AC Del Re wrote:
Hi,
Is there an easy way to remove
On Nov 22, 2011, at 12:43 PM, AC Del Re wrote:
Hi,
Is there an easy way to remove dataframe rows without duplicated
values of
a specified column ('id')? e.g.,
dat - data.frame(id = c(1,1,1,2,3,3), value = c(5,6,7,4,5,4),
value2 =
c(1,4,3,3,4,3))
dat
id value value2
1 1 5 1
On Jun 2, 2011, at 11:35 AM, Petr Savicky wrote:
On Thu, Jun 02, 2011 at 11:23:28AM -0400, Jim Silverton wrote:
Hi,
Can someone tell me how to remove rows of zeros from a matrix?
For example if I have the following matrix,
0 0
0 1
2 8
0 0
4 56
I should end up with
0 1
2 8
4 56
Hi.
Try
Hi,
Can someone tell me how to remove rows of zeros from a matrix?
For example if I have the following matrix,
0 0
0 1
2 8
0 0
4 56
I should end up with
0 1
2 8
4 56
--
Thanks,
Jim.
[[alternative HTML version deleted]]
__
Assuming the matrix is named X:
X[which(rowSums(X) 0),]
should work.
Also, this list is a text-only list. As you are using gmail, sending
text only messages is very easy, and may clear confusion in future
posts.
HTH,
Jon
On Thu, Jun 2, 2011 at 11:23 AM, Jim Silverton jim.silver...@gmail.com
On Thu, Jun 02, 2011 at 11:23:28AM -0400, Jim Silverton wrote:
Hi,
Can someone tell me how to remove rows of zeros from a matrix?
For example if I have the following matrix,
0 0
0 1
2 8
0 0
4 56
I should end up with
0 1
2 8
4 56
Hi.
Try the following
a - matrix(c(0, 0, 2, 0,
Thanks to everyone. Joshua's response seemed the most concise one, but it
used up so much memory that my R just gave error. I checked the other
replies and all in all I came up with this, and thought to share it with
others and get comments.
My structure was as follows:
ACCOUNT RULE DATE
A1
David Winsemius dwinsem...@comcast.net
on Fri, 24 Dec 2010 11:47:05 -0500 writes:
On Dec 24, 2010, at 11:04 AM, David Winsemius wrote:
On Dec 24, 2010, at 8:45 AM, Ali Salekfard wrote:
Hi all,
I'm new to the list but have benfited from it quite
On Dec 29, 2010, at 9:24 AM, Ali Salekfard wrote:
Thanks to everyone. Joshua's response seemed the most concise one,
but it
used up so much memory that my R just gave error. I checked the other
replies and all in all I came up with this, and thought to share it
with
others and get
On Dec 29, 2010, at 11:03 AM, Ali Salekfard wrote:
David,
Thanks alot. Your code is worked fine on the whole dataset (no
memory error as I had with the other ideas). I do like the style -
especialy the fact that it is all in one line - , but for large
datasets it takes longer than
David,
Thanks alot. Your code is worked fine on the whole dataset (no memory error
as I had with the other ideas). I do like the style - especialy the fact
that it is all in one line - , but for large datasets it takes longer than
what I wrote. I ran it on the same machine with the same set of
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Ali Salekfard
Sent: Wednesday, December 29, 2010 6:25 AM
To: r-help@r-project.org
Subject: Re: [R] Removing rows with earlier dates
Thanks to everyone. Joshua's response
Hi all,
I'm new to the list but have benfited from it quite extensively. Straight to
my rather strange question:
I have a data frame that contains mapping rules in this way:
ACCOUNT, RULE COLUMNS, Effective Date
The dataframe comes from a database that stores all dates. What I would like
to
On Dec 24, 2010, at 8:45 AM, Ali Salekfard wrote:
Hi all,
I'm new to the list but have benfited from it quite extensively.
Straight to
my rather strange question:
I have a data frame that contains mapping rules in this way:
ACCOUNT, RULE COLUMNS, Effective Date
The dataframe comes from
On Dec 24, 2010, at 11:04 AM, David Winsemius wrote:
On Dec 24, 2010, at 8:45 AM, Ali Salekfard wrote:
Hi all,
I'm new to the list but have benfited from it quite extensively.
Straight to
my rather strange question:
I have a data frame that contains mapping rules in this way:
ACCOUNT,
Hi,
On Fri, Dec 24, 2010 at 5:45 AM, Ali Salekfard salekf...@googlemail.com wrote:
[snip]
I have a data frame that contains mapping rules in this way:
ACCOUNT, RULE COLUMNS, Effective Date
The dataframe comes from a database that stores all dates. What I would like
to do is to create a
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Ali Salekfard
Sent: Friday, December 24, 2010 5:46 AM
To: r-help@r-project.org
Subject: [R] Removing rows with earlier dates
Hi all,
I'm new to the list but have benfited
with(YourDataFrame, tapply(`Effective Date`, `RULE COLUMNS`,
function(x) x[which.max(x)]))
David pointed out that this will just return a table of dates. One
work around is:
do.call(rbind, by(DataFrame, DataFrame[, RULE COLUMNS],
function(x) x[which.max(x[, Effective Date]), ]))
but that
Whenever a task calls for breaking a data object into pieces, operate on the
pieces, then put it back together, then think about using the plyr package.
Sent from my iPod
On Dec 24, 2010, at 6:58 AM, Ali Salekfard salekf...@googlemail.com wrote:
Hi all,
I'm new to the list but have
I tired this and seems to capture only a few
--
View this message in context:
http://r.789695.n4.nabble.com/removing-rows-from-a-matrix-using-condition-within-groups-tp3004132p3005894.html
Sent from the R help mailing list archive at Nabble.com.
__
thanks Henrique , it did work with a slight modif
subset(merge(X, Y, by.x = 'groups', by.y = 1, all = TRUE), var2var3).
--
View this message in context:
http://r.789695.n4.nabble.com/removing-rows-from-a-matrix-using-condition-within-groups-tp3004132p3005899.html
Sent from the R help mailing
I am needing some help in removing certain rows in a data.matrix and then do
some calculation. So Iam need to removing certain values above a threshold
or value from another vector.
For eg.. in the below data matrix X there are 6 groups (A, B, C, D, E ,F)
X
rowsgroups values
1 A
Try this:
subset(merge(X, Y, by.x = 'groups', by.y = 1, all = TRUE), values V2, -V2)
On Wed, Oct 20, 2010 at 1:37 PM, swam sundars...@yahoo.com wrote:
I am needing some help in removing certain rows in a data.matrix and then
do
some calculation. So Iam need to removing certain values
Dear all,
I have a data.frame with some NAs that can
happens anywere, and I would like to keep
only rows without NAs. Thanks in advance
for your help, and Merry Xmas.
myvect-runif(100)
myvect[sample(1:100)[1:5]]-NA
myDF-data.frame(matrix(myvect,ncol=5))
myDF
miltinho
[[alternative HTML
try this:
myDF[complete.cases(myDF), ]
Best,
Dimitris
milton ruser wrote:
Dear all,
I have a data.frame with some NAs that can
happens anywere, and I would like to keep
only rows without NAs. Thanks in advance
for your help, and Merry Xmas.
myvect-runif(100)
myvect[sample(1:100)[1:5]]-NA
Hi All,
act_2
DateDtime Hour Min Second Rep
51 2006-02-22 14:52:18 14 52 18 useractivity_act
52 2006-02-22 14:52:18 14 52 18 4
55 2006-02-22 14:52:49 14 52 49 4
57 2006-02-22 14:52:51 14 52 51
##I want to remove the rows where the row sums are zero and this is as
far as I have gotten
ffg - (structure(list(CD = c(0, 0, 0, 0, 3.125, 0, 0, 0, 0, 1.6, 3.125,
0, 0, 6.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.125, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.6, 0, 0, 0, 0, 0,
0, 0, 0,
On Thu, 2008-11-20 at 12:01 -0500, stephen sefick wrote:
##I want to remove the rows where the row sums are zero and this is as
far as I have gotten
Given your ffg,
## the which() call returns row indices for rows with rowSum 0
ffg[which(rowSums(ffg) 0, ]
does the trick
HTH
G
ffg -
On Thu, 2008-11-20 at 17:08 +, Gavin Simpson wrote:
On Thu, 2008-11-20 at 12:01 -0500, stephen sefick wrote:
##I want to remove the rows where the row sums are zero and this is as
far as I have gotten
Given your ffg,
## the which() call returns row indices for rows with rowSum 0
On Thu, Nov 20, 2008 at 12:28 PM, Gavin Simpson [EMAIL PROTECTED] wrote:
But Prof. Ripley has pointed out (off list) that
ffg[rowSums(ffg) 0, ]
I suggested much the same solution off-list (using apply rather than
rowSums, as I'm
apparently incapable of remembering the existence of the
Hi...
I have a rather large dataframe that I'm trying to remove rows from.
I'm issuing the command:
dtx[-which(dtx$rdate 2008-06-16),]
and it tries to print out over 170,000 lines of output. So...I did:
options(max.print=1e6)
and ran it again. It worked, but when I did a:
which(dtx$rdate
R is doing what you are telling it to do. You aren't assigning the
result of your indexing to a new data.frame, and so it is simply
print()ing the result. Example,
x - 1:10
x[-1]
x
vs.
x - 1:10
x - x[-1]
x
Joe Trubisz wrote:
Hi...
I have a rather large dataframe that I'm trying to
Hi, I have a problem regarding matrix handeling. I am working with a serie of
matrixes containing several columns. Now I would like to delete those rows of
the matrixes,that in one of the columns contain values less than 50 or greater
than 1000. How would this be possible, I have tried to
Hi, I have a problem regarding matrix handeling. I am working with
a serie of matrixes containing several columns. Now I would like to
delete those rows of the matrixes,that in one of the columns contain
values less than 50 or greater than 1000.
Try this:
m - matrix(runif(150, 0, 1050),
63 matches
Mail list logo