I'm using R Version 2.6.1 under Windows XP.
> search()
[1] ".GlobalEnv""s" "s"
"package:cairoDevice"
[5] "package:datasets" "package:foreign" "package:graphics"
"package:grDevices"
[9] "package:gWidgetsrJava" "package:
Dear all,
I have received some data on birds that looks sth like this:
# a unique id for each individual
id <- c(1,1,1,2,2,2,3,3,3,4,4,5,6)
# the year the bird was measured
year <- c(1995, 1996, 1997, 1995, 1996, 1997, 1996, 1997, 1998, 1996, 1997,
1997, 1998)
# the year the bird was hatched
y
PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Matthias Wendel
Sent: Friday, January 04, 2008 10:37 AM
To: r-help@r-project.org
Subject: [R] subsetting
I'm using R Version 2.6.1 under Windows XP.
> search()
[1] ".GlobalEnv""s" &qu
Here are three ways:
1. Define inner inside outer:
outer <- function() { s <- 1; inner <- function() s; inner() }
outer() # 1
2. Use parent.frame:
inner <- function() parent.frame()$s
outer <- function() { s <- 1; inner() }
outer() # 1
3. Pass s explicitly:
inner <- function(s) s
outer <- fu
I don't understand the criteria that gives you just
the three ids.
As I read the criteria if we put the data into a
data.frame you have
subset(mydata ,year==year.hatch & year.1st.reprod ==
year.hatch+1)
but this gives more than the three ids. What am I
missing?
--- [EMAIL PROTECTED] wrote:
Dear R list,
I think my question maybe easy for you but I really spent entire day to
resolve it.
Say I have a matrix, rows are 6000 genes, columns(1-6) are 3 genotypes
(a,b,c) with 2 repeat.
I have to use two groups each time for t-test, a vs. c or b vs. c, but I
dont know how to write correct cod
Hello Everyone:
As usual, thanks in advance for any help.
I was hoping to get some more advice on this question:
I'm trying to write a subsetting routine for an S3 object I've created --
lets call it myObject.
myObject has a few attributes basically of type string and numerics. Its
atomic va
Hi R-users,
I have an array similar to this:
tmp <- array(1:6, c(2,3,3))
n1 <- c("one", "two")
n2 <- c("three", "four", "five")
n3 <- c("six", "seven", "eight")
dimnames(tmp) <- list(n1, n2, n3)
tmp[1,,1] <- NA
tmp[1,3,2] <- NA
tmp[2,,3] <- NA
tmp
How to subset !is.na(x) rows resulting
, , six
All,
I'm having problems w/ a simple attempt to subset an xyplot.
The first plot below is a plot of y versus x for certain values of a third
categorical variable z. Now I'd like to further restrict this to certain
values of variable y. Neither of the two attempts below work. Any
suggestions m
windows XP
R 2.6.0
I am having problems deleting a row from a data frame. I create my dataframe by
subsetting a larger dataframe:
ShortLavin<-Lavin[Lavin[,"Site"]=="PP" | Lavin[,"Site"]=="CC" |
Lavin[,"Site"]=="FH",]
I then perform a glm using the data frame and plot the results.
fit1poisson
Dear all,
I would like to be able to subset a data.frame in a special way. I will put
here an example:
Score Name
88 19_0070
88 19_0070
87 19_0070
79 002127_0658
79 002127_0658
77 002127_0658
So, for the abo
Hi, I have only 2 months' experience with R.
Here is one sort of problem that arose:
* Site 1 has transects A,B,C,D.
* Site 2 has transects A,B,C,D,E,F.
* Site 3 has transect A.
* ... and Site 1000 has transects A,B,C.
At each transect, measure ALL of the various
categories belonging to propertie
Hi all,
Firstly I appologise if this question has been answered previously,
however searching of the archives and the internet generally has not
yielded any results.
I am looking in to the effects of summer weather conditions
(temperature, humidity etc), on the incidences of a breathing dis
Hi all,
I am working on a single color expression data using limma. I would like to
perform a cluster analysis after selecting the differentially genes based on
the P value (say 0.001). As far as my knowledge is concerned I have to do
the sub setting of these selected genes on the normalized data
I have a data frame that looks like this:
V1 V2 V3
ab0:1:12
df1:2:1
cd1:0:9
where V3 is in the form x:y:z
Can someone show me how to subset the rows where the values of x, y and z <=
10:
V1 V2 V3
df1:2:1
cd1:0:9
Thanks
Joseph
[[alternative
help(rowttests) says that fac needs to be a factor. So how about ?
m <- matrix( rnorm(30), nc=6 )
genotype <- c("a", "a", "b", "b", "c", "c")
w1 <- which( genotype %in% c("a", "b") )
w2 <- which( genotype %in% c("a", "c") )
w3 <- which( genotype %in% c("b", "c") )
list( ab = rowttes
Hi Adai,
It works!! Thanks a lot!!
Hui-Yi
On Fri, Sep 12, 2008 at 11:26 AM, Adaikalavan Ramasamy <
[EMAIL PROTECTED]> wrote:
> help(rowttests) says that fac needs to be a factor. So how about ?
>
> m <- matrix( rnorm(30), nc=6 )
> genotype <- c("a", "a", "b", "b", "c", "c")
>
> w1 <- which(
Dear R users,
I'm new but already fascinated R user so please forgive for my
ignorance. I have the problem, I read most of help pages but couldn't
find the solution. The problem follows
I have large data set 10,000 rows and more than 100 columns... Say
something like
var1,var2,var2,var4.
Message-
From: [EMAIL PROTECTED] on behalf of Gregory Wall
Sent: Wed 1/9/2008 3:59 PM
To: r-help@r-project.org
Subject: [R] Subsetting Method [ Revisited
Hello Everyone:
As usual, thanks in advance for any help.
I was hoping to get some more advice on this question:
I'm trying to w
Lauri Nikkinen wrote:
> Hi R-users,
>
> I have an array similar to this:
>
> tmp <- array(1:6, c(2,3,3))
> n1 <- c("one", "two")
> n2 <- c("three", "four", "five")
> n3 <- c("six", "seven", "eight")
> dimnames(tmp) <- list(n1, n2, n3)
> tmp[1,,1] <- NA
> tmp[1,3,2] <- NA
> tmp[2,,3] <- NA
> tmp
>
I have a list of observations of individuals. I would like to make a
list of individuals, with a data frame of observations for each individual.
The following code usually works, but not always
--
# Make a list of empty data
David:
Thank you for your very valuable response. In fact, I was trying to
_avoid_ partial matching, not accomplish it. Subset is a _much_ better
way of doing what I was trying to do.
Humorously, however, your code also reproduces the mistake that brought
me here, AFAICT. I think my code
I want to take the first row of each unique ID value from a data frame.
For instance
> ddTable <-
data.frame(Id=c(1,1,2,2),name=c("Paul","Joe","Bob","Larry"))
I want a dataset that is
Id Name
1 Paul
2 Bob
> unique(ddTable)
Will give me all 4 rows, and
> unique(ddTable$Id)
Will
Try this:
xyplot(y ~ x , data = junk.frm, type = c("g", "p","smooth"), pch=20,
subset=z=="D" & y < 2)
On 26/02/2008, David Afshartous <[EMAIL PROTECTED]> wrote:
>
> All,
>
> I'm having problems w/ a simple attempt to subset an xyplot.
>
> The first plot below is a plot of y versus x for certa
See the description of the subset argument in ?xyplot
subset: logical or integer indexing vector (can be specified in terms
of variables in 'data'). Only these rows of 'data' will be
used for the plot. If 'subscripts' is 'TRUE', the subscripts
will provide ind
On Tue, 4 Mar 2008, John Sorkin wrote:
> windows XP
> R 2.6.0
>
> I am having problems deleting a row from a data frame. I create my dataframe
> by subsetting a larger dataframe:
>
> ShortLavin<-Lavin[Lavin[,"Site"]=="PP" | Lavin[,"Site"]=="CC" |
> Lavin[,"Site"]=="FH",]
>
> I then perform a glm
/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
- Original Message -
From: "John Sorkin" <[EMAIL PROTECTED]>
To:
Sent: Tuesday, March 04, 2008 2:41 PM
Subject: [R] subsetting a dataframe
> windows XP
&g
On 3/4/2008 8:41 AM, John Sorkin wrote:
> windows XP
> R 2.6.0
>
> I am having problems deleting a row from a data frame. I create my dataframe
> by subsetting a larger dataframe:
>
> ShortLavin<-Lavin[Lavin[,"Site"]=="PP" | Lavin[,"Site"]=="CC" |
> Lavin[,"Site"]=="FH",]
I would do that in
Hi all,
I have a question regarding subsetting of large data frames. I have two
data frames “catches” and “tows” and they both have the same 30 variables
(columns). I would like to select rows in the data frame “tows” where all 5
specific variables are NOT matched in “catches. That is to say, th
Is this what you want?
> x <- read.table(textConnection("Score Name
+ 88 19_0070
+ 88 19_0070
+ 87 19_0070
+ 79 002127_0658
+ 79 002127_0658
+ 77 002127_0658"), header=TRUE)
> # return best scores
> best <- by(x, x$Name, f
jim holtman wrote:
> Is this what you want?
>
>
>> x <- read.table(textConnection("Score Name
>>
> + 88 19_0070
> + 88 19_0070
> + 87 19_0070
> + 79 002127_0658
> + 79 002127_0658
> + 77 002127_0658"), header=TRUE)
Hello everybody
How do you subset a data.frame when your boundaries are a combination of
explicit and implicit limits?
For example, I need to subset from the fourth (explicit) to the last
(implicit) column a data.frame named A.
In other languages you would do A[ , 4:]. Would anybody show me the
Try this:
Lines <- "Date,Temp
1-Apr-1997,50
3-Sept-2001,60"
library(zoo)
# function to reduce 4 char mos to 3 char
convert.date <- function(x, format) as.Date(sub("(-...).-", "\\1-", x), format)
# z <- read.zoo("myfile.csv", header = TRUE, sep = ",", FUN =
convert.date, format = "%d-%b-%Y")
z <
Continuing on, to just get points from May to Sep
mo <- as.numeric(format(time(z), "%m"))
z.summer <- z[mo >= 5 & mo <= 9]
If in your case z is multivariate rather than univariate (as it is in
our example) then it would be:
z.summer <- z[mo >= 5 & mo <= 9, ]
On Mon, Jul 21, 2008 at 9:55 AM, Gabo
Forecasting
[EMAIL PROTECTED]
-Original Message-
From: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
Sent: Monday, July 21, 2008 3:26 PM
To: Williams, Robin
Cc: R-help@r-project.org
Subject: Re: [R] Subsetting data by date
Continuing on, to just get points from May to Sep
mo <- as.nume
]
-Original Message-
From: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
Sent: Monday, July 21, 2008 3:26 PM
To: Williams, Robin
Cc: R-help@r-project.org
Subject: Re: [R] Subsetting data by date
Continuing on, to just get points from May to Sep
mo <- as.numeric(format(time(z),
PM
> To: Williams, Robin
> Cc: R-help@r-project.org
> Subject: Re: [R] Subsetting data by date
>
> Continuing on, to just get points from May to Sep
>
> mo <- as.numeric(format(time(z), "%m"))
> z.summer <- z[mo >= 5 & mo <= 9]
>
> If in your case
?subset is one of several ways. You don't need a loop. Loops are BAD in R :)
--- On Mon, 7/21/08, Williams, Robin <[EMAIL PROTECTED]> wrote:
> From: Williams, Robin <[EMAIL PROTECTED]>
> Subject: Re: [R] Subsetting data by date
> To: "Gabor Grothendieck"
26 PM
> To: Williams, Robin
> Cc: R-help@r-project.org
> Subject: Re: [R] Subsetting data by date
>
> Continuing on, to just get points from May to Sep
>
> mo <- as.numeric(format(time(z), "%m"))
> z.summer <- z[mo >= 5 & mo <= 9]
>
> If in your case
Have you tried reading some of the material from the BioConductor
workshop http://bioconductor.org/workshops/ ?
Here is a simplistic way of proceeding:
## Calculate pvalues from t-test
p <- apply( mat, function(x) t.test( x ~ cl )$p.value )
## Subset
mat.sub <- mat[ p, ]
## Cluster
heat
on 09/03/2008 05:06 PM joseph wrote:
> I have a data frame that looks like this:
> V1 V2 V3
> ab0:1:12
> df1:2:1
> cd1:0:9
> where V3 is in the form x:y:z
> Can someone show me how to subset the rows where the values of x, y and z <=
> 10:
> V1 V2 V3
> df1:2:1
> c
Hello
How can I change the function to get the rows with the sum (x+y+z) = 10?
Thank you very much
Joseph
- Original Message
From: Marc Schwartz <[EMAIL PROTECTED]>
To: joseph <[EMAIL PROTECTED]>
Cc: r-help@r-project.org
Sent: Wednesday, September 3, 2008 3:24:58 PM
Sub
nt: Saturday, September 6, 2008 10:43:09 AM
Subject: Re: [R] subsetting a data frame
Dear Joseph,
Try
DF[sapply(strsplit(as.character(DF$V3), ":"),
function(i) all(as.numeric(i) == 10)), ]
HTH,
Jorge
On Sat, Sep 6, 2008 at 1:24 PM, joseph <[EMAIL PROTECTED]> wrote:
h <[EMAIL PROTECTED]>
> Sent: Saturday, September 6, 2008 10:43:09 AM
> Subject: Re: [R] subsetting a data frame
>
>
>
> Dear Joseph,
>
> Try
>
>
> DF[sapply(strsplit(as.character(DF$V3), ":"),
> function(i) all(as.numeric(i) == 10))
ssage
>> From: Jorge Ivan Velez <[EMAIL PROTECTED]>
>> To: joseph <[EMAIL PROTECTED]>
>> Sent: Saturday, September 6, 2008 10:43:09 AM
>> Subject: Re: [R] subsetting a data frame
>>
>>
>> Dear Joseph,
>> Try
>>
>> DF
oseph
>
> - Original Message
> From: Jorge Ivan Velez <[EMAIL PROTECTED]>
> To: joseph <[EMAIL PROTECTED]>
> Sent: Saturday, September 6, 2008 10:43:09 AM
> Subject: Re: [R] subsetting a data frame
>
>
> Dear Joseph,
> Try
>
>
> DF[sapply(st
?complete.cases
On Jan 1, 2008 8:50 PM, Marko Milicic <[EMAIL PROTECTED]> wrote:
> Dear R users,
>
> I'm new but already fascinated R user so please forgive for my
> ignorance. I have the problem, I read most of help pages but couldn't
> find the solution. The problem follows
>
> I have large
You could try
> complete.case.df <- na.omit(df)
Ross Darnell
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Marko Milicic
Sent: Wednesday, 2 January 2008 11:50 AM
To: r-help@r-project.org
Subject: [R] Subsetting data frame problem
Dear R
PROTECTED] [mailto:[EMAIL PROTECTED]
> On Behalf Of Marko Milicic
> Sent: Wednesday, 2 January 2008 11:50 AM
> To: r-help@r-project.org
> Subject: [R] Subsetting data frame problem
>
> Dear R users,
>
> I'm new but already fascinated R user so please forgiv
I have not seen you describe the value of doing partial matching in
this application, so pardon this perhaps non-responsive reply:
Wouldn't it have been much, much simpler to have used the subset
function (which returns a dataframe object) at the first assignment to
donotprint?
Something
On 6/6/2008 9:35 AM, Emslie, Paul [Ctr] wrote:
I want to take the first row of each unique ID value from a data frame.
For instance
ddTable <-
data.frame(Id=c(1,1,2,2),name=c("Paul","Joe","Bob","Larry"))
I want a dataset that is
Id Name
1 Paul
2 Bob
unique(ddTable)
Will give m
I don't have R on this machine but will this work.
myrows <- unique(ddTable[,1])
unis <- ddTable(myrows, ]
--- On Fri, 6/6/08, Emslie, Paul [Ctr] <[EMAIL PROTECTED]> wrote:
> From: Emslie, Paul [Ctr] <[EMAIL PROTECTED]>
> Subject: [R] Subsetting to unique valu
Emslie, Paul [Ctr] atac.mil> writes:
>
> I want to take the first row of each unique ID value from a data frame.
> For instance
> > ddTable <-
> data.frame(Id=c(1,1,2,2),name=c("Paul","Joe","Bob","Larry"))
>
> I want a dataset that is
> IdName
> 1 Paul
> 2 Bob
>
> > unique(ddTable
The interesting thing about R is that there are several ways to "skin the
cat"; here is yet another solution:
> do.call(rbind, by(ddTable, ddTable$Id, function(z) z[1,,drop=FALSE]))
Id name
1 1 Paul
2 2 Bob
>
On Fri, Jun 6, 2008 at 9:35 AM, Emslie, Paul [Ctr] <[EMAIL PROTECTED]> wrote:
> I
Dear Paul,
Try also:
ddTable <-
data.frame(Id=c(1,1,2,2),name=c("Paul","Joe","Bob","Larry"))
ddTable[unique(ddTable$Id),]
HTH,
Jorge
On Fri, Jun 6, 2008 at 9:35 AM, Emslie, Paul [Ctr] <[EMAIL PROTECTED]> wrote:
> I want to take the first row of each unique ID value from a data frame.
> For
I need some help with sub-setting my data. I am trying to divide a data frame
into multiple data frames based on the year collected, and stored in a list
with each new data frame labeled with "year X" where X is the year the data was
collected. When I run my current code I get nine error messa
on 12/07/2008 11:16 AM hesicaia wrote:
> Hi all,
> I have a question regarding subsetting of large data frames. I have two
> data frames “catches” and “tows” and they both have the same 30 variables
> (columns). I would like to select rows in the data frame “tows” where all 5
> specific variables
It worked wonderfully - Thanks very much!
hesicaia wrote:
>
> Hi all,
> I have a question regarding subsetting of large data frames. I have two
> data frames “catches” and “tows” and they both have the same 30 variables
> (columns). I would like to select rows in the data frame “tows” where
You can for example use ncol(A) to get the number of columns.
Sarah
On Thu, May 21, 2009 at 12:06 PM, culpritNr1 wrote:
>
> Hello everybody
>
> How do you subset a data.frame when your boundaries are a combination of
> explicit and implicit limits?
>
> For example, I need to subset from the four
Dear culprit
Try this:
A[ , 4:ncol(A) ]
HTH,
Jorge
On Thu, May 21, 2009 at 12:06 PM, culpritNr1 wrote:
>
> Hello everybody
>
> How do you subset a data.frame when your boundaries are a combination of
> explicit and implicit limits?
>
> For example, I need to subset from the fourth (explicit
Hi Sarah and Jorge,
ncol(). How elegant!
Thank you.
Jorge Ivan Velez wrote:
>
> Dear culprit
> Try this:
> A[ , 4:ncol(A) ]
>
> HTH,
>
> Jorge
>
>
>
> On Thu, May 21, 2009 at 12:06 PM, culpritNr1
> wrote:
>
>>
>> Hello everybody
>>
>> How do you subset a data.frame when your bounda
Hi,
Consider the following
x = c(1,2)
y = c(3,4)
d = data.frame(cbind(x,y))
d$x
[1] 1 2
d$"x"
[1] 1 2
foo = function(val)
+ {
+ return(d$val)
+ }
bar = function()
+ {
+ return(d$"x")
+ }
foo("x")
NULL
bar()
[1] 1 2
I'm a little surprised that R accepts both the form d$x and
?split.
Hadley
On Wed, Oct 29, 2008 at 3:22 PM, t c <[EMAIL PROTECTED]> wrote:
> I need some help with sub-setting my data. I am trying to divide a data
> frame into multiple data frames based on the year collected, and stored in a
> list with each new data frame labeled with "year X" where X
Dear All,
I have matrix of size 2500 x 12. I would like to select all the rows if 6 out
12 values are > 0. How can I do that in R?
Thanks in advance.
Kind regards,
Ezhil
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-he
Hello,
I have a large matrix (data), in which there is a column offerid. The values
are numbers (lets say 1:5)
There is another vector (idnew), which contains some of the offerids and
many more (3:10).
I want a subset of the matrix wiith only those rows, which match the
criteria of the vector.
Dear R users,
I am interested in taking the columns from multiple dataframes, the
problem is that the different dataframes have different combinations
of the same variable names, here's a simple example:
a<-rep(1:10)
b<-rep(1:10)
c<-rep(21:30)
d<-rep(31:40)
dat.a<-data.frame(a,b,c,d)
names(d
I realize this should be simple but I'm having trouble subsetting vectors
and matrices, for example extracting all values meeting a certain
criterion, from a vector. Cannot seem to figure out the correct syntax and
help page not very helpful. Or should I be using some other function than
subset.
Try this
foo1 = function(val)
{
return(d[val])
}
foo1("x")
Good luck
miltinho astronauta
brazil
On 8/6/08, Faheem Mitha <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> Consider the following
>
> x = c(1,2)
>> y = c(3,4)
>> d = data.frame(cbind(x,y))
>> d$x
>>
> [1] 1 2
>
>> d$"x"
>>
> [1] 1
On Wed, 6 Aug 2008, milton ruser wrote:
Try this
foo1 = function(val)
{
return(d[val])
}
foo1("x")
Thanks for the suggestion. I appreciate it. My original question wasn't
just a pragmatic "how do I do this" type question. I was also wondering
about the language issues involved.
On Wed, 6 Aug 2008, Faheem Mitha wrote:
Hi,
Consider the following
x = c(1,2)
y = c(3,4)
d = data.frame(cbind(x,y))
d$x
[1] 1 2
d$"x"
[1] 1 2
foo = function(val)
+ {
+ return(d$val)
+ }
bar = function()
+ {
+ return(d$"x")
+ }
foo("x")
NULL
bar()
[1] 1 2
I'm a little surpr
On Wed, Aug 06, 2008 at 11:53:25AM -0400, Faheem Mitha wrote:
>
> Hi,
>
> Consider the following
>
>> x = c(1,2)
>> y = c(3,4)
>> d = data.frame(cbind(x,y))
>> d$x
> [1] 1 2
>> d$"x"
> [1] 1 2
>>
>> foo = function(val)
> + {
> + return(d$val)
> + }
>>
>> bar = function()
> + {
> + return(d$"x")
Is there a way to select a subset of a dataframe consisting of all
those rows with rownames *except* from a subset of rownames to be
excluded? Example:
> a <- data.frame(x=1:10,y=10:1)
> a <- a[order(a$y),] # to make rownames differ visually
> a[8,]
x y
3 3 8
> a["8",]
x y
8 8 3
> a[-
Example data frame:
a = c("Alpha", "Beta", "Gamma", "Beeta", "Alpha", "beta")
b = c(1:6)
example = data.frame("Title" = a, "Vals" = b)
> example
Title Vals
1 Alpha1
2 Beta2
3 Gamma3
4 Beeta4
5 Alpha5
6 beta6
>
I would like to be able to get a new data frame from
Hi,
I have a very simple problem but I can't think how to solve it without
using a for loop and creating a large logical vector. However given the
nature of the problem I am sure there is a "1-liner" that could do the
same thing much more efficiently.
bascially I have a dataframe with charac
Greetings.
At the moment, I'm applying R to some AIX 'nmon' output, trying to get
a handle on some disk performance metrics. In case anyone's
interested:
http://docs.osg.ufl.edu/tsm/pdf/
some of them are more edifying than others. (ahem)
I'm trying to develop a somewhat general framework for
one way is:
mat <- matrix(rnorm(2500*12), 2500, 12)
ind <- rowSums(mat > 0) > 6
mat[ind, ]
I hope it helps.
Best,
Dimitris
A Ezhil wrote:
Dear All,
I have matrix of size 2500 x 12. I would like to select all the rows if 6 out 12 values are > 0. How can I do that in R?
Thanks in advance
have a look at ?"%in%"
Best,
Dimitris
jorgusch wrote:
Hello,
I have a large matrix (data), in which there is a column offerid. The values
are numbers (lets say 1:5)
There is another vector (idnew), which contains some of the offerids and
many more (3:10).
I want a subset of the matrix wiith
Hi jorgusch,
First, do not call your data, "data" :-)
require(fortunes)
fortune('dog')
Here are two suggestions to do what you asked for:
# your data
id <- 1:5
idnew <- 3:10
# to get the indexes
id %in% idnew
# to get the id's matching the new vector
id[ id %in% idnew ]
# another way
inters
On Sep 22, 2009, at 5:58 PM, Corey Sparks wrote:
Dear R users,
I am interested in taking the columns from multiple dataframes, the
problem is that the different dataframes have different combinations
of the same variable names, here's a simple example:
a<-rep(1:10)
b<-rep(1:10)
c<-rep(21:3
You can use intersect also:
dat.a[intersect(names(dat.a), names(dat.b))]
On Tue, Sep 22, 2009 at 6:58 PM, Corey Sparks wrote:
> Dear R users,
> I am interested in taking the columns from multiple dataframes, the problem
> is that the different dataframes have different combinations of the same
both the following will probably do the trick.
?subset
?"["
Basically on the second one, you want to come down to something that
looks like
x[L]
where x is a matrix/vector, and L is a logical vector that has the
same dimension as x, but is TRUE on the values of x that you want to
select.
for i
Hi
Is it possible to subset an n-dimensional array by a vector of n dimensions?
E.g. assume I have
x <- array(1:24, dim=2:4)
x[1,1,2]
[1] 7
dims <- c(1,1,2)
I would like a function that I can supply x and dims as parameters to, and have
it return 7. Also, I would like to do something like
Hi,
I have a long matrix of the following form which I would like to subset
according to the third column:
[x y z]:
a1 c1 1
a1 c1 2
a2 c1 1
a1 c2 1
a1 c2 2
. . .
The first two columns a characters ai and cj.
I would like to keep all the rows where there are two entries for z, 1 and 2.
Tha
On Sat, 11 Oct 2008, Alexy Khrabrov wrote:
Is there a way to select a subset of a dataframe consisting of all those rows
with rownames *except* from a subset of rownames to be excluded? Example:
Yes: DF[is.na(match(row.names(DF), exclude_me)), ]
a <- data.frame(x=1:10,y=10:1)
a <- a[order
On 1/21/2008 5:18 AM, Karin Lagesen wrote:
> Example data frame:
>
>
> a = c("Alpha", "Beta", "Gamma", "Beeta", "Alpha", "beta")
> b = c(1:6)
> example = data.frame("Title" = a, "Vals" = b)
>
>
>> example
> Title Vals
> 1 Alpha1
> 2 Beta2
> 3 Gamma3
> 4 Beeta4
> 5 Alpha5
> a = c("Alpha", "Beta", "Gamma", "Beeta", "Alpha", "beta")
> b = c(1:6)
> example = data.frame("Title" = a, "Vals" = b)
>
>
> > example
> Title Vals
> 1 Alpha1
> 2 Beta2
> 3 Gamma3
> 4 Beeta4
> 5 Alpha5
> 6 beta6
> >
>
> I would like to be able to get a new data fra
On 6/13/2008 10:07 AM, james perkins wrote:
Hi,
I have a very simple problem but I can't think how to solve it without
using a for loop and creating a large logical vector. However given the
nature of the problem I am sure there is a "1-liner" that could do the
same thing much more efficientl
james perkins wrote:
> Hi,
>
> I have a very simple problem but I can't think how to solve it without
> using a for loop and creating a large logical vector. However given
> the nature of the problem I am sure there is a "1-liner" that could do
> the same thing much more efficiently.
>
> bascially
Thanks a lot for that. Its the %in% I needed to work out mainly
large didn't mean anything in particular, just that it gets quite long
with the real data.
I did mean: names = c("John", "Phil", "Robert")
The only problem is that using the method you suggest is that I lose the
indexing, ie in t
james perkins wrote:
> Thanks a lot for that. Its the %in% I needed to work out mainly
>
> large didn't mean anything in particular, just that it gets quite long
> with the real data.
> I did mean: names = c("John", "Phil", "Robert")
>
> The only problem is that using the method you suggest is that
james perkins wrote:
> Thanks a lot for that. Its the %in% I needed to work out mainly
>
> large didn't mean anything in particular, just that it gets quite long
> with the real data.
> I did mean: names = c("John", "Phil", "Robert")
>
> The only problem is that using the method you suggest is that
try:
input[,targets, drop=FALSE]
see:
?"["
for an explanation.
On 2/8/08, Allen S. Rout <[EMAIL PROTECTED]> wrote:
>
> Greetings.
>
> At the moment, I'm applying R to some AIX 'nmon' output, trying to get
> a handle on some disk performance metrics. In case anyone's
> interested:
>
> http://
I think I understand this. Try
str(input) and you will see that input$disk2 in a
vector. You can force a data.frame using
data.frame(input(,targets))
--- "Allen S. Rout" <[EMAIL PROTECTED]> wrote:
>
> Greetings.
>
> At the moment, I'm applying R to some AIX 'nmon'
> output, trying to get
>
Try this also:
input[targets]
On 08/02/2008, Allen S. Rout <[EMAIL PROTECTED]> wrote:
>
> Greetings.
>
> At the moment, I'm applying R to some AIX 'nmon' output, trying to get
> a handle on some disk performance metrics. In case anyone's
> interested:
>
> http://docs.osg.ufl.edu/tsm/pdf/
>
> som
"jim holtman" <[EMAIL PROTECTED]> writes:
> try:
> input[,targets, drop=FALSE]
> see:
> ?"["
> for an explanation.
Thanks, you who responded; this was exactly helpful, and a good
reference to the part of the FM I was missing. To unpack (and
demonstrate some comprehension gained.. ;) the sub
Prof Brian Ripley stats.ox.ac.uk> writes:
> Yes: DF[is.na(match(row.names(DF), exclude_me)), ]
Assuming everything is possible in R: would it be possible to make the below
work without breaking existing code?
a <- data.frame(x=1:10)
rownames(a) = letters[1:10]
exclude = c("a","c")
a[is.na(matc
On Mon, 13 Oct 2008, Dieter Menne wrote:
Prof Brian Ripley stats.ox.ac.uk> writes:
Yes: DF[is.na(match(row.names(DF), exclude_me)), ]
Assuming everything is possible in R: would it be possible to make the below
work without breaking existing code?
It would be possible, but not I think des
On Oct 13, 2008, at 5:36 AM, Dieter Menne wrote:
Prof Brian Ripley stats.ox.ac.uk> writes:
Yes: DF[is.na(match(row.names(DF), exclude_me)), ]
Assuming everything is possible in R: would it be possible to make
the below
work without breaking existing code?
a <- data.frame(x=1:10)
rowna
Hi,
I am trying to subset a dataset based on a filter defined by a user...
I prompt the user for input.. resulting in a string logical expression
("X1 < 3").
I have tried using subset, but it is looking for a logical expression, not
a character string.
I keep getting the error: 'subset' must
I have a data that looks like this:
http://dpaste.com/88988/plain/
How can I extract/subset the data frame
based on selected uniq ID.
Let's say I want the first K uniq ID.
I want to be able to specify the parameter "K" here,
(i.e. given K=3, we hope to extract dat$V2 = 0,1,2).
I'm stuck with thi
1 - 100 of 130 matches
Mail list logo