> * William Dunlap [2012-08-31 18:38:52 +]:
>
> Is the following something like what you are doing?
yes, absolutely, thanks a lot!
--
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.childpsy.net/ http://pmw.org.il http://dhimmi.com
http://palesti
quot;c","f": 1 2
There are other ways to do this, but I don't know if this is the problem
you want to solve.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> * David Winsemius [2012-08-30 10:14:34 -0700]:
>
>> str( as.data.frame( do.call(rbind, strsplit(c("a,1","b,2","c,3"),
> ",") ) , stringsAsFactors=FALSE) )
> 'data.frame': 3 obs. of 2 variables:
> $ V1: chr "a" "b" "c"
> $ V2: chr "1" "2" "3"
do.call/rbind appeared to be TRT. I tried it a
Hello,
Em 31-08-2012 11:35, Martin Maechler escreveu:
Hi Rui,
I think when people are asking how to do such basic things in R,
the answer should *not* be to use a (non-base / -recommended)
package...
You're right, that's why I've called it an alternative.
but then, you may have really want
Hi
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Sam Steingold
> Sent: Thursday, August 30, 2012 9:17 PM
> To: William Dunlap
> Cc: r-help@r-project.org
> Subject: Re: [R] apply --> data.frame
>
> * William Dunlap [2012-08-30 17:35:08 +]:
>
> I don't agree with your analysis of what went wrong with your example
>> a double conversion: from number to string first (by c()) and then back.
I did not make myself quite clear, sorry.
I should have written something like
c(1,2,"a") ==> "1" "2
> * Bert Gunter [2012-08-30 09:59:46 -0700]:
>
> You really should spend a little more time with the docs figuring out
> what R _does_ and a little less complaining about what you think R
> cannot do.
The only thing I think R cannot do is compact its memory, thus,
effectively, leaking it in _some
Hello,
Yet another alternative.
library(plyr)
dfr <- ldply(strsplit(c("a,1", "b,2", "c,3"), ","), identity)
str(dfr)
#dfr$V2 <- as.numeric(dfr$V2)
So, if the op was about conversion to df, the answer is yes.
Rui Barradas
Em 30-08-2012 18:14, David Winsemius escreveu:
On Aug 30, 2012, at 9
,1", and returns a list of vectors of strings,
like list(c("a","1")). The c() function has nothing to do with it.
Functions like read.table() will guess when it is appropriate to convert things
from strings to numbers, but most times you have to do the conversion
explicitl
On Aug 30, 2012, at 9:44 AM, Sam Steingold wrote:
* Sam Steingold [2012-08-30 08:56:17 -0400]:
Is there a way for an apply-type function to return a data frame?
the closest thing I think of is
foo <- as.data.frame(t(sapply(...)))
names(foo) <- c()
alas, this has a problem of creating
?lapply
> z <-data.frame(a=1:3,b=letters[1:3])
> lapply(z,"[",1:2)
$a
[1] 1 2
$b
[1] a b
Levels: a b c
> data.frame(lapply(z,"[",1:2)) ## Is this not what you want?
a b
1 1 a
2 2 b
You really should spend a little more time with the docs figuring out
what R _does_ and a little less complaini
> * Sam Steingold [2012-08-30 08:56:17 -0400]:
>
> Is there a way for an apply-type function to return a data frame?
> the closest thing I think of is
>
> foo <- as.data.frame(t(sapply(...)))
> names(foo) <- c()
alas, this has a problem of creating a "homogeneous" data frame, i.e.,
all th
I forgot to mention data.table package and also function aggregate as part
of base R functions could be useful here
Andrija
On 30 Aug 2012 13:09, "andrija djurovic" wrote:
>
> hi
> try with plyr library and function ddply
>
> Andrija
>
> On 30 Aug 2012 12:58, "Sam Steingold" wrote:
> >
> > Is t
hi
try with plyr library and function ddply
Andrija
On 30 Aug 2012 12:58, "Sam Steingold" wrote:
>
> Is there a way for an apply-type function to return a data frame?
> the closest thing I think of is
>
> foo <- as.data.frame(sapply(...))
> names(foo) <- c()
>
> is there a more "elegant"
Is there a way for an apply-type function to return a data frame?
the closest thing I think of is
foo <- as.data.frame(sapply(...))
names(foo) <- c()
is there a more "elegant" way?
Thanks!
--
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.chil
15 matches
Mail list logo