Re: [R] get is.na !is.na count of various combinations of columns

2014-03-19 Thread arun
Hi,
I just noticed that you also have all is.na() or !is.na() subsets.  To do that:
mydatatest - structure(list(CaseID = structure(1:8, .Label = c(1605928, 
1605943, 1605945, 1605947, 1605949, 1605951, 1605952, 
1605953), class = factor), Structure = structure(c(1L, 1L, 
3L, 2L, 2L, 3L, 3L, 4L), .Label = c(corp, LLC, prop, LAC
), class = factor), Poster = c(1, 1, 1, NA, NA, 1, 1, NA), 
    Records = c(1, 1, 1, 1, 1, NA, 1, NA), MWBW = c(NA, NA, 495.1, 
    NA, NA, NA, 425, NA), OT = c(NA, NA, NA, NA, 411.25, NA, 
    432.5, NA), CL = c(NA, NA, NA, 13.52, NA, NA, 14.72, NA)), .Names = 
c(CaseID, 
Structure, Poster, Records, MWBW, OT, CL), row.names = c(NA, 
8L), class = data.frame)



vec1 - names(mydatatest)[-(1:2)]
res - lapply(c(0,seq(length(vec1))),function(i) {x1 - 
as.data.frame(combn(vec1,i),stringsAsFactors=FALSE); lapply(x1, function(x) 
{indx - vec1 %in% x; nisna - if(length(vec1[!indx])  0 ) 
paste(paste0(!is.na,(, vec1[!indx],)),collapse=  );isna - 
if(length(vec1[indx])  0 ) paste(paste0(is.na,(, vec1[indx],)),collapse= 
  ); nisna_isna - gsub(^  |  $,, paste(nisna, isna, sep=   )); 
subset(mydatatest, eval(parse(text=nisna_isna)))})})

names1 -  unlist(lapply(c(0,seq(length(vec1))),function(i) {x1 - 
as.data.frame(combn(vec1,i),stringsAsFactors=FALSE); unlist(lapply(x1, 
function(x) {indx - vec1 %in% x; nisna - if(length(vec1[!indx])  0 ) 
paste(paste0(!is.na,(, vec1[!indx],)),collapse=  );isna - 
if(length(vec1[indx])  0 ) paste(paste0(is.na,(, vec1[indx],)),collapse= 
  ); nisna_isna - gsub(^  |  $,, paste(nisna, isna, sep=   
))}))}),use.names=FALSE)

res1 - unlist(res,recursive=FALSE)
names(res1) - names1
res2 - res1[sapply(res1,nrow)!=0]


A.K.


On Wednesday, March 19, 2014 12:59 AM, arun smartpink...@yahoo.com wrote:
If you want to identify the combination of columns:

names1 -  unlist(lapply(seq(length(vec1)-1),function(i) {x1 - 
as.data.frame(combn(vec1,i),stringsAsFactors=FALSE); unlist(lapply(x1, 
function(x) {indx - vec1 %in% x; paste(paste(paste0(!is.na,(, 
vec1[!indx],)),collapse=  ), paste(paste0(is.na,(, 
vec1[indx],)),collapse=   ), sep=   ) }))}),use.names=FALSE)


res1 - unlist(res,recursive=FALSE)
 names(res1) - names1

res1
 length(res1)
#[1] 30
res1[30]
#$`!is.na(Poster)  is.na(Records)  is.na(MWBW)  is.na(OT)  is.na(CL)`
#   CaseID Structure Poster Records MWBW OT CL
#6 1605951  prop  1  NA   NA NA NA
res2 - res1[sapply(res1,nrow)!=0]
res2[4]
#$`!is.na(Poster)  !is.na(Records)  is.na(MWBW)  is.na(OT)  is.na(CL)`
#   CaseID Structure Poster Records MWBW OT CL
#1 1605928  corp  1   1   NA NA NA
#2 1605943  corp  1   1   NA NA NA

Hope this helps.


A.K.





On , arun smartpink...@yahoo.com wrote:
Hi,
May be this helps:
res -  lapply(seq(length(vec1)-1),function(i) {x1 - 
as.data.frame(combn(vec1,i),stringsAsFactors=FALSE); lapply(x1, function(x) 
{indx - vec1 %in% x; nisna - paste(paste0(!is.na,(, 
vec1[!indx],)),collapse=  );isna - paste(paste0(is.na,(, 
vec1[indx],)),collapse=   );subset(mydatatest, eval(parse(text=nisna))  
eval(parse(text=isna)))})})

A.K.





On Tuesday, March 18, 2014 11:45 PM, bcrombie bcrom...@utk.edu wrote:
I'm trying to count the number of combinations of columns containing data 
not containing data as described below.  Im not sure how to do this in R
and need some help.

#get TRUE/FALSE count of various combinations of columns per CaseID or per
Structure
mydatatest - data.frame (CaseID = c(1605928, 1605943, 1605945,
1605947, 1605949, 1605951),
                      Structure = c(corp, corp, prop, LLC, LLC,
prop),
                      Poster = c(1, 1, 1, NA, NA, 1),
                      Records = c(1, 1, 1, 1, 1, NA),
                      MWBW = c(NA, NA, 495.10, NA, NA, NA),
                      OT = c(NA, NA, NA, NA, 411.25, NA),
                      CL = c(NA, NA, NA, 13.52, NA, NA))

combo1 - subset(mydatatest, !is.na(Poster  Records  MWBW  OT  CL))
combo2 - subset(mydatatest, !is.na(Poster  Records  MWBW  OT) 
is.na(CL))
combo3 - subset(mydatatest, !is.na(Poster  Records  MWBW)  is.na(OT 
CL))
combo4 - subset(mydatatest, !is.na(Poster  Records)  is.na(MWBW  OT 
CL))
combo5 - subset(mydatatest, !is.na(Poster)  is.na(Records  MWBW  OT 
CL))
combo6 - subset(mydatatest, !is.na(Records)  is.na(Poster  MWBW  OT 
CL))
combo7 - subset(mydatatest, !is.na(MWBW)  is.na(Poster  Records  OT 
CL))
combo8 - subset(mydatatest, !is.na(OT)  is.na(Poster  Records  MWBW 
CL))
combo9 - subset(mydatatest, !is.na(CL)  is.na(Poster  Records  MWBW 
OT))
etc.



--
View this message in context: 
http://r.789695.n4.nabble.com/get-is-na-is-na-count-of-various-combinations-of-columns-tp4687084.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.



Re: [R] Data file verification protocol

