Hi,
You could try this:
dat2<- read.table(text='
case pin some_data
"A" "1" "data"
"A" "2" "data"
"A" "1" "data"
"A" "2" "data"
"B" "1" "data"
"B" "2" "data"
',sep="",header=TRUE,stringsAsFactors=FALSE)
dat2[!duplicated(dat2[,1:2]),]
# case pin some_data
#1 A 1 data
Thanks Arun,
Jorge,s idea worked... I can't believe I lost so much time with this...
Â
mike
>
> From:arun
>To: Mihai Nica
>Cc: R help
>Sent: Monday, April 22, 2013 4:57 PM
>Subject:Re: [R] subset dataframe
>
>
>HI,
>C
6304
# $ X2000: int 24950 15292 25260
A.K.
- Original Message -
From: arun
To: Mihai Nica
Cc: R help
Sent: Monday, April 22, 2013 5:57 PM
Subject: Re: [R] subset dataframe
HI,
Could you provide an example dataset?
set.seed(15)
agoa<- data.frame(X.1=rep(c("AGOA","
AGOA 13019 15292
#7 AGOA 16304 25260
agoa[agoa$X.1=="AGOA",]
# X.1 X1996 X2000
#1 AGOA 12043 24950
#4 AGOA 13019 15292
#7 AGOA 16304 25260
A.K.
From: Mihai Nica
To: "r-help@r-project.org"
Sent: Monday, April 22, 2013 5:14 PM
Subje
Mike,
You need
subset(agoa, agoa$X.1 == "AGOA ")
instead of
subset(agoa, agoa$X.1 == "AGOA")
(note the space after the last A in "AGOA".
HTH,
Jorge.-
On Tue, Apr 23, 2013 at 7:14 AM, Mihai Nica wrote:
> I can't understand what is happening. This is the code and results:
>
> > agoa <- read
I can't understand what is happening. This is the code and results:
> agoa <- read.table(file =
>"C:/Users/HTPC/Documents/_Documents/Research/WithDidia/AGOAUSImports.txt",
>header = T, sep = "\t", dec = ".", na.strings = "NA", stringsAsFactors = T)#
> str(agoa); names(agoa)
'data.frame':10
Also look at the documentation for read.csv2().
--
David.
On Jun 2, 2009, at 5:43 AM, Cecilia Carmo wrote:
Thank you all!!!
The problem was the decimal symbol! My data was saved in a txt file,
so I’ve introduced the dec="," in «read.table» and it worked.
What I’ve done was
coeficient
Thank you all!!!
The problem was the decimal symbol! My data was saved in a
txt file, so Ive introduced the dec="," in «read.table»
and it worked. What Ive done was
coeficientes<-read.table("coeficientes.txt",sep="\t",header=T,dec=",")
Then, subset worked fine
coeficientesWanted<-subset(coe
Dear Cecilia,
I have followed the replies you got and I found that, perhaps, what you are
experiencing has something to do with the decimal symbol in your data.
Consider the following:
# Reading the data as you sent it to the list
x <- read.table(textConnection("caedois b1 b2
So now is the time to back up to the beginning and demonstrate how you
created the coeficientes object. Ideally you would also provide the
results of:
dput(coeficientes)
or
str(coeficientes)
Subset will only work with dataframes, so if coeficientes is not a
dataframe, then you will need
It doesn't work. b1 was substituted by NA's with this
message:
Warning message:
NAs introduced by coercion
I will see in the webpage that you mentioned.
Thanks,
Cecília
Em Mon, 1 Jun 2009 13:23:12 -0400
David Winsemius escreveu:
On Jun 1, 2009, at 1:01 PM, Cecilia Carmo wrote:
Hi R-help
On Jun 1, 2009, at 1:01 PM, Cecilia Carmo wrote:
Hi R-helpers!
I have the following object:
head(coeficientes)
caedois b1 b2 b3
1 10,033120395 -20,29478338 -0,274638864
2 2 -0,040629634 74,54239889 -0,069958424
3 5 -0,001116816 35
Hi R-helpers!
I have the following object:
head(coeficientes)
caedois b1 b2 b3
1 10,033120395 -20,29478338 -0,274638864
2 2 -0,040629634 74,54239889 -0,069958424
3 5 -0,001116816 35,2398622 0,214327185
4 10 0,171875
5
Here is one way of doing it:
> moreThan <- ave(choose$code, choose$code, FUN=length)
> moreThan
[1] 2 2 4 4 4 4 2 2 6 6 6 6 6 6
> choose[moreThan > 2,]
firm year code
3 2 2000 11
4 2 2001 11
5 2 2002 11
6 2 2003 11
9 4 2001 13
104 2002 13
114 2003 13
1
Hi R helpers!
I have the following dataframe «choose»
choose<-data.frame(firm=c(1,1,2,2,2,2,3,3,4,4,4,4,4,4),
year=c(2000,2001,2000,2001,2002,2003,2000,2003,2001,2002,2003,2004,2005,2006),code=c(10,10,11,11,11,11,12,12,13,13,13,13,13,13))
choose
I want to subset it to obtain another one with t
ch appreciate your help, thanks again.
Zack
CC: r-help@r-project.org
From: ba...@exeter.ac.uk
To: zack_hol...@hotmail.com
Subject: Re: [R] subset dataframe by rows using character vector?
Date: Tue, 14 Apr 2009 15:56:45 +0100
Is this what you want?
plotNam
Is this what you want?
plotNames <- c("plot1", "plot2", "plot3") # plot is probably best
left as the name of the base function
full.data[full.data$PLOTID %in% plotNames, ] # note the comma
HTH,
baptiste
On 14 Apr 2009, at 15:20, zack holden wrote:
Dear List,
I'm stuck on what seems
Dear List,
I'm stuck on what seems like a simple indexing problem, I'd be very grateful to
anyone willing to help me out.
I queried a dataframe which returns a character vector called "plot". I have
another dataframe from which I want to subset or select only those rows that
match "plot".
18 matches
Mail list logo