Hi there
I have two dataframes
Dataframe_1
column_1colum_2
121 12345
145 1675
167 2765
Dataframe_2
column_1 column2
121abc
345lmn
167efg
I want a resulting dataframe
121 12345abc
167 2765 efg
how do i go abt it
Ramya
--
On Dec 3, 2009, at 2:47 PM, Ramya wrote:
Hi there
I have two dataframes
Dataframe_1
column_1colum_2
121 12345
145 1675
167 2765
Dataframe_2
column_1 column2
121abc
345lmn
167efg
I want a resulting dataframe
121 12345abc
167
Try this:
both - merge(left, right, by.x=column1, by.y=column1)
left dataset
column1column2
121 12345
145 1675
167 2765
right datset
column1 column3
121abc
345lmn
167efg
HTH,
Peng
On Thu, Dec 3, 2009 at 2:47 PM, Ramya ramya.vict...@gmail.com wrote:
Thanks it worked!!! i was trying to use %in% and matching it.
Ramya
On Thu, Dec 3, 2009 at 2:06 PM, Peng Cai [via R]
ml-node+947950-541874...@n4.nabble.comml-node%2b947950-541874...@n4.nabble.com
wrote:
Try this:
both - merge(left, right, by.x=column1, by.y=column1)
left dataset
Don MacQueen wrote:
As others noted, you can use the built in function colSums, but you said
you're writing your own. Given what you've got so far, that makes the
issue one of structuring the output.
Try
csum - function(m)
{
a = data.frame(m)
s = lapply(a,sum)
unlist(s)
}
Alright, so I am trying to write my own function to calculate column sums in
a matrix. I want the result as a single list with the values.
So far I have:
csum-function(m)
{
a = data.frame(m)
s = lapply(a,sum)
return(s)
}
What is the easiest way to have it return in a
[mailto:r-help-boun...@r-project.org]
On Behalf Of voidobscura
Sent: Thursday, July 16, 2009 2:26 PM
To: r-help@r-project.org
Subject: [R] DataFrame help
Alright, so I am trying to write my own function to calculate column
sums in
a matrix. I want the result as a single list with the values.
So
Dear voidobscura,
Try either:
colSums(mdat)
# or
apply(mdat, 2, sum)
See ?colSums and ?apply for more details.
HTH,
Jorge
On Thu, Jul 16, 2009 at 2:25 PM, voidobscura nshah...@gmail.com wrote:
Alright, so I am trying to write my own function to calculate column sums
in
a matrix. I
As others noted, you can use the built in function colSums, but you
said you're writing your own. Given what you've got so far, that
makes the issue one of structuring the output.
Try
csum - function(m)
{
a = data.frame(m)
s = lapply(a,sum)
unlist(s)
}
lapply()
Rajasekaramya ramya.victory at gmail.com writes:
Hi there,
I have a dataframe length.unique.info
length.unique.info
abc 12 345
def 16 550
lmn 6 600
I want those names that fall under the condition (length.unique.info[,2][i]
=5 length.unique.info[,3][i] =500)
[...]
Hello,
you will get more help if you provide code that can be copied and
pasted into an R session.
?dput
#untested to say the least
foo[unique(foo),]
On Mon, Nov 24, 2008 at 5:36 PM, Rajasekaramya [EMAIL PROTECTED] wrote:
hi there
I have a dataframe
abc 123 345
abc 345 456
lmn 567 345
hkl
Not sure that solution properly focuses the unique function on the
first column, and even when I tried to do so, my code using did not
produce what I expected. The unique function does not return a logical
vector.
Try:
ships[!duplicated(ships$type), ]
And Rajasekaramya, please include
hi there
I have a dataframe
abc 123 345
abc 345 456
lmn 567 345
hkl 568 535
lmn 096 456
lmn 768 094
i want the uniques of column 1 and there corresponsing column 2 and 3
output
abc 123 345
lmn 567 345
hkl 568 535
cbind(DF1[,1],DF1[which(unique(DF1[,1]),c(2,3)])
but didnt work
kindly let
Hi there,
I have a dataframe length.unique.info
length.unique.info
abc 12 345
def 16 550
lmn 6 600
I want those names that fall under the condition (length.unique.info[,2][i]
=5 length.unique.info[,3][i] =500)
abcder-length.unique.info[which(length.unique.info[,2][i] =5
Hello -
Rajasekaramya wrote:
Hi there,
I have a dataframe length.unique.info
length.unique.info
abc 12 345
def 16 550
lmn 6 600
Is this really the output when you print your data.frame? You may have
column names for columns 1, 2, and 3? Is the first column a column of
row.names,
15 matches
Mail list logo