2014-03-19 Thread Barry Rowlingson
On Wed, Mar 19, 2014 at 4:03 AM, Wolf, Steven wolfs...@msu.edu wrote:

 Hi R users,

 This isn't a R-specific issue, per-se, but I thought that this list would
 have some helpful input on this topic.  First, a bit of background.  I am
 working on a project which is interested in following approx 1000 students
 each semester, and collects about 15 different measurements about each
 student.  These are both numeric and text, for example grades in a course,
 race, gender, etc.

 I am looking for a verification protocol which can look at a data file and
 see if it has been modified.  Ideally, this should be something that I can
 check the file with to see if the file has been changed or corrupted and
 incorporate into my analysis workflow.  (i.e., every time I look at my
 data, I can run this protocol to ensure the file hasn't changed.)


 Operating systems will keep the last modification time of a file, and you
can use the file.info function in R to check that. However, if someone just
opens and re-saves the file without changing it that will usually trigger
an update of the modification time.

 The big question you haven't answered is has the file been changed since
when?. Since you last ran your analysis? This then looks like a job for
the 'make' utility. You specify rules in a 'Makefile' that specify how to
create targets based on dependencies. For example:

results.txt: data.dat process.R
Rscript process.R

- says that results.txt depends on data.dat (your input data) and
process.R (your R code that creates results.txt from data.dat), and would
run Rscript process.R if data.dat or process.R have a newer modification
time than results.txt. Run twice in rapid succession, this makefile
wouldn't run R the second time because results.txt would be newer then its
dependencies since it was just created.

 Objects within R don't have timestamps, so its not possible to
conditionally run an R function if its parameter objects are newer than the
result object. But if you save R objects as .RData files, you can use
make based on the timestamps of the .RData files.

 Alternatively you can just keep recent versions of the file hanging around
(1000x15 is pretty small, even multiplied by another 1000 is still not
exactly Big Data) and compare them. In a unix environment the cmp command
will quickly test two files for equality, or if you don't want to store
copies of your file you simply compute a checksum or digest and compare
digests. In a unix environment you'd typically use the md5sum command
which spits out a 128-bit (32 character) checksum for its arguments. If the
checksum is different, then the file is different.

 Your use case is still a bit vague - for example you haven't said what the
file format is, or how its being updated.

Barry

[[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] [R-pkgs] New package metap on CRAN

2014-03-19 Thread Michael Dewey

This package provides meta-analysis of significance values.

Although the preferred way of performing meta-analysis uses effect 
sizes sometimes these are unavailable and only p-values can be 
obtained from the primary studies. The metap package provides several 
ways of synthesising p-values and a graphical display. There exist a 
number of packages on CRAN which use one or other of these techniques 
in the context of genetic studies but metap is designed for general 
purpose use.


Comments welcome.


Michael Dewey
i...@aghmed.fsnet.co.uk
http://www.aghmed.fsnet.co.uk/home.html

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
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] Data file verification protocol

2014-03-19 Thread rex
Wolf, Steven wolfs...@msu.edu [2014-03-18 21:05]:
 I am looking for a verification protocol which can look at a data file and 
 see if it has been modified.  Ideally, this should be something that I can 
 check the file with to see if the file has been changed or corrupted and 
 incorporate into my analysis workflow.  (i.e., every time I look at my data, 
 I can run this protocol to ensure the file hasn?t changed.)

http://dirk.eddelbuettel.com/code/digest.html

Overview

digest provides `hash' function summaries for GNU R objects. The md5,
sha-1, sha-256 and crc32 hash functions are available. The md5
algorithm by Ron Rivest is specified in RFC 1321, the SHA-1 and
SHA-256 algorithm is specified in FIPS-180-1 and FIPS-180-2,
respectively, and the crc32 algorithm is described in here. For md5,
sha-1 and sha-256, this packages uses small standalone C
implementations that were provided by by Christophe Devine. For crc32,
code from the zlib library is used. For sha-512, a routine by Aaron
Gifford is used. Please note that this package is not meant to be
deployed for cryptographic purposes for which more comprehensive (and
widely tested) libraries such as OpenSSL should be used.

Example

The following verbatim R session loads digest and runs the example()
from the corresponding help page:

 library(digest)
 example(digest)

digest md5Input - c(, a, abc, message digest, 
abcdefghijklmnopqrstuvwxyz,
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,
paste(12345678901234567890123456789012345678901234567890123456789012,
34567890123456 ... ... [TRUNCATED]
[...]

HTH,

-rex
-- 
...I paid a visit to Schrodinger in his Vienna apartment before his death...
There were no cats. I was told he did not like cats. -quantam leaps,
bernstein.

__
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] write.csv: set the name of the column containing the row.names

2014-03-19 Thread Luca Cerone
Hi everybody,
I am sorry if this is a silly question (I have tried to search it at
http://tolstoy.newcastle.edu.au/R/ but I get a 404 page).

I have a script writing some data.frames to csv files.
I write the csv files using the write.csv function and the option
row.names=TRUE.
Everything works fine, except that I am not able to set the name of
the column holding the row.names.

For example I tried to set the column name to ID like this:

df = data.frame(a=c(1,2,3), b=c(3,4,5))
rownames(df) = c(A,B,C)

write.csv(df, row.names=TRUE, colnames=c(ID, colnames(df)))

This fails with the following error:
Error in write.table(df, row.names = TRUE, colnames = c(ID,
colnames(df)),  :
  unused argument (colnames = c(ID, colnames(df)))

How can I do this? I have tried to use write.table() as well, but it
seems I never get to set the options right.

Thanks a lot in advance for the help,

Cheers,
Luca

__
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] write.csv: set the name of the column containing the row.names

2014-03-19 Thread Ista Zahn
The argument is col.names, not colnames.

Best,
Ista
On Mar 19, 2014 6:14 AM, Luca Cerone luca.cer...@gmail.com wrote:

 Hi everybody,
 I am sorry if this is a silly question (I have tried to search it at
 http://tolstoy.newcastle.edu.au/R/ but I get a 404 page).

 I have a script writing some data.frames to csv files.
 I write the csv files using the write.csv function and the option
 row.names=TRUE.
 Everything works fine, except that I am not able to set the name of
 the column holding the row.names.

 For example I tried to set the column name to ID like this:

 df = data.frame(a=c(1,2,3), b=c(3,4,5))
 rownames(df) = c(A,B,C)

 write.csv(df, row.names=TRUE, colnames=c(ID, colnames(df)))

 This fails with the following error:
 Error in write.table(df, row.names = TRUE, colnames = c(ID,
 colnames(df)),  :
   unused argument (colnames = c(ID, colnames(df)))

 How can I do this? I have tried to use write.table() as well, but it
 seems I never get to set the options right.

 Thanks a lot in advance for the help,

 Cheers,
 Luca

 __
 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] write.csv: set the name of the column containing the row.names

2014-03-19 Thread Luca Cerone
Thanks Ista,
sorry it was a typo in my email, but in the code I have the right option.

On Wed, Mar 19, 2014 at 11:58 AM, Ista Zahn istaz...@gmail.com wrote:
 The argument is col.names, not colnames.

 Best,
 Ista

 On Mar 19, 2014 6:14 AM, Luca Cerone luca.cer...@gmail.com wrote:

 Hi everybody,
 I am sorry if this is a silly question (I have tried to search it at
 http://tolstoy.newcastle.edu.au/R/ but I get a 404 page).

 I have a script writing some data.frames to csv files.
 I write the csv files using the write.csv function and the option
 row.names=TRUE.
 Everything works fine, except that I am not able to set the name of
 the column holding the row.names.

 For example I tried to set the column name to ID like this:

 df = data.frame(a=c(1,2,3), b=c(3,4,5))
 rownames(df) = c(A,B,C)

 write.csv(df, row.names=TRUE, colnames=c(ID, colnames(df)))

 This fails with the following error:
 Error in write.table(df, row.names = TRUE, colnames = c(ID,
 colnames(df)),  :
   unused argument (colnames = c(ID, colnames(df)))

 How can I do this? I have tried to use write.table() as well, but it
 seems I never get to set the options right.

 Thanks a lot in advance for the help,

 Cheers,
 Luca

 __
 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.


Re: [R] write.csv: set the name of the column containing the row.names

2014-03-19 Thread Luca Cerone
Thanks Duncan,
I knew that, I wanted to know if there was some way not involving
having to recreate the df.
It is not a big issue in this case (they are not very big), but it
might be problematic for big data frames.

Thanks for advice on using col.names=NA.

Cheers,
Luca
Luca Cerone

Tel: +34 692 06 71 28
Skype: luca.cerone


On Wed, Mar 19, 2014 at 11:44 AM, Duncan Murdoch
murdoch.dun...@gmail.com wrote:
 On 14-03-19 6:12 AM, Luca Cerone wrote:

 Hi everybody,
 I am sorry if this is a silly question (I have tried to search it at
 http://tolstoy.newcastle.edu.au/R/ but I get a 404 page).

 I have a script writing some data.frames to csv files.
 I write the csv files using the write.csv function and the option
 row.names=TRUE.
 Everything works fine, except that I am not able to set the name of
 the column holding the row.names.

 For example I tried to set the column name to ID like this:

  df = data.frame(a=c(1,2,3), b=c(3,4,5))
  rownames(df) = c(A,B,C)

  write.csv(df, row.names=TRUE, colnames=c(ID, colnames(df)))

 This fails with the following error:
  Error in write.table(df, row.names = TRUE, colnames = c(ID,
 colnames(df)),  :
unused argument (colnames = c(ID, colnames(df)))

 How can I do this? I have tried to use write.table() as well, but it
 seems I never get to set the options right.


 You can't get a column heading for the row names.  If you want a blank entry
 there, use col.names=NA and row.names=TRUE.  If you want the heading to be
 ID, then you need to write the row names as a regular column of the
 dataframe, e.g.

 df2 - data.frame(ID=rownames(df), df)

 and then write df2 *without* rownames (so they don't appear twice).

 Duncan Murdoch

__
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] write.csv: set the name of the column containing the row.names

2014-03-19 Thread Rui Barradas

Hello,

 write.csv(df, row.names=TRUE, col.names=c(ID, colnames(df)))
,a,b
A,1,3
B,2,4
C,3,5
Warning message:
In write.csv(df, row.names = TRUE, col.names = c(ID, colnames(df))) :
  attempt to set 'col.names' ignored

This gives a warning, not an error message. I've also tried setting 
col.names = NA, and the same warning message is given. Why I don't know, 
according to the help page ?write.csv the default behavior should be 
overriden.


Hope this helps,

Rui Barradas

Em 19-03-2014 11:01, Luca Cerone escreveu:

Thanks Ista,
sorry it was a typo in my email, but in the code I have the right option.

On Wed, Mar 19, 2014 at 11:58 AM, Ista Zahn istaz...@gmail.com wrote:

The argument is col.names, not colnames.

Best,
Ista

On Mar 19, 2014 6:14 AM, Luca Cerone luca.cer...@gmail.com wrote:


Hi everybody,
I am sorry if this is a silly question (I have tried to search it at
http://tolstoy.newcastle.edu.au/R/ but I get a 404 page).

I have a script writing some data.frames to csv files.
I write the csv files using the write.csv function and the option
row.names=TRUE.
Everything works fine, except that I am not able to set the name of
the column holding the row.names.

For example I tried to set the column name to ID like this:

 df = data.frame(a=c(1,2,3), b=c(3,4,5))
 rownames(df) = c(A,B,C)

 write.csv(df, row.names=TRUE, colnames=c(ID, colnames(df)))

This fails with the following error:
 Error in write.table(df, row.names = TRUE, colnames = c(ID,
colnames(df)),  :
   unused argument (colnames = c(ID, colnames(df)))

How can I do this? I have tried to use write.table() as well, but it
seems I never get to set the options right.

Thanks a lot in advance for the help,

Cheers,
Luca

__
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.



__
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] computationally singular

2014-03-19 Thread Matthias Endres
Hi Weiwei,

I found your post on Mahalanobis distances five years ago.

/  Error in solve.default(cov, ...) : system is computationally singular:
//  reciprocal condition number = 1.09501e-25

/I have the same problem now - and I don't know how to deal with it. I would be 
thankful if you could help me with that.

All the best,
Matthias
//


[[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] Fwd: help

2014-03-19 Thread Mehrshad Koleini
Topic: importing data from a web page


Dear Sir/ Madam



Hi. First I apologize for this question. But this also shows I'm
inexperienced in using R.

 I need to import some tables from a web page (https) into R and analyze
them through the readHTMLTable function. After loading XML package, the
following commands are run:



 url - https://.../TopUp/CdrReport.aspx?lang=DK;

mydata - readHTMLTable(url)



and there is a warning:



  XML content does not seem to be XML: ' https://
.../TopUp/CdrReport.aspx?lang=DK'



Would you do me a favor on this issue, please?



Kind regards


Mehrshad Koleini

[[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] Row names at the end of the record

2014-03-19 Thread Ankush Sharma
HI all

How to add row names at the end of the record after transposing a matrix

Sample code
Data = read.table(set_a_2.txt,header = TRUE, sep = \t)
Data.T - t(Data[,0:ncol(fooData)])
write.table(Data.T, file =set_a_2_format.tab,row.names = TRUE, col.names
= TRUE, quote = FALSE)


 example of Transposed matrix
class  rs1 rs2 rs3 rs4 rs5
LG_1 BB AB BB BB BB
LG_2 BB AA BB BB BB
LG_3 BB BB AB AB BB
LG_4 AA BB BB BB BB
LG_5 BB AB BB BB BB

how can i add row headers (LG_1) at the end of rows also

Regards,
Ankush Sharma

[[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] [R-pkgs] RSelenium package

2014-03-19 Thread John Harrison
I would like to announce the release of version 1.2.2 of the RSelenium
package on CRAN.  RSelenium is an R package that provides a set of R
bindings for the Selenium 2.0 webdriver. Selenium automates browsers. Using
RSelenium you can automate browsers locally or remotely. The set of
supported browsers includes Chrome, Firefox, Internet Explorer, Opera,
Safari, PhantomJS and HtmlUnit running on operating systems including
Linux, Mac, Windows, Android, iOS, Firefox OS and Windows Phone.

RSelenium has a project page at

http://johndharrison.github.io/RSelenium/
http://cran.r-project.org/web/packages/RSelenium/index.html

The package comes with several vignettes which contain overviews on basic
operation and a few examples linking to projects such as Shiny and
SauceLabs. Selenium uses include automated application testing, load
testing and web scraping.

Comments and suggestions are greatly appreciated.

John Harrison

[[alternative HTML version deleted]]

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
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] Row names at the end of the record

2014-03-19 Thread PIKAL Petr
Hi

Not sure what you exactly want but some comments in line

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Ankush Sharma
 Sent: Wednesday, March 19, 2014 11:36 AM
 To: r-help@r-project.org
 Subject: [R] Row names at the end of the record

 HI all

 How to add row names at the end of the record after transposing a
 matrix

 Sample code
 Data = read.table(set_a_2.txt,header = TRUE, sep = \t)
 Data.T - t(Data[,0:ncol(fooData)])

Indexing by 0 although in this case it probably does not matter.

 write.table(Data.T, file =set_a_2_format.tab,row.names = TRUE,
 col.names
 = TRUE, quote = FALSE)


  example of Transposed matrix
 class  rs1 rs2 rs3 rs4 rs5
 LG_1 BB AB BB BB BB
 LG_2 BB AA BB BB BB
 LG_3 BB BB AB AB BB
 LG_4 AA BB BB BB BB
 LG_5 BB AB BB BB BB

 how can i add row headers (LG_1) at the end of rows also

trans.matrix$whatever - transmatrix$class

Or you want something different?

Petr



 Regards,
 Ankush Sharma

   [[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.


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
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] Fwd: help

2014-03-19 Thread PIKAL Petr
Hi

Although I am not experienced with XML package the warning seems pretty 
straightforward to me. The object you want to load is not recognised as XML. 
Most probably readHTMLTable requires some format as input and your url is not 
accepted.

Regards
Petr

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Mehrshad Koleini
 Sent: Wednesday, March 19, 2014 11:10 AM
 To: r-help@r-project.org
 Subject: [R] Fwd: help

 Topic: importing data from a web page


 Dear Sir/ Madam



 Hi. First I apologize for this question. But this also shows I'm
 inexperienced in using R.

  I need to import some tables from a web page (https) into R and
 analyze them through the readHTMLTable function. After loading XML
 package, the following commands are run:



  url - https://.../TopUp/CdrReport.aspx?lang=DK;

 mydata - readHTMLTable(url)



 and there is a warning:



   XML content does not seem to be XML: ' https://
 .../TopUp/CdrReport.aspx?lang=DK'



 Would you do me a favor on this issue, please?



 Kind regards


 Mehrshad Koleini

   [[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.


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
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] help

2014-03-19 Thread peter dalgaard

On 19 Mar 2014, at 11:10 , Mehrshad Koleini mehrkole...@gmail.com wrote:
 
 I need to import some tables from a web page (https) into R and analyze
 them through the readHTMLTable function. After loading XML package, the
 following commands are run:
 
 url - https://.../TopUp/CdrReport.aspx?lang=DK;
 mydata - readHTMLTable(url)
 
 and there is a warning:
  XML content does not seem to be XML: ' https://
 .../TopUp/CdrReport.aspx?lang=DK'
 
 Would you do me a favor on this issue, please?

Maybe, but you're not giving us much to go on...

If the page really isn't HTML or XML, then readHTMLTable() is not going to help 
you. So perhaps first see what is in there; either by opening the URL in a 
browser and using View Source, or by using

con - url(url) ## you might want to reconsider the naming...
readLines(con)
close(con) 


-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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.


Re: [R] Row names at the end of the record

2014-03-19 Thread Noah Marconi

Is this what you're trying to do?

mtrx - structure(c(BB, AB, BB, BB, BB, BB, AA, BB, 
BB,
BB, BB, BB, AB, AB, BB, AA, BB, 
BB, BB, BB,
BB, AB, BB, BB, BB), .Dim = c(5L, 5L), 
.Dimnames = list(
  c(rs1, rs2, rs3, rs4, rs5), c(LG_1, 
LG_2, LG_3,
  LG_4, 
LG_5)))


mtrx - cbind(mtrx, dimnames(mtrx)[[1]])

write.table(mtrx, file =set_a_2_format.tab,row.names = TRUE, col.names
= TRUE, quote = FALSE)



Before saving simply cbind the row names onto the end of your matrix.


NM

On 2014-03-19 06:36, Ankush Sharma wrote:

HI all

How to add row names at the end of the record after transposing a 
matrix


Sample code
Data = read.table(set_a_2.txt,header = TRUE, sep = \t)
Data.T - t(Data[,0:ncol(fooData)])
write.table(Data.T, file =set_a_2_format.tab,row.names = TRUE, 
col.names

= TRUE, quote = FALSE)


 example of Transposed matrix
class  rs1 rs2 rs3 rs4 rs5
LG_1 BB AB BB BB BB
LG_2 BB AA BB BB BB
LG_3 BB BB AB AB BB
LG_4 AA BB BB BB BB
LG_5 BB AB BB BB BB

how can i add row headers (LG_1) at the end of rows also

Regards,
Ankush Sharma

[[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.


Re: [R] Fwd: R basic data manipulation Queries

2014-03-19 Thread arun
HI,
It seems like you used ?attach().  Better would be to use ?with.
set.seed(45)
dat1 - as.data.frame(matrix(sample(LETTERS,80,replace=TRUE),20,4))
lapply(dat1,levels) ##get the levels of all the dataset variables in a list

 with(dat1,levels(V1))


A.K.





I have another question, at the moment I am looking at the levels for some of 
my variables in my dataset. 
Instead of typing levels statement everytime, is there a shortcut for doing 
that? 

So at the moment I am writing 
levels(time) 
levels(hour) 
level(date) 
levels(qrtr) 
and so on... 
can I do all this in one step? 





 -Original Message-
 From: pavnee...@yahoo.co.uk
 Sent: Tue, 18 Mar 2014 10:10:38 +
 To: r-help@r-project.org
 Subject: [R] Fwd: R basic data manipulation Queries
 
 
 
 
 
 
 Sent from Samsung Mobile
 
  Original message 
 Subject: R basic data manipulation Queries
 From: Pavneet Arora pavneet.ar...@uk.rsagroup.com
 To: pavnee...@yahoo.co.uk
 CC:
 
 Hello Guys
 
 I am new in R, so please excuse the really basic questions. I have tried
 reading numeral tutorials, but I am still stuck.
 Question 1:
 If I perform correlation on my data [cor(nums2)] or try to produce
 variance matrix [var(nums2)]. The output comes in R console. Is there any
 way I can make it go directly to excel somehow?

Not exactly but fairly easily. Have a look at the R-site and go to the Manuals 
section.  There is a R Import and Export manual there.
 
 Question 2:
 Also is there any way I can permanently change the variable name in a
 data frame.
 I basically imported my dataset from SAS using read.ssd function in
 library(foreign). However, this package cuts off the variable names and
 only allows 8 characters! So that means I will have to rename some of my
 variable names, so they make more sense as to what it is.
 
 part (a):
 At the moment, I did the following to change the variable names, using
 library(plyr). First of all, is this the most succint way of doing this?
 new_acc - rename(acc_mod,c(NAME_OF_=weekName, ACCIDENT=AccSev,
 YEARMONH=YrMonHr,
 X_1ST_ROA=1RdCls.N, ROAD_TYP=RdType.N, LOCATION=LocEast))
 
 part (b):
 Secondly, I wanted to do the above, to change the name permanently - but
 I don't think it worked, because when I do the following, I get:
 class(LocEast) # New name of LOCATION
 class(LOCATION)
 R Output:
 class(LocEast)
 Error: object 'LocEast' not found
 class(LOCATION)
 [1] numeric
 
 Thanks so much!B
     [[alternative HTML version deleted]]
 

I have never used plyr for thhis but just
names(aac.mod)  -  c(Newname1, Newname2) and so on for a new name for each 
column in the data.frame should do it.


Protect your computer files with professional cloud backup.
Get PCRx Backup and upload unlimited files automatically. 
Learn more at http://backup.pcrx.com/mail


__
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.


[R] Does a survival probability(the probability not experiencing an event) have to be non-increasing?

2014-03-19 Thread Zhiyuan Sun
My question is related to a cox model with time-dependent variable.
When I think about it more, I get a little confused about
non-increasing assumption for survival probability for an individual.
For example, for a time-dependent ,say x, assuming increasing x
increases the risk of event. Assume,time t1  t2.  If at x at t1 x
at t2, obviously, hazard at t1 will less than hazard at t2, assuming
no other covariaates. But is it possible that s(t2|x at t2)  s(t1|x
at t1), since at t2, an individual is at greater risk.  This is kind
of confusing to me.

Thanks for any helpful insights!

Zhiyuan

__
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] fitting

2014-03-19 Thread IZHAK shabsogh
given the data below 



x1-c(-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1)
y-c(-1,-1,-1,0,0,0,1,1,1,-1,-1,-1,0,0,0,1,1,1,-1,-1,-1,0,0,0,1,1,1)
z-c(-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1)

using maple i can fit as below and get (1)

#PolynomialFit(3, x1, y1, z) ;

Fit(a+b*(x^2+y^2+z^2), Matrix([x1,y1,z1]),m1,[x,y,z]);

(1)



my question, is there a way we can do the same in R (i.e to obtain (1) using R)

[[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] ZOO objects: Creating, Plotting, Analyzing

2014-03-19 Thread Rich Shepard

  I need to plot and analyze irregular time series. Having read the JSS
article on zoo (2005), ?zoo, ?plot.zoo, and the quickref vignette I'm still
not doing this correctly.

  My work flow is to read the *.csv file to create a dataframe, convert the
df to a matrix using as.matrix() (see s95.ec.txt attached), then cr⎈eate a
zoo object specifying 'sampdate' as the order.by index. The result is the
second attachment (s95.ec.z.txt) which does not appear correct to me.

  Of the several zoo methods involving NA values, none of the imputations
seem appropriate for my data as there is neither pattern or sufficiently
short gaps between observed values, so I chose 'na.omit.' Putting that in
the command, e.g., s95.ec.z - zoo(s95.ec, order.by = 'sampdate', na.omit)
produced an error:

s95.ec.z - zoo(s95.ec, order.by = 'sampdate', na.omit)
Error in frequency  1 :
  comparison (6) is possible only for atomic and list types

  I suspect that the first hurdle I need to overcome is correctly creating a
zoo object from the matrix.

  All the data I analyze have irregular collection dates and I need to
become fluent with zoo objects so I can correctly analyze and plot the time
series of these data.

Rich
structure(c(1992-03-12, 1992-04-22, 1992-05-22, 1992-06-03, 
1992-11-06, 1993-01-28, 1993-02-18, 1993-03-03, 1993-03-15, 
1993-04-08, 1993-04-30, 1993-05-11, 1993-05-27, 1993-06-10, 
1993-06-25, 1993-07-09, 1993-07-31, 1994-03-28, 1994-04-07, 
1994-04-26, 1994-05-27, 1994-06-23, 1995-04-11, 1995-04-29, 
1995-05-30, 1995-06-23, 1995-07-26, 1995-12-04, 1996-01-16, 
1996-05-07, 1996-06-05, 1996-07-02, 1997-04-30, 1997-05-14, 
1997-06-16, 1997-07-29, 1998-05-25, 1998-05-28, 1998-07-27, 
1998-09-15, 1998-10-21, 1998-11-24, 1999-05-10, 1999-05-25, 
1999-06-22, 1999-07-22, 1999-11-09, 1999-12-01, 2000-03-04, 
2000-03-10, 2000-04-21, 2000-05-09, 2000-06-28, 2000-11-27, 
2000-12-07, 2001-02-16, 2001-03-07, 2001-04-30, 2001-05-11, 
2001-06-25, 2002-05-04, 2002-06-21, 2003-05-03, 2003-06-15, 
2004-06-28, 2004-07-01,  85,  80,  85, NA,  90, 110, 
 90, 100, 875,  85,  83,  75,  49,  65,  57, 
 55,  64,  60,  80,  80,  45,  65,  83,  60, 
 40,  62,  80, 119,  55,  65,  44,  48,  68, 
 43,  50,  70,  52,  45,  66,  92,  92, 134, 
 77,  52, 382,  72,  83,  78,  78,  77,  62, 
 51,  59,  79,  65,  77,  81,  59,  55,  67, 
 67,  16,  70, NA,  42,  42), .Dim = c(66L, 2L), .Dimnames = list(
c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 
42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 
62, 63, 64, 65, 66), c(sampdate, EC)))
structure(c(1992-03-12,  85), .Dim = 1:2, .Dimnames = list(
1, c(sampdate, EC)), index = sampdate, class = zoo)
__
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] Help with finding mean at 1 second interval

2014-03-19 Thread arun
Hi Satish,

Pascal's suggestion is better. 

Please use ?dput() to show the example data.

 op - options(digits.secs=6)
library(zoo)
##added a couple more rows
 dat - read.zoo(text=V1 V2 V3 V4 V5 V6
'2014-03-14 22:41:46.988804'  10   2   8   3  14
'2014-03-14 22:41:46.991126'  13   4   9   5  15
'2014-03-14 22:41:46.993506'  12   4   8   3  14
'2014-03-14 22:41:46.993755'  19   4  15   5  22
'2014-03-14 22:41:46.997780'  21   5  16   7  24
'2014-03-14 22:41:47.000154'  18   5  13   3  21
'2014-03-14 22:41:47.002376'  21   5  16   6  23
'2014-03-14 22:41:47.011106'  12   4   8   3  14
'2014-03-14 22:41:47.012691'  12   4   8   3  16
'2014-03-14 22:41:47.017579'  11   2   9   3  12
'2014-03-14 22:41:47.019463'  12   5   7   3  15
'2014-03-14 22:41:47.020247'  14   6   8   3  17
'2014-03-15 22:41:47.017579'  11   2   9   3  12
'2014-03-15 22:41:47.019463'  12   5   7   3  15
'2014-03-15 22:41:47.020247'  14   6   8   3  17, 
index.column=1,sep=,header=TRUE, format= %Y-%m-%d %H:%M:%OS,FUN=as.POSIXct) 
options(op)
library(xts)
 period.apply(dat,endpoints(dat,seconds),mean)
#  V2   V3    V4   V5   V6
#2014-03-14 22:41:46 15.0 3.80 11.20 4.60 17.8
#2014-03-14 22:41:47 14.28571 4.428571  9.857143 3.428571 16.85714
#2014-03-15 22:41:47 12.3 4.33  8.00 3.00 14.7


A.K.





On Tuesday, March 18, 2014 7:27 PM, Pascal Oettli kri...@ymail.com wrote:
Hello,

Please have a look at the xts package.

Please don't post in HTML.

Regards,
Pascal

On Wed, Mar 19, 2014 at 12:26 AM, Satish Anupindi Rao
satish.anupindi@ericsson.com wrote:
 Hi,
 I have a zoo object with the first column as index. The columns have not been 
 named yet... but that I can change. It looks like this :
                                                           V2 V3 V4 V5 V6
 2014-03-14 22:41:46.988804  10   2   8   3  14
 2014-03-14 22:41:46.991126  13   4   9   5  15
 2014-03-14 22:41:46.993506  12   4   8   3  14
 2014-03-14 22:41:46.993755  19   4  15   5  22
 2014-03-14 22:41:46.997780  21   5  16   7  24
 2014-03-14 22:41:47.000154  18   5  13   3  21
 2014-03-14 22:41:47.002376  21   5  16   6  23
 2014-03-14 22:41:47.011106  12   4   8   3  14
 2014-03-14 22:41:47.012691  12   4   8   3  16
 2014-03-14 22:41:47.017579  11   2   9   3  12
 2014-03-14 22:41:47.019463  12   5   7   3  15
 2014-03-14 22:41:47.020247  14   6   8   3  17

 I would like to find the mean of the V2 to V6 columns on a per second 
 interval. Would anyone please be able to help me with a function and 
 implementation for that please?

 Thanks so much!


         [[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.



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan


__
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.


Re: [R] package environment versus namespace environment

2014-03-19 Thread Suraj Gupta
As the author of that post, I must respond...

# -  first comment ---

Ducan: The article that Henrik cited gives a reasonable description up
until near the end

Suraj: Given the complexity of the topics at hand, the many accolades I've
received for the post, and how thoroughly I've approached the topic and
carefully navigated the user through rough terrain, I feel that
characterizing my description as reasonable substantially shortchanges
it.  I wrote the post because the available descriptions (including those
from well-established R community members) were confusing and filled with
holes.

# -  next comment ---

Duncan: ...up until near the end, where (in my opinion) it makes things
unnecessarily complicated

Suraj: I think Duncan is confusing iterative teaching, repetition, and
thoroughness with complexity.  These topics ARE complex.  The need for a
resource such as mine is a testament to that.  My approach to complex
topics is to break them down fully; to be diligent in the explanation so
there are no leaps in logic.  It's far more difficult to do that than to
assume a reader can connect the dots and default to brevity.

# -  next comment ---

Duncan: I'd recommend that you stop reading around where he tries to
explain the dotted lines.

Suraj:  It's a disservice to yourself to stop here.  This section provides
a light bulb moment on the path to understanding the search/find
mechanism.  As stated in the blog post Function execution is the most
complex piece of the puzzle.   I specifically encourage readers to re-read
that section.  Other resources will provide the same understanding, but
it's likely a cumbersome process for the average reader.  I synthesized
these insights after laboring over words in books and articles, tinkering
in R, and asking lots of questions.

# -  next comment ---

Duncan: In particular, ignore the second version of the Map of the
World; the first one is accurate, the second is just misleading

Suraj:  A reader that doesn't understand the second Map cannot fully grasp
the search/find mechanism.  Everything in the post builds up to the second
map.  The second map encompasses function execution.  I challenge anyone
(in a friendly way) to create a better visualization of enclosing
environments and function execution that allows a reader to easily navigate
environment-space and figure out how R searches for symbols and where it
finds them.  I'll replace my map with yours if you can do that - we will
all be better off for it!

# -  last comment ---

Duncan: Gupta's article misses the possibility of packages that are loaded
but not in the search path...

Suraj: I'm pretty sure I discuss all of this in Imports v Depends
section.  I have a diagram that shows package PLYR as loaded but not in the
search path and I discuss it.


On Wed, Mar 19, 2014 at 1:12 PM, Mark Leeds marklee...@gmail.com wrote:

 Hi Everyone: Suraj will respond to Duncan's comments below promptly. Suraj
 doesn't have the original thread so I am just helping out by commenting
 here so that he can respond and the thread can be kept continuous.

 Mark





 On Sun, Mar 9, 2014 at 9:09 AM, Duncan Murdoch murdoch.dun...@gmail.com
 wrote:

  On 14-03-08 6:42 PM, Benjamin Tyner wrote:
 
  Duncan,
 
  Thank you for the informative link. So, do the loaded namespaces have an
  ordering akin to the package search path that determines that
  functions in the base namespace can see objects in the utils namespace?
  (I noticed that loadedNamespaces() just comes back in alphabetical
 order.)
 
 
  No.  The article that Henrik cited gives a reasonable description up
 until
  near the end, where (in my opinion) it makes things unnecessarily
  complicated.  I'd recommend that you stop reading around where he tries
 to
  explain the dotted lines.  In particular, ignore the second version of
 the
  Map of the World; the first one is accurate, the second is just
  misleading.
 
  In answer to your question:  Gupta's article misses the possibility of
  packages that are loaded but not in the search path.  In the notation of
  the first part of that article, loading a namespace just puts it in the
  middle two columns (i.e. creates the namespace and imports environments)
  without putting it in the search list.  That happens when you import or
  load a package without attaching it.  The search path imposes an
 ordering,
  things that aren't in it aren't ordered.
 
  Duncan Murdoch
 
 
 
  Regards
  Ben
 
  On 03/07/2014 11:46 AM, Duncan Murdoch wrote:
 
  On 07/03/2014 10:16 AM, Benjamin Tyner wrote:
 
  Hello,
 
  I realize that a function in environment: base (for example,
 function
  head1 below) is unable to see (without resorting to ::, anyway)
  objects in utils (for example, head below), since package:base is
  after package:utils on the search path.
 
 
 
  However, I'm wondering what is the machinery that allows a function in
  environment: namespace:base (for example, function head2 

Re: [R] package environment versus namespace environment

2014-03-19 Thread Mark Leeds
Hi Everyone: Suraj will respond to Duncan's comments below promptly. Suraj
doesn't have the original thread so I am just helping out by commenting
here so that he can respond and the thread can be kept continuous.

Mark





On Sun, Mar 9, 2014 at 9:09 AM, Duncan Murdoch murdoch.dun...@gmail.comwrote:

 On 14-03-08 6:42 PM, Benjamin Tyner wrote:

 Duncan,

 Thank you for the informative link. So, do the loaded namespaces have an
 ordering akin to the package search path that determines that
 functions in the base namespace can see objects in the utils namespace?
 (I noticed that loadedNamespaces() just comes back in alphabetical order.)


 No.  The article that Henrik cited gives a reasonable description up until
 near the end, where (in my opinion) it makes things unnecessarily
 complicated.  I'd recommend that you stop reading around where he tries to
 explain the dotted lines.  In particular, ignore the second version of the
 Map of the World; the first one is accurate, the second is just
 misleading.

 In answer to your question:  Gupta's article misses the possibility of
 packages that are loaded but not in the search path.  In the notation of
 the first part of that article, loading a namespace just puts it in the
 middle two columns (i.e. creates the namespace and imports environments)
 without putting it in the search list.  That happens when you import or
 load a package without attaching it.  The search path imposes an ordering,
 things that aren't in it aren't ordered.

 Duncan Murdoch



 Regards
 Ben

 On 03/07/2014 11:46 AM, Duncan Murdoch wrote:

 On 07/03/2014 10:16 AM, Benjamin Tyner wrote:

 Hello,

 I realize that a function in environment: base (for example, function
 head1 below) is unable to see (without resorting to ::, anyway)
 objects in utils (for example, head below), since package:base is
 after package:utils on the search path.



 However, I'm wondering what is the machinery that allows a function in
 environment: namespace:base (for example, function head2 below) to
 be able to see head just fine, without needing to resort to ::.



 See Luke Tierney's article in R News,

 Name space management for R. Luke Tierney, R News, 3(1):2-6, June 2003
 http://cran.r-project.org/doc/Rnews/Rnews_2003-1.pdf

 There's a link to it from the R help system.  Run help.start(), then
 look at Technical papers in the Miscellaneous Material section.

 I believe most of what it says is still current; the only thing I can
 see at a glance that is no longer correct is that in those days
 namespaces were optional in packages.  Now all packages have namespaces.

 Duncan Murdoch


 I'm also wondering more generally, why there is a need (practically
 speaking) for a distinction between the environment associated with a
 package and the environment associated with the namespace.

 $ export R_PROFILE=/home/btyner/Rprofile.site

 $ cat /home/btyner/Rprofile.site
 sys.source(/home/btyner/head1.R, envir = baseenv())
 sys.source(/home/btyner/head2.R, envir = .BaseNamespaceEnv)

 $ cat /home/btyner/head1.R
 head1 - function(x) head(x)

 $ cat /home/btyner/head2.R
 head2 - function(x) head(x)

 $ Rscript -e head1(letters)
 Error in head1(letters) : could not find function head
 Execution halted

 $ Rscript -e head2(letters)
 [1] a b c d e f

 $ Rscript -e sessionInfo()
 R version 3.0.1 (2013-05-16)
 Platform: x86_64-pc-linux-gnu (64-bit)

 locale:
  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=C LC_NAME=C
  [9] LC_ADDRESS=C   LC_TELEPHONE=C
 [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

 attached base packages:
 [1] stats graphics  grDevices utils datasets  base

 Regards
 Ben



 __
 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.


[[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] Reshaping Data in R - Transforming Two Columns Into One

2014-03-19 Thread PIKAL Petr
Hi

Isn't melt just what you want?

melt(mydt)

Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Abraham Mathew
 Sent: Tuesday, March 18, 2014 1:59 AM
 To: r-help@r-project.org (r-help@r-project.org)
 Subject: [R] Reshaping Data in R - Transforming Two Columns Into One

 I have the following data frame. Using the stringr package, I've
 attempted
 to map the url's to some specific elements that are in each url. I then
 used the reshape package to join two different data frames. The next
 step
 is to transform the two columns in the mydt data frame (forester and
 customer_support) into one column which specified whether or not it
 contained that element or not (0 or 1).


 url =
 data.frame(u=c(http://www.subaru.com/vehicles/impreza/index.html;,
 
 http://www.subaru.com/index.html?s_kwcid=subaruk_clickid=214495e6-
 dbe0-6668-9222-3d7cd876prid=87k_affcode=76602
 ,
 http://www.subaru.com/customer-support.html;,
 http://www.subaru.com/;,
 http://www.subaru.com/vehicles/forester/index.html;))
 url

 cs = c(customer-support)
 f = c(forester)
 one_match - str_c(cs, collapse = |)
 two_match - str_c(f, collapse = |)
 main - function(df) {
   df$customer_support - as.numeric(str_detect(url$u, one_match))
   df
 }
 d1 = main(url)
 d1
 main - function(df) {
   df$forester - as.numeric(str_detect(url$u, two_match))
   df
 }
 d2 = main(url)
 d2
 mydt = join(d1, d2)
 str(mydt)
 reshape(mydt, direction=long, idvar=u, varying=2:3, sep=)
 reshape(mydt, varying=2:3, direction =long,  idvar = u)



 I've messed around with the reshape package but I'm not able to figure
 it
 out. Is there an alternative package or function I can use to get the
 desired result.

   [[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.


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 

[R] Calculations with aggregate data: mean +/- standard deviation

2014-03-19 Thread Luigi Marongiu
Dear all,
I have obtained the averages (means) and standard deviations (SD) of
different variable using the aggregate function, which I have found very
useful for these kind of computation.
However I would like to calculate the lower and upper ends of the
data (that is mean - SD and mean + SD) varible-wise, but I don't know how
to cope with this aggregate data. I cannot simply subtract the aggregated
results (which I have called AVG and SD) and the aggregate function is a
bit too complicated for me.
Does anybody knows how to add and subtract the means and standard
deviations obtained using the aggregate function?

Best regards,
Luigi


 my.data-structure(list(
   column_1 = 1:120,
   column_2 = structure(c(
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8,
 1,2,3,4,5,6,7,8), .Label = c(Unstimulated, ESAT6, CFP10, Rv3615c,
Rv2654, Rv3879, Rv3873, PHA), class = factor),
 column_3 = c(
 
192.0519108,183.6403531,53.46798757,83.60638077,69.60749873,159.4706861,256.8765622,499.2899303,
 
2170.799076,1411.349719,2759.472348,2098.973397,2164.739515,1288.676574,1611.486543,6205.229575,
 
870.7424981,465.9967135,191.8962375,864.0937485,2962.693675,1289.259137,2418.651212,7345.712517,
 0,168.1198893,674.4342961,101.1575401,47.81596237,0,0,1420.793922,
 
142.6871331,5.466468742,291.9564635,80.73914133,73.02239621,64.47806871,144.3543635,3167.959757,
 
3164.748333,1092.634557,28733.20269,1207.87783,729.6090973,151.8706088,241.2466141,9600.963594,
 
1411.718287,12569.96285,1143.254476,6317.378481,16542.27718,79.68025792,1958.495138,7224.503437,
 
208.4382941,69.48609769,656.691151,0.499017582,7114.910926,187.6296174,41.73980805,8930.784541,
 
4.276752185,0.432300363,60.89228665,1.103924786,0.490686366,1.812993239,7.264531581,1518.610307,
 
2172.051528,595.8513744,17141.84336,589.6565971,1340.287628,117.350942,593.7034054,24043.61463,
 
0,81.83292179,1539.864321,36.41722958,8.385131047,161.7647376,65.21615696,7265.573875,
 
97.84753179,154.051827,0.613835842,10.06138851,45.04879285,176.8284258,18795.75462,3067686.769,
 
5780.34957,944.2200834,2398.235596,1083.393165,2541.714557,1251.670895,1547.178549,1792.679176,
 
3067.988416,8117.210173,23676.02226,8251.937547,17360.80494,18563.61561,16941.865,31453.96708,
 
2767.493803,4796.33016,12292.93705,3864.657567,9380.673835,14886.44683,8457.88646,26050.47191)),
.Names = c(row, stimulation, copy), row.names = c(NA, -120L),
 class = data.frame)
attach(my.data)

AVG-aggregate(copy ~ stimulation  , my.data, mean, na.rm = T)
SD-aggregate(copy ~ stimulation  , my.data, sd, na.rm = T)

# ??? question: AVG-SD and AVG + SD ???

[[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] ZOO objects: Creating, Plotting, Analyzing

2014-03-19 Thread Rich Shepard

  I need to plot and analyze irregular time series. Having read the JSS
article on zoo (2005), ?zoo, ?plot.zoo, and the quickref vignette I'm still
not doing this correctly. This did not post to the list with the dput()
outputs attached; they are at the end of this message.

  My work flow is to read the *.csv file to create a data.frame, subset the
df to yield a date/data file for each constituent, convert the subset df to
a matrix using as.matrix() (see s95.ec.txt attached), then create a zoo
object specifying 'sampdate' as the order.by index. The result is the second
attachment (s95.ec.z.txt) which does not appear correct to me.

  Of the several zoo methods involving NA values, none of the imputations
seem appropriate for my data as there is neither pattern or sufficiently
short gaps between observed values, so I chose 'na.omit.' Putting that in
the command, e.g., s95.ec.z - zoo(s95.ec, order.by = 'sampdate', na.omit)
produced an error:

s95.ec.z - zoo(s95.ec, order.by = 'sampdate', na.omit)
Error in frequency  1 :
  comparison (6) is possible only for atomic and list types

  I suspect that the first hurdle I need to overcome is correctly creating a
zoo object from the matrix.

  All the data I analyze have irregular collection dates and I need to
become fluent with zoo objects so I can correctly analyze and plot the time
series of these data.

Rich

s95.ec.txt++
structure(c(1992-03-12, 1992-04-22, 1992-05-22, 1992-06-03, 
1992-11-06, 1993-01-28, 1993-02-18, 1993-03-03, 1993-03-15, 
1993-04-08, 1993-04-30, 1993-05-11, 1993-05-27, 1993-06-10, 
1993-06-25, 1993-07-09, 1993-07-31, 1994-03-28, 1994-04-07, 
1994-04-26, 1994-05-27, 1994-06-23, 1995-04-11, 1995-04-29, 
1995-05-30, 1995-06-23, 1995-07-26, 1995-12-04, 1996-01-16, 
1996-05-07, 1996-06-05, 1996-07-02, 1997-04-30, 1997-05-14, 
1997-06-16, 1997-07-29, 1998-05-25, 1998-05-28, 1998-07-27, 
1998-09-15, 1998-10-21, 1998-11-24, 1999-05-10, 1999-05-25, 
1999-06-22, 1999-07-22, 1999-11-09, 1999-12-01, 2000-03-04, 
2000-03-10, 2000-04-21, 2000-05-09, 2000-06-28, 2000-11-27, 
2000-12-07, 2001-02-16, 2001-03-07, 2001-04-30, 2001-05-11, 
2001-06-25, 2002-05-04, 2002-06-21, 2003-05-03, 2003-06-15, 
2004-06-28, 2004-07-01,  85,  80,  85, NA,  90, 110, 
 90, 100, 875,  85,  83,  75,  49,  65,  57, 
 55,  64,  60,  80,  80,  45,  65,  83,  60, 
 40,  62,  80, 119,  55,  65,  44,  48,  68, 
 43,  50,  70,  52,  45,  66,  92,  92, 134, 
 77,  52, 382,  72,  83,  78,  78,  77,  62, 
 51,  59,  79,  65,  77,  81,  59,  55,  67, 
 67,  16,  70, NA,  42,  42), .Dim = c(66L, 2L), .Dimnames = list(

c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, 65, 66), c(sampdate, EC)))

s95.ex.z.txt+++
structure(c(1992-03-12,  85), .Dim = 1:2, .Dimnames = list(
1, c(sampdate, EC)), index = sampdate, class = zoo)

__
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] reading row title

2014-03-19 Thread eliza botto
Dear R-Family,
I have a data-set of the following format. I am only presenting a part of it.
DateA B   C 
  D

 
 
 
 
 
 
  1-Jan-61
  0.00
  1.27
  8.128
  
  0.25
 
 
  
2-Jan-61
  
6.10
  
9.144
  
94.742
  
  

15.49


 
 
  3-Jan-61
  0.00
  0.508
  1.27
  
  
0.00


 
 
  4-Jan-61
  0.00
  0
  NA
  
  
0.00


 
 
  5-Jan-61
  0.00
  0
  0
  
  
0.00


 
 
  6-Jan-61
  0.00
  NA
  0
  
  
0.00


 
 
  7-Jan-61
  0.00
  0
  0
  
  
0.00


 
 
  8-Jan-61
  0.00
  NA
  0
  
  
0.00


 
 
  9-Jan-61
  0.00
  NA
  0
  
  
NA


 
 
  
10-Jan-61
  
0.00
  
4.064
  
4.826
  


  
0.76
 
You can see that each column has some NAs in it, What i want to do is to learn 
that which date has NA for each column. 
Here it should be something like the following

A BC
D
   6-Jan-61   4-Jan-61  
   9-Jan-61
   8-Jan-61
   9-Jan-61

Thankyou very much in advance

Eliza 
[[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] reading row title

2014-03-19 Thread eliza botto
Dear Arun and Jim,
Thanks for your replies. I will be extremely careful next time.Anyway, here is 
the dput format of dat
 dput(dat)
structure(list(Date = c(1-Jan-61, 2-Jan-61, 3-Jan-61, 4-Jan-61, 
5-Jan-61, 6-Jan-61, 7-Jan-61, 8-Jan-61, 9-Jan-61, 10-Jan-61), A = 
c(0, 6.1, 0, 0, 0, 0, 0, 0, 0, 0), B = c(1.27, 9.144, 0.508, 0, 0, NA, 0, NA, 
NA, 4.064), C = c(8.128, 94.742, 1.27, NA, 0, 0, 0, 0, 0, 4.826), D = c(0.25, 
15.49, 0, 0, 0, 0, 0, 0, NA, 0.76)), .Names = c(Date, A, B, C, D), 
class = data.frame, row.names = c(NA, -10L))
 dput(res)
structure(list(A = c(, , ), B = c(6-Jan-61, 8-Jan-61, 9-Jan-61), C 
= c(4-Jan-61, , ), D = c(9-Jan-61, , )), .Names = c(A, B, C, 
D), row.names = c(NA, -3L), class = data.frame) Eliza

 Date: Wed, 19 Mar 2014 12:11:43 -0700
 From: smartpink...@yahoo.com
 Subject: Re: [R] reading row title
 To: eliza_bo...@hotmail.com
 
 BTW, if you had looked at your post, you would understand how HTML mangled 
 your post.á It is better to dput().á You are posting for sometime now, so I 
 hope you understand it...
 
 
 
 
 On Wednesday, March 19, 2014 3:04 PM, arun smartpink...@yahoo.com wrote:
 Hi,
 
 dat - read.table(text=Dateáá Aááá Báá Cááá D
 1-Jan-61áá 0.00á 1.27áá 8.128á 0.25
 2-Jan-61 6.10 9.144 94.742 15.49
 3-Jan-61á 0.00 0.508á 1.27 0.00
 4-Jan-61á 0.00á 0á NA 0.00
 5-Jan-61á 0.00á 0á 0 0.00
 6-Jan-61áá 0.00á NAá 0 0.00
 7-Jan-61á 0.00á 0á 0 0.00
 8-Jan-61á 0.00á NAá 0 0.00
 9-Jan-61á 0.00á NAá 0 NA
 10-Jan-61 0.00 4.064 4.826 0.76,sep=,header=TRUE,stringsAsFactors=FALSE)
 
 res -á as.data.frame(apply(dat[,-1],2,FUN=function(x) {x1 
 -dat[,1][is.na(x)]; x2 - max(colSums(is.na(dat[,-1]))); if(length(x1)  x2) 
 c(x1, rep(,x2-length(x1))) else x1}),stringsAsFactors=FALSE)
 
 
 A.K.
 
 
 
 On Wednesday, March 19, 2014 2:39 PM, eliza botto eliza_bo...@hotmail.com 
 wrote:
 Dear R-Family,
 I have a data-set of the following format. I am only presenting a part of it.
 Dateá á á á á á á á Aá á á á á á á áá Bá á á á á á á á á á á á áá Cá á á á á 
 á á á á á á á á á á á áá D
 
 
 
 
 
 
 
 á 1-Jan-61
 á 0.00
 á 1.27
 á 8.128
 á 
 á 0.25
 
 
 á 
 2-Jan-61
 á 
 6.10
 á 
 9.144
 á 
 94.742
 á 
 á 
 
 15.49
 
 
 
 
 á 3-Jan-61
 á 0.00
 á 0.508
 á 1.27
 á 
 á 
 0.00
 
 
 
 
 á 4-Jan-61
 á 0.00
 á 0
 á NA
 á 
 á 
 0.00
 
 
 
 
 á 5-Jan-61
 á 0.00
 á 0
 á 0
 á 
 á 
 0.00
 
 
 
 
 á 6-Jan-61
 á 0.00
 á NA
 á 0
 á 
 á 
 0.00
 
 
 
 
 á 7-Jan-61
 á 0.00
 á 0
 á 0
 á 
 á 
 0.00
 
 
 
 
 á 8-Jan-61
 á 0.00
 á NA
 á 0
 á 
 á 
 0.00
 
 
 
 
 á 9-Jan-61
 á 0.00
 á NA
 á 0
 á 
 á 
 NA
 
 
 
 
 á 
 10-Jan-61
 á 
 0.00
 á 
 4.064
 á 
 4.826
 á 
 
 
 á 
 0.76
 
 You can see that each column has some NAs in it, What i want to do is to 
 learn that which date has NA for each column. 
 Here it should be something like the following
 
 Aá á á á á á á á á á á á á áá Bá á á á á á á á á á á á á á á á Cá á á á á á á 
 á á á á á á á á á á á á á D
 á á á á á á á á á á áá 6-Jan-61á á á á á á á á á á á á áá 4-Jan-61á á á á á á 
 á á á á á áá 9-Jan-61
 á á á á á á á á á á áá 8-Jan-61
 á á á á á á á á á á áá 9-Jan-61
 
 Thankyou very much in advance
 
 Eliza ááá  ááá áá ááá ááá á 
 ááá [[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.


Re: [R] reading row title

2014-03-19 Thread arun
Hi,

dat - read.table(text=Date   A    B   C    D
1-Jan-61   0.00  1.27   8.128  0.25
2-Jan-61 6.10 9.144 94.742 15.49
3-Jan-61  0.00 0.508  1.27 0.00
4-Jan-61  0.00  0  NA 0.00
5-Jan-61  0.00  0  0 0.00
6-Jan-61   0.00  NA  0 0.00
7-Jan-61  0.00  0  0 0.00
8-Jan-61  0.00  NA  0 0.00
9-Jan-61  0.00  NA  0 NA
10-Jan-61 0.00 4.064 4.826 0.76,sep=,header=TRUE,stringsAsFactors=FALSE)

res -  as.data.frame(apply(dat[,-1],2,FUN=function(x) {x1 -dat[,1][is.na(x)]; 
x2 - max(colSums(is.na(dat[,-1]))); if(length(x1)  x2) c(x1, 
rep(,x2-length(x1))) else x1}),stringsAsFactors=FALSE)


A.K.


On Wednesday, March 19, 2014 2:39 PM, eliza botto eliza_bo...@hotmail.com 
wrote:
Dear R-Family,
I have a data-set of the following format. I am only presenting a part of it.
Date                A                 B                           C             
                      D







  1-Jan-61
  0.00
  1.27
  8.128
  
  0.25


  
2-Jan-61
  
6.10
  
9.144
  
94.742
  
  

15.49




  3-Jan-61
  0.00
  0.508
  1.27
  
  
0.00




  4-Jan-61
  0.00
  0
  NA
  
  
0.00




  5-Jan-61
  0.00
  0
  0
  
  
0.00




  6-Jan-61
  0.00
  NA
  0
  
  
0.00




  7-Jan-61
  0.00
  0
  0
  
  
0.00




  8-Jan-61
  0.00
  NA
  0
  
  
0.00




  9-Jan-61
  0.00
  NA
  0
  
  
NA




  
10-Jan-61
  
0.00
  
4.064
  
4.826
  


  
0.76

You can see that each column has some NAs in it, What i want to do is to learn 
that which date has NA for each column. 
Here it should be something like the following

A                             B                                C                
                        D
                       6-Jan-61                           4-Jan-61              
           9-Jan-61
                       8-Jan-61
                       9-Jan-61

Thankyou very much in advance

Eliza                           
    [[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.


Re: [R] Calculations with aggregate data: mean +/- standard deviation

2014-03-19 Thread Rui Barradas

Hello,

Maybe something like the following.

res - merge(AVG, SD, by = stimulation)
names(res)[2:3] - c(AVG, SD)
res$lower - res$AVG - res$SD
res$upper - res$AVG + res$SD
res


Hope this helps,

Rui Barradas

Em 19-03-2014 18:15, Luigi Marongiu escreveu:

Dear all,
I have obtained the averages (means) and standard deviations (SD) of
different variable using the aggregate function, which I have found very
useful for these kind of computation.
However I would like to calculate the lower and upper ends of the
data (that is mean - SD and mean + SD) varible-wise, but I don't know how
to cope with this aggregate data. I cannot simply subtract the aggregated
results (which I have called AVG and SD) and the aggregate function is a
bit too complicated for me.
Does anybody knows how to add and subtract the means and standard
deviations obtained using the aggregate function?

Best regards,
Luigi


  my.data-structure(list(
column_1 = 1:120,
column_2 = structure(c(
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8,
  1,2,3,4,5,6,7,8), .Label = c(Unstimulated, ESAT6, CFP10, Rv3615c,
Rv2654, Rv3879, Rv3873, PHA), class = factor),
  column_3 = c(
  
192.0519108,183.6403531,53.46798757,83.60638077,69.60749873,159.4706861,256.8765622,499.2899303,
  
2170.799076,1411.349719,2759.472348,2098.973397,2164.739515,1288.676574,1611.486543,6205.229575,
  
870.7424981,465.9967135,191.8962375,864.0937485,2962.693675,1289.259137,2418.651212,7345.712517,
  0,168.1198893,674.4342961,101.1575401,47.81596237,0,0,1420.793922,
  
142.6871331,5.466468742,291.9564635,80.73914133,73.02239621,64.47806871,144.3543635,3167.959757,
  
3164.748333,1092.634557,28733.20269,1207.87783,729.6090973,151.8706088,241.2466141,9600.963594,
  
1411.718287,12569.96285,1143.254476,6317.378481,16542.27718,79.68025792,1958.495138,7224.503437,
  
208.4382941,69.48609769,656.691151,0.499017582,7114.910926,187.6296174,41.73980805,8930.784541,
  
4.276752185,0.432300363,60.89228665,1.103924786,0.490686366,1.812993239,7.264531581,1518.610307,
  
2172.051528,595.8513744,17141.84336,589.6565971,1340.287628,117.350942,593.7034054,24043.61463,
  
0,81.83292179,1539.864321,36.41722958,8.385131047,161.7647376,65.21615696,7265.573875,
  
97.84753179,154.051827,0.613835842,10.06138851,45.04879285,176.8284258,18795.75462,3067686.769,
  
5780.34957,944.2200834,2398.235596,1083.393165,2541.714557,1251.670895,1547.178549,1792.679176,
  
3067.988416,8117.210173,23676.02226,8251.937547,17360.80494,18563.61561,16941.865,31453.96708,
  
2767.493803,4796.33016,12292.93705,3864.657567,9380.673835,14886.44683,8457.88646,26050.47191)),
.Names = c(row, stimulation, copy), row.names = c(NA, -120L),
  class = data.frame)
attach(my.data)

AVG-aggregate(copy ~ stimulation  , my.data, mean, na.rm = T)
SD-aggregate(copy ~ stimulation  , my.data, sd, na.rm = T)

# ??? question: AVG-SD and AVG + SD ???

[[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.


Re: [R] Does a survival probability(the probability not experiencing an event) have to be non-increasing?

2014-03-19 Thread Federico Lasa
Don't really understand your equations but.

If X is the (random variable of) time of event, then the survival

 S(x) = 1 -  Pr( X  x )

has to be non increasing since:

If t1  t2. then

S(t1) - S(t2) = Pr(X  t2) - Pr( X  t1 ) = Pr( t1  X  t2)  0

which means that

S(t1)  S(t2).

But you must not confuse this with the conditional probability of survival
given the age.


On Wed, Mar 19, 2014 at 10:41 AM, Zhiyuan Sun sam.d@gmail.com wrote:

 My question is related to a cox model with time-dependent variable.
 When I think about it more, I get a little confused about
 non-increasing assumption for survival probability for an individual.
 For example, for a time-dependent ,say x, assuming increasing x
 increases the risk of event. Assume,time t1  t2.  If at x at t1 x
 at t2, obviously, hazard at t1 will less than hazard at t2, assuming
 no other covariaates. But is it possible that s(t2|x at t2)  s(t1|x
 at t1), since at t2, an individual is at greater risk.  This is kind
 of confusing to me.

 Thanks for any helpful insights!

 Zhiyuan

 __
 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] cforest sampling methods

2014-03-19 Thread Maggie Makar
Hi all,

I've been using the randomForest package and I'm trying to make the switch
over to party. My problem is that I have an extremely unbalanced outcome
(only 1% of the data has a positive outcome) which makes resampling methods
necessary.

randomForest has a very useful argument that is sampsize which allows me to
use a balanced subsample to build each tree in my forest. lets say the
number of positive cases is 100, my forest would look something like this:

rf-randomForest(y~. ,data=train, ntree=800,replace=TRUE,sampsize = c(100,
100))

so I use 100 cases and 100 controls to build each individual tree. Can I do
the same for cforests? I know I can always upsample but I'd rather not.

I've tried playing around with the weights argument but I'm either not
getting it right or it's just the wrong thing to use.

Any advice on how to adapt cforests to datasets with imbalanced outcomes is
greatly appreciated...



Thanks!

[[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] cforest sampling methods

2014-03-19 Thread Max Kuhn
You might look at the 'bag' function in the caret package. It will not
do the subsampling of variables at each split but you can bag a tree
and down-sample the data at each iteration. The help page has an
examples bagging ctree (although you might want to play with the tree
depth a little).

Max

On Wed, Mar 19, 2014 at 3:32 PM, Maggie Makar maggieyma...@gmail.com wrote:
 Hi all,

 I've been using the randomForest package and I'm trying to make the switch
 over to party. My problem is that I have an extremely unbalanced outcome
 (only 1% of the data has a positive outcome) which makes resampling methods
 necessary.

 randomForest has a very useful argument that is sampsize which allows me to
 use a balanced subsample to build each tree in my forest. lets say the
 number of positive cases is 100, my forest would look something like this:

 rf-randomForest(y~. ,data=train, ntree=800,replace=TRUE,sampsize = c(100,
 100))

 so I use 100 cases and 100 controls to build each individual tree. Can I do
 the same for cforests? I know I can always upsample but I'd rather not.

 I've tried playing around with the weights argument but I'm either not
 getting it right or it's just the wrong thing to use.

 Any advice on how to adapt cforests to datasets with imbalanced outcomes is
 greatly appreciated...



 Thanks!

 [[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.


Re: [R] package environment versus namespace environment

2014-03-19 Thread Duncan Murdoch

On 14-03-19 1:18 PM, Suraj Gupta wrote:

As the author of that post, I must respond...

# -  first comment ---

Ducan: The article that Henrik cited gives a reasonable description up
until near the end

Suraj: Given the complexity of the topics at hand, the many accolades
I've received for the post, and how thoroughly I've approached the topic
and carefully navigated the user through rough terrain, I feel that
characterizing my description as reasonable substantially shortchanges
it.  I wrote the post because the available descriptions (including
those from well-established R community members) were confusing and
filled with holes.


Okay, next time I write about it I'll be sure to make the positive parts 
more effusive in their praise.  I can't remember all the details of my 
complaints now (I wrote the quoted lines 10 days ago), and I doubt if 
anyone would be interested in hearing them, so I'll just let them and 
your responses stand.


Duncan Murdoch



# -  next comment ---

Duncan: ...up until near the end, where (in my opinion) it makes things
unnecessarily complicated

Suraj: I think Duncan is confusing iterative teaching, repetition, and
thoroughness with complexity.  These topics ARE complex.  The need for a
resource such as mine is a testament to that.  My approach to complex
topics is to break them down fully; to be diligent in the explanation so
there are no leaps in logic.  It's far more difficult to do that than to
assume a reader can connect the dots and default to brevity.

# -  next comment ---

Duncan: I'd recommend that you stop reading around where he tries to
explain the dotted lines.

Suraj:  It's a disservice to yourself to stop here.  This section
provides a light bulb moment on the path to understanding the
search/find mechanism.  As stated in the blog post Function execution
is the most complex piece of the puzzle.   I specifically encourage
readers to re-read that section.  Other resources will provide the same
understanding, but it's likely a cumbersome process for the average
reader.  I synthesized these insights after laboring over words in books
and articles, tinkering in R, and asking lots of questions.

# -  next comment ---

Duncan: In particular, ignore the second version of the Map of the
World; the first one is accurate, the second is just misleading

Suraj:  A reader that doesn't understand the second Map cannot fully
grasp the search/find mechanism.  Everything in the post builds up to
the second map.  The second map encompasses function execution.  I
challenge anyone (in a friendly way) to create a better visualization of
enclosing environments and function execution that allows a reader to
easily navigate environment-space and figure out how R searches for
symbols and where it finds them.  I'll replace my map with yours if you
can do that - we will all be better off for it!

# -  last comment ---

Duncan: Gupta's article misses the possibility of packages that are
loaded but not in the search path...

Suraj: I'm pretty sure I discuss all of this in Imports v Depends
section.  I have a diagram that shows package PLYR as loaded but not in
the search path and I discuss it.


On Wed, Mar 19, 2014 at 1:12 PM, Mark Leeds marklee...@gmail.com
mailto:marklee...@gmail.com wrote:

Hi Everyone: Suraj will respond to Duncan's comments below promptly.
Suraj
doesn't have the original thread so I am just helping out by commenting
here so that he can respond and the thread can be kept continuous.

Mark





On Sun, Mar 9, 2014 at 9:09 AM, Duncan Murdoch
murdoch.dun...@gmail.com mailto:murdoch.dun...@gmail.comwrote:

  On 14-03-08 6:42 PM, Benjamin Tyner wrote:
 
  Duncan,
 
  Thank you for the informative link. So, do the loaded namespaces
have an
  ordering akin to the package search path that determines that
  functions in the base namespace can see objects in the utils
namespace?
  (I noticed that loadedNamespaces() just comes back in
alphabetical order.)
 
 
  No.  The article that Henrik cited gives a reasonable description
up until
  near the end, where (in my opinion) it makes things unnecessarily
  complicated.  I'd recommend that you stop reading around where he
tries to
  explain the dotted lines.  In particular, ignore the second
version of the
  Map of the World; the first one is accurate, the second is just
  misleading.
 
  In answer to your question:  Gupta's article misses the
possibility of
  packages that are loaded but not in the search path.  In the
notation of
  the first part of that article, loading a namespace just puts it
in the
  middle two columns (i.e. creates the namespace and imports
environments)
  without putting it in the search list.  That happens when you
import or
  load a package without attaching it.  The search path imposes an
ordering,

[R] ZOO objects: Creating, Plotting, Analyzing

2014-03-19 Thread Rich Shepard

  I need to plot and analyze irregular time series. Despite reading the 2005
JSS article on zoo, ?zoo, ?plot.zoo, and the quickref vignette I'm still not
doing this correctly. dput() output of a matrix and the zoo object are at
the end of this message.

  My work flow is to read the *.csv file to create a data.frame, subset the
df to yield a date/data file for each constituent, convert the subset df to
a matrix using as.matrix() (see s95.ec.txt attached), then create a zoo
object specifying 'sampdate' as the order.by index. The result is the second
attachment (s95.ec.z.txt) which does not appear correct to me.

  Of the several zoo methods involving NA values, none of the imputations
seem appropriate for my data as there is neither pattern or sufficiently
short gaps between observed values, so I chose 'na.omit.' Putting that in
the command, e.g., s95.ec.z - zoo(s95.ec, order.by = 'sampdate', na.omit)
produced an error:

s95.ec.z - zoo(s95.ec, order.by = 'sampdate', na.omit)
Error in frequency  1 :
  comparison (6) is possible only for atomic and list types

  I suspect that the first hurdle I need to overcome is correctly creating a
zoo object from the matrix.

  All the data I analyze have irregular collection dates and I need to
become fluent with zoo objects so I can correctly analyze and plot the time
series of these data.

Rich

s95.ec.txt++
structure(c(1992-03-12, 1992-04-22, 1992-05-22, 1992-06-03, 
1992-11-06, 1993-01-28, 1993-02-18, 1993-03-03, 1993-03-15, 
1993-04-08, 1993-04-30, 1993-05-11, 1993-05-27, 1993-06-10, 
1993-06-25, 1993-07-09, 1993-07-31, 1994-03-28, 1994-04-07, 
1994-04-26, 1994-05-27, 1994-06-23, 1995-04-11, 1995-04-29, 
1995-05-30, 1995-06-23, 1995-07-26, 1995-12-04, 1996-01-16, 
1996-05-07, 1996-06-05, 1996-07-02, 1997-04-30, 1997-05-14, 
1997-06-16, 1997-07-29, 1998-05-25, 1998-05-28, 1998-07-27, 
1998-09-15, 1998-10-21, 1998-11-24, 1999-05-10, 1999-05-25, 
1999-06-22, 1999-07-22, 1999-11-09, 1999-12-01, 2000-03-04, 
2000-03-10, 2000-04-21, 2000-05-09, 2000-06-28, 2000-11-27, 
2000-12-07, 2001-02-16, 2001-03-07, 2001-04-30, 2001-05-11, 
2001-06-25, 2002-05-04, 2002-06-21, 2003-05-03, 2003-06-15, 
2004-06-28, 2004-07-01,  85,  80,  85, NA,  90, 110,  90, 
100, 875,  85,  83,  75,  49,  65,  57,  55,  64,  60,  
80,  80,  45,  65,  83,  60,  40,  62,  80, 119,  55,  
65,  44,  48,  68,  43,  50,  70,  52,  45,  66,  92,  
92, 134,  77,  52, 382,  72,  83,  78,  78,  77,  62,  
51,  59,  79,  65,  77,  81,  59,  55,  67,  67,  16,  
70, NA,  42,  42), .Dim = c(66L, 2L), .Dimnames = list(

c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, 65, 66), c(sampdate, EC)))

s95.ex.z.txt+++
structure(c(1992-03-12,  85), .Dim = 1:2, .Dimnames = list(
1, c(sampdate, EC)), index = sampdate, class = zoo)

__
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] 2013-06-28 coverts to 15884?

2014-03-19 Thread Jason Rupert
MaxUpdated_row-NULL
MaxUpdated_val- 2013-06-28


rbind(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))
  [,1]
[1,] 15884

c(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))
[1] 15884
c(MaxUpdated_row, MaxUpdated_val)
[1] 15884

Evidently, I'm again missing something simple, as I would prefer to be able to 
see the actual date to be shown.  

I found a work around, but I don't like it, as I have to convert back to date 
later:
c(MaxUpdated_row, as.character(MaxUpdated_val))

Any alternatives suggestions are much appreciated. 
[[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] 2013-06-28 coverts to 15884?

2014-03-19 Thread Jim Lemon

On 03/20/2014 08:46 AM, Jason Rupert wrote:

MaxUpdated_row-NULL
MaxUpdated_val- 2013-06-28


rbind(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))
   [,1]
[1,] 15884

c(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))

[1] 15884

c(MaxUpdated_row, MaxUpdated_val)

[1] 15884


Evidently, I'm again missing something simple, as I would prefer to be able to 
see the actual date to be shown.

I found a work around, but I don't like it, as I have to convert back to date 
later:
c(MaxUpdated_row, as.character(MaxUpdated_val))


Hi Jason,
You aren't converting the date to something else, just displaying it as 
a character vector by using the format function. Whenever you form a 
vector, R tries to convert everything in it to the same data type. If 
you _assign_ that vector to something else:


mymax-c(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))

you will have the date type in the MaxUpdated_val and the character type 
in mymax.


Jim

__
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] 2013-06-28 coverts to 15884?

2014-03-19 Thread Jason Rupert
Not sure I follow. 

I would like the date formatting information preserved as is implemented when 
using as.character: 
MaxUpdated_row-NULL
MaxUpdated_val- 2013-06-28

c(MaxUpdated_row, as.character(MaxUpdated_val))
[1] 2013-06-28

However, when I try to used as.Date(...) I loose the date formatting 
information:
c(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))
[1] 15884


I thought as.Date was an instruction describing how the data element should be 
represented?


Maybe as.character is the only way to preserve the date formatting 
information in character string format in a vector and then just convert it 
back later on...


Thanks again.




On Wednesday, March 19, 2014 5:42 PM, Jim Lemon j...@bitwrit.com.au wrote:
 
On 03/20/2014 08:46 AM, Jason Rupert wrote:

 MaxUpdated_row-NULL
 MaxUpdated_val- 2013-06-28


 rbind(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))
        [,1]
 [1,] 15884

 c(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))
 [1] 15884
 c(MaxUpdated_row, MaxUpdated_val)
 [1] 15884

 Evidently, I'm again missing something simple, as I would prefer to be able 
 to see the actual date to be shown.

 I found a work around, but I don't like it, as I have to convert back to date 
 later:
 c(MaxUpdated_row, as.character(MaxUpdated_val))

Hi Jason,
You aren't converting the date to something else, just displaying it as 
a character vector by using the format function. Whenever you form a 
vector, R tries to convert everything in it to the same data type. If 
you _assign_ that vector to something else:

mymax-c(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))

you will have the date type in the MaxUpdated_val and the character type 
in mymax.

Jim
[[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] 2013-06-28 coverts to 15884?

2014-03-19 Thread William Dunlap
Instead of making your initial value of MaxUpdated_row  NULL,
make it a 0-long Date object.  Then c() will work as you wish
(but not rbind).  E.g.,

 MaxUpdated_row - as.Date(character(0))
 MaxUpdated_row - c(MaxUpdated_row, as.Date(2013-06-28, %Y-%m-%d))
 MaxUpdated_row - c(MaxUpdated_row, as.Date(2013-07-06, %Y-%m-%d))
 str(MaxUpdated_row)
 Date[1:2], format: 2013-06-28 2013-07-06

Bill Dunlap
TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Jason Rupert
 Sent: Wednesday, March 19, 2014 2:47 PM
 To: R-help@r-project.org
 Subject: [R] 2013-06-28 coverts to 15884?
 
 MaxUpdated_row-NULL
 MaxUpdated_val- 2013-06-28
 
 
 rbind(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))
   [,1]
 [1,] 15884
 
 c(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))
 [1] 15884
 c(MaxUpdated_row, MaxUpdated_val)
 [1] 15884
 
 Evidently, I'm again missing something simple, as I would prefer to be able 
 to see the
 actual date to be shown.
 
 I found a work around, but I don't like it, as I have to convert back to date 
 later:
 c(MaxUpdated_row, as.character(MaxUpdated_val))
 
 Any alternatives suggestions are much appreciated.
   [[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] package environment versus namespace environment

2014-03-19 Thread Mark Leeds
Hi Duncan: If you  think there is anything incorrect in the document, I'd
be interested because I refer to that document whenever I'm confused about
namespaces, importing etc. Thanks.




On Wed, Mar 19, 2014 at 4:31 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote:

 On 14-03-19 1:18 PM, Suraj Gupta wrote:

 As the author of that post, I must respond...

 # -  first comment ---

 Ducan: The article that Henrik cited gives a reasonable description up
 until near the end

 Suraj: Given the complexity of the topics at hand, the many accolades
 I've received for the post, and how thoroughly I've approached the topic
 and carefully navigated the user through rough terrain, I feel that
 characterizing my description as reasonable substantially shortchanges
 it.  I wrote the post because the available descriptions (including
 those from well-established R community members) were confusing and
 filled with holes.


 Okay, next time I write about it I'll be sure to make the positive parts
 more effusive in their praise.  I can't remember all the details of my
 complaints now (I wrote the quoted lines 10 days ago), and I doubt if
 anyone would be interested in hearing them, so I'll just let them and your
 responses stand.

 Duncan Murdoch


 # -  next comment ---

 Duncan: ...up until near the end, where (in my opinion) it makes things
 unnecessarily complicated

 Suraj: I think Duncan is confusing iterative teaching, repetition, and
 thoroughness with complexity.  These topics ARE complex.  The need for a
 resource such as mine is a testament to that.  My approach to complex
 topics is to break them down fully; to be diligent in the explanation so
 there are no leaps in logic.  It's far more difficult to do that than to
 assume a reader can connect the dots and default to brevity.

 # -  next comment ---

 Duncan: I'd recommend that you stop reading around where he tries to
 explain the dotted lines.

 Suraj:  It's a disservice to yourself to stop here.  This section
 provides a light bulb moment on the path to understanding the
 search/find mechanism.  As stated in the blog post Function execution
 is the most complex piece of the puzzle.   I specifically encourage
 readers to re-read that section.  Other resources will provide the same
 understanding, but it's likely a cumbersome process for the average
 reader.  I synthesized these insights after laboring over words in books
 and articles, tinkering in R, and asking lots of questions.

 # -  next comment ---

 Duncan: In particular, ignore the second version of the Map of the
 World; the first one is accurate, the second is just misleading

 Suraj:  A reader that doesn't understand the second Map cannot fully
 grasp the search/find mechanism.  Everything in the post builds up to
 the second map.  The second map encompasses function execution.  I
 challenge anyone (in a friendly way) to create a better visualization of
 enclosing environments and function execution that allows a reader to
 easily navigate environment-space and figure out how R searches for
 symbols and where it finds them.  I'll replace my map with yours if you
 can do that - we will all be better off for it!

 # -  last comment ---

 Duncan: Gupta's article misses the possibility of packages that are
 loaded but not in the search path...

 Suraj: I'm pretty sure I discuss all of this in Imports v Depends
 section.  I have a diagram that shows package PLYR as loaded but not in
 the search path and I discuss it.


 On Wed, Mar 19, 2014 at 1:12 PM, Mark Leeds marklee...@gmail.com
 mailto:marklee...@gmail.com wrote:

 Hi Everyone: Suraj will respond to Duncan's comments below promptly.
 Suraj
 doesn't have the original thread so I am just helping out by
 commenting
 here so that he can respond and the thread can be kept continuous.

 Mark





 On Sun, Mar 9, 2014 at 9:09 AM, Duncan Murdoch
 murdoch.dun...@gmail.com mailto:murdoch.dun...@gmail.comwrote:


   On 14-03-08 6:42 PM, Benjamin Tyner wrote:
  
   Duncan,
  
   Thank you for the informative link. So, do the loaded namespaces
 have an
   ordering akin to the package search path that determines that
   functions in the base namespace can see objects in the utils
 namespace?
   (I noticed that loadedNamespaces() just comes back in
 alphabetical order.)
  
  
   No.  The article that Henrik cited gives a reasonable description
 up until
   near the end, where (in my opinion) it makes things unnecessarily
   complicated.  I'd recommend that you stop reading around where he
 tries to
   explain the dotted lines.  In particular, ignore the second
 version of the
   Map of the World; the first one is accurate, the second is just
   misleading.
  
   In answer to your question:  Gupta's article misses the
 possibility of
   packages that are loaded but not in the search path.  

[R] How to fix the warning message the condition has length 1 and only the first element will be used?

2014-03-19 Thread jcrosbie
I'm trying to create a function to return the date x months in the past. 

With the code below I'm getting the warning message:

Warning message:
In if (MonthsBack = CurrentMonth) { :
  the condition has length  1 and only the first element will be used


##

DateBack - function(CurrentYear, CurrentMonth, MonthsBack){
if(MonthsBack 13){
if(MonthsBack=CurrentMonth){
month-12+CurrentMonth-MonthsBack
datet-paste(CurrentYear-1,month, sep=-)
} 
else{
month-CurrentMonth-MonthsBack
datet-paste(CurrentYear-1, month, sep=-)
}
} 
else{
Years - trunc(MonthsBack/12,0)
if((MonthsBack-12*Years)=CurrentMonth){
month-12+CurrentMonth-MonthsBack
} 
else{
month-CurrentMonth-MonthsBack
}
datet-paste(CurrentYear-Years, month, sep=-)
}
return(datet)
}

CurrentYear- c(2000, 2000, 2003, 2004)
CurrentMonth-c(1, 2, 6, 12) 

df- data.frame(CurrentYear, CurrentMonth)

df$MonthsBack - DateBack(df$CurrentYear,df$CurrentMonth,1)






--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-fix-the-warning-message-the-condition-has-length-1-and-only-the-first-element-will-be-used-tp4687140.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.


Re: [R] 2013-06-28 coverts to 15884?

2014-03-19 Thread Pascal Oettli
Hello,

It works for me:

R MaxUpdated_row - NULL
R MaxUpdated_val - 2013-06-28
R
R
R rbind(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))
  [,1]
[1,] 15884
R c(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))
[1] 15884
R c(MaxUpdated_row, MaxUpdated_val)
[1] 2013-06-28
R

Regards,
Pascal

On Thu, Mar 20, 2014 at 6:46 AM, Jason Rupert jasonkrup...@yahoo.com wrote:
 MaxUpdated_row-NULL
 MaxUpdated_val- 2013-06-28


 rbind(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))
   [,1]
 [1,] 15884

 c(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))
[1] 15884
 c(MaxUpdated_row, MaxUpdated_val)
[1] 15884

 Evidently, I'm again missing something simple, as I would prefer to be able 
 to see the actual date to be shown.

 I found a work around, but I don't like it, as I have to convert back to date 
 later:
 c(MaxUpdated_row, as.character(MaxUpdated_val))

 Any alternatives suggestions are much appreciated.
 [[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.




-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

__
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 fix the warning message the condition has length 1 and only the first element will be used?

2014-03-19 Thread Franklin Bretschneider
Hi jcrosbie ,


Re:


 I'm trying to create a function to return the date x months in the past. 
 
 With the code below I'm getting the warning message:
 
 Warning message:
 In if (MonthsBack = CurrentMonth) { :
 the condition has length  1 and only the first element will be used
 

Use ifelse(), that's for vectors. If is intended for single elements only.

Best wishes,


Franklin
-



Franklin Bretschneider
Dept of Biology
Utrecht University
brets...@xs4all.nl

__
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] ZOO objects: Creating, Plotting, Analyzing

2014-03-19 Thread Achim Zeileis

On Wed, 19 Mar 2014, Rich Shepard wrote:


 I need to plot and analyze irregular time series. Despite reading the 2005
JSS article on zoo, ?zoo, ?plot.zoo, and the quickref vignette I'm still not
doing this correctly. dput() output of a matrix and the zoo object are at
the end of this message.


It's sufficient to send such messages once even if others don't reply 
within minutes.


 My work flow is to read the *.csv file to create a data.frame, subset 
the df to yield a date/data file for each constituent, convert the 
subset df to a matrix using as.matrix() (see s95.ec.txt attached), then 
create a zoo object specifying 'sampdate' as the order.by index. The 
result is the second attachment (s95.ec.z.txt) which does not appear 
correct to me.


Please have a look at read.zoo() and the accompanying read.zoo vignette 
which does exactly what you are looking for (reading .csv files and 
turning it into a zoo series).



 Of the several zoo methods involving NA values, none of the imputations
seem appropriate for my data as there is neither pattern or sufficiently
short gaps between observed values, so I chose 'na.omit.' Putting that in
the command, e.g., s95.ec.z - zoo(s95.ec, order.by = 'sampdate', na.omit)
produced an error:

s95.ec.z - zoo(s95.ec, order.by = 'sampdate', na.omit)
Error in frequency  1 :
 comparison (6) is possible only for atomic and list types

 I suspect that the first hurdle I need to overcome is correctly 
creating a zoo object from the matrix.


Yes. The first argument should be a numeric vector or matrix and the 
second argument should be something suitable as a time index. In your case 
s95.ec is a data.frame with two character columns which is not suitable 
directly. This works:


s95.ec.z - zoo(as.numeric(s95.ec[,2]), order.by = as.Date(s95.ec[,1]))
plot(s95.ec.z)

But the route via read.zoo should be more convenient, I guess.


 All the data I analyze have irregular collection dates and I need to
become fluent with zoo objects so I can correctly analyze and plot the time
series of these data.

Rich

s95.ec.txt++
structure(c(1992-03-12, 1992-04-22, 1992-05-22, 1992-06-03, 
1992-11-06, 1993-01-28, 1993-02-18, 1993-03-03, 1993-03-15, 
1993-04-08, 1993-04-30, 1993-05-11, 1993-05-27, 1993-06-10, 
1993-06-25, 1993-07-09, 1993-07-31, 1994-03-28, 1994-04-07, 
1994-04-26, 1994-05-27, 1994-06-23, 1995-04-11, 1995-04-29, 
1995-05-30, 1995-06-23, 1995-07-26, 1995-12-04, 1996-01-16, 
1996-05-07, 1996-06-05, 1996-07-02, 1997-04-30, 1997-05-14, 
1997-06-16, 1997-07-29, 1998-05-25, 1998-05-28, 1998-07-27, 
1998-09-15, 1998-10-21, 1998-11-24, 1999-05-10, 1999-05-25, 
1999-06-22, 1999-07-22, 1999-11-09, 1999-12-01, 2000-03-04, 
2000-03-10, 2000-04-21, 2000-05-09, 2000-06-28, 2000-11-27, 
2000-12-07, 2001-02-16, 2001-03-07, 2001-04-30, 2001-05-11, 
2001-06-25, 2002-05-04, 2002-06-21, 2003-05-03, 2003-06-15, 
2004-06-28, 2004-07-01,  85,  80,  85, NA,  90, 110,  90, 
100, 875,  85,  83,  75,  49,  65,  57,  55,  64,  60, 
 80,  80,  45,  65,  83,  60,  40,  62,  80, 119,  55, 
 65,  44,  48,  68,  43,  50,  70,  52,  45,  66,  92, 
 92, 134,  77,  52, 382,  72,  83,  78,  78,  77,  62, 
 51,  59,  79,  65,  77,  81,  59,  55,  67,  67,  16, 
 70, NA,  42,  42), .Dim = c(66L, 2L), .Dimnames = list(

   c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
   12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
   22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
   32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
   42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
   52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
   62, 63, 64, 65, 66), c(sampdate, EC)))

s95.ex.z.txt+++
structure(c(1992-03-12,  85), .Dim = 1:2, .Dimnames = list(
   1, c(sampdate, EC)), index = sampdate, class = zoo)

__
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.


Re: [R] ZOO objects: Creating, Plotting, Analyzing

2014-03-19 Thread Rich Shepard

On Thu, 20 Mar 2014, Achim Zeileis wrote:

It's sufficient to send such messages once even if others don't reply within 
minutes.


Achim,

  I sent it but my postfix spam filter would not let it out. There should
have been only a single copy.


Please have a look at read.zoo() and the accompanying read.zoo vignette
which does exactly what you are looking for (reading .csv files and
turning it into a zoo series).


  Thank you, I'll do that. I missed that help file and vignette.


Yes. The first argument should be a numeric vector or matrix and the
second argument should be something suitable as a time index. In your case
s95.ec is a data.frame with two character columns which is not suitable
directly.  This works:

s95.ec.z - zoo(as.numeric(s95.ec[,2]), order.by = as.Date(s95.ec[,1]))
plot(s95.ec.z)

But the route via read.zoo should be more convenient, I guess.


  That clarifies my mis-understanding. I'll read about read.zoo, too.

Thank you,

Rich

__
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] 2013-06-28 coverts to 15884?

2014-03-19 Thread Jim Lemon

On 03/20/2014 09:57 AM, Jason Rupert wrote:

Not sure I follow.

I would like the date formatting information preserved as is implemented
when using as.character:
MaxUpdated_row-NULL
MaxUpdated_val- 2013-06-28

c(MaxUpdated_row, as.character(MaxUpdated_val))
[1] 2013-06-28

However, when I try to used as.Date(...) I loose the date formatting
information:
c(MaxUpdated_row, as.Date(MaxUpdated_val, %Y-%m-%d))
[1] 15884

I thought as.Date was an instruction describing how the data element
should be represented?

Maybe as.character is the only way to preserve the date formatting
information in character string format in a vector and then just convert
it back later on...

As I wrote before, all of the data types in a vector object in R must be 
the same. So when you catenate (c) two things that are different data 
types, R coerces them to the same type. Because you are just displaying 
the values in the vector you have created, it doesn't change the data 
type of MaxUpdated_val:


MaxUpdated_val-as.Date(2013-06-28,%Y-%m-%d)
# prints as a formatted date
MaxUpdated_val
[1] 2013-06-28
# make a vector with a numeric and MaxUpdated_val
c(0,MaxUpdated_val)
# R coerces the value to numeric and prints both
[1] 0 15884
# now assign it to something
mynewmax-c(0,MaxUpdated_val)
# in mynewmax the value is numeric
mynewmax
[1] 0 15884
# but MaxUpdated_val is still a date type on its own
MaxUpdated_val
[1] 2013-06-28

Jim

__
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.