Re: [R] Quotes

2015-11-11 Thread PIKAL Petr
Hi

Can you explain little bit more about your intention?

Here is some explanation about quotes

https://stat.ethz.ch/R-manual/R-devel/library/base/html/Quotes.html

http://stackoverflow.com/questions/13449233/send-a-text-string-containing-double-quotes-to-function

You could find it yourself easily by internet search as I did.

If this is not what you want, you need to be more specific.

Cheers
Petr


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Daniel
> Wiegert
> Sent: Thursday, November 12, 2015 3:55 AM
> To: r-help@r-project.org
> Subject: [R] Quotes
>
> Hello, I am trying to use a code which requires quotes around each of
> about 1000 entries. When I did this in Microsoft programs, R rejected
> every quote. I converted the font to courier new size 10 true type (the
> R default). No luck. I had to find a sample code and copy the quotes
> from that 2000 times for R to accept them, or type them in manually in
> R.
>
> Is there anyway to make this easier? What font in Word/Excel etc. does
> R prefer and will function using quotes? Commas, letters, numbers, all
> work, just the full double quotes won't work.
>
> Thank you,
>
> Daniel
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] seconds to h:m:s format

2015-11-11 Thread Jim Lemon
Any date would do as you are only getting the H:M:S at the end. I just
chose the zero date.

Jim


On Thu, Nov 12, 2015 at 1:25 PM, Omar André Gonzáles Díaz <
oma.gonza...@gmail.com> wrote:

> Thank you, Jim.
>
> Just to understand it:
>
> You replicated 10 times: "1970-01-01". Why this specific date?
>
>
>
>
>
> 2015-11-11 20:22 GMT-05:00 Jim Lemon :
>
>> Hi Omar,
>> There is some sort of error in your structure definition, but the
>> following works for me:
>>
>> session.duration.fuente <-
>>  data.frame(mes=c(rep("oct",5),rep("nov",5)),
>>   fuente=c("adwords", "directo", "organico", "redes sociales",
>>"referral", "adwords", "directo", "organico", "redes sociales",
>>"referral"),
>>   avg.session.duration = c(970178, 1642455, 780485,
>>3170400, 179184, 352995, 833827, 260610, 2318928, 49836))
>>
>> base_dates<-strptime(rep("1970-01-01",10),"%Y-%m-%d")
>> format(base_dates+session.duration.fuente$avg.session.duration,"%H:%M:%S")
>>  [1] "05:29:38" "00:14:15" "00:48:05" "16:40:00" "01:46:24" "02:03:15"
>>  [7] "15:37:07" "00:23:30" "20:08:48" "13:50:36"
>>
>> Jim
>>
>> On Thu, Nov 12, 2015 at 10:15 AM, Omar André Gonzáles Díaz <
>> oma.gonza...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I've a data frame with 3 columns: "mes", "fuente",
>>> "avg.sessions.duration".
>>>
>>> "avg.sessions.duration" is a column containing seconds.
>>>
>>> I need you help with:
>>>
>>> 1.-  Help to put these values in "h:m:s" format.
>>> .
>>>
>>> ===
>>>
>>> I've found this german page:
>>>
>>> http://forum.r-statistik.de/viewtopic.php?f=25&t=5284
>>>
>>> So I've tried:
>>>
>>> for (i in 1:nrow(session.duration.fuente)) {
>>>
>>>   session.duration.fuente$avg.session.duration <-
>>> format(as.POSIXct('0001-01-01 00:00:00') +
>>> session.duration.fuente$avg.session.duration[i], "%H:%M:%S")
>>>
>>> }
>>>
>>> but got this error:
>>>
>>>  Error in unclass(e1) + unclass(e2) :
>>>   non-numeric argument to binary operator
>>>
>>> ===
>>>
>>> After that I've tried: strptime:
>>>
>>> session.duration.fuente$avg.session.duration <-
>>> strptime(session.duration.fuente$avg.session.duration, "%H:%M:%OS")
>>>
>>> But got NAs.
>>>
>>> 
>>>
>>> Here is the data:
>>>
>>>
>>> session.duration.fuente <- structure(list(mes = structure(c(1L, 1L, 1L,
>>> 1L,
>>> 1L, 2L, 2L,
>>> 2L, 2L, 2L), .Label = c("oct", "nov"), class = c("ordered", "factor"
>>> )), fuente = c("adwords", "directo", "organico", "redes sociales",
>>> "referral", "adwords", "directo", "organico", "redes sociales",
>>> "referral"), avg.session.duration = c(970178, 1642455, 780485,
>>> 3170400, 179184, 352995, 833827, 260610, 2318928, 49836)), row.names =
>>> c(NA,
>>> -10L), class = c("grouped_df", "tbl_df", "tbl", "data.frame"), vars =
>>> list(
>>> mes), drop = TRUE, .Names = c("mes", "fuente", "avg.session.duration"
>>> ))
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> 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 -- To UNSUBSCRIBE and more, see
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] Quotes

2015-11-11 Thread David Winsemius

> On Nov 11, 2015, at 6:54 PM, Daniel Wiegert  wrote:
> 
> Hello, I am trying to use a code which requires quotes around each of about 
> 1000 entries. When I did this

The use of pronouns in place of code is a major cause of ambiguity. What was … 
“this”?


> in Microsoft programs, R rejected every quote.

Again. the phrase "R rejected” is completely ambiguous. Did you see an error 
message after you did . If so, please offer up for examination both 
the  and the error message.


> I converted the font to courier new size 10 true type (the R default). No 
> luck. I had to find a sample code and copy the quotes from that 2000 times 
> for R to accept them, or type them in manually in R. 

Word typically uses smart quotes rather than either the single-quote or 
double-quotes. You can change this behavior in Word by changing the 
preferences. But you really should not be using Word for either data entry or 
for code.

> 
> Is there anyway to make this easier? What font in Word/Excel etc. does R 
> prefer and will function using quotes? Commas, letters, numbers, all work, 
> just the full double quotes won't work. 

As above. The “quotes” that Word uses are not shared by most codign platforms.

> 
> Thank you,
> 
> Daniel
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Plot with pauses?

2015-11-11 Thread David Winsemius

> On Nov 11, 2015, at 9:30 PM, Judson  wrote:
> 
> I'm trying to create a 
> series of demos for students.  
> 
> It would be helpful
> if plotted data points
> could appear one by one
> with, say, half-second delays 
> between points.  
> 

?Sys.sleep


> For instance, 
> code like this
> 
> v<-0:60
> z<-3/5+4i/5
> t<-z^(v/9)
> plot(Re(t),Im(t))

If you want to plot points then use:

?points


> 
> would be better if I 
> could invoke some 
> pausing between points 
> so the student could see
> the progression of 
> the process.  Many 
> mathematical progressions 
> might be more understandable
> if the viewer could see
> this happen over intervals
> of time.   
> 
> Naturally I'd like to 
> avoid for loops if that's 
> possible.  
> 
> I really don't know
> where to start my 
> search.   Any suggestions?  
> 
> . judson blake  
>   [[alternative HTML version deleted]]
> 


David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Problem with Downloading TRMM

2015-11-11 Thread Eliza Botto
Dear Users of R,
I have this following confusion.
I want to download 3 hourly TRMM data from NASA website by using R, from the 
following website


