Hmm, that is a bit tricky. The conversion from a table to a data
frame uses the dimension names, which are always character. To bypass
this, you would need to save the dimension names, convert the ones you
want numeric to numeric (I am assuming everything except Conc, so the
indices would be
I have a data frame:
head(df)
Time Temp Conc ReplLog10
10 -20H1 6.406547
22 -20H1 5.738683
37 -20H1 5.796394
4 14 -20H1 4.413691
504H1 6.406547
774H1 5.705433
str(df)
'data.frame': 177 obs. of 5
Hi:
Try this:
dd - data.frame(a = factor(rep(1:5, each = 4)),
+ b = factor(rep(rep(1:2, each = 2), 5)),
+ y = rnorm(20))
str(dd)
'data.frame': 20 obs. of 3 variables:
$ a: Factor w/ 5 levels 1,2,3,4,..: 1 1 1 1 2 2 2 2 3 3 ...
$ b: Factor w/ 2 levels 1,2:
Dr. LaBudde,
Perhaps
as.numeric(as.character(x))
is what you are looking for.
HTH,
Jorge
On Sun, Jun 5, 2011 at 12:31 AM, Robert A. LaBudde wrote:
I have a data frame:
head(df)
Time Temp Conc ReplLog10
10 -20H1 6.406547
22 -20H1 5.738683
37 -20
Hi Robert,
Try this:
## Example data converting mtcars to factors
testdf - as.data.frame(lapply(mtcars, factor))
str(testdf)
## taking advantage of assignment methods to avoid an explicit call to
as.data.frame
## convert factor to numeric using the technique recommended in ?factor
testdf[] -
Exactly! Thanks.
At 12:49 AM 6/5/2011, Jorge Ivan Velez wrote:
Dr. LaBudde,
Perhaps
as.numeric(as.character(x))
is what you are looking for.
HTH,
Jorge
On Sun, Jun 5, 2011 at 12:31 AM, Robert A. LaBudde wrote:
I have a data frame:
head(df)
Time Temp Conc ReplLog10
10 -20H
Thanks for your help.
As far as your question below is concerned, the data frame arose as a
result of some data cleaning on an original data frame, which was
changed into a table, modified, and changed back to a data frame:
ttcrmean- as.table(by(ngbe[,'Log10'],
Thanks! Exactly what I wanted, as the same as Jorge also suggested.
At 12:49 AM 6/5/2011, Dennis Murphy wrote:
Hi:
Try this:
dd - data.frame(a = factor(rep(1:5, each = 4)),
+ b = factor(rep(rep(1:2, each = 2), 5)),
+ y = rnorm(20))
str(dd)
'data.frame':
8 matches
Mail list logo