Re: [R] Text Mining in Non English Speaking Countries

2014-09-24 Thread Flavio Barros
I used already with portuguese. No problems.


Flavio Barros

www.flaviobarros.net
<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.flaviobarros.net&sn=>
[image: Facebook]
<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.facebook.com%2Fflavio.barros.1650%3Fref%3Dtn_tnmn&sn=>
[image:
LinkedIn]
<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.linkedin.com%2Fprofile%2Fview%3Fid%3D61839390%26trk%3Dtab_pro&sn=>
[image:
about.me]
<http://s.wisestamp.com/links?url=http%3A%2F%2Fabout.me%2Fflavio_barros&sn=>
Contact me: [image: Google Talk] flaviomargar...@gmail.com
“"We are not victims by nature...we are programmed to be victims...for good
reason...if we truly embraced our power, we would never be controlled. Live
WISE~" - Gail Blackman
<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.quotesdaddy.com%2Fquote%2F1403644%2Fgail-blackman%2Fwe-are-not-victims-by-naturewe-are-programmed-to-be&sn=>
”  Get this email app!
<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.wisestamp.com%2Fapps%2Fquotes%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_term%3Dquotes%26utm_campaign%3Dapps&sn=>

[image: WordPress Blog Posts]
<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.flaviobarros.net&sn=>My
latest post:Data Preparation – Part II
<http://s.wisestamp.com/links?url=http%3A%2F%2Ffeedproxy.google.com%2F~r%2FFlavioBarros%2F~3%2F9MTu1M40mhE%2F&sn=>
Read more
<http://s.wisestamp.com/links?url=http%3A%2F%2Ffeedproxy.google.com%2F~r%2FFlavioBarros%2F~3%2F9MTu1M40mhE%2F&sn=>
| My blog
<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.flaviobarros.net&sn=>
[image: Share on Facebook]
<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.facebook.com%2Fsharer.php%3Fu%3Dhttp%253A%252F%252Ffeedproxy.google.com%252F~r%252FFlavioBarros%252F~3%252F9MTu1M40mhE%252F&sn=>
[image:
Share on Twitter]
<http://s.wisestamp.com/links?url=https%3A%2F%2Ftwitter.com%2Fintent%2Ftweet%3Ftext%3DData%2520Preparation%2520%25E2%2580%2593%2520Part%2520II%2520%2520(via%2520%2540wisestamp)&sn=>
  Get this email app!
<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.wisestamp.com%2Fapps%2Fwordpress%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_term%3Dwordpress%26utm_campaign%3Dapps&sn=>


<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.linkedin.com%2Fin%2F&sn=>
 Create your free signature:
<http://s.wisestamp.com/links?url=http%3A%2F%2Fr1.wisestamp.com%2Fr%2Flanding%3Fpromo%3D33%26dest%3Dhttp%253A%252F%252Fwww.wisestamp.com%252Femail-install%253Futm_source%253Dextension%2526utm_medium%253Demail%2526utm_campaign%253Dpromo_33&sn=>
CLICK
HERE!
<http://s.wisestamp.com/links?url=http%3A%2F%2Fr1.wisestamp.com%2Fr%2Flanding%3Fpromo%3D33%26amp%3Bdest%3Dhttp%253A%252F%252Fwww.wisestamp.com%252Femail-install%253Futm_source%253Dextension%2526utm_medium%253Demail%2526utm_campaign%253Dpromo_33&sn=>
​

On Wed, Sep 24, 2014 at 8:30 AM,  wrote:

> Hello All,
>
> I am interested in conducting text mining in languages other English.  My
> understanding is the following R packages can analyze alternative (to
> English) languages:
>
>
> 1.   "topicmodels"
>
> 2.   "snowball"
>
> 3.   "tm"
>
> Can anyone confirm?  Specifically, I am interested in Hindi and Chinese (2
> or so most popular dialects).  If so, can you recommend relevant
> documentation and share your experiences with these packages.
>
> Thank you in advance.
>
> Ziad Elmously
>
>
>
>
>
> http://www.kantar.com/disclaimer.html
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Indirect Association Rules

2013-10-07 Thread Flavio Barros
There is some implementation on R for the IDARM algorithm?

http://link.springer.com/chapter/10.1007%2F3-540-32392-9_9#page-1

in fact any implementation of indirect association rules would be
 usefull.