##main Link
http://giovanni.gsfc.nasa.gov/giovanni/#service=ArAvTs&starttime=2008-12-31T00:00:00Z&endtime=2009-12-31T23:59:59Z&bbox=67,-50,67,-50&data=TRMM_3B42_007_precipitation
##the link allows to download data either in CSV format or png format. I prefer 
CSV format. The exact link to CSV file is
#Download link
http://giovanni.gsfc.nasa.gov/giovanni/daac-bin/serializer.pl?SESSION=BBF227CA-88F9-11E5-9F55-BE455C2ADB03:BBC3D554-88FA-11E5-BA70-60705B2ADB03:BBC8D64E-88FA-11E5-BA70-60705B2ADB03&FILE=g4.areaAvgTimeSeries.TRMM_3B42_007_precipitation.20081231-20091231.67E_50S_67E_50S.nc

In main link "bbox=67,-50,67,-50" shows the point where I want to download the 
data in the form of CSV file. The problem is that I have a vector of such 
points, a small part of which is below
structure(c(72, 71, 54, 67, 50, 53, 30, -50), .Dim = c(4L, 2L), .Dimnames = 
list(c("d", "e", "f", "g"), NULL))
How can I make a loop to download the data on given points automatically?

N.B.
It was fairly easy to download it, a few months ago. But ever since the outlook 
of website is changed. I cant use the previous codes that I use to use to 
download data.
The previous codes are
##

setwd("C:\\Users\\Eliza\\Desktop\\hrly")

A few coordinates from the sample where I want to download data.

df2 <- data.frame(Longitude = c(45.75,46.25,46.75,), Latitude = 
c(34.75,34.25,33.75)) 

urlPattern1<-("http://disc2.nascom.nasa.gov/daac-bin/Giovanni/tovas/Giovanni_cgi.pl?west=%s&north=%s&east=%s&south=%s¶ms=1%%7C3B42_V7&plot_type=Time+Plot&byr=1998&bmo=01&bdy=1&bhr=00&eyr=1998&emo=12&edy=31&ehr=21&begin_date=1998%%2F01%%2F01%%2F00&end_date=2014%%2F02%%2F28%%2F21&cbar=cdyn&cmin=&cmax=&yaxis=ydyn&ymin=&ymax=&yint=&ascres=0.25x0.25&global_cfg=tovas.global.cfg.pl&instance_id=TRMM_V7&prod_id=3B42&action=ASCII+Output";)


fileDestination <- c("C:\\Users\\Eliza\\Desktop\\hrly") 
fileNames <- paste("precip", df2[,1], df2[,2], sep = "_")
 fileNames <- paste(fileNames, "txt", sep = ".")
 files <- file.path(fileDestination, fileNames) for (i in 1:nrow(df2)){
queryUrl <- sprintf(urlPattern1, df2[i, 1], df2[i, 2], df2[i, 1], df2[i, 2])
download.file(queryUrl, files[i])}
 ## import data in first file 
precip <- read.table(files[1], skip = 4, header = TRUE, na.strings = 
"-9990649570314828644352.",sep = "", 
check.names = FALSE, stringsAsFactors = FALSE) 
head(precip,2) 
Kindly help me out on it.
Thankyou very much in advance.
  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Quotes

2015-11-11 Thread Daniel Wiegert
Hello, I am trying to use a code which requires quotes around each of about 
1000 entries. When I did this in Microsoft programs, R rejected every quote. I 
converted the font to courier new size 10 true type (the R default). No luck. I 
had to find a sample code and copy the quotes from that 2000 times for R to 
accept them, or type them in manually in R. 

Is there anyway to make this easier? What font in Word/Excel etc. does R prefer 
and will function using quotes? Commas, letters, numbers, all work, just the 
full double quotes won't work. 

Thank you,

Daniel
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Plot with pauses?

2015-11-11 Thread Judson
I'm trying to create a 
series of demos for students.  

It would be helpful
if plotted data points
could appear one by one
with, say, half-second delays 
between points.  
 
For instance, 
code like this

v<-0:60
z<-3/5+4i/5
t<-z^(v/9)
plot(Re(t),Im(t))

would be better if I 
could invoke some 
pausing between points 
so the student could see
the progression of 
the process.  Many 
mathematical progressions 
might be more understandable
if the viewer could see
this happen over intervals
of time.   

Naturally I'd like to 
avoid for loops if that's 
possible.  

I really don't know
where to start my 
search.   Any suggestions?  

. judson blake
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Calculating distance between words in string

2015-11-11 Thread Jim Lemon
Perhaps what you are seeking is a sparse distance matrix.

"How far is each word from every other matching word"

sentence<-"How far is each word from every other matching word"
words<-tolower(unlist(strsplit(sentence," ")))
nwords<-length(words)
wdm<-matrix(NA,nrow=nwords,ncol=nwords)
for(word in 1:nwords) {
 wordmatch<-grep(words[word],words,fixed=TRUE)
 wdm[word,wordmatch]<-wordmatch-word
}
rownames(wdm)<-colnames(wdm)<-words
wdm

The result contains zeros for a self-match, relative positions for the
desired matches and NA for non-matches.

Jim



On Thu, Nov 12, 2015 at 12:15 AM, S Ellison  wrote:

> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Karl
> > Subject: [R] Calculating distance between words in string
> >
> > .. given a specific keyword, I need to assign labels to the other words
> > based on the distance (number of words) to this keyword.
> >
> >...
> > If the sentence contains more than one instance of the keyword, I need
> values
> > for each instance.
>
> What would you like to happen when the sentence contains more than one
> instance of other words and more than one instance of both?
>
> e.g. what output do you want from
> " amet is not the only instance of 'amet', and there is more than one
> instance of 'instance', 'is', 'of' and 'and'."
>
>
> S Ellison
>
>
> ***
> This email and any attachments are confidential. Any u...{{dropped:13}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Cleaning

2015-11-11 Thread Boris Steipe
If what you posted here is what you typed, your syntax is wrong.
I strongly advise you to consult the two links here:

http://adv-r.had.co.nz/Reproducibility.html
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
... and please read the posting guide and don't post in HTML.


B.


On Nov 11, 2015, at 10:03 PM, Ashta  wrote:

> Sarah,
> 
> Thank you very much.   For the other variables
> I was trying to do the same job in different way because it is easier to
> list it
> 
> Example
> 
> test < which(dat$var1  !="BAA" | dat$var1 !="FAG" )
> {
>dat <- dat[-test,]}   and I did not get the  right result. What am I
> missing here?
> 
> 
> 
> 
> 
> On Wed, Nov 11, 2015 at 7:54 PM, Sarah Goslee 
> wrote:
> 
>> On Wed, Nov 11, 2015 at 8:44 PM, Ashta  wrote:
>>> Hi Sarah,
>>> 
>>> I used the following to clean my data, the program crushed several times.
>>> 
>>> test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
>>> 
>>> What is the difference between these two
>>> 
>>> test <- dat[dat$Var1  %in% "YYZ" | dat$Var1 %in% "MSN" ,]
>> 
>> Besides that you're using %in% wrong? I told you how to proceed.
>> 
>> myvalues <- c("YYZ", "MSN")
>> 
>> test <- subset(dat, Var1 %in% myvalues)
>> 
>> 
>>> subset(dat, Var1 %in% myvalues)
>>  X Var1 Freq
>> 3 3  MSN 1040
>> 4 4  YYZ  300
>> 
>>> 
>>> 
>>> 
>>> 
>>> On Wed, Nov 11, 2015 at 6:38 PM, Sarah Goslee 
>>> wrote:
 
 Please keep replies on the list so others may participate in the
 conversation.
 
 If you have a character vector containing the potential values, you
 might look at %in% for one approach to subsetting your data.
 
 Var1 %in% myvalues
 
 Sarah
 
 On Wed, Nov 11, 2015 at 7:10 PM, Ashta  wrote:
> Thank you Sarah for your prompt response!
> 
> I have the list of values of the variable Var1 it is around 20.
> How can I modify this one to include all the 20 valid values?
> 
> test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
> 
> Is there a way (efficient )  of doing it?
> 
> Thank you again
> 
> 
> 
> On Wed, Nov 11, 2015 at 6:02 PM, Sarah Goslee >> 
> wrote:
>> 
>> Hi,
>> 
>> On Wed, Nov 11, 2015 at 6:51 PM, Ashta  wrote:
>>> Hi all,
>>> 
>>> I have a data frame with  huge rows and columns.
>>> 
>>> When I looked at the data,  it has several garbage values need to
>> be
>>> 
>>> cleaned. For a sample I am showing you the frequency distribution
>>> of one variables
>>> 
>>>Var1 Freq
>>> 1:3
>>> 2]6
>>> 3MSN 1040
>>> 4YYZ  300
>>> 5\\4
>>> 6+ 3
>>> 7.   ?>   15
>> 
>> Please use dput() to provide your data. I made a guess at what you
>> had
>> in R, but could be wrong.
>> 
>> 
>>> and continues.
>>> 
>>> I want to keep those rows that contain only a valid variable value
>>> 
>>> In this  case MSN and YYZ. I tried the following
>>> 
>>> *test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]*
>>> 
>>> but I am not getting the desired result.
>> 
>> What are you getting? How does it differ from the desired result?
>> 
>>> I have
>>> 
>>> Any help or idea?
>> 
>> I get:
>> 
>>> dat <- structure(list(X = 1:7, Var1 = c(":", "]", "MSN", "YYZ",
>>> "",
>> + "+", "?>"), Freq = c(3L, 6L, 1040L, 300L, 4L, 3L, 15L)), .Names =
>> c("X",
>> + "Var1", "Freq"), class = "data.frame", row.names = c(NA, -7L))
>>> 
>>> test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
>>> test
>>  X Var1 Freq
>> 3 3  MSN 1040
>> 4 4  YYZ  300
>> 
>> Which seems reasonable to me.
>> 
>> 
>>> 
>>>[[alternative HTML version deleted]]
>> 
>> Please don't post in HTML either: it introduces all sorts of errors
>> to
>> your message.
>> 
>> Sarah
>> 
>>> 
>>> 
>> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Cleaning

2015-11-11 Thread Ashta
Sarah,

Thank you very much.   For the other variables
I was trying to do the same job in different way because it is easier to
list it

Example

test < which(dat$var1  !="BAA" | dat$var1 !="FAG" )
 {
dat <- dat[-test,]}   and I did not get the  right result. What am I
missing here?





On Wed, Nov 11, 2015 at 7:54 PM, Sarah Goslee 
wrote:

> On Wed, Nov 11, 2015 at 8:44 PM, Ashta  wrote:
> > Hi Sarah,
> >
> > I used the following to clean my data, the program crushed several times.
> >
> > test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
> >
> > What is the difference between these two
> >
> > test <- dat[dat$Var1  %in% "YYZ" | dat$Var1 %in% "MSN" ,]
>
> Besides that you're using %in% wrong? I told you how to proceed.
>
> myvalues <- c("YYZ", "MSN")
>
> test <- subset(dat, Var1 %in% myvalues)
>
>
> > subset(dat, Var1 %in% myvalues)
>   X Var1 Freq
> 3 3  MSN 1040
> 4 4  YYZ  300
>
> >
> >
> >
> >
> > On Wed, Nov 11, 2015 at 6:38 PM, Sarah Goslee 
> > wrote:
> >>
> >> Please keep replies on the list so others may participate in the
> >> conversation.
> >>
> >> If you have a character vector containing the potential values, you
> >> might look at %in% for one approach to subsetting your data.
> >>
> >> Var1 %in% myvalues
> >>
> >> Sarah
> >>
> >> On Wed, Nov 11, 2015 at 7:10 PM, Ashta  wrote:
> >> > Thank you Sarah for your prompt response!
> >> >
> >> > I have the list of values of the variable Var1 it is around 20.
> >> > How can I modify this one to include all the 20 valid values?
> >> >
> >> > test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
> >> >
> >> > Is there a way (efficient )  of doing it?
> >> >
> >> > Thank you again
> >> >
> >> >
> >> >
> >> > On Wed, Nov 11, 2015 at 6:02 PM, Sarah Goslee  >
> >> > wrote:
> >> >>
> >> >> Hi,
> >> >>
> >> >> On Wed, Nov 11, 2015 at 6:51 PM, Ashta  wrote:
> >> >> > Hi all,
> >> >> >
> >> >> > I have a data frame with  huge rows and columns.
> >> >> >
> >> >> > When I looked at the data,  it has several garbage values need to
> be
> >> >> >
> >> >> > cleaned. For a sample I am showing you the frequency distribution
> >> >> > of one variables
> >> >> >
> >> >> > Var1 Freq
> >> >> > 1:3
> >> >> > 2]6
> >> >> > 3MSN 1040
> >> >> > 4YYZ  300
> >> >> > 5\\4
> >> >> > 6+ 3
> >> >> > 7.   ?>   15
> >> >>
> >> >> Please use dput() to provide your data. I made a guess at what you
> had
> >> >> in R, but could be wrong.
> >> >>
> >> >>
> >> >> > and continues.
> >> >> >
> >> >> > I want to keep those rows that contain only a valid variable value
> >> >> >
> >> >> > In this  case MSN and YYZ. I tried the following
> >> >> >
> >> >> > *test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]*
> >> >> >
> >> >> > but I am not getting the desired result.
> >> >>
> >> >> What are you getting? How does it differ from the desired result?
> >> >>
> >> >> >  I have
> >> >> >
> >> >> > Any help or idea?
> >> >>
> >> >> I get:
> >> >>
> >> >> > dat <- structure(list(X = 1:7, Var1 = c(":", "]", "MSN", "YYZ",
> >> >> > "",
> >> >> + "+", "?>"), Freq = c(3L, 6L, 1040L, 300L, 4L, 3L, 15L)), .Names =
> >> >> c("X",
> >> >> + "Var1", "Freq"), class = "data.frame", row.names = c(NA, -7L))
> >> >> >
> >> >> > test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
> >> >> > test
> >> >>   X Var1 Freq
> >> >> 3 3  MSN 1040
> >> >> 4 4  YYZ  300
> >> >>
> >> >> Which seems reasonable to me.
> >> >>
> >> >>
> >> >> >
> >> >> > [[alternative HTML version deleted]]
> >> >>
> >> >> Please don't post in HTML either: it introduces all sorts of errors
> to
> >> >> your message.
> >> >>
> >> >> Sarah
> >> >>
> >
> >
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] seconds to h:m:s format

2015-11-11 Thread Omar André Gonzáles Díaz
Thank you, Jim.

Just to understand it:

You replicated 10 times: "1970-01-01". Why this specific date?





2015-11-11 20:22 GMT-05:00 Jim Lemon :

