Thanks you all,
With your recomendations I built my solution as follows:
:> writeLines(c("uno dos tres", "cuatro cinco", "seis"), "tempfile.txt")
:> o <- pipe("wc < tempfile.txt", open="r")
:> readLines(o)
:[1] " 3 6 31"
best regards,
--Sergio.
__
Hi,
If you want to just count the words in R, try this:
vec1<-c("uno dos tres", "cuatro cinco", "seis")
#get individual word count within quotes
res1<-unlist(lapply(strsplit(vec1, " "),length))
res1
#[1] 3 2 1
#get whole word count
length(unlist(strsplit(vec1, " ")))
#[1] 6
- Original Me
On Wed, Sep 12, 2012 at 12:40:54PM -0500, Julio Sergio Santana wrote:
> Hi,
> I'm trying to use pipes in R. By now, I could launch the linux command "wc"
> (to count words from a text), but
> I don't know how to capture the results, say in a vector of chars...
> Here is the R code I'm trying:
>
>
On 12/09/2012 1:40 PM, Julio Sergio Santana wrote:
Hi,
I'm trying to use pipes in R. By now, I could launch the linux command "wc"
(to count words from a text), but
I don't know how to capture the results, say in a vector of chars...
Here is the R code I'm trying:
:> f <- pipe("wc", open="w")
:>
No, this is not what I want, "wc" is just an example. What I want is to
shut a process to do a task outside R, and to
get its results back in R
On Wed, Sep 12, 2012 at 1:07 PM, arun wrote:
> Hi,
>
> If you want to just count the words in R, try this:
> vec1<-c("uno dos tres", "cuatro cinco", "
5 matches
Mail list logo