Thank you mate!
--
View this message in context:
http://r.789695.n4.nabble.com/Data-frame-to-Matrix-by-category-tp4669669p4669768.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/
Hello,
Maybe something like the following.
dat <- read.table(text = "
isin dt
1 FR0109970386 2010-01-12
2 FR0109970386 2011-01-12
3 FR0109970386 2012-01-12
4 FR0116114978 2010-01-12
5 FR0116114978 2011-01-12
6 FR0116114978 2012-01-12
", header = TRUE, stringsAsFactors = FALSE)
Hello Folks,
I try to use plyr and reshape 2 to take a data frame of the form:
> head(cf_dt)
isin dt
1 FR0109970386 2010-01-12
2 FR0109970386 2011-01-12
3 FR0109970386 2012-01-12
4 FR0116114978 2010-01-12
5 FR0116114978 2011-01-12
6 FR0116114978 2012-01-12
to create a matrix o
Hi:
Here are a couple of ways. Since your data frame does not contain a
'c' in ID2, we redefine the factor to give it all five levels rather
than the observed four:
> df <- read.table(textConnection("
+ ID1 ID2 Value
+ a b 1
+ b d 1
+ c a 2
+ c e 1
+ d a 1
+ e d 2"), header = TRUE)
str(df)
> str(
tigo, WI 54409 USA
715-627-4317, ext. 3125 (Office)
715-216-8014 (Cell)
715-623-6773 (FAX)
http://www.glsc.usgs.gov (GLSC web site)
http://profile.usgs.gov/jvadams (My homepage)
jvad...@usgs.gov (E-mail)
From:
Jagz Bell
To:
"r-help@R-project.org"
Date:
08/02/2011 12:13
Hi,
I've tried to look through all the previous related Threads/posts but can't
find a solution to what's probably a simple question.
I have a data frame comprised of three columns e.g.:
ID1 ID2 Value
a b 1
b d 1
c a 2
c e 1
d a 1
e d 2
I'd like to convert the data to a matrix i.e.:
a b c
My Coyne a écrit :
> I have a data frame and would like to convert it into a matrix, how do I do
> that?
either use the df for the initialisation values
mat = matrix(df, ...)
or
as.matrix() could do the trick.
__
R-help@r-project.org mailing list
https:
Hello,
I have a data frame and would like to convert it into a matrix, how do I do
that?
Thanks
--My Coyne
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r
8 matches
Mail list logo