> Hi Omar,
> There is some sort of error in your structure definition, but the
> following works for me:
>
> session.duration.fuente <-
>  data.frame(mes=c(rep("oct",5),rep("nov",5)),
>   fuente=c("adwords", "directo", "organico", "redes sociales",
>"referral", "adwords", "directo", "organico", "redes sociales",
>"referral"),
>   avg.session.duration = c(970178, 1642455, 780485,
>3170400, 179184, 352995, 833827, 260610, 2318928, 49836))
>
> base_dates<-strptime(rep("1970-01-01",10),"%Y-%m-%d")
> format(base_dates+session.duration.fuente$avg.session.duration,"%H:%M:%S")
>  [1] "05:29:38" "00:14:15" "00:48:05" "16:40:00" "01:46:24" "02:03:15"
>  [7] "15:37:07" "00:23:30" "20:08:48" "13:50:36"
>
> Jim
>
> On Thu, Nov 12, 2015 at 10:15 AM, Omar André Gonzáles Díaz <
> oma.gonza...@gmail.com> wrote:
>
>> Hi,
>>
>> I've a data frame with 3 columns: "mes", "fuente",
>> "avg.sessions.duration".
>>
>> "avg.sessions.duration" is a column containing seconds.
>>
>> I need you help with:
>>
>> 1.-  Help to put these values in "h:m:s" format.
>> .
>>
>> ===
>>
>> I've found this german page:
>>
>> http://forum.r-statistik.de/viewtopic.php?f=25&t=5284
>>
>> So I've tried:
>>
>> for (i in 1:nrow(session.duration.fuente)) {
>>
>>   session.duration.fuente$avg.session.duration <-
>> format(as.POSIXct('0001-01-01 00:00:00') +
>> session.duration.fuente$avg.session.duration[i], "%H:%M:%S")
>>
>> }
>>
>> but got this error:
>>
>>  Error in unclass(e1) + unclass(e2) :
>>   non-numeric argument to binary operator
>>
>> ===
>>
>> After that I've tried: strptime:
>>
>> session.duration.fuente$avg.session.duration <-
>> strptime(session.duration.fuente$avg.session.duration, "%H:%M:%OS")
>>
>> But got NAs.
>>
>> 
>>
>> Here is the data:
>>
>>
>> session.duration.fuente <- structure(list(mes = structure(c(1L, 1L, 1L,
>> 1L,
>> 1L, 2L, 2L,
>> 2L, 2L, 2L), .Label = c("oct", "nov"), class = c("ordered", "factor"
>> )), fuente = c("adwords", "directo", "organico", "redes sociales",
>> "referral", "adwords", "directo", "organico", "redes sociales",
>> "referral"), avg.session.duration = c(970178, 1642455, 780485,
>> 3170400, 179184, 352995, 833827, 260610, 2318928, 49836)), row.names =
>> c(NA,
>> -10L), class = c("grouped_df", "tbl_df", "tbl", "data.frame"), vars =
>> list(
>> mes), drop = TRUE, .Names = c("mes", "fuente", "avg.session.duration"
>> ))
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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 -- To UNSUBSCRIBE and more, see
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] Cleaning

2015-11-11 Thread Sarah Goslee
On Wed, Nov 11, 2015 at 8:44 PM, Ashta  wrote:
> Hi Sarah,
>
> I used the following to clean my data, the program crushed several times.
>
> test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
>
> What is the difference between these two
>
> test <- dat[dat$Var1  %in% "YYZ" | dat$Var1 %in% "MSN" ,]

Besides that you're using %in% wrong? I told you how to proceed.

myvalues <- c("YYZ", "MSN")

test <- subset(dat, Var1 %in% myvalues)


> subset(dat, Var1 %in% myvalues)
  X Var1 Freq
3 3  MSN 1040
4 4  YYZ  300

>
>
>
>
> On Wed, Nov 11, 2015 at 6:38 PM, Sarah Goslee 
> wrote:
>>
>> Please keep replies on the list so others may participate in the
>> conversation.
>>
>> If you have a character vector containing the potential values, you
>> might look at %in% for one approach to subsetting your data.
>>
>> Var1 %in% myvalues
>>
>> Sarah
>>
>> On Wed, Nov 11, 2015 at 7:10 PM, Ashta  wrote:
>> > Thank you Sarah for your prompt response!
>> >
>> > I have the list of values of the variable Var1 it is around 20.
>> > How can I modify this one to include all the 20 valid values?
>> >
>> > test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
>> >
>> > Is there a way (efficient )  of doing it?
>> >
>> > Thank you again
>> >
>> >
>> >
>> > On Wed, Nov 11, 2015 at 6:02 PM, Sarah Goslee 
>> > wrote:
>> >>
>> >> Hi,
>> >>
>> >> On Wed, Nov 11, 2015 at 6:51 PM, Ashta  wrote:
>> >> > Hi all,
>> >> >
>> >> > I have a data frame with  huge rows and columns.
>> >> >
>> >> > When I looked at the data,  it has several garbage values need to be
>> >> >
>> >> > cleaned. For a sample I am showing you the frequency distribution
>> >> > of one variables
>> >> >
>> >> > Var1 Freq
>> >> > 1:3
>> >> > 2]6
>> >> > 3MSN 1040
>> >> > 4YYZ  300
>> >> > 5\\4
>> >> > 6+ 3
>> >> > 7.   ?>   15
>> >>
>> >> Please use dput() to provide your data. I made a guess at what you had
>> >> in R, but could be wrong.
>> >>
>> >>
>> >> > and continues.
>> >> >
>> >> > I want to keep those rows that contain only a valid variable value
>> >> >
>> >> > In this  case MSN and YYZ. I tried the following
>> >> >
>> >> > *test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]*
>> >> >
>> >> > but I am not getting the desired result.
>> >>
>> >> What are you getting? How does it differ from the desired result?
>> >>
>> >> >  I have
>> >> >
>> >> > Any help or idea?
>> >>
>> >> I get:
>> >>
>> >> > dat <- structure(list(X = 1:7, Var1 = c(":", "]", "MSN", "YYZ",
>> >> > "",
>> >> + "+", "?>"), Freq = c(3L, 6L, 1040L, 300L, 4L, 3L, 15L)), .Names =
>> >> c("X",
>> >> + "Var1", "Freq"), class = "data.frame", row.names = c(NA, -7L))
>> >> >
>> >> > test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
>> >> > test
>> >>   X Var1 Freq
>> >> 3 3  MSN 1040
>> >> 4 4  YYZ  300
>> >>
>> >> Which seems reasonable to me.
>> >>
>> >>
>> >> >
>> >> > [[alternative HTML version deleted]]
>> >>
>> >> Please don't post in HTML either: it introduces all sorts of errors to
>> >> your message.
>> >>
>> >> Sarah
>> >>
>
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Cleaning

2015-11-11 Thread Ashta
Hi Sarah,

I used the following to clean my data, the program crushed several times.


*test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]*



*What is the difference between these two**test <- dat[dat$Var1
**%in% "YYZ" | dat$Var1** %in% "MSN" ,]*




On Wed, Nov 11, 2015 at 6:38 PM, Sarah Goslee 
wrote:

> Please keep replies on the list so others may participate in the
> conversation.
>
> If you have a character vector containing the potential values, you
> might look at %in% for one approach to subsetting your data.
>
> Var1 %in% myvalues
>
> Sarah
>
> On Wed, Nov 11, 2015 at 7:10 PM, Ashta  wrote:
> > Thank you Sarah for your prompt response!
> >
> > I have the list of values of the variable Var1 it is around 20.
> > How can I modify this one to include all the 20 valid values?
> >
> > test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
> >
> > Is there a way (efficient )  of doing it?
> >
> > Thank you again
> >
> >
> >
> > On Wed, Nov 11, 2015 at 6:02 PM, Sarah Goslee 
> > wrote:
> >>
> >> Hi,
> >>
> >> On Wed, Nov 11, 2015 at 6:51 PM, Ashta  wrote:
> >> > Hi all,
> >> >
> >> > I have a data frame with  huge rows and columns.
> >> >
> >> > When I looked at the data,  it has several garbage values need to be
> >> >
> >> > cleaned. For a sample I am showing you the frequency distribution
> >> > of one variables
> >> >
> >> > Var1 Freq
> >> > 1:3
> >> > 2]6
> >> > 3MSN 1040
> >> > 4YYZ  300
> >> > 5\\4
> >> > 6+ 3
> >> > 7.   ?>   15
> >>
> >> Please use dput() to provide your data. I made a guess at what you had
> >> in R, but could be wrong.
> >>
> >>
> >> > and continues.
> >> >
> >> > I want to keep those rows that contain only a valid variable value
> >> >
> >> > In this  case MSN and YYZ. I tried the following
> >> >
> >> > *test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]*
> >> >
> >> > but I am not getting the desired result.
> >>
> >> What are you getting? How does it differ from the desired result?
> >>
> >> >  I have
> >> >
> >> > Any help or idea?
> >>
> >> I get:
> >>
> >> > dat <- structure(list(X = 1:7, Var1 = c(":", "]", "MSN", "YYZ",
> "",
> >> + "+", "?>"), Freq = c(3L, 6L, 1040L, 300L, 4L, 3L, 15L)), .Names =
> c("X",
> >> + "Var1", "Freq"), class = "data.frame", row.names = c(NA, -7L))
> >> >
> >> > test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
> >> > test
> >>   X Var1 Freq
> >> 3 3  MSN 1040
> >> 4 4  YYZ  300
> >>
> >> Which seems reasonable to me.
> >>
> >>
> >> >
> >> > [[alternative HTML version deleted]]
> >>
> >> Please don't post in HTML either: it introduces all sorts of errors to
> >> your message.
> >>
> >> Sarah
> >>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] seconds to h:m:s format

2015-11-11 Thread Jim Lemon
Hi Omar,
There is some sort of error in your structure definition, but the following
works for me:

session.duration.fuente <-
 data.frame(mes=c(rep("oct",5),rep("nov",5)),
  fuente=c("adwords", "directo", "organico", "redes sociales",
   "referral", "adwords", "directo", "organico", "redes sociales",
   "referral"),
  avg.session.duration = c(970178, 1642455, 780485,
   3170400, 179184, 352995, 833827, 260610, 2318928, 49836))

base_dates<-strptime(rep("1970-01-01",10),"%Y-%m-%d")
format(base_dates+session.duration.fuente$avg.session.duration,"%H:%M:%S")
 [1] "05:29:38" "00:14:15" "00:48:05" "16:40:00" "01:46:24" "02:03:15"
 [7] "15:37:07" "00:23:30" "20:08:48" "13:50:36"

Jim

On Thu, Nov 12, 2015 at 10:15 AM, Omar André Gonzáles Díaz <
oma.gonza...@gmail.com> wrote:

> Hi,
>
> I've a data frame with 3 columns: "mes", "fuente", "avg.sessions.duration".
>
> "avg.sessions.duration" is a column containing seconds.
>
> I need you help with:
>
> 1.-  Help to put these values in "h:m:s" format.
> .
>
> ===
>
> I've found this german page:
>
> http://forum.r-statistik.de/viewtopic.php?f=25&t=5284
>
> So I've tried:
>
> for (i in 1:nrow(session.duration.fuente)) {
>
>   session.duration.fuente$avg.session.duration <-
> format(as.POSIXct('0001-01-01 00:00:00') +
> session.duration.fuente$avg.session.duration[i], "%H:%M:%S")
>
> }
>
> but got this error:
>
>  Error in unclass(e1) + unclass(e2) :
>   non-numeric argument to binary operator
>
> ===
>
> After that I've tried: strptime:
>
> session.duration.fuente$avg.session.duration <-
> strptime(session.duration.fuente$avg.session.duration, "%H:%M:%OS")
>
> But got NAs.
>
> 
>
> Here is the data:
>
>
> session.duration.fuente <- structure(list(mes = structure(c(1L, 1L, 1L, 1L,
> 1L, 2L, 2L,
> 2L, 2L, 2L), .Label = c("oct", "nov"), class = c("ordered", "factor"
> )), fuente = c("adwords", "directo", "organico", "redes sociales",
> "referral", "adwords", "directo", "organico", "redes sociales",
> "referral"), avg.session.duration = c(970178, 1642455, 780485,
> 3170400, 179184, 352995, 833827, 260610, 2318928, 49836)), row.names =
> c(NA,
> -10L), class = c("grouped_df", "tbl_df", "tbl", "data.frame"), vars = list(
> mes), drop = TRUE, .Names = c("mes", "fuente", "avg.session.duration"
> ))
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Cleaning

2015-11-11 Thread Sarah Goslee
Please keep replies on the list so others may participate in the conversation.

If you have a character vector containing the potential values, you
might look at %in% for one approach to subsetting your data.

Var1 %in% myvalues

Sarah

On Wed, Nov 11, 2015 at 7:10 PM, Ashta  wrote:
> Thank you Sarah for your prompt response!
>
> I have the list of values of the variable Var1 it is around 20.
> How can I modify this one to include all the 20 valid values?
>
> test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
>
> Is there a way (efficient )  of doing it?
>
> Thank you again
>
>
>
> On Wed, Nov 11, 2015 at 6:02 PM, Sarah Goslee 
> wrote:
>>
>> Hi,
>>
>> On Wed, Nov 11, 2015 at 6:51 PM, Ashta  wrote:
>> > Hi all,
>> >
>> > I have a data frame with  huge rows and columns.
>> >
>> > When I looked at the data,  it has several garbage values need to be
>> >
>> > cleaned. For a sample I am showing you the frequency distribution
>> > of one variables
>> >
>> > Var1 Freq
>> > 1:3
>> > 2]6
>> > 3MSN 1040
>> > 4YYZ  300
>> > 5\\4
>> > 6+ 3
>> > 7.   ?>   15
>>
>> Please use dput() to provide your data. I made a guess at what you had
>> in R, but could be wrong.
>>
>>
>> > and continues.
>> >
>> > I want to keep those rows that contain only a valid variable value
>> >
>> > In this  case MSN and YYZ. I tried the following
>> >
>> > *test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]*
>> >
>> > but I am not getting the desired result.
>>
>> What are you getting? How does it differ from the desired result?
>>
>> >  I have
>> >
>> > Any help or idea?
>>
>> I get:
>>
>> > dat <- structure(list(X = 1:7, Var1 = c(":", "]", "MSN", "YYZ", "",
>> + "+", "?>"), Freq = c(3L, 6L, 1040L, 300L, 4L, 3L, 15L)), .Names = c("X",
>> + "Var1", "Freq"), class = "data.frame", row.names = c(NA, -7L))
>> >
>> > test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
>> > test
>>   X Var1 Freq
>> 3 3  MSN 1040
>> 4 4  YYZ  300
>>
>> Which seems reasonable to me.
>>
>>
>> >
>> > [[alternative HTML version deleted]]
>>
>> Please don't post in HTML either: it introduces all sorts of errors to
>> your message.
>>
>> Sarah
>>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Cleaning

