Here is an implementation.
> t <-
> data.frame(x=c(1,1,1,1,1,2,2,2,2,2),y=c("a","a","a","b","b","a","a","b","b","b"))
> t
x y
1 1 a
2 1 a
3 1 a
4 1 b
5 1 b
6 2 a
7 2 a
8 2 b
9 2 b
10 2 b
> assignSeq
function(test)
{
temp <- test[order(test$x),]
InC <- numeric(length(test))
inD <-
Hi,
Maybe a beginning of solution with this?
test <-
data.frame(x=c(1,1,1,1,1,1,2,2,2,2,2,2),y=c("a","a","a","b","b","b","a","a","b","b","b","a"))
test[order(test$x),]
out <- split(test,test$x)
for (i in 1:length(out)) {
foo <- unique(out[[i]][,2])
out[[i]][,2] <- rep(foo,(nrow(out[[
If you already have the order stored in a list or so:
For example:
dat1 <- as.data.frame(mat,stringsAsFactors=FALSE)
lst1 <- list(c("OF","ON"), c("US","UK", "WW","BO","BR","CA"),
c("P2","P3","P1"),c("S2","S1","S3"))
dat1[] <- lapply(seq_along(lst1),function(i)
factor(dat1[,i],levels=lst1[[i]]))
Hi,
Not sure whether this helps:
dat1 <- as.data.frame(mat,stringsAsFactors=FALSE)
dat1$c4 <- factor(dat1$c4,levels=c("OF","ON"))
dat1$c1 <- factor(dat1$c1,levels=c("US","UK","WW","BO","BR","CA"))
dat1$c2 <- factor(dat1$c2, levels=c("P2","P3","P1"))
dat1$c3 <- factor(dat1$c3, levels=c("S2","S1"
Hi,
Hope this is what you meant..
with(dat1,mean(V21[(V2==1|V2==0) & V24<25],na.rm=TRUE))
#[1] 2.8125
sapply(0:1,function(i) with(dat1,mean(V21[V2==i & V24<25],na.rm=TRUE)))
#[1] 2.75 3.00
". who are in condition 1 or 0 (V2) and then vice
versa ..."
dat1[,21]
# [1] NA 3.40 3.00 3
Hi,
It's not clear what you really wanted. May be this helps:
dat1<- read.table(text="
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21
V22 V23 V24 V25 V26
1 1 1 3 1 NA NA 1 NA NA 1 2 7 5 3 2 1.0 15 17 5 1
NA 1 2 19 1 1
2
I have 1 data frame "Data" with my main data points (red points: latitude,
longitude and other biological parameters) and 3 other data frames for each
blue line "front_x" (latitude, longitude).
I need to sort the data (red points) according to these lines of points, so
one file for each 4 differen
Thanks to all,
>a <- a[order(a[[4]]),]
gives desired result
>sort(a[,4])
sorts the data a[4]
regards,.
On Fri, Oct 28, 2011 at 7:42 PM, John Sorkin wrote:
> I am not sure (I can't test at the moment) but will this work?
> sort(a[,4])
>
>
> John David Sorkin M.D., Ph.D.
> Chief, Biostatistics a
I am not sure (I can't test at the moment) but will this work?
sort(a[,4])
John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1
a <- a[order(a[[4]]),]
On Fri, Oct 28, 2011 at 10:01 AM, nandan amar wrote:
> I want to sort my following data set according to value in 4th column
>
> 0 1 0 27877.3044386212 15.8733019973557 2640.42407064348
> 0 1 1 27470.1699006254 35.4182473588807 2303.26461260826
> 0 1 2 27468.0314985496 3
I want to sort my following data set according to value in 4th column
0 1 0 27877.3044386212 15.8733019973557 2640.42407064348
0 1 1 27470.1699006254 35.4182473588807 2303.26461260826
0 1 2 27468.0314985496 38.4400363878507 2300.05521684593
0 1 3 27469.1130543141 40.7540672493746 2299.32564458
Try this:
X = 1:5; names(X) = letters[sample(5)]
Y = matrix(1:25, 5); colnames(Y) = letters[1:5]
Y[ , names(X)]
Hope this helps,
Michael Weylandt
On Oct 3, 2011, at 6:20 AM, "Samir Benzerfa" wrote:
> Hi everyone,
>
>
>
> My (simplified) problem is the following one: I have two tables. The
Hi everyone,
My (simplified) problem is the following one: I have two tables. The first
table contains 5 columns with 5 values and the second table contains a
single value for each vector name of the first table (see tables below):
Table 1:
A B C D
îåáéõ
To:
Date:
07/28/2011 09:03 AM
Subject:
[R] sorting data from dataframe with oter dataframe
Sent by:
r-help-boun...@r-project.org
Hi, the subject isn't define well the problem, so i'll explain it in
detail:
i've got a csv.file with data on number of factors (every
Hi, the subject isn't define well the problem, so i'll explain it in detail:
i've got a csv.file with data on number of factors (every column got the
name
of the factor as header and the data below). on another csv file, i've got
the
factors sorted by their type. for example-
This will give you the unique gene values:
> colA <- c("M-012847-00" ,"M-012847-00" ,"M-015544-00", "M-015544-00",
> "M-024202-00","M-024202-00")
> colB <- c("NM_057175", "NM_057175", "NM_153008", "NM_153027", "NM_207330",
> "NM_207330")
> colC <- c( 'NARG1', 'TBDN100', 'FLJ30277', 'FLJ31659', '
Is this what you want:
> colA <- c("M-012847-00" ,"M-012847-00" ,"M-015544-00", "M-015544-00",
> "M-024202-00","M-024202-00")
> colB <- c("NM_057175", "NM_057175", "NM_153008", "NM_153027", "NM_207330",
> "NM_207330")
> colC <- c( 'NARG1', 'TBDN100', 'FLJ30277', 'FLJ31659', 'NIPAL1', 'NPAL1')
>
Hello all!
I am currently trying to sort a data frame in a particular way, but I am having
some difficulties with this. Specifically I want to sort the below dataset in
such a way that there is only one line per ProteinID and if there are multiple
GeneID or GeneName entries for a single prote
try sqldf:
> x
Sample_no Species Nitrogen Carbon
1 1 Cod 15.2 -19.0
2 2 Haddock 14.8 -20.2
3 3 Cod 15.6 -18.5
4 4 Cod 13.2 -20.1
5 5 Haddock 14.3 -18.8
> require(sqldf)
> sqldf("select Species, avg(Nitrogen) Nitrogen, a
(apologies for any double hits; forgot to reply all...)
Or, you could just go back to basics, and write yourself a general loop that
goes through whatever levels of a variable and gives you back whatever
statistics you want... below is an example where you estimate means for each
level, but you co
-help-boun...@r-project.org] On
Behalf Of Ramsvatn Silje
Sent: donderdag 4 november 2010 13:28
To: R-help@r-project.org
Subject: [R] Sorting data from one column with strings
Hello,
I have tried to find this out some other way, but unsuccessful I have to try
this list.
I assume this should be
On Nov 4, 2010, at 8:28 AM, Ramsvatn Silje wrote:
Hello,
I have tried to find this out some other way, but unsuccessful I
have to
try this list.
I assume this should be quite simple.
I have a dataset with 4 columns, "Sample_no", "Species", "Nitrogen",
"Carbon" in csv format. In the specie
Hello,
I have tried to find this out some other way, but unsuccessful I have to
try this list.
I assume this should be quite simple.
I have a dataset with 4 columns, "Sample_no", "Species", "Nitrogen",
"Carbon" in csv format. In the species column I have many different
species with varying numbe
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of emwater
> Sent: Wednesday, March 10, 2010 1:07 AM
> To: r-help@r-project.org
> Subject: Re: [R] sorting data whilst ignoring NA's
>
>
> Thanks
Thanks for these suggestions. I tried them out and I get the error message:
Error in qdata$flow : $ operator is invalid for atomic vectors
Can anyone offer further suggestions on how to extract the values from
atomic vectors?
Thanks again
Emma
--
View this message in context:
http://n4.nabble
On 2010-03-09 9:57, emwater wrote:
Hello,
I am very new to R and have hit my first main problem that I hope someone
can easily resolve.
I have some data that looks like this (there are 20,000 rows):
qdata
day month yearflow
[1,] 210 1945 NA
[2,] 310 194
On Mar 9, 2010, at 11:57 AM, emwater wrote:
Hello,
I am very new to R and have hit my first main problem that I hope
someone
can easily resolve.
I have some data that looks like this (there are 20,000 rows):
qdata
day month yearflow
[1,] 210 1945 NA
[2,] 3
Hello,
I am very new to R and have hit my first main problem that I hope someone
can easily resolve.
I have some data that looks like this (there are 20,000 rows):
> qdata
day month yearflow
[1,] 210 1945 NA
[2,] 310 1945 NA
[3,] 410 1945 NA
28 matches
Mail list logo