Flavio Barros
[image: 
Facebook]<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.facebook.com%2Fflavio.barros.1650%3Fref%3Dtn_tnmn&sn=>
[image:
LinkedIn]<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.linkedin.com%2Fprofile%2Fview%3Fid%3D61839390%26trk%3Dtab_pro&sn=>
Contact me: [image: Google Talk] flaviomargar...@gmail.com
“"Only as high as I reach can I grow, only as far as I seek can I go, only
as deep as I look can I see, only as much as I dream can I be." -
Karen 
Ravn<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.quotesdaddy.com%2Fquote%2F958812%2Fkaren-ravn%2Fonly-as-high-as-i-reach-can-i-grow-only-as-far-as&sn=>
”  Get this email app!
<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.wisestamp.com%2Fapps%2Fquotes%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_term%3Dquotes%26utm_campaign%3Dapps&sn=>

 Create your free signature:
<http://s.wisestamp.com/links?url=http%3A%2F%2Fr1.wisestamp.com%2Fr%2Flanding%3Fpromo%3D33%26dest%3Dhttp%253A%252F%252Fwww.wisestamp.com%252Femail-install%253Futm_source%253Dextension%2526utm_medium%253Demail%2526utm_campaign%253Dpromo_33&sn=>
CLICK
HERE!<http://s.wisestamp.com/links?url=http%3A%2F%2Fr1.wisestamp.com%2Fr%2Flanding%3Fpromo%3D33%26amp%3Bdest%3Dhttp%253A%252F%252Fwww.wisestamp.com%252Femail-install%253Futm_source%253Dextension%2526utm_medium%253Demail%2526utm_campaign%253Dpromo_33&sn=>


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] transferring a graph from R into word

2013-10-02 Thread Flavio Barros
If you will use the graph on latex i recommend save as pdf. Ex:

pdf(file='graph.pdf')
plot( ... )
dev.off()

and your graph will be saved on the working directory.

For Microsoft Word i prefer png. You can set the resolution to the highest
possible in order to get a resizable figure.


Flavio Barros
[image: 
Facebook]<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.facebook.com%2Fflavio.barros.1650%3Fref%3Dtn_tnmn&sn=>
[image:
LinkedIn]<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.linkedin.com%2Fprofile%2Fview%3Fid%3D61839390%26trk%3Dtab_pro&sn=>
Contact me: [image: Google Talk] flaviomargar...@gmail.com
“"If ever there is tomorrow when we're not together.. there is something
you must always remember. you are braver than you believe, stronger than
you seem, and smarter than you think. but the most important thing is, even
if we're apart.. i'll always be with you." - Winnie the
Pooh<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.quotesdaddy.com%2Fquote%2F280037%2Fwinnie-the-pooh%2Fif-ever-there-is-tomorrow-when-were-not-together-there&sn=>
”  Get this email app!
<http://s.wisestamp.com/links?url=http%3A%2F%2Fwww.wisestamp.com%2Fapps%2Fquotes%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_term%3Dquotes%26utm_campaign%3Dapps&sn=>

 Create your free signature:
<http://s.wisestamp.com/links?url=http%3A%2F%2Fr1.wisestamp.com%2Fr%2Flanding%3Fpromo%3D33%26dest%3Dhttp%253A%252F%252Fwww.wisestamp.com%252Femail-install%253Futm_source%253Dextension%2526utm_medium%253Demail%2526utm_campaign%253Dpromo_33&sn=>
CLICK
HERE!<http://s.wisestamp.com/links?url=http%3A%2F%2Fr1.wisestamp.com%2Fr%2Flanding%3Fpromo%3D33%26amp%3Bdest%3Dhttp%253A%252F%252Fwww.wisestamp.com%252Femail-install%253Futm_source%253Dextension%2526utm_medium%253Demail%2526utm_campaign%253Dpromo_33&sn=>



On Wed, Oct 2, 2013 at 5:36 AM, Rui Barradas  wrote:

> Hello,
>
> Left click on the graph and then on the file menu, choose "save as". You
> will have a choice of graphics file formats. Word accepts several of them,
> so it's up for you to choose. PNG or BMP, for instance.
>
> Hope this helps,
>
> Rui Barradas
>
> Em 02-10-2013 07:32, Charles Thuo escreveu:
>
>  I have been  copying graphs as bitmap image from R by right clicking on
>> them and pasting on word. However this does not seem to be working any
>> more. Is there another way.
>>
>> Charles
>>
>> [[alternative HTML version deleted]]
>>
>> __**
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
> __**
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide http://www.R-project.org/**
> posting-guide.html <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Looping an lapply linear regression function

2013-09-05 Thread Flavio Barros
Hello Arun. Can you provide some data? To help you better i will need a
complete reproducible example ok?