2015-11-11 Thread Sarah Goslee
Hi,

On Wed, Nov 11, 2015 at 6:51 PM, Ashta  wrote:
> Hi all,
>
> I have a data frame with  huge rows and columns.
>
> When I looked at the data,  it has several garbage values need to be
>
> cleaned. For a sample I am showing you the frequency distribution
> of one variables
>
> Var1 Freq
> 1:3
> 2]6
> 3MSN 1040
> 4YYZ  300
> 5\\4
> 6+ 3
> 7.   ?>   15

Please use dput() to provide your data. I made a guess at what you had
in R, but could be wrong.


> and continues.
>
> I want to keep those rows that contain only a valid variable value
>
> In this  case MSN and YYZ. I tried the following
>
> *test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]*
>
> but I am not getting the desired result.

What are you getting? How does it differ from the desired result?

>  I have
>
> Any help or idea?

I get:

> dat <- structure(list(X = 1:7, Var1 = c(":", "]", "MSN", "YYZ", "",
+ "+", "?>"), Freq = c(3L, 6L, 1040L, 300L, 4L, 3L, 15L)), .Names = c("X",
+ "Var1", "Freq"), class = "data.frame", row.names = c(NA, -7L))
>
> test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]
> test
  X Var1 Freq
3 3  MSN 1040
4 4  YYZ  300

Which seems reasonable to me.


>
> [[alternative HTML version deleted]]

Please don't post in HTML either: it introduces all sorts of errors to
your message.

Sarah

-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Cleaning

2015-11-11 Thread Ashta
Hi all,

I have a data frame with  huge rows and columns.

When I looked at the data,  it has several garbage values need to be

cleaned. For a sample I am showing you the frequency distribution
of one variables

Var1 Freq
1:3
2]6
3MSN 1040
4YYZ  300
5\\4
6+ 3
7.   ?>   15

and continues.

I want to keep those rows that contain only a valid variable value

In this  case MSN and YYZ. I tried the following

*test <- dat[dat$Var1 == "YYZ" | dat$Var1 =="MSN" ,]*

but I am not getting the desired result.

 I have

Any help or idea?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] seconds to h:m:s format

2015-11-11 Thread Omar André Gonzáles Díaz
Hi,

I've a data frame with 3 columns: "mes", "fuente", "avg.sessions.duration".

"avg.sessions.duration" is a column containing seconds.

I need you help with:

1.-  Help to put these values in "h:m:s" format.
.

===

I've found this german page:

http://forum.r-statistik.de/viewtopic.php?f=25&t=5284

So I've tried:

for (i in 1:nrow(session.duration.fuente)) {

  session.duration.fuente$avg.session.duration <-
format(as.POSIXct('0001-01-01 00:00:00') +
session.duration.fuente$avg.session.duration[i], "%H:%M:%S")

}

but got this error:

 Error in unclass(e1) + unclass(e2) :
  non-numeric argument to binary operator

===

After that I've tried: strptime:

session.duration.fuente$avg.session.duration <-
strptime(session.duration.fuente$avg.session.duration, "%H:%M:%OS")

But got NAs.



Here is the data:


session.duration.fuente <- structure(list(mes = structure(c(1L, 1L, 1L, 1L,
1L, 2L, 2L,
2L, 2L, 2L), .Label = c("oct", "nov"), class = c("ordered", "factor"
)), fuente = c("adwords", "directo", "organico", "redes sociales",
"referral", "adwords", "directo", "organico", "redes sociales",
"referral"), avg.session.duration = c(970178, 1642455, 780485,
3170400, 179184, 352995, 833827, 260610, 2318928, 49836)), row.names =
c(NA,
-10L), class = c("grouped_df", "tbl_df", "tbl", "data.frame"), vars = list(
mes), drop = TRUE, .Names = c("mes", "fuente", "avg.session.duration"
))

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] About error: L-BFGS-B needs finite values of 'fn'

2015-11-11 Thread Ravi Varadhan
It seems like there is substantial finite-sample bias in the MLEs.  Either that 
or there is some error in your procedure.  See attached code.

Ravi

From: Ravi Varadhan
Sent: Wednesday, November 11, 2015 2:33 PM
To: 'denizozo...@gazi.edu.tr' ; r-help@r-project.org
Cc: 'profjcn...@gmail.com' 
Subject: Re: [R] About error: L-BFGS-B needs finite values of 'fn'

With a small sample size, n=30, you will have realizations of data where you 
will run into difficulties with the MLE of generalized Gamma distribution.  
This is mainly due to the `k' parameter.  Increase the sample size (e.g., n=50 
or 100) and this problem is less likely to happen (but can still happen).

I would strongly suggest that when you are doing simulations, you should 
encapsulate the parameter estimation inside a `try' or `tryCatch' statement so 
that when there is an error, the simulation keeps going rather than crashing 
out.

See the attached code.

Best,
Ravi

Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg)
Associate Professor,  Department of Oncology
Division of Biostatistics & Bionformatics
Sidney Kimmel Comprehensive Cancer Center
Johns Hopkins University
550 N. Broadway, Suite -E
Baltimore, MD 21205
410-502-2619

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] About error: L-BFGS-B needs finite values of 'fn'

2015-11-11 Thread Ravi Varadhan
With a small sample size, n=30, you will have realizations of data where you 
will run into difficulties with the MLE of generalized Gamma distribution.  
This is mainly due to the `k' parameter.  Increase the sample size (e.g., n=50 
or 100) and this problem is less likely to happen (but can still happen).

I would strongly suggest that when you are doing simulations, you should 
encapsulate the parameter estimation inside a `try' or `tryCatch' statement so 
that when there is an error, the simulation keeps going rather than crashing 
out.

See the attached code.

Best,
Ravi

Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg)
Associate Professor,  Department of Oncology
Division of Biostatistics & Bionformatics
Sidney Kimmel Comprehensive Cancer Center
Johns Hopkins University
550 N. Broadway, Suite -E
Baltimore, MD 21205
410-502-2619

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 packages/code for CART that is written entirely in R (not C)

2015-11-11 Thread Andrew Crane-Droesch
Thanks for the reference!  I'd still be grateful for any pointers 
towards code for CART that has been written entirely in R, perhaps that 
hasn't made its way onto CRAN.


On 11/11/2015 02:00 PM, David Winsemius wrote:

On Nov 11, 2015, at 9:25 AM, Andrew Crane-Droesch  wrote:

Dear List,

I'd like to make a few modifications to the typical CART algorithm, and
I'd rather not code the whole thing from scratch.  Specifically I want
to use different in-sample and out-of-sample fit criteria in the split
choosing and cross-validation stages.

I see however that the code for CART in both the rpart and the tree
packages is written in C.

Two questions:

  * Where is the C code?  It might be possible to get a C-fluent
programmer to help me with this.
  * Is there any code for CART that is written entirely in R?

Read: "R Help Desk: Accessing the Sources” by Uwe Ligges in:

https://www.r-project.org/doc/Rnews/Rnews_2006-4.pdf

The current sources are here:

https://svn.r-project.org/R/trunk/



Thanks,
Andrew

[[alternative HTML version deleted]]

For future questions, this is a plain text mailing list.


PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

—
David Winsemius
Alameda, CA, USA



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 packages/code for CART that is written entirely in R (not C)

2015-11-11 Thread David Winsemius

> On Nov 11, 2015, at 9:25 AM, Andrew Crane-Droesch  wrote:
> 
> Dear List,
> 
> I'd like to make a few modifications to the typical CART algorithm, and 
> I'd rather not code the whole thing from scratch.  Specifically I want 
> to use different in-sample and out-of-sample fit criteria in the split 
> choosing and cross-validation stages.
> 
> I see however that the code for CART in both the rpart and the tree 
> packages is written in C.
> 
> Two questions:
> 
>  * Where is the C code?  It might be possible to get a C-fluent
>programmer to help me with this.
>  * Is there any code for CART that is written entirely in R?

Read: "R Help Desk: Accessing the Sources” by Uwe Ligges in:

https://www.r-project.org/doc/Rnews/Rnews_2006-4.pdf

The current sources are here:

https://svn.r-project.org/R/trunk/


> 
> Thanks,
> Andrew
> 
>   [[alternative HTML version deleted]]

For future questions, this is a plain text mailing list.

> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

— 
David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] R packages/code for CART that is written entirely in R (not C)

2015-11-11 Thread Andrew Crane-Droesch
Dear List,

I'd like to make a few modifications to the typical CART algorithm, and 
I'd rather not code the whole thing from scratch.  Specifically I want 
to use different in-sample and out-of-sample fit criteria in the split 
choosing and cross-validation stages.

I see however that the code for CART in both the rpart and the tree 
packages is written in C.

Two questions:

  * Where is the C code?  It might be possible to get a C-fluent
programmer to help me with this.
  * Is there any code for CART that is written entirely in R?

Thanks,
Andrew

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Advice collating an R package

2015-11-11 Thread Jeff Newmiller
A) Do you have problem? Have you tried it?

B) There is a mailing list for this sort of question... read the Posting Guide.

C) What is a constant? In R, it is just another variable. The purpose of 
packages is to collect variables in namespaces in memory for easy access. Which 
means that "include" is not necessary. 
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On November 11, 2015 7:16:44 AM PST, Glenn Schultz  wrote:
>Hi All,
>When collating a package - where does the file of constants go?
>
>I have an R package that defines 36 new classes and the AllClasses file
>is getting quite long.  I would like to re-organize the files the
>following way - which is also easier for my personal mental map of what
>is going on.
>
>#' @includes foo1.R foo2.R
>setClass
>setGeneric
>setMethod(initialize)
>constructor function
>
>I also have a file fooC.R which defines the constants like
>days.in.month etc.  So should every file be 
>#' @includes fooC. R foo1.R foo2.R
>setClass
>setGeneric
>setMethod(initialize)
>constructor function
>
>Thanks,
>Glenn
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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 -- To UNSUBSCRIBE and more, see
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] random number generation

2015-11-11 Thread Michael Dewey

Dear Leila

Does the function mvrnorm in package MASS do what you want?

On 11/11/2015 08:38, leila zamani via R-help wrote:

Hi every one,
I'm new to R. I read about R and search all the packages but I couldn't find 
the package that I want. I want to generate 2D (matrices) random numbers that 
have correlation between them. One of my friends said that R has a function in 
geor like rand...(spherical (correlation coefficient=0.5)), but I read all 
packages with geo,like geor,geoRlgm,georob and etc, but I didn't find this! Can 
you help me? Thanks.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



--
Michael
http://www.dewey.myzen.co.uk/home.html

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] random number generation

2015-11-11 Thread Karim Mezhoud
Hi,
This generate matrix:
matrix( rnorm(5*4,mean=0,sd=1), 5, 4)

for correlated matrix please see this link:
http://stackoverflow.com/questions/10680658/how-can-i-create-a-correlation-matrix-in-r
Karim


On Wed, Nov 11, 2015 at 9:38 AM, leila zamani via R-help <
r-help@r-project.org> wrote:

> Hi every one,
> I'm new to R. I read about R and search all the packages but I couldn't
> find the package that I want. I want to generate 2D (matrices) random
> numbers that have correlation between them. One of my friends said that R
> has a function in geor like rand...(spherical (correlation
> coefficient=0.5)), but I read all packages with geo,like
> geor,geoRlgm,georob and etc, but I didn't find this! Can you help me?
> Thanks.
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Advice collating an R package

2015-11-11 Thread Duncan Murdoch

On 11/11/2015 7:16 AM, Glenn Schultz wrote:

Hi All,
When collating a package - where does the file of constants go?

I have an R package that defines 36 new classes and the AllClasses file is 
getting quite long.  I would like to re-organize the files the following way - 
which is also easier for my personal mental map of what is going on.

#' @includes foo1.R foo2.R
setClass
setGeneric
setMethod(initialize)
constructor function

I also have a file fooC.R which defines the constants like days.in.month etc.  
So should every file be
#' @includes fooC. R foo1.R foo2.R
setClass
setGeneric
setMethod(initialize)
constructor function



Scoping in R doesn't care about the order of declaration.  The times 
when collation order matters are when you need to use one object in the 
package to build another one.  (You should be thinking of the source 
files as executable scripts that create a collection of objects, not as 
declarations.)


So just make sure that if you use object A from your package when 
building object B, that the source to build A is executed first.  Most 
people do this by naming the files:  they'll be executed in C collation 
order by default.  (You can list the files in the Collate field of your 
DESCRIPTION file if you want a different order; see Writing R Extensions 
for details).


Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] TRMM download loop

2015-11-11 Thread Eliza Botto
Dear Users of R,
I have this following confusion.
Some months ago I use to download 3 hourly TRMM data from NASA website by using 
the R from the following website

http://giovanni.gsfc.nasa.gov/giovanni/#service=ArAvTs&starttime=2008-12-31T00:00:00Z&endtime=2009-12-31T23:59:59Z&bbox=67,-50,67,-50&data=TRMM_3B42_007_precipitation

bbox=67,-50,67,-50 show the point where I want to download the data in the form 
of CSV file. The problem is that I have a vector of such points, a small of 
which is below
structure(c(72, 71, 54, 67, 50, 53, 30, -50), .Dim = c(4L, 2L), .Dimnames = 
list(c("d", "e", "f", "g"), NULL))
How can I make a loop to download the data on given points automatically?
Thankyou very much in advance.
Eliza
  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Advice collating an R package

2015-11-11 Thread Glenn Schultz

Hi All,
When collating a package - where does the file of constants go?

I have an R package that defines 36 new classes and the AllClasses file is 
getting quite long.  I would like to re-organize the files the following way - 
which is also easier for my personal mental map of what is going on.

#' @includes foo1.R foo2.R
setClass
setGeneric
setMethod(initialize)
constructor function

I also have a file fooC.R which defines the constants like days.in.month etc.  
So should every file be 
#' @includes fooC. R foo1.R foo2.R
setClass
setGeneric
setMethod(initialize)
constructor function

Thanks,
Glenn
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] TRMM download loop

2015-11-11 Thread Eliza Botto
Dear Users of R,
I have this following confusion.
Some months ago I use to download 3 hourly TRMM data from NASA website by using 
the R from the following website

http://giovanni.gsfc.nasa.gov/giovanni/#service=ArAvTs&starttime=2008-12-31T00:00:00Z&endtime=2009-12-31T23:59:59Z&bbox=67,-50,67,-50&data=TRMM_3B42_007_precipitation

bbox=67,-50,67,-50 show the point where I want to download the data in the form 
of CSV file. The problem is that I have a vector of such points, a small of 
which is below
structure(c(72, 71, 54, 67, 50, 53, 30, -50), .Dim = c(4L, 2L), .Dimnames = 
list(c("d", "e", "f", "g"), NULL))
How can I make a loop to download the data on given points automatically?
Thankyou very much in advance.
Eliza
  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] random number generation

2015-11-11 Thread leila zamani via R-help
Hi every one,
I'm new to R. I read about R and search all the packages but I couldn't find 
the package that I want. I want to generate 2D (matrices) random numbers that 
have correlation between them. One of my friends said that R has a function in 
geor like rand...(spherical (correlation coefficient=0.5)), but I read all 
packages with geo,like geor,geoRlgm,georob and etc, but I didn't find this! Can 
you help me? Thanks.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] no results

2015-11-11 Thread William Dunlap
If you are running these commands from a file using source() then
replacing 'summary(sem)' with 'print(summary(sem))' would help,
as would adding echo=TRUE or print.eval=TRUE to the source()
command.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Nov 10, 2015 at 11:47 AM, Alaa Sindi  wrote:

> Hi All,
>
> I am not getting any summary results and I do not have any error. what
> would be the problem?
>
>
>
> sem=mlogit.optim ( LL  , Start, method = 'nr', iterlim = 2000, tol =
> 1E-05, ftol = 1e-08, steptol = 1e-10, print.level = 0)
> summary(sem)
>
> thanks
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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 regex to truncate repeating characters

2015-11-11 Thread Marc Schwartz

> On Nov 11, 2015, at 3:02 AM, Karl  wrote:
> 
> Hi all,
> 
> I'm trying to learn how to use regex inside R. I'm far from an expert when
> it comes to this, but google is my friend when it comes to finding suitable
> pieces of syntax to start building from. For example, this post seems to do
> what I want:
> 
> http://stackoverflow.com/questions/12258622/regular-expression-to-check-for-repeating-characters
> However, how do I implement this in R? gsub()?
> For example, with Perl-style regex, are there syntax modifications that
> need to be done before it will work with R?
> 
> My task is that I want to truncate/limit repeated characters to 3. If I
> have the string:
> "Lorem ipsum dolor sit ammet, consectetur adipiscing elt"
> 
> I want to truncate it to:
> "Looorem ipsum dolor sit ammmet, consectetur adipiscing eliiit"
> 
> Thank you!
> 
> BR,
> Josip


Hi,

Not extensively tested, but something like this should work:

text <- "Lorem ipsum dolor sit ammet, consectetur adipiscing 
elt"

> gsub("([[:alnum:]])\\1{3,}", "\\1\\1\\1", text)
[1] "Looorem ipsum dolor sit ammmet, consectetur adipiscing eliiit"


The regex is looking for any alphanumeric character as a group, which is 
represented by:

  ([[:alnum:]])

That is followed by a backreference:

  \\1{3,}

which says find repeated characters in the prior alphanumeric character group 
of at least 3 repeats and return just the unique character.

The returned expression:

  \\1\\1\\1

says repeat the unique character 3 times.

See ?gsub and ?regex for some additional information.


Regards,

Marc Schwartz

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Calculating distance between words in string

2015-11-11 Thread S Ellison
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Karl
> Subject: [R] Calculating distance between words in string
>
> .. given a specific keyword, I need to assign labels to the other words
> based on the distance (number of words) to this keyword.
> 
>...
> If the sentence contains more than one instance of the keyword, I need values
> for each instance. 

What would you like to happen when the sentence contains more than one instance 
of other words and more than one instance of both?

e.g. what output do you want from 
" amet is not the only instance of 'amet', and there is more than one instance 
of 'instance', 'is', 'of' and 'and'."


S Ellison


***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 calculate variance on multiple numbers at once?

2015-11-11 Thread S Ellison


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Luigi
> Marongiu
> if I have a sample set of the following numbers x1=0.09, x2=0.94, x3=0.48,
> x4=0.74, x5=0.04 I can calculate the variance easily.
Not without concatenating them into a vector, you can't. You need them in a 
vector, as in
var( c(x1, x2, x3, x4, x5) )

> But if each x is actually a subset of multiple values, what would be the 
> formula
> to calculate the variance? and it is possible to implement such mathematical
> function in R?
This is what R wants anyway, so the function you are looking for is var()

> For instance if I have the following: x1=(0.77, 0.22, 0.44), x2=(0.26, 0.89, 
> 0.58),
> x3=(0.20, 0.25, 0.91), x4=(0.06, 0.13, 0.26) and x5=(0.65, 0.16, 0.72) how 
> can i
> calculate the variance for each x?
var(x1)
var(x2)


or, if you want to be a bit more slick about it and do it in one line

lapply(list( x1, x2, x3, ...), var  ) 

(or sapply() if you want a vector result)






***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] How to calculate variance on multiple numbers at once?

2015-11-11 Thread Luigi Marongiu
Dear all,

if I have a sample set of the following numbers x1=0.09, x2=0.94,
x3=0.48, x4=0.74, x5=0.04 I can calculate the variance easily.
But if each x is actually a subset of multiple values, what would be
the formula to calculate the variance? and it is possible to implement
such mathematical function in R?

For instance if I have the following: x1=(0.77, 0.22, 0.44), x2=(0.26,
0.89, 0.58), x3=(0.20, 0.25, 0.91), x4=(0.06, 0.13, 0.26) and
x5=(0.65, 0.16, 0.72) how can i calculate the variance for each x?

Thank you

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Mixed modelling course, Lisbon, Portugal

2015-11-11 Thread Highland Statistics Ltd

We would like to announce the following statistics course:

Course: Introduction to Linear mixed effects models,  GLMM and MCMC with R
Where:  Lisbon, Portugal
When:   15-19 February 2016

Course website: http://www.highstat.com/statscourse.htm
Course flyer: 
http://highstat.com/Courses/Flyers/Flyer2016_02Lisbon_GLMM.pdf




Kind regards,

Alain Zuur


--
Dr. Alain F. Zuur

First author of:
1. Beginner's Guide to GAMM with R (2014).
2. Beginner's Guide to GLM and GLMM with R (2013).
3. Beginner's Guide to GAM with R (2012).
4. Zero Inflated Models and GLMM with R (2012).
5. A Beginner's Guide to R (2009).
6. Mixed effects models and extensions in ecology with R (2009).
7. Analysing Ecological Data (2007).

Highland Statistics Ltd.
9 St Clair Wynd
UK - AB41 6DZ Newburgh
Tel:   0044 1358 788177
Email: highs...@highstat.com
URL:   www.highstat.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Using regex to truncate repeating characters

2015-11-11 Thread Karl
Hi all,

I'm trying to learn how to use regex inside R. I'm far from an expert when
it comes to this, but google is my friend when it comes to finding suitable
pieces of syntax to start building from. For example, this post seems to do
what I want:

http://stackoverflow.com/questions/12258622/regular-expression-to-check-for-repeating-characters
However, how do I implement this in R? gsub()?
For example, with Perl-style regex, are there syntax modifications that
need to be done before it will work with R?

My task is that I want to truncate/limit repeated characters to 3. If I
have the string:
"Lorem ipsum dolor sit ammet, consectetur adipiscing elt"

I want to truncate it to:
"Looorem ipsum dolor sit ammmet, consectetur adipiscing eliiit"

Thank you!

BR,
Josip

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.