On Thu, Sep 5, 2013 at 1:49 PM, arun  wrote:

> HI,
> May be this helps:
>  set.seed(28)
>  dat1<-
> setNames(as.data.frame(matrix(sample(1:40,10*5,replace=TRUE),ncol=5)),letters[1:5])
> indx<-as.data.frame(combn(names(dat1),2),stringsAsFactors=FALSE)
> res<-t(sapply(indx,function(x)
> {x1<-cbind(dat1[x[1]],dat1[x[2]]);summary(lm(x1[,1]~x1[,2]))$coef[,4]}))
>  rownames(res)<-apply(indx,2,paste,collapse="_")
>  colnames(res)[2]<- "Coef1"
>  head(res,3)
> #(Intercept) Coef1
> #a_b  0.39862676 0.8365606
> #a_c  0.02427885 0.6094141
> #a_d  0.37521423 0.7578723
>
>
> #permutation
> indx2<-expand.grid(names(dat1),names(dat1),stringsAsFactors=FALSE)
> #or
> indx2<- expand.grid(rep(list(names(dat1)),2),stringsAsFactors=FALSE)
> indx2New<- indx2[indx2[,1]!=indx2[,2],]
> res2<-t(sapply(seq_len(nrow(indx2New)),function(i) {x1<- indx2New[i,];
> x2<-cbind(dat1[x1[,1]],dat1[x1[,2]]);summary(lm(x2[,1]~x2[,2]))$coef[,4]}))
> row.names(res2)<-apply(indx2New,1,paste,collapse="_")
>  colnames(res2)<- colnames(res)
>
>
> A.K.
>
>
> Hi everyone,
>
> First off just like to say thanks to everyone´s contributions.
> Up until now, I´ve never had to post as I´ve always found the answers
> from trawling through the database. I´ve finally managed to stump
> myself, and although for someone out there, I´m sure the answer to my
> problem is fairly simple, I, however have spent the whole day infront of
>  my computer struggling. I know I´ll probably get an absolute ribbing
> for making a basic mistake, or not understanding something fully, but
> I´m blind to the mistake now after looking so long at it.
>
> What I´m looking to do, is formulate a matrix ([28,28]) of
> p-values produced from running linear regressions of 28 variables
> against themselves (eg a~b, a~c, a~d.b~a, b~c etc...), if that makes
>  sense. I´ve managed to get this to work if I just input each variable
> by hand, but this isn´t going to help when I have to make 20 matrices.
>
> My script is as follows;
>
>
> for (j in [1:28])
> {
>  ##This section works perfectly, if I don´t try to loop it, I know
> this wont work at the moment, because I haven´t designated what j is,
> but I´m showing to highlight what I´m attempting to do.
>
>
>models <- lapply(varlist, function(x) {
> lm(substitute(ANS ~ i, list(i = as.name(x))), data = con.i)
>   })
>
>   abc<- lapply(models, function(f) summary(f)$coefficients[,4])
>
>   abc<- do.call(rbind, abc)
>
>
>
> }
>
> I get the following error when I try to loop it...
>
> Error in model.frame.default(formula = substitute(j ~ i, list(i = 
> as.name(x))),
>  :
>   variable lengths differ (found for 'ANS') ##ÄNS being my first variable
>
> All variables are of the same length, with 21 recordings for each
>
>
> If anyone can suggest a method of looping, or another means
> or producing ´models´ for each of my 28 variables, without having to do
> it by hand that would be fantastic.
>
> Thanks in advance!!
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to import data from excel to R

2012-11-14 Thread Flavio Barros
Simple:

> install.packages('xlsx')
> setwd('C://) (Define directory with your file)
> data <- read.xlsx('file.xlsx', 1) (Read the first spreed sheet)

On Wed, Nov 14, 2012 at 3:25 PM, jim holtman  wrote:

> Also checkout the XLConnect package since it can read/write EXCEL
> files directly so that you do not have to go through the step of
> creating a CSV file.  Really nice when you want to create an Excel
> file with multiple worksheets containing different phases of your
> analysis.
>
> On Wed, Nov 14, 2012 at 8:45 AM, shwetank  wrote:
> > The simplest way, in my opinion is:
> >>save .xls file as .csv in ms excel "save as" option. csv means comma
> > delimited.
> >>now type following command on R console;
> > >mydata<-read.csv(file.choose())
> >  this will open a dialog box will open and select your .csv
> > file.
> > now the data will be saved as "mydata" is actually a data frame.
> >
> > Enjoy,
> > regards.
> >
> >
> >
> >
> > --
> > View this message in context:
> http://r.789695.n4.nabble.com/how-to-import-data-from-excel-to-R-tp966629p4649487.html
> > Sent from the R help mailing list archive at Nabble.com.
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do it.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Att,

Flávio Barros

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using "apply" instead of "for" loop / multithreading

2012-11-13 Thread Flavio Barros
That worked better because of vectorization, but isn't multithreaded.

To have this resource look at plyr package.

On Mon, Nov 12, 2012 at 9:08 PM, Charles D.  wrote:

> it works really faster !
> thank you
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Using-apply-instead-of-for-loop-multithreading-tp4649326p4649346.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Att,

Flávio Barros

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reshape

2012-11-13 Thread Flavio Barros
I think that the better solution is to use the transform function. Lets
suppose that your data is in table:

> table <- transform(table, n12 = 2400 - n11)

and its done.

On Tue, Nov 13, 2012 at 4:16 AM, arun  wrote:

> Hi,
> You can try this:
> dat1<-read.table(text="
> Rad:0
> Rad1:2
> Rad3:3
> ",sep="",header=FALSE)
>
>
>
>  
> Variable<-do.call(rbind,lapply(strsplit(as.character(dat1[[1]]),split=":"),`[`,1))
> n11<-do.call(rbind,lapply(strsplit(as.character(dat1[[1]]),split=":"),function(x)
> as.numeric(x[2])))
>  n12<-2400-n11
>  dat2<-data.frame(Variable,n11,n12)
>  dat2
> #  Variable n11  n12
> #1  Rad   0 2400
> #2 Rad1   2 2398
> #3 Rad3   3 2397
>  str(dat2)
> #'data.frame':3 obs. of  3 variables:
> # $ Variable: Factor w/ 3 levels "Rad","Rad1","Rad3": 1 2 3
> # $ n11 : num  0 2 3
> # $ n12 : num  2400 2398 2397
>
> #or if you want it as a matrix:
>  newmat<-do.call(rbind,strsplit(as.character(dat1[[1]]),split=":"))
>  n12<-2400-as.numeric(newmat[,2])
>  newmat2<-cbind(newmat,n12)
> colnames(newmat2)[1:2]<-c("Variable","n11")
> A.K.
>
>
>
>
>
>
> - Original Message -
> From: farnoosh sheikhi 
> To: "r-help@R-project.org" 
> Cc:
> Sent: Monday, November 12, 2012 5:52 PM
> Subject: [R] reshape
>
> Hi,
>
> I have a R output that looks as follow:
> Rad:0
> Rad1:2
> Rad3:3
>
> I want to make a new matrix that looks like : sample size is 2400
> Variablen11  n12
> Rad0 2400-0=2400
> Rad1  2   2400-2
> Rad3  3  2400-3
>
> Thanks a lot for your time and help:)
> Best,Farnoosh Sheikhi
> [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Att,

Flávio Barros

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R

2012-11-08 Thread Flavio Barros
Any directory in your computer can store your files. To define the working
directory use:

> setwd('/home/user/')

or

> setwd('C:\\')

and every time you use some function like write.table() you will write
files on that directory.

On Thu, Nov 8, 2012 at 9:14 AM, anna ek  wrote:

>
> Hi!
>
> How Can I create a directory in R to save my files?
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Att,

Flávio Barros

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Opening SAS file using read.sas7bdat() function in sas7bdat library.

2012-10-29 Thread Flavio Barros
I had the same error. I think this package is still experimental.

On Mon, Oct 29, 2012 at 4:28 PM, Praveen Surendran  wrote:

> Hi,
>
>
>
> I have a file in .sas7bdat format. I tried to open this file using
> read.sas7bdat() function.
>
> This gave me an error - "Error in read.sas7bdat("bnp_genetic.sas7bdat") :
>
>   unknown host X64_7PRO".
>
> Could someone tell me what this error means?
>
>
>
> Thank you,
>
>
>
> Praveen.
>
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Att,

Flávio Barros

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Creating a new by variable in a dataframe

2012-10-19 Thread Flavio Barros
I think i have a better solution

*## Example data.frame*
d <- data.frame(stringsAsFactors = FALSE, transaction = c("T01", "T02",
"T03", "T04", "T05", "T06", "T07", "T08", "T09", "T10"),date =
c("2012-10-19", "2012-10-19", "2012-10-19", "2012-10-19", "2012-10-22",
"2012-10-23", "2012-10-23", "2012-10-23", "2012-10-23", "2012-10-23"),time
= c("08:00", "09:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00",
"16:00", "17:00"))

*## As date tranfomation*
d$date <- as.Date(d$date)
d$time <- strptime(d$time, format='%H')

library(reshape)

*## Create factor to split the data*
fdate <- factor(format(d$date, '%D'))

*## Create a list with logical TRUE when is the last transaction*
ex <- sapply(split(d, fdate), function(x)
ifelse(as.numeric(x[,'time'])==max(as.numeric(x[,'time'])),T,F))

*## Coerce to logical vector*
flag <- unlist(rbind(ex))

*## With reshape we have the transform function e can add the flag column *
d <- transform(d, flag = flag)

On Fri, Oct 19, 2012 at 3:51 PM, William Dunlap  wrote:

> Suppose your data frame is
> d <- data.frame(
>  stringsAsFactors = FALSE,
>  transaction = c("T01", "T02", "T03", "T04", "T05", "T06",
> "T07", "T08", "T09", "T10"),
>  date = c("2012-10-19", "2012-10-19", "2012-10-19",
> "2012-10-19", "2012-10-22", "2012-10-23",
> "2012-10-23", "2012-10-23", "2012-10-23",
> "2012-10-23"),
>  time = c("08:00", "09:00", "10:00", "11:00", "12:00",
> "13:00", "14:00", "15:00", "16:00", "17:00"
> ))
> (Convert the date and time to your favorite classes, it doesn't matter
> here.)
>
> A general way to say if an item is the last of its group is:
>   isLastInGroup <- function(...)  ave(logical(length(..1)), ...,
> FUN=function(x)seq_along(x)==length(x))
>   is_last_of_dayA <- with(d, isLastInGroup(date))
> If you know your data is sorted by date you could save a little time for
> large
> datasets by using
>   isLastInRun <- function(x) c(x[-1] != x[-length(x)], TRUE)
>   is_last_of_dayB <- isLastInRun(d$date)
> The above d is sorted by date so you get the same results for both:
>   > cbind(d, is_last_of_dayA, is_last_of_dayB)
>  transaction   date  time is_last_of_dayA is_last_of_dayB
>   1  T01 2012-10-19 08:00   FALSE   FALSE
>   2  T02 2012-10-19 09:00   FALSE   FALSE
>   3  T03 2012-10-19 10:00   FALSE   FALSE
>   4  T04 2012-10-19 11:00TRUETRUE
>   5  T05 2012-10-22 12:00TRUETRUE
>   6  T06 2012-10-23 13:00   FALSE   FALSE
>   7  T07 2012-10-23 14:00   FALSE   FALSE
>   8  T08 2012-10-23 15:00   FALSE   FALSE
>   9  T09 2012-10-23 16:00   FALSE   FALSE
>   10 T10 2012-10-23 17:00TRUETRUE
>
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf
> > Of ramoss
> > Sent: Friday, October 19, 2012 10:52 AM
> > To: r-help@r-project.org
> > Subject: [R] Creating a new by variable in a dataframe
> >
> > Hello,
> >
> > I have a dataframe w/ 3 variables of interest: transaction,date(tdate) &
> > time(event_tim).
> > How could I create a 4th variable (last_trans) that would flag the last
> > transaction of the day for each day?
> > In SAS I use:
> > proc sort data=all6;
> > by tdate event_tim;
> > run;
> >  /*Create last transaction flag per day*/
> > data all6;
> >   set all6;
> >   by tdate event_tim;
> >   last_trans=last.tdate;
> >
> > Thanks ahead for any suggestions.
> >
> >
> >
> > --
> > View this message in context:
> http://r.789695.n4.nabble.com/Creating-a-new-by-
> > variable-in-a-dataframe-tp4646782.html
> > Sent from the R help mailing list archive at Nabble.com.
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Att,

Flávio Barros

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] multiple graphs, lapply and different titles

2012-10-19 Thread Flavio Barros
I have a list of data.frames, and i want to iterate over this list and
generate graphs with the same title of the data.frame.

I did the graphs with:

lapply(anual, function(x) plot(x[,'chuva'], type='l', xlab= 'anos', ylab =
'Precicipatação(mm)', col='red'))

where anual is list of data.frames. I am plotting just the column "chuva"
at each data.frame.

How can i do that?

-- 
Att,

Flávio Barros

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] predictive apriori

2011-11-11 Thread Flavio Barros
Dear list members,

I know that there is the arules package with the implementation of the
apriori algorithm. However i want to use the "predictive apriori" instead.
These algorithm can mine as rules as i want and there is an implementation
on weka.

There is some implementation on R?

-- 
Att,

Flávio Barros

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.