[R] Writing Unicode Text into Text File from R (in Windows)

2014-02-04 Thread Majid Einian
Dear R Helpers,

See the Code:

a - intToUtf8(1777)
show(a)
zz - file(description=test.txt,open=w,encoding=UTF-8)
cat(a, file = zz)
close(zz)

in a Unicode aware environment (such as RGui console or RStudio Console)
you will see this as output:

[1] Û±


but the character is not written correctly in the file test.txt (which is
encoded in UTF-8 without BOM) :

U+06F1

The problem seems to be this: R changes text to the locale of system (for
me this is Arabic Windows (Codepage 1256) that does not have a relevant
code for U+06F1, then changes it back to UTF-8 and writes it into file.
What do I miss here?
 How can I write a Unicode string into a text file correctly?


Majid Einian,
Economics Researcher, Monetary and Banking Research Institute, Central Bank
of Islamic Republic of Iran, Tehran, IRAN
and
PhD Candidate in Economics, Graduate School of Management and
Economics, Sharif University of Technology, Tehran, IRAN

[[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] Selecting elements in lists with a row condition

2014-02-04 Thread Francesca
Dear Contributors
I am asking some advice on how to solve the following problem.
I have a list composed of 78 elements, each of which is a matrix of factors
and numbers, similar to the following

bank_name   date px_last_CIB   Q.Yp_made p_for
1   CIB 10/02/061.33 p406-q406406 406
2   CIB 10/23/061.28 p406-q406406 406
3   CIB 11/22/061.28 p406-q406406 406
4   CIB 10/02/061.35 p406-q107406 107
5   CIB 10/23/061.32 p406-q107406 107
6   CIB 11/22/061.32 p406-q107406 107


-- 

Francesca

--
Francesca Pancotto, PhD
Università di Modena e Reggio Emilia
Viale A. Allegri, 9
40121 Reggio Emilia
Office: +39 0522 523264
Web: https://sites.google.com/site/francescapancotto/
--

[[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] Selecting elements in lists with a row condition

2014-02-04 Thread Francesca
Dear Contributors
sorry but the message was sent involuntary.
I am asking some advice on how to solve the following problem.
I have a list composed of 78 elements, each of which is a matrix of factors
and numbers, similar to the following

bank_name   date px_last_CIB   Q.Yp_made p_for
1   CIB 10/02/061.33 p406-q406406 406
2   CIB 10/23/061.28 p406-q406406 406
3   CIB 11/22/061.28 p406-q406406 406
4   CIB 10/02/061.35 p406-q107406 107
5   CIB 10/23/061.32 p406-q107406 107
6   CIB 11/22/061.32 p406-q107406 107


Each of these matrixes changes for the column name bank_name and for the
suffix _CIB which reports the name as in bank_name. Moreover each matrix as
a different number of rows, so that I cannot transform it into a large
matrix.

I need to create a matrix made of the rows of each element of the list that
respect the criterium
that the column p_made is = to 406.
I need to pick each of the elements of each matrix that is contained in the
list elements, that satisfy this condition.

It seems difficult to me but perhaps is super easy.
Thanks for any help you can provide.

Francesca



On 4 February 2014 12:42, Francesca francesca.panco...@gmail.com wrote:

 Dear Contributors
 I am asking some advice on how to solve the following problem.
 I have a list composed of 78 elements, each of which is a matrix of
 factors and numbers, similar to the following

 bank_name   date px_last_CIB   Q.Yp_made p_for
 1   CIB 10/02/061.33 p406-q406406 406
 2   CIB 10/23/061.28 p406-q406406 406
 3   CIB 11/22/061.28 p406-q406406 406
 4   CIB 10/02/061.35 p406-q107406 107
 5   CIB 10/23/061.32 p406-q107406 107
 6   CIB 11/22/061.32 p406-q107406 107


 --

 Francesca

 --
 Francesca Pancotto, PhD
 Università di Modena e Reggio Emilia
 Viale A. Allegri, 9
 40121 Reggio Emilia
 Office: +39 0522 523264
 Web: https://sites.google.com/site/francescapancotto/
 --




-- 

Francesca

--
Francesca Pancotto, PhD
Università di Modena e Reggio Emilia
Viale A. Allegri, 9
40121 Reggio Emilia
Office: +39 0522 523264
Web: https://sites.google.com/site/francescapancotto/
--

[[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] Running the Loop

2014-02-04 Thread Katherine Gobin
Dear R forum,

I have following data.frames

dat = data.frame(id = c(1:3), root = c(0.10, 0.20, 0.74), maturity_period = 
c(20, 155, 428), mtm = c(1000, 1, 10), curve = c(USD, USD, USD))


 dat
  id root maturity_period   mtm curve
1  1 0.10              20 1e+03   USD
2  2 0.20             155 1e+04   USD
3  3 0.74             428 1e+05   USD

standard_tenors = data.frame(T = c(1m, 3m, 6m, 12m, 5yr), D = c(30, 
91, 182, 365, 1825))


 standard_tenors
    T    D
1  1m   30
2  3m   91
3  6m  182
4 12m  365
5 5yr 1825

# 
.

library(plyr)


T = standard_tenors$T

D = standard_tenors$D
n = length(standard_tenors$T)


mtm_split_function = function(maturity_period, curve, root, mtm)

{

for(i in 1:(n-1))
{
if (maturity_period  D[i])


{
N1 = paste(curve, T[i], sep =_)
N2 = paste(curve, T[i], sep =_)
PV1 = mtm
PV2 = 0
}else

if (maturity_period  D[i]  maturity_period  D[i+1])

{
N1 = paste(curve, T[i], sep =_)
N2 = paste(curve, T[1+1], sep =_)
PV1 = (mtm)*root
PV2 = (mtm)*(1-root)
}else

if (maturity_period  D[i+1])
{
N1 = paste(curve, T[i], sep =_)
N2 = paste(curve, T[i], sep =_)
PV1 = 0
PV2 = mtm
}

}


return(data.frame(Risk_factor1 = N1, Risk_factor2 = N2, Risk_factor1_mtm = PV1,
Risk_factor2_mtm = PV2))
}

# 
.

splitted_mtm - ddply(.data = dat, .variables = id,
                .fun=function(x) mtm_split_function(maturity_period = 
x$maturity_period, curve = x$curve, root = x$root, mtm = x$mtm))

# OUTPUT I am getting

  id Risk_factor1 Risk_factor2 Risk_factor1_mtm Risk_factor2_mtm
1  1      USD_12m      USD_12m             1000                0
2  2      USD_12m      USD_12m            1                0
3  3      USD_12m       USD_3m            74000            26000




# My PROBLEM

However, My OUTPUT should be  

  id Risk_factor1 Risk_factor2 Risk_factor1_mtm Risk_factor2_mtm
1  1      USD_1m       USD_1m             1000                0
2  2      USD_3m       USD_6m             2000             8000
3  3      USD_12m      USD_5yr           74000            26000

Kindly guide

With warm regards

Katherine
[[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] Capturing output of a C executable

2014-02-04 Thread Duncan Murdoch

On 14-02-03 5:44 PM, Phil Spector wrote:

Dennis -
  The return value from .C will almost never be useful.


Are you limiting this to the specific situation Dennis described, or 
making a more general claim?  The more general claim is clearly false.


Lots of packages return useful results using .C calls.  The idea is that 
all arguments to the C function are passed by reference and may be 
modified in place, so you just pass a vector to receive the result. 
That's equivalent to what you describe below, but I think it seems 
simpler, since passing an address from R sounds like an exotic 
operation, not the norm.


Duncan Murdoch

 If you want to bring

results from the C environment into R, you need to do it by passing an address 
to
.C which will receive the result.
  You may find this document helpful when interfacing R to C:

   http://www.stat.berkeley.edu/classes/s243/calling.pdf

- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Sun, 2 Feb 2014, Dennis Fisher wrote:


R 3.0.1
OS X

Colleagues,

I am experimenting with incorporating C code into R.  After compiling the C 
code with:
R CMD SHLIB -o FILE.so FILE.c
and executing:
dyn.load(“FILE.so”)
(without any errors), I execute the following R functions in a terminal window:
READSAS - function(sourcefile) .C(readsas, sourcefile)
OUTPUT  - READSAS(../SASFILES/sdrug.sas7bdat)
R / C then reads a sas7bdat file and sends the contents to the terminal window.

I expected OUTPUT to contain the text that appear in the terminal window (i.e., 
the contents of the file).  But, that is not the case; OUTPUT contains:
[[1]]
[1] ../SASFILES/sdrug.sas7bdat
It is not clear to my how to capture that appears in the terminal window.

Ultimately, I may need to modify the C code so that the output goes to a file, 
which I then read into R.  However, it would be better if I did not need to 
modify the C code.
Does anyone have any ideas of how I can capture this output within R?

Dennis

Dennis Fisher MD
P  (The P Less Than Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com

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





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



__
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] Fit Negbin glm model with autoregressive correlation structure

2014-02-04 Thread F.Vial
Dear Cristiano,
Thank you for your suggestion. It looks like an interesting option for what
we are trying to do. We'll look at your paper and package in more details.
Regards,
Flavie



--
View this message in context: 
http://r.789695.n4.nabble.com/Fit-Negbin-glm-model-with-autoregressive-correlation-structure-tp4684489p4684694.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] Writing Unicode Text into Text File from R (in Windows)

2014-02-04 Thread Duncan Murdoch

On 14-02-04 5:49 AM, Majid Einian wrote:

Dear R Helpers,

See the Code:

a - intToUtf8(1777)
show(a)
zz - file(description=test.txt,open=w,encoding=UTF-8)
cat(a, file = zz)
close(zz)

in a Unicode aware environment (such as RGui console or RStudio Console)
you will see this as output:

[1] Û±


but the character is not written correctly in the file test.txt (which is
encoded in UTF-8 without BOM) :

U+06F1

The problem seems to be this: R changes text to the locale of system (for
me this is Arabic Windows (Codepage 1256) that does not have a relevant
code for U+06F1, then changes it back to UTF-8 and writes it into file.
What do I miss here?
  How can I write a Unicode string into a text file correctly?


There are a lot of places in R where it converts strings to the local 
encoding, perhaps too many. On the other hand, maybe Windows should be 
offering UTF-8 locales by now.


I haven't tested in your locale, but I believe writeLines() to a 
connection declared to be in a UTF-8 encoding will maintain the 
encoding.  You can declare a file to be in encoding UTF-8-BOM if you 
want to ignore a BOM on input; I forget whether it will write one on 
output.  If it doesn't, you can always write one explicitly.


I was hoping to make some progress on this before R 3.1.0 so that more 
cases of writing strings to UTF-8 files would work, but time is running out.


Duncan Murdoch




Majid Einian,
Economics Researcher, Monetary and Banking Research Institute, Central Bank
of Islamic Republic of Iran, Tehran, IRAN
and
PhD Candidate in Economics, Graduate School of Management and
Economics, Sharif University of Technology, Tehran, IRAN

[[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] creating an equivalent of r-help on r.stackexchange.com ?

2014-02-04 Thread Marc Schwartz

On Feb 3, 2014, at 8:54 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote:

 On Mon, Feb 3, 2014 at 8:41 PM, Marc Schwartz marc_schwa...@me.com wrote:
 
 Hi All,
 
 As I have noted in a prior reply in this thread, which began last November, 
 I don't post in SO, but I do keep track of the traffic there via RSS feeds. 
 However, the RSS feeds are primarily for new posts and do not seem to update 
 with follow ups to the initial post.
 
 I do wish that they would provide an e-mail interface, which would help to 
 address some of the issues raised here today. They do provide notifications 
 on comments to posts, as do many other online fora. However, there is no 
 routine mailing of new posts with a given tag (eg. 'R'), at least as far as 
 I can see, as I had searched there previously for that functionality. That 
 would be a nice push based approach, as opposed to having to go to the web 
 site.
 
 
 You can set up email subscriptions for specific tags.  See the
 preferences section of your account.  I get regular emails of the
 r_filter.
 Here are the first few lines of an email I juist received (I have
 pasted it into this text plain email but they are received as HTML and
 there are links to the specific questions).

snip

Thanks for the pointer Gabor. I did not have an account on SE/SO and had only 
searched the various help resources there attempting to find out what kind of 
e-mail push functionality was available. A number of posts had suggested a non 
real time e-mail ability, which indeed seems to be the case.

I went ahead and created an account to get a sense of what was available. As 
you note, you can sign up for e-mail subscriptions based upon various tag 
criteria. However, it would seem that you need to specify time intervals for 
the frequency of the e-mails. These can be daily, every 3 hours or every 15 
minutes. So there seems to be a polling/digest based process going on.

I created an e-mail subscription last evening and selected every 15 minutes. 
What appears to be happening is that the frequency of the e-mails actually 
varies. Overnight and this morning, I have e-mails coming in every 20 to 30 
minutes or more apart. It is not entirely clear what the trigger is, given the 
inconsistency in frequency. Perhaps the infrastructure is not robust enough to 
support a more consistent polling/digest e-mail capability yet.

The e-mails contain snippets of new questions only and not responses 
(paralleling the RSS feed content). I need to actually go to the web site to 
see the full content of the question and to see if the question has been 
answered. In most cases, by the time that I get to the site, even right away 
after getting the e-mail, there are numerous replies already present. There is, 
of course, no way to respond via e-mail.

I would say that if one is looking for an efficient e-mail based interface to 
SE/SO, it does not exist at present. It is really designed as a web site only 
interaction, where you are likely going to need to have a browser continuously 
open to the respective site or sites in order to be able to interact 
effectively, if it is your intent to monitor and to respond in a timely fashion 
to queries. 

Alternatively, perhaps a real-time or near real-time updating RSS feed reader 
might make more sense for the timeliness of knowing about new questions. It is 
not clear to me how those who respond quickly (eg. within minutes) are 
interacting otherwise.

There appear to be some browser extensions to support notifications (eg. for 
Chrome), but again, you need to have your browser open. There also appear to be 
some desktop apps in alpha/beta stages that might be helpful. However, they 
seem to track new comments to questions that are specifically being followed 
(eg. questions that you have posted), rather than all new questions, thus 
paralleling the SE/SO Inbox content.

That being said, obviously, a lot of people are moving in that direction given 
the traffic decline here and the commensurate increase there.

Regards,

Marc

__
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] Selecting elements in lists with a row condition

2014-02-04 Thread arun
Hi,
Try:

If `lst1` is the list:
do.call(rbind,lapply(lst1,function(x) x[x[,p_made]==406,]))
A.K.




On Tuesday, February 4, 2014 8:53 AM, Francesca francesca.panco...@gmail.com 
wrote:
Dear Contributors
sorry but the message was sent involuntary.
I am asking some advice on how to solve the following problem.
I have a list composed of 78 elements, each of which is a matrix of factors
and numbers, similar to the following

bank_name   date px_last_CIB       Q.Y    p_made p_for
1       CIB 10/02/06        1.33 p406-q406    406     406
2       CIB 10/23/06        1.28 p406-q406    406     406
3       CIB 11/22/06        1.28 p406-q406    406     406
4       CIB 10/02/06        1.35 p406-q107    406     107
5       CIB 10/23/06        1.32 p406-q107    406     107
6       CIB 11/22/06        1.32 p406-q107    406     107


Each of these matrixes changes for the column name bank_name and for the
suffix _CIB which reports the name as in bank_name. Moreover each matrix as
a different number of rows, so that I cannot transform it into a large
matrix.

I need to create a matrix made of the rows of each element of the list that
respect the criterium
that the column p_made is = to 406.
I need to pick each of the elements of each matrix that is contained in the
list elements, that satisfy this condition.

It seems difficult to me but perhaps is super easy.
Thanks for any help you can provide.

Francesca



On 4 February 2014 12:42, Francesca francesca.panco...@gmail.com wrote:

 Dear Contributors
 I am asking some advice on how to solve the following problem.
 I have a list composed of 78 elements, each of which is a matrix of
 factors and numbers, similar to the following

 bank_name   date px_last_CIB       Q.Y    p_made p_for
 1       CIB 10/02/06        1.33 p406-q406    406     406
 2       CIB 10/23/06        1.28 p406-q406    406     406
 3       CIB 11/22/06        1.28 p406-q406    406     406
 4       CIB 10/02/06        1.35 p406-q107    406     107
 5       CIB 10/23/06        1.32 p406-q107    406     107
 6       CIB 11/22/06        1.32 p406-q107    406     107


 --

 Francesca

 --
 Francesca Pancotto, PhD
 Università di Modena e Reggio Emilia
 Viale A. Allegri, 9
 40121 Reggio Emilia
 Office: +39 0522 523264
 Web: https://sites.google.com/site/francescapancotto/

 --




-- 

Francesca

--
Francesca Pancotto, PhD
Università di Modena e Reggio Emilia
Viale A. Allegri, 9
40121 Reggio Emilia
Office: +39 0522 523264
Web: https://sites.google.com/site/francescapancotto/
--

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


[R] Handling special characters in reading and writing to CSV

2014-02-04 Thread Venkata Kirankumar
Hi All,


I have some data with different special characters, newline character, and
different language characters in a CSV file like `~!@#$%^*|
()-_+={[}]|\:;',.?/
in data, while I am trying to read this CSV and trying to do calculations I
am not able to get this data as there in single cell. I found something
like RFC 4180 format can help to solve this problem.



If anyone can give suggestion related to handling these special characters
it will be help full for me



Thanks in advance,

D V Kiran Kumar

[[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] correlog function in pgirmess package

2014-02-04 Thread Alicia
Dear R-help,

I used the correlog function of pgirmess package to create a spatial
correlogram for Moran's I.
The function gives Moran's coefficient with a p value for each distance
class. My question is what is the unit for the distance classes? 
Here is the outcome of the function:

Moran I statistic 
  dist.class  coefp.valuen
 [1,]   1.283804 -0.0127393244 0.62182018 3288
 [2,]   3.851412 -0.0070005170 0.53767024 5642
 [3,]   6.419020 -0.0020360457 0.41371395 6546
 [4,]   8.986627  0.0173943620 0.07212314 5814
 [5,]  11.554235 -0.0225794695 0.84271228 4918
 [6,]  14.121842 -0.0050324772 0.49452160 3372
 [7,]  16.689450 -0.0007194256 0.42712852 2232
 [8,]  19.257058 -0.0162570231 0.60272799 1242
 [9,]  21.824665 -0.0330641732 0.74239660 1208
[10,]  24.392273  0.0602675483 0.09440368  508
[11,]  26.959881 -0.0007420201 0.43708138  270
[12,]  29.527488  0.0765320993 0.10876925  190
[13,]  32.095096 -0.0046161786 0.44659399  142
[14,]  34.662703 -0.0797066199 0.61910376   58
[15,]  37.230311 -0.7840212074 0.99986700   28
[16,]  39.797919 -0.7770962373 0.99839965   18

I first thought the distance unit was kilometers but the dist.class are only
going until 40 and my data are taken from all around the Mediterranean sea
(about 3700km long) so it cannot be right.

In the correlog help it is said that Distances are in the same unit as the
spatial coordinates but I don't get what that means. I gave spatial
coordinates in decimal degree.

It must be very simple but I was not able to find the answer anywhere.

Thanks for your help,
Cheers,

Alicia



--
View this message in context: 
http://r.789695.n4.nabble.com/correlog-function-in-pgirmess-package-tp4684706.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] GCV=0

2014-02-04 Thread Husam El Alqamy
Dear List

I am trying to use gam function in mgcv 17.26. I have a big data set of
about 40,000 data points. Every time that I run it ,it results in GCV score
of 0

 

Family: gaussian 

Link function: identity 

 

Formula:

D ~ s(Ghazl_res) + s(Depth)

 

Estimated degrees of freedom:

3.77 2.91  total = 7.68 

 

GCV score: 0

 

Plotting the curves of the predictor variables also gives a straight
horizontal line along the zero value of the y axis. I really couldn't
interpret whats going wrong. Appreciate it if anyone can comment

 

Husam El Alqamy,  B.Sc, M.Phil.

Sr. Biodiversity GIS Analyst,

Enivronmental Information Sector

Environment Agency - Abu Dhabi

 


[[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] Categorizing and displaying excel data in tabular format

2014-02-04 Thread ashrafali
R_format.csv http://r.789695.n4.nabble.com/file/n4684711/R_format.csv  

Hi, 

I am new to R Programming and need help on categorizing and plotting the
data in the attached excel file into tabular format. Please help. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Categorizing-and-displaying-excel-data-in-tabular-format-tp4684711.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] Categorizing and displaying excel data in tabular format

2014-02-04 Thread Greg Snow
First, .csv files are not Excel files (and I was unable to open the
one you link to).

Second, while the word Help is used many ways, this list is intended
to assist, i.e. you show that you have done some work and tell us
where you are stuck and we are happy to give hints and pointers to
help you get unstuck.  This list is not a we do everything for you
list.  You should read the posting guide (link at the bottom of this
and every post) and An Introduction to R.  Then show us what you
have tried, what is not working for you, and what you would like to
see.

As it is, your question does not even have enough information to let
us know what question(s) you are trying to answer.  There are many
different plots to explore data in many different ways to answer
different questions, your question does not narrow things down enough
to give us a direction to point you.  See `fortune(122)`.



On Tue, Feb 4, 2014 at 9:27 AM, ashrafali ashraf...@techie.com wrote:
 R_format.csv http://r.789695.n4.nabble.com/file/n4684711/R_format.csv

 Hi,

 I am new to R Programming and need help on categorizing and plotting the
 data in the attached excel file into tabular format. Please help.



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Categorizing-and-displaying-excel-data-in-tabular-format-tp4684711.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.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@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] update.formula() to add interaction terms

2014-02-04 Thread Marie-Pierre Sylvestre
Many thanks, that is exactly what I was looking for. I did not know about
bquote, interesting!
MP


On Mon, Feb 3, 2014 at 6:29 PM, William Dunlap wdun...@tibco.com wrote:

 Is this the sort of thing you are looking for?
 fm - y ~ x1 + x2 + x3 + log(x4)
 # Use terms() instead of just all.vars() to keep log(x4) as log(x4)
 xVars - with(attributes(terms(fm)),
 as.list(variables)[-c(1,response+1)])
 str(xVars)
List of 4
 $ : symbol x1
 $ : symbol x2
 $ : symbol x3
 $ : language log(x4)
 # use bquote to make the addition to the formula
 update(fm, bquote( ~ . + .(xVars[[1]]) * .(xVars[[length(xVars)]])))
y ~ x1 + x2 + x3 + log(x4) + x1:log(x4)

 As a function it would be
addInteraction - function(formula){
   xVars - with(attributes(terms(formula)),
 as.list(variables)[-c(1,response+1)])
  update(formula, bquote( ~ . + .(xVars[[1]]) *
 .(xVars[[length(xVars)]])))
}
 used as
 addInteraction(y~x1+x2+sqrt(x3))
y ~ x1 + x2 + sqrt(x3) + x1:sqrt(x3)

 If the last 'term' in the formula is a compound like x4:x5 and you
 want x1:x4:x5 added you will need to do more work (look at the
 'factors' attribute of terms()'s output) - currently it adds x1:x5.


 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 Marie-Pierre Sylvestre
  Sent: Monday, February 03, 2014 12:54 PM
  To: r-help@r-project.org
  Subject: [R] update.formula() to add interaction terms
 
  Hi,
  I have a list of formulae that I need to modify. For each formula, I need
  to add an interaction term between the first independent variable and the
  last one. I want to write a function to achieve that because the list of
  formulae to modify is long.
 
  For example, if the formula is y ~ x1 + x2 + x3 + x4, then I need to turn
  it either into
 
  y ~ x1*x4 + x2 + x3
 
  or
 
  y ~ x1 + x2 + x3 + x4 + x4:x1
 
  (I know they are the same, but one may be easier to work with than the
  other).
 
 
  Suppose I have the formula a which is defined as a - formula(y ~
  x1+x2+x3+x4)
 
  I know how to access to the first and last independent variables of my
  formula:
 
  firstvar - all.vars(a[[3]])[1]
  lastvar - all.vars(a[[3]])[length( all.vars(a[[3]]))]
 
 
  What I can't figure out is how to use update.formula() to include my
  interaction term in order to get y ~ x1+x2+x3+x4 + x1:x4. Specifically,
 
  update.formula(a, ~ . + paste(all.vars(a[[3]])[1],firstvar, lastvar, sep
 =
  ':'))
 
  is not producing y ~ x1+x2+x3+x4 + x1:x4.
 
  Any idea?
 
  Thanks in advance,
  MP
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


[R] mgcv: distribution of dev with Poisson data

2014-02-04 Thread Greg Dropkin
mgcv: distribution of dev

hi

I can't tell if this is a simple error.
I'm puzzled by the distribution of dev when fitting a gam to Poisson
generated data.
I expected dev to be approximately chi-squared on residual d.f., i.e.
about 1000 in each case below.
In particular, the low values in the 3rd and 4th versions would suggest
scale  1, yet the data is Poisson generated.
The problem isn't caused by insufficient k values in the smoother.
Does this mean that with sparse data the distribution of dev is no longer
approx chi-sq on residual df?
Does it mean the scale estimate when fitting quasipoisson should be the
Pearson version?

thanks

greg

library(mgcv)
set.seed(1)
x1-runif(1000)
linp-2+exp(-2*x1)*sin(8*x1)
sum(exp(linp))
dev1-dev2-sums-rep(0,20)
for (j in 1:20)
{
y-rpois(1000,exp(linp))
sums[j]-sum(y)
m1-gam(y~s(x1),family=poisson)
m2-gam(y~s(x1,k=20),family=poisson)
dev1[j]=m1$dev
dev2[j]=m2$dev
}
mean(sums)
sd(sums)
mean(dev1)
sd(dev1)
mean(dev2)
sd(dev2)

#dev slighly higher than expected

linpa--1+exp(-2*x1)*sin(8*x1)
sum(exp(linpa))
dev1a-dev2a-sumsa-rep(0,20)
for (j in 1:20)
{
y-rpois(1000,exp(linpa))
sumsa[j]-sum(y)
m1-gam(y~s(x1),family=poisson)
m2-gam(y~s(x1,k=20),family=poisson)
dev1a[j]=m1$dev
dev2a[j]=m2$dev
}
mean(sumsa)
sd(sumsa)
mean(dev1a)
sd(dev1a)
mean(dev2a)
sd(dev2a)

#dev a bit lower than expected

linpb--1.5+exp(-2*x1)*sin(8*x1)
sum(exp(linpb))
dev1b-dev2b-sumsb-rep(0,20)
for (j in 1:20)
{
y-rpois(1000,exp(linpb))
sumsb[j]-sum(y)
m1-gam(y~s(x1),family=poisson)
m2-gam(y~s(x1,k=20),family=poisson)
dev1b[j]=m1$dev
dev2b[j]=m2$dev
}
mean(sumsb)
sd(sumsb)
mean(dev1b)
sd(dev1b)
mean(dev2b)
sd(dev2b)

#dev much lower than expected

m1q-gam(y~s(x1),family=quasipoisson,scale=-1)
m1q$scale
m1q$dev/(1000-sum(m1q$edf))

#scale estimate  1

sum((y-fitted(m1q))^2/fitted(m1q))/(1000-sum(m1q$edf))

#Pearson estimate of scale closer, but also  1


linpc--2+exp(-2*x1)*sin(8*x1)
sum(exp(linpc))
dev1c-dev2c-sumsc-rep(0,20)
for (j in 1:20)
{
y-rpois(1000,exp(linpc))
sumsc[j]-sum(y)
m1-gam(y~s(x1),family=poisson)
m2-gam(y~s(x1,k=20),family=poisson)
dev1c[j]=m1$dev
dev2c[j]=m2$dev
}
mean(sumsc)
sd(sumsc)
mean(dev1c)
sd(dev1c)
mean(dev2c)
sd(dev2c)

#dev much lower than expected

m1q-gam(y~s(x1),family=quasipoisson,scale=-1)
m1q$scale
m1q$sig2
m1q$dev/(1000-sum(m1q$edf))

#scale estimate  1

sum((y-fitted(m1q))^2/fitted(m1q))/(1000-sum(m1q$edf))

#Pearson estimate of scale ok

__
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] How to describe gls post-hoc test in manuscript

2014-02-04 Thread Beaulieu, Jake
Hello,

I used the gls function from the nlme package to run a generalized least 
squares model.  One of the predictor variables is a factor with 3 levels.  Here 
is a reproducible example:

library(nlme)
response - c(rnorm(5,1,3), rnorm(5,6,1), rnorm(5,10,5))
foo - data.frame(response = response,
 X=rep(letters[1:3], each=5),
 Y=rep(LETTERS[1:3], each=5))
m1 - gls(response ~ X, weights = varIdent(form= ~1|Y), data=foo)

The anova command indicates that the factor X is significant:
anova(m1)

The summary command compares the mean of each level of X to the reference 
level, which is 'a' in this case:
summary(m1)

Based on the summary command, I will report that levels 'b' and 'c' are greater 
than 'a' at the p  0.05 level.  My question is, what test should I cite for 
these post hoc comparisons?  Are these contrasts a version of Tukeys, Scheffe, 
Fisher LSD, or something similar.

This reproducible example can also be viewed at:
http://rpubs.com/jbeaulie/12839


==
Jake J. Beaulieu, PhD
US Environmental Protection Agency
National Risk Management Research Lab
26 W. Martin Luther King Drive
Cincinnati, OH 45268
USA
513-569-7842  (desk)
513-487-2511 (fax)
beaulieu.j...@epa.gov


[[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] Not able to find files in working directory

2014-02-04 Thread Sschratz87
Hello. I am new to R here and I am coming across a small error in my code I
am trying to run. I am trying to make a table of some value from a folder on
my computer. I was able to pull a txt file from the folder and make bar
graphs etc... however now I cannot do anything from this file and R is
throwing errors at me from every direction.  I will paste what I am trying
to do. 

 table(Squid$YEAR)
Error in table(Squid$YEAR) : object 'Squid' not found
 table(Squid$MONTH,Squid$YEAR)
Error in table(Squid$MONTH, Squid$YEAR) : object 'Squid' not found
 setwd(/Users/SamSchratz/Desktop/Spring 2014/Taking/Bio Stats/Lab/Lab 2 -
 Descriptive Statistics)
Error in setwd(/Users/SamSchratz/Desktop/Spring 2014/Taking/Bio
Stats/Lab/Lab 2 - Descriptive Statistics) : 
  cannot change working directory
 
It is confusing because I was able to run this earlier:
barplot(table(Squid$MONTH,Squid$YEAR),main=Sampling by Year and
Month,xlab=Year and Month, ylab=Sampling Size)

and got:
http://r.789695.n4.nabble.com/file/n4684710/SquidYearMonth.png 

Thoughts? I appreciate whatever you can tell me...



--
View this message in context: 
http://r.789695.n4.nabble.com/Not-able-to-find-files-in-working-directory-tp4684710.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] Change file name

2014-02-04 Thread arun
Hi,
Try:
from1 - list.files() ##folder where files are stored
 from1
#[1] p126r62_5t19880613_nn1.tif.gz p126r62_5t19880613_nn2.tif.gz
#[3] p200r65_5t19880613_nn1.tif.gz

to1 - 
gsub(^p(\\d+)r(\\d+)\\_.{2}(\\d{8})\\_nn(.*),LT5\\10\\2\\3_B\\4,from1)
 file.rename(from1,to1)
#[1] TRUE TRUE TRUE
 list.files()
#[1] LT512606219880613_B1.tif.gz LT512606219880613_B2.tif.gz
#[3] LT520006519880613_B1.tif.gz
A.K.



Hi guys, 

Thank you for reply 

Actually I have thousands of  files and I would like to change file name, then 
I can use it in my software   

e.g The original file 
      p126r62_5t19880613_nn1.tif.gz 

The expected change 
LT512606219880613_B1.tif.gz 

The every single character in original files has some meaning 
  p126r62_5t19880613_nn1.tif.gz 
p(path)126(path number) r (raw)62(rownumber)_5t(name of 
instrument)19880613(date)_nn1(band number).tif.gz 
So I would like to replace some part 

p       = LT5 
r        = 0 
_5t    =remove 
_nn    =B 
=add after date 

I have tried file.rename() function but I was unable to apply this change to 
all files. 
is it possible to use file.rename function to apply for all file? 



On Monday, February 3, 2014 10:48 AM, arun smartpink...@yahoo.com wrote:
Hi,
Check ?file.rename()
http://stackoverflow.com/questions/10758965/how-do-i-rename-files-using-r


A.K.


I have list of files in folder 

e.g p126r62_5t19880613_nn1.tif.gz 
     p126r62_5t19880613_nn2.tif.gz 
     p200r65_5t19880613_nn1.tif.gz 

and I would like to change file name to 
     LT512606219880613XX_B1.tif.gz 
     LT512606219880613XX_B2.tif.gz 
     LT520006519880613XX_B1.tif.gz 

Does any body knows how It can be changed?

__
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 Books from Chapman Hall/CRC

2014-02-04 Thread Calver, Rob
Take advantage of a 20% discount on the most recent R books from Chapman  
Hall/CRC! 

We are pleased to offer our latest R books at a 20% discount through our 
website. To take advantage of this offer, simply visit www.crcpress.com, choose 
your titles, and insert code EZL20 in the Promotion Code field at checkout. 
Standard Shipping is always FREE on all orders from CRCPress.com!

***

Analyzing Spatial Models of Choice and Judgment with R 
David A. Armstrong, II, Ryan Bakker, Royce Carroll, Christopher Hare, Keith T. 
Poole, and Howard Rosenthal

ISBN: 978-1-4665-1715-8
Publication Date: Jan 2014
Number of Pages: 352

With recent advances in computing power and the widespread availability of 
political choice data, such as legislative roll call and public opinion survey 
data, the empirical estimation of spatial models has never been easier or more 
popular. This book demonstrates how to estimate and interpret spatial models 
using a variety of methods with the popular, open-source programming language R.

List Price: $69.95 / £44.99

For more details and to order: 
http://www.crcpress.com/product/isbn/9781466517158

Also available as an eBook

***

Nonlinear Time Series: Theory, Methods and Applications with R Examples 
Randal Douc, Eric Moulines, and David Stoffer

ISBN: 978-1-4665-0225-3
Publication Date: Jan 2014
Number of Pages: 551

This text emphasizes nonlinear models for a course in time series analysis. 
After introducing stochastic processes, Markov chains, Poisson processes, and 
ARMA models, the authors cover functional autoregressive, ARCH, threshold AR, 
and discrete time series models as well as several complementary approaches. 
They discuss the main limit theorems for Markov chains, useful inequalities, 
statistical techniques to infer model parameters, and GLMs. Moving on to HMM 
models, the book examines filtering and smoothing, parametric and nonparametric 
inference, advanced particle filtering, and numerical methods for inference.

List Price: $99.95 / £63.99

For more details and to order: 
http://www.crcpress.com/product/isbn/9781466502253

***

Analyzing Baseball Data with R
Max Marchi and Jim Albert

ISBN: 978-1-4665-7022-1
Publication Date: Oct 2013
Number of Pages: 334

This book provides an introduction to R for sabermetricians, baseball 
enthusiasts, and students interested in exploring the rich sources of baseball 
data. It equips readers with the necessary skills and software tools to perform 
all of the analysis steps, from gathering the datasets and entering them in a 
convenient format to visualizing the data via graphs to performing a 
statistical analysis.

List Price: $39.95 / £25.99

For more details and to order: 
http://www.crcpress.com/product/isbn/9781466570221

Visit the authors' blog for advice on using R in sabermetrics research and for 
keeping up to date with new developments: http://baseballwithr.wordpress.com/.

***

Reproducible Research with R and RStudio 
Christopher Gandrud

ISBN: 978-1-4665-7284-3
Publication Date: Jul 2013
Number of Pages: 294

Bringing together computational research tools in one accessible source, this 
book guides you in creating dynamic and highly reproducible research. Suitable 
for researchers in any quantitative empirical discipline, it presents practical 
tools for data collection, data analysis, and the presentation of results. 
Whether you're an advanced user or just getting started with tools such as R 
and LaTeX, this book saves you time searching for information and helps you 
successfully carry out computational research. It provides a practical 
reproducible research workflow that you can use to gather and analyze data as 
well as dynamically present results in print and on the web.

List Price: $69.95 / £44.99

For more details and to order: 
http://www.crcpress.com/product/isbn/9781466572843

Also available as an eBook

***

Dynamic Documents with R and knitr
Yihui Xie

ISBN: 978-1-4822-0353-0
Publication Date: Jul 2013
Number of Pages: 216

Suitable for both beginners and advanced users, this book shows you how to 
write reports in simple languages such as Markdown. The reports range from 
homework, projects, exams, books, blogs, and web pages to any documents related 
to statistical graphics, computing, and data analysis. While familiarity with 
LaTeX and HTML is helpful, the book requires no prior experience with advanced 
programs or languages. For beginners, the text provides enough features to get 
started on basic applications. For power users, the last several chapters 
enable an understanding of the extensibility of the knitr package. 

List Price: $59.95 / £38.99

For more details and to order: 
http://www.crcpress.com/product/isbn/9781482203530

Also available as an eBook

***

Foundations of Statistical Algorithms: With References to R Packages 
Claus Weihs, Olaf Mersmann, and Uwe Ligges

ISBN: 978-1-4398-7885-9
Publication Date: Dec 2013
Number of Pages: 474

A new and refreshingly different approach 

Re: [R] Not able to find files in working directory

2014-02-04 Thread Ista Zahn
You need to read the file in first. More generally, you need to spend
some time with an introductory R tutorial. There are many, including
the Introduction to R shipped with every copy of R, as well as the
ones listed on the R website at
http://cran.r-project.org/other-docs.html.

Best,
Ista

On Tue, Feb 4, 2014 at 11:27 AM, Sschratz87
samuel.schr...@smail.astate.edu wrote:
 Hello. I am new to R here and I am coming across a small error in my code I
 am trying to run. I am trying to make a table of some value from a folder on
 my computer. I was able to pull a txt file from the folder and make bar
 graphs etc... however now I cannot do anything from this file and R is
 throwing errors at me from every direction.  I will paste what I am trying
 to do.

 table(Squid$YEAR)
 Error in table(Squid$YEAR) : object 'Squid' not found
 table(Squid$MONTH,Squid$YEAR)
 Error in table(Squid$MONTH, Squid$YEAR) : object 'Squid' not found
 setwd(/Users/SamSchratz/Desktop/Spring 2014/Taking/Bio Stats/Lab/Lab 2 -
 Descriptive Statistics)
 Error in setwd(/Users/SamSchratz/Desktop/Spring 2014/Taking/Bio
 Stats/Lab/Lab 2 - Descriptive Statistics) :
   cannot change working directory

 It is confusing because I was able to run this earlier:
 barplot(table(Squid$MONTH,Squid$YEAR),main=Sampling by Year and
 Month,xlab=Year and Month, ylab=Sampling Size)

 and got:
 http://r.789695.n4.nabble.com/file/n4684710/SquidYearMonth.png

 Thoughts? I appreciate whatever you can tell me...



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Not-able-to-find-files-in-working-directory-tp4684710.html
 Sent from the R help mailing list archive at Nabble.com.

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

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


[R] two active RGL device / linked devices

2014-02-04 Thread Omphalodes Verna
Dear list!

My question is, if there is an option in RGL, that two devices can be active. 
It means, when eg. points in first device is rotated also points in second 
devies is rotated. For example:

library(rgl)
x - rnorm(1000)
y - rnorm(1000)
z - rnorm(1000)
open3d()
points3d(x,y,z)
open3d()
points3d(x,y,z)

rgl.set(c(1,2), silent=TRUE) #does not work

Thanks for suggestions.

OV

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


Re: [R] creating an equivalent of r-help on r.stackexchange.com ?

2014-02-04 Thread Keith S Weintraub
My sentiments exactly!

Thanks to all for taking the time to flesh out the potential flaws of the 
stackexchange solution.

KW


 Date: Tue, 04 Feb 2014 10:36:21 +1300
 From: Rolf Turner r.tur...@auckland.ac.nz
 To: Bert Gunter gunter.ber...@gene.com
 Cc: r-help@r-project.org r-help@r-project.org
 Subject: Re: [R] creating an equivalent of r-help on
   r.stackexchange.com ?
 Message-ID: 52f00bd5@auckland.ac.nz
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 
 
 For what it's worth, I would like to say that I concur completely with 
 Don and Bert.  (Also I would like second Bert's vote of thanks to Don 
 for expressing the position so clearly.)
 
 cheers,
 
 Rolf Turner
 --
 

__
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] two active RGL device / linked devices

2014-02-04 Thread Duncan Murdoch

On 04/02/2014 12:08 PM, Omphalodes Verna wrote:

Dear list!

My question is, if there is an option in RGL, that two devices can be active. 
It means, when eg. points in first device is rotated also points in second 
devies is rotated. For example:

library(rgl)
x - rnorm(1000)
y - rnorm(1000)
z - rnorm(1000)
open3d()
points3d(x,y,z)
open3d()
points3d(x,y,z)

rgl.set(c(1,2), silent=TRUE) #does not work


The demo(stereo) code does something like this.

There are plans for some changes that might make this all easier, but 
they are likely several months away from completion.  (The idea will be 
to allow multiple scenes to be displayed in the same window; there 
should be a lot of flexibility in how the mouse affects them. The 
demo(stereo) method will still be needed to control multiple devices.)


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] creating an equivalent of r-help on r.stackexchange.com ? (was: Re: Should there be an R-beginners list?)

2014-02-04 Thread Law, Jason
Clint and Liviu,

Stackoverflow also has rss feeds available, if you prefer being pushed the 
information that way.  For the R tagged questions it's here: 
http://stackoverflow.com/feeds/tag/r.  Since some e-mail clients double as feed 
readers, you may be able to read the feed from your e-mail client.  Otherwise, 
it does mean another application.

Regards,

Jason

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Liviu Andronic
Sent: Monday, February 03, 2014 11:24 PM
To: Clint Bowman
Cc: r-help@r-project.org; Bert Gunter
Subject: Re: [R] creating an equivalent of r-help on r.stackexchange.com ? 
(was: Re: Should there be an R-beginners list?)

Dear Clint,


On Tue, Feb 4, 2014 at 1:27 AM, Clint Bowman cl...@ecy.wa.gov wrote:
 Liviu,

 Thanks for the excellent description of the advantages of SE.
 However, there is a significant fraction of the population that
 prefers that information be pushed out to them rather than having to
 pull it to them. The best system is one that accommodates both equally well.

It's not exactly the same as in a mail client, but you also have a push-like 
interface on SE, sort of:
http://stackoverflow.com/questions/tagged/r
- The 'Newest' tab displays all recent questions, sorted in chronological order 
with latest on top; it gets refreshed automatically, as in a mail client 
(hence, push-like)
- The 'Active' tab displays all questions with recent activity (question asked, 
answered or commented upon)
- You also have the very useful 'Unanswered' tab, which allows to identify 
questions that haven't yet received useful advice

Another push-like element in SE is that once you ask a question or answer, any 
subsequent comments on your post will be notified to you either in the web 
interface or by email. This helps keep discussions alive.

Regards,
Liviu



 Clint

 Clint BowmanINTERNET:   cl...@ecy.wa.gov
 Air Quality Modeler INTERNET:   cl...@math.utah.edu
 Department of Ecology   VOICE:  (360) 407-6815
 PO Box 47600FAX:(360) 407-7534
 Olympia, WA 98504-7600

 USPS:   PO Box 47600, Olympia, WA 98504-7600
 Parcels:300 Desmond Drive, Lacey, WA 98503-1274

 On Tue, 4 Feb 2014, Liviu Andronic wrote:

 Dear Don and Bert,
 Allow me to address some of your concerns below.


 On Mon, Feb 3, 2014 at 9:56 PM, Bert Gunter gunter.ber...@gene.com
 wrote:

 I find SO's voting for posting business especially irritating. I
 wish merely to post or to read the posts of others without being
 subjected to some kind of online pseudo game and ratings
 competition. That alone keeps me away. But Don said it better.

 On SO voting is irrelevant for either posting a question or an answer.
 *Anyone* (with an account) can ask a question, and *anyone* can
 answer a question. Their system of privileges is explained here:
 http://askubuntu.com/help/privileges . But to summarize:
 - if you're interested only in giving help, then the only really
 relevant threshold is 10 and 50 votes (removing some new user
 restrictions and allowing you to comment on posts, respectively)
 - if you're interested only in seeking  help, then all thresholds are
 irrelevant really

 All other thresholds are relevant only if you're interested in
 contributing to the organization of information, or in moderating
 this whole forum-slash-wiki thingy. And as a note, given the quality
 of your answers on r-help, Bert, I have no doubt that you will clock
 upwards 50 upvotes in a couple of hours or so.


 I realize that I may be out of step with the masses here, and the
 masses should certainly decide. Hopefully I won't be around if/when
 they decide that R-help should go.

 The proposal is not necessarily to close down r-help. From the myriad
 lists it currently has, R Core could keep only r-help and r-devel,
 and encourage new users to seek help on r.stackexchange.com. The
 scope of r-help could be redefined.


 On Mon, Feb 3, 2014 at 12:42 PM, MacQueen, Don macque...@llnl.gov
 wrote:

 - They waste copious amounts of screen space on irrelevant things
 such as votes, the number of views, the elapsed time since
 something or other happened, fancy web-page headers, and so on. Oh,
 and advertisements. The Mathematica stackexchange example given in
 a link in one of the emails below
 (http://mathematica.stackexchange.com/) illustrates these
 shortcomings -- and it's not the worst such example.


 Well, I've seen my fair share of advertisements on Gmail, Yahoo Mail
 or what have you. I know some use dedicated clients, but not all do.
 (And sofar I haven't noticed one single intrusive or distracting ad
 on
 SE.)

 As for the number of votes, this is actually the most useful bit of
 this QA interface: it allows for the best questions (or most often
 asked) to stand out from all the noise. And it allows for the best
 answers (or those most authoritative) to stand 

Re: [R] Selecting elements in lists with a row condition

2014-02-04 Thread Francesca Pancotto
Hello A. k. 
thanks for the suggestion.

I tried this but it does not work. I probably use it in the wrong way.
This is what it tells me, 


 do.call(rbind,lapply(bank.list,function(x) x[x[,p_made]==406,]))

Errore in match.names(clabs, names(xi)) : 
  names do not match previous names

What am I doing wrong?
f.

--
Francesca Pancotto
Università degli Studi di Modena e Reggio Emilia
Palazzo Dossetti - Viale Allegri, 9 - 42121 Reggio Emilia
Office: +39 0522 523264
Web: https://sites.google.com/site/francescapancotto/
--

Il giorno 04/feb/2014, alle ore 16:42, arun smartpink...@yahoo.com ha scritto:

 Hi,
 Try:
 
 If `lst1` is the list:
 do.call(rbind,lapply(lst1,function(x) x[x[,p_made]==406,]))
 A.K.
 
 
 
 
 On Tuesday, February 4, 2014 8:53 AM, Francesca 
 francesca.panco...@gmail.com wrote:
 Dear Contributors
 sorry but the message was sent involuntary.
 I am asking some advice on how to solve the following problem.
 I have a list composed of 78 elements, each of which is a matrix of factors
 and numbers, similar to the following
 
 bank_name   date px_last_CIB   Q.Yp_made p_for
 1   CIB 10/02/061.33 p406-q406406 406
 2   CIB 10/23/061.28 p406-q406406 406
 3   CIB 11/22/061.28 p406-q406406 406
 4   CIB 10/02/061.35 p406-q107406 107
 5   CIB 10/23/061.32 p406-q107406 107
 6   CIB 11/22/061.32 p406-q107406 107
 
 
 Each of these matrixes changes for the column name bank_name and for the
 suffix _CIB which reports the name as in bank_name. Moreover each matrix as
 a different number of rows, so that I cannot transform it into a large
 matrix.
 
 I need to create a matrix made of the rows of each element of the list that
 respect the criterium
 that the column p_made is = to 406.
 I need to pick each of the elements of each matrix that is contained in the
 list elements, that satisfy this condition.
 
 It seems difficult to me but perhaps is super easy.
 Thanks for any help you can provide.
 
 Francesca
 
 
 
 On 4 February 2014 12:42, Francesca francesca.panco...@gmail.com wrote:
 
 Dear Contributors
 I am asking some advice on how to solve the following problem.
 I have a list composed of 78 elements, each of which is a matrix of
 factors and numbers, similar to the following
 
 bank_name   date px_last_CIB   Q.Yp_made p_for
 1   CIB 10/02/061.33 p406-q406406 406
 2   CIB 10/23/061.28 p406-q406406 406
 3   CIB 11/22/061.28 p406-q406406 406
 4   CIB 10/02/061.35 p406-q107406 107
 5   CIB 10/23/061.32 p406-q107406 107
 6   CIB 11/22/061.32 p406-q107406 107
 
 
 --
 
 Francesca
 
 --
 Francesca Pancotto, PhD
 Università di Modena e Reggio Emilia
 Viale A. Allegri, 9
 40121 Reggio Emilia
 Office: +39 0522 523264
 Web: https://sites.google.com/site/francescapancotto/
 
 --
 
 
 
 
 -- 
 
 Francesca
 
 --
 Francesca Pancotto, PhD
 Università di Modena e Reggio Emilia
 Viale A. Allegri, 9
 40121 Reggio Emilia
 Office: +39 0522 523264
 Web: https://sites.google.com/site/francescapancotto/
 --
 
 [[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] Categorizing and displaying excel data in tabular format

2014-02-04 Thread Rui Barradas

Hello,

With me the following worked:

URL - http://r.789695.n4.nabble.com/file/n4684711/R_format.csv;
dat - read.csv(URL)

str(dat)
'data.frame':   34 obs. of  2 variables:
 $ Tasks  : Factor w/ 10 levels Code upgrade BE/FE,..: 4 4 4 
4 8 6 6 6 6 6 ...
 $ Client.Mnemonic: Factor w/ 18 levels AHSW_CA,ANMC_AK,..: 2 2 18 
18 2 9 9 8 8 8 ...


I also find fortune(122) appropriate.

Rui Barradas

Em 04-02-2014 16:49, Greg Snow escreveu:

First, .csv files are not Excel files (and I was unable to open the
one you link to).

Second, while the word Help is used many ways, this list is intended
to assist, i.e. you show that you have done some work and tell us
where you are stuck and we are happy to give hints and pointers to
help you get unstuck.  This list is not a we do everything for you
list.  You should read the posting guide (link at the bottom of this
and every post) and An Introduction to R.  Then show us what you
have tried, what is not working for you, and what you would like to
see.

As it is, your question does not even have enough information to let
us know what question(s) you are trying to answer.  There are many
different plots to explore data in many different ways to answer
different questions, your question does not narrow things down enough
to give us a direction to point you.  See `fortune(122)`.



On Tue, Feb 4, 2014 at 9:27 AM, ashrafali ashraf...@techie.com wrote:

R_format.csv http://r.789695.n4.nabble.com/file/n4684711/R_format.csv

Hi,

I am new to R Programming and need help on categorizing and plotting the
data in the attached excel file into tabular format. Please help.



--
View this message in context: 
http://r.789695.n4.nabble.com/Categorizing-and-displaying-excel-data-in-tabular-format-tp4684711.html
Sent from the R help mailing list archive at Nabble.com.

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






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


Re: [R] MCPMod method

2014-02-04 Thread Adams, Jean
I can't answer your question, but I did notice the CRAN page for the MCPMod
package states, The MCPMod package will not be further developed, all
future development of the MCP-Mod methodology will be done in the
DoseFinding R-package.
http://cran.r-project.org/web/packages/MCPMod/index.html

Jean



On Mon, Feb 3, 2014 at 2:32 PM, Mahboobe Akhlaghi 
mahboobe.akhla...@ymail.com wrote:



 hi, I  have a question about MCPMod package for finding optimal dose.
 does MCPMod method better than fuzzy method for finding dose?and why?
 many 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.


[[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] Which analysis for a set of dummy variables alone ?

2014-02-04 Thread Adams, Jean
This sounds more like a statistics question than an R question.  You may
have better luck posting to a different forum, e.g., Cross Validated,
http://stats.stackexchange.com/.

Jean


On Tue, Feb 4, 2014 at 3:19 AM, sylvain willart
sylvain.will...@gmail.comwrote:

 Dear R-users,

 I have a dataset I would like to analyze and plot
 It consists of 100 dummy variables (0/1) for about 2,000,000 observations
 There is absolutely no quantitative variable, nor anything I could use as
 an explained variable for a regression analysis.

 Actually, the dataset represents the patronage of 2 billion customers for
 100 stores. It equals 1 if the consumer go to the store, 0 if he doesn't.
 With no further information.

 As the variable look like factors (0/1), I thought I could go for a
 Mutliple Correspondence Analysis (MCA). However, the resulting plot
 consists of 2 points for each variable (one for 1 and one for 0) which is
 not easily interpretable. (or is there a method for not plotting certain
 points in MCA?)

 I also tried to consider my dataset as a bipartite network
 (consumer-store). However, the plot is not really insightful, as I am
 especially looking for links between stores. (kind of if a consumer go to
 that store, he probably also goes to this one...)

 So, I have a simple question: which method you would choose for computing
 and plotting the links between a set of dummy variable?

 Thanks in advance

 Sylvain
 PhD Marketing
 Associate Professor University of Lille - FR

 [[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] GLM weights for the Poisson family

2014-02-04 Thread David Winsemius

On Feb 3, 2014, at 11:12 PM, IamRandom wrote:

 I am running a simple example of GLM.  If I include weights when 
 family=poisson then the weights are calculated iteratively and $weights and 
 $prior.weights return different values.  The $prior.weights are what I 
 supplied and $weights are the posterior weights of the IWLS.  If I include 
 weights with family=gaussian then the weights are static and $weights and 
 $prior.weights return the same values; it seems to ignore IWLS algorithm 
 procedure.

I don't think so. I think it's just starting where you specify and proceeding 
normally from there.

  I really want the family=poisson to behave like the family=gaussian and 
 use the static weights.  Thoughts?

I was under the impression there is no need to iterate for family=gaussian. 
If my understanding is correct only one iteration gets done.

Maybe you should say what you are trying to accomplish.

-- 

David Winsemius
Alameda, CA, USA

__
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] GLM weights for the Poisson family

2014-02-04 Thread Rolf Turner


On 04/02/14 20:12, IamRandom wrote:


I am running a simple example of GLM.  If I include weights when
family=poisson then the weights are calculated iteratively and
$weights and $prior.weights return different values.  The $prior.weights
are what I supplied and $weights are the posterior weights of the
IWLS.  If I include weights with family=gaussian then the weights are
static and $weights and $prior.weights return the same values; it seems
to ignore IWLS algorithm procedure.  I really want the family=poisson
to behave like the family=gaussian and use the static weights.  Thoughts?


As far as I understand things, your desideratum makes no sense.  The 
prior weights and the just-plain-weights are very different creatures.
The reason they wind up being the same for the gaussian family is that 
for the gaussian family the likelihood is maximized by least squares; 
there is no need for iteration or for re-weighting.


The poisson family cannot behave like the gaussian family because for 
the poisson family (or any family *other* than gaussian) iteration is 
necessary in order to maximize the likelihood.


You might get some insight into what's going on if you were to read 
Annette Dobson's book An Introduction to Generalized Linear Models

(Chapman and Hall, 1990).

cheers,

Rolf Turner

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


Re: [R] creating an equivalent of r-help on r.stackexchange.com ? (was: Re: Should there be an R-beginners list?)

2014-02-04 Thread Clint Bowman

Jason,

Thanks--I've found an RSS feed from EPA very useful and will check 
Stackoverflow's.


Clint

Clint BowmanINTERNET:   cl...@ecy.wa.gov
Air Quality Modeler INTERNET:   cl...@math.utah.edu
Department of Ecology   VOICE:  (360) 407-6815
PO Box 47600FAX:(360) 407-7534
Olympia, WA 98504-7600

USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274

On Tue, 4 Feb 2014, Law, Jason wrote:


Clint and Liviu,

Stackoverflow also has rss feeds available, if you prefer being pushed the 
information that way.  For the R tagged questions it's here: 
http://stackoverflow.com/feeds/tag/r.  Since some e-mail clients double as feed 
readers, you may be able to read the feed from your e-mail client.  Otherwise, 
it does mean another application.

Regards,

Jason

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Liviu Andronic
Sent: Monday, February 03, 2014 11:24 PM
To: Clint Bowman
Cc: r-help@r-project.org; Bert Gunter
Subject: Re: [R] creating an equivalent of r-help on r.stackexchange.com ? 
(was: Re: Should there be an R-beginners list?)

Dear Clint,


On Tue, Feb 4, 2014 at 1:27 AM, Clint Bowman cl...@ecy.wa.gov wrote:

Liviu,

Thanks for the excellent description of the advantages of SE.
However, there is a significant fraction of the population that
prefers that information be pushed out to them rather than having to
pull it to them. The best system is one that accommodates both equally well.


It's not exactly the same as in a mail client, but you also have a push-like 
interface on SE, sort of:
http://stackoverflow.com/questions/tagged/r
- The 'Newest' tab displays all recent questions, sorted in chronological order with 
latest on top; it gets refreshed automatically, as in a mail client (hence, 
push-like)
- The 'Active' tab displays all questions with recent activity (question asked, 
answered or commented upon)
- You also have the very useful 'Unanswered' tab, which allows to identify 
questions that haven't yet received useful advice

Another push-like element in SE is that once you ask a question or answer, any 
subsequent comments on your post will be notified to you either in the web 
interface or by email. This helps keep discussions alive.

Regards,
Liviu




Clint

Clint BowmanINTERNET:   cl...@ecy.wa.gov
Air Quality Modeler INTERNET:   cl...@math.utah.edu
Department of Ecology   VOICE:  (360) 407-6815
PO Box 47600FAX:(360) 407-7534
Olympia, WA 98504-7600

USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274

On Tue, 4 Feb 2014, Liviu Andronic wrote:


Dear Don and Bert,
Allow me to address some of your concerns below.


On Mon, Feb 3, 2014 at 9:56 PM, Bert Gunter gunter.ber...@gene.com
wrote:


I find SO's voting for posting business especially irritating. I
wish merely to post or to read the posts of others without being
subjected to some kind of online pseudo game and ratings
competition. That alone keeps me away. But Don said it better.


On SO voting is irrelevant for either posting a question or an answer.
*Anyone* (with an account) can ask a question, and *anyone* can
answer a question. Their system of privileges is explained here:
http://askubuntu.com/help/privileges . But to summarize:
- if you're interested only in giving help, then the only really
relevant threshold is 10 and 50 votes (removing some new user
restrictions and allowing you to comment on posts, respectively)
- if you're interested only in seeking  help, then all thresholds are
irrelevant really

All other thresholds are relevant only if you're interested in
contributing to the organization of information, or in moderating
this whole forum-slash-wiki thingy. And as a note, given the quality
of your answers on r-help, Bert, I have no doubt that you will clock
upwards 50 upvotes in a couple of hours or so.



I realize that I may be out of step with the masses here, and the
masses should certainly decide. Hopefully I won't be around if/when
they decide that R-help should go.


The proposal is not necessarily to close down r-help. From the myriad
lists it currently has, R Core could keep only r-help and r-devel,
and encourage new users to seek help on r.stackexchange.com. The
scope of r-help could be redefined.



On Mon, Feb 3, 2014 at 12:42 PM, MacQueen, Don macque...@llnl.gov
wrote:


- They waste copious amounts of screen space on irrelevant things
such as votes, the number of views, the elapsed time since
something or other happened, fancy web-page headers, and so on. Oh,
and advertisements. The Mathematica stackexchange example given in
a link in one of the emails below
(http://mathematica.stackexchange.com/) illustrates these
shortcomings -- 

Re: [R] Selecting elements in lists with a row condition

2014-02-04 Thread arun
Hi,
Looks like the colnames of list elements are not the same.
For e.g.
lst1 - list(structure(list(bankname = structure(c(1L, 1L, 1L, 1L, 1L, 
1L), .Label = CIB, class = factor), date = structure(c(1L, 
2L, 3L, 1L, 2L, 3L), .Label = c(10/02/06, 10/23/06, 11/22/06
), class = factor), px_last_CIB = c(1.33, 1.28, 1.28, 1.35, 
1.32, 1.32), Q.Y = structure(c(2L, 2L, 2L, 1L, 1L, 1L), .Label = c(p406-q107, 
p406-q406), class = factor), p_made = c(406L, 406L, 406L, 
406L, 406L, 406L), p_for = c(406L, 406L, 406L, 107L, 107L, 107L
)), .Names = c(bankname, date, px_last_CIB, Q.Y, p_made, 
p_for), class = data.frame, row.names = c(1, 2, 3, 
4, 5, 6)), structure(list(bank_name = structure(c(1L, 1L, 
1L, 1L), .Label = CBA, class = factor), date = structure(c(1L, 
2L, 3L, 1L), .Label = c(10/02/06, 10/23/06, 11/22/06), class = factor), 
    px_last_CIB = c(1.33, 1.28, 1.28, 1.35), Q.Y = structure(c(2L, 
    2L, 2L, 1L), .Label = c(p406-q107, p406-q406), class = factor), 
    p_made = c(406L, 406L, 402L, 402L), p_for = c(406L, 406L, 
    402L, 107L)), .Names = c(bank_name, date, px_last_CIB, 
Q.Y, p_made, p_for), class = data.frame, row.names = c(1, 
2, 3, 4)), structure(list(bank_name = structure(c(1L, 1L, 
1L, 1L), .Label = CAA, class = factor), date = structure(c(1L, 
2L, 3L, 1L), .Label = c(10/02/06, 10/23/06, 11/22/06), class = factor), 
    px_last_CIB = c(1.33, 1.28, 1.28, 1.35), Q.Y = structure(c(2L, 
    2L, 2L, 1L), .Label = c(p406-q107, p406-q406), class = factor), 
    p_made = c(401L, 401L, 406L, 402L), p_for = c(401L, 401L, 
    406L, 107L)), .Names = c(bank_name, date, px_last_CIB, 
Q.Y, p_made, p_for), class = data.frame, row.names = c(1, 
2, 3, 4)))

names(lst1[[2]])[1]
#[1] bank_name


 names(lst1[[2]])[1]
#[1] bank_name

do.call(rbind,lapply(lst1,function(x) x[x[,p_made]==406,]))
Error in match.names(clabs, names(xi)) : 
  names do not match previous names


 lst2 - lapply(lst1,function(x) {names(x) -names(lst1[[2]]);x})
do.call(rbind,lapply(lst2,function(x) x[x[,p_made]==406,]))
   bank_name date px_last_CIB   Q.Y p_made p_for
1    CIB 10/02/06    1.33 p406-q406    406   406
2    CIB 10/23/06    1.28 p406-q406    406   406
3    CIB 11/22/06    1.28 p406-q406    406   406
4    CIB 10/02/06    1.35 p406-q107    406   107
5    CIB 10/23/06    1.32 p406-q107    406   107
6    CIB 11/22/06    1.32 p406-q107    406   107
11   CBA 10/02/06    1.33 p406-q406    406   406
21   CBA 10/23/06    1.28 p406-q406    406   406
31   CAA 11/22/06    1.28 p406-q406    406   406
A.K.




On Tuesday, February 4, 2014 3:01 PM, Francesca Pancotto 
francesca.panco...@gmail.com wrote:

Hello A. k. 
thanks for the suggestion.
I tried this but it does not work. I probably use it in the wrong way.
This is what it tells me, 


 do.call(rbind,lapply(bank.list,function(x) x[x[,p_made]==406,]))

Errore in match.names(clabs, names(xi)) : 
  names do not match previous names

What am I doing wrong?
f.


--
Francesca Pancotto
Università degli Studi di Modena e Reggio Emilia
Palazzo Dossetti - Viale Allegri, 9 - 42121 Reggio Emilia
Office: +39 0522 523264
Web: https://sites.google.com/site/francescapancotto/
--

Il giorno 04/feb/2014, alle ore 16:42, arun smartpink...@yahoo.com ha scritto:

Hi,
Try:

If `lst1` is the list:
do.call(rbind,lapply(lst1,function(x) x[x[,p_made]==406,]))
A.K.




On Tuesday, February 4, 2014 8:53 AM, Francesca francesca.panco...@gmail.com 
wrote:
Dear Contributors
sorry but the message was sent involuntary.
I am asking some advice on how to solve the following problem.
I have a list composed of 78 elements, each of which is a matrix of factors
and numbers, similar to the following

bank_name   date px_last_CIB       Q.Y    p_made p_for
1       CIB 10/02/06        1.33 p406-q406    406     406
2       CIB 10/23/06        1.28 p406-q406    406     406
3       CIB 11/22/06        1.28 p406-q406    406     406
4       CIB 10/02/06        1.35 p406-q107    406     107
5       CIB 10/23/06        1.32 p406-q107    406     107
6       CIB 11/22/06        1.32 p406-q107    406     107


Each of these matrixes changes for the column name bank_name and for the
suffix _CIB which reports the name as in bank_name. Moreover each matrix as
a different number of rows, so that I cannot transform it into a large
matrix.

I need to create a matrix made of the rows of each element of the list that
respect the criterium
that the column p_made is = to 406.
I need to pick each of the elements of each matrix that is contained in the
list elements, that satisfy this condition.

It seems difficult to me but perhaps is super easy.
Thanks for any help you can provide.

Francesca



On 4 February 2014 12:42, Francesca francesca.panco...@gmail.com wrote:


Dear Contributors
I am asking some advice on how to solve the following problem.
I have a list composed of 78 elements, each of which is a 

Re: [R] Handling special characters in reading and writing to CSV

2014-02-04 Thread David Winsemius

On Feb 4, 2014, at 7:58 AM, Venkata Kirankumar wrote:

 Hi All,
 
 
 I have some data with different special characters, newline character, and
 different language characters in a CSV file like `~!@#$%^*|
 ()-_+={[}]|\:;',.?/
 in data, while I am trying to read this CSV and trying to do calculations I
 am not able to get this data as there in single cell. I found something
 like RFC 4180 format can help to solve this problem.
 
 
 
 If anyone can give suggestion related to handling these special characters
 it will be help full for me
 

I'm having a difficult time understanding your expectations and thedata 
situation. If it's a csv file,  then how can all three of comma, 
single-quote, and double-quote be properly distinguished when they are also 
part of the data?


You might consider using readLines (from base) or read.fwf (from the utils 
package)



 
 
 Thanks in advance,
 
 D V Kiran Kumar
 
   [[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.

David Winsemius
Alameda, CA, USA

__
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] Selecting elements in lists with a row condition

2014-02-04 Thread Jim Lemon

On 02/05/2014 06:54 AM, Francesca Pancotto wrote:

Hello A. k.
thanks for the suggestion.

I tried this but it does not work. I probably use it in the wrong way.
This is what it tells me,


  do.call(rbind,lapply(bank.list,function(x) x[x[,p_made]==406,]))

Errore in match.names(clabs, names(xi)) :
   names do not match previous names

What am I doing wrong?


Hi Francesca,
This is not as elegant as Arun's solution, but it seems to work:

bank.list-list()
bank.list[[1]]-read.table(
text=bank_name   date px_last_CIB   Q.Yp_made p_for
CIB 10/02/061.33 p406-q406406 406
CIB 10/23/061.28 p406-q406406 406
CIB 11/22/061.28 p406-q406406 406
CIB 10/02/061.35 p406-q107406 107
CIB 10/23/061.32 p406-q107406 107
CIB 11/22/061.32 p406-q107406 107,header=TRUE)
bank.list[[2]]-read.table(
text=bank_name   date px_last_CIB   Q.Yp_made p_for
DIB 10/02/061.33 p406-q406406 406
DIB 10/23/061.28 p406-q406406 406
DIB 11/22/061.28 p406-q406406 406
DIB 10/02/061.35 p406-q107406 107
DIB 10/23/061.32 p406-q107406 107
DIB 11/22/061.32 p406-q107406 107,header=TRUE)
bank.list[[3]]-read.table(
text=bank_name   date px_last_CIB   Q.Yp_made p_for
EIB 10/02/061.33 p406-q406406 406
EIB 10/23/061.28 p406-q406406 406
EIB 11/22/061.28 p406-q406406 406
EIB 10/02/061.35 p406-q107406 107
EIB 10/23/061.32 p406-q107406 107
EIB 11/22/061.32 p406-q107406 107,header=TRUE)
get_rows-function(x,field_name,field_value) {
 return(x[x[,field_name]==field_value,])
}
collapse_df_list-function(x,collapse_field) {
 listlen-length(x)
 newdf-x[[1]]
 for(listel in 2:listlen) newdf-rbind(newdf,x[[listel]])
 return(newdf)
}
select_list-lapply(bank.list,get_rows,p_for,406)
merged_list-collapse_df_list(select_list,p_for)

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] Selecting elements in lists with a row condition

2014-02-04 Thread David Winsemius

On Feb 4, 2014, at 11:54 AM, Francesca Pancotto wrote:

 Hello A. k. 
 thanks for the suggestion.
 
 I tried this but it does not work. I probably use it in the wrong way.
 This is what it tells me, 
 
 
 do.call(rbind,lapply(bank.list,function(x) x[x[,p_made]==406,]))
 
 Errore in match.names(clabs, names(xi)) : 
  names do not match previous names
 

As teh message says, you are either  working with a set of list which have 
different names or you are creating data.frames with that problem. What does 
this show

sapply(bank.list, names)

If they are all the same, then the output should be very , very regular.

-- 
david.
 What am I doing wrong?
 f.
 
 --
 Francesca Pancotto
 Università degli Studi di Modena e Reggio Emilia
 Palazzo Dossetti - Viale Allegri, 9 - 42121 Reggio Emilia
 Office: +39 0522 523264
 Web: https://sites.google.com/site/francescapancotto/
 --
 
 Il giorno 04/feb/2014, alle ore 16:42, arun smartpink...@yahoo.com ha 
 scritto:
 
 Hi,
 Try:
 
 If `lst1` is the list:
 do.call(rbind,lapply(lst1,function(x) x[x[,p_made]==406,]))
 A.K.
 
 
 
 
 On Tuesday, February 4, 2014 8:53 AM, Francesca 
 francesca.panco...@gmail.com wrote:
 Dear Contributors
 sorry but the message was sent involuntary.
 I am asking some advice on how to solve the following problem.
 I have a list composed of 78 elements, each of which is a matrix of factors
 and numbers, similar to the following
 
 bank_name   date px_last_CIB   Q.Yp_made p_for
 1   CIB 10/02/061.33 p406-q406406 406
 2   CIB 10/23/061.28 p406-q406406 406
 3   CIB 11/22/061.28 p406-q406406 406
 4   CIB 10/02/061.35 p406-q107406 107
 5   CIB 10/23/061.32 p406-q107406 107
 6   CIB 11/22/061.32 p406-q107406 107
 
 
 Each of these matrixes changes for the column name bank_name and for the
 suffix _CIB which reports the name as in bank_name. Moreover each matrix as
 a different number of rows, so that I cannot transform it into a large
 matrix.
 
 I need to create a matrix made of the rows of each element of the list that
 respect the criterium
 that the column p_made is = to 406.
 I need to pick each of the elements of each matrix that is contained in the
 list elements, that satisfy this condition.
 
 It seems difficult to me but perhaps is super easy.
 Thanks for any help you can provide.
 
 Francesca
 
 
 
 On 4 February 2014 12:42, Francesca francesca.panco...@gmail.com wrote:
 
 Dear Contributors
 I am asking some advice on how to solve the following problem.
 I have a list composed of 78 elements, each of which is a matrix of
 factors and numbers, similar to the following
 
 bank_name   date px_last_CIB   Q.Yp_made p_for
 1   CIB 10/02/061.33 p406-q406406 406
 2   CIB 10/23/061.28 p406-q406406 406
 3   CIB 11/22/061.28 p406-q406406 406
 4   CIB 10/02/061.35 p406-q107406 107
 5   CIB 10/23/061.32 p406-q107406 107
 6   CIB 11/22/061.32 p406-q107406 107
 
 
 --
 
 Francesca
 
 --
 Francesca Pancotto, PhD
 Università di Modena e Reggio Emilia
 Viale A. Allegri, 9
 40121 Reggio Emilia
 Office: +39 0522 523264
 Web: https://sites.google.com/site/francescapancotto/
 
 --
 
 
 
 
 -- 
 
 Francesca
 
 --
 Francesca Pancotto, PhD
 Università di Modena e Reggio Emilia
 Viale A. Allegri, 9
 40121 Reggio Emilia
 Office: +39 0522 523264
 Web: https://sites.google.com/site/francescapancotto/
 --
 
[[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.

David Winsemius
Alameda, CA, USA

__
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] Categorizing and displaying excel data in tabular format

2014-02-04 Thread David Winsemius

On Feb 4, 2014, at 8:49 AM, Greg Snow wrote:

 First, .csv files are not Excel files (and I was unable to open the
 one you link to).
 

This is what was in the linked file:

Tasks,Client Mnemonic
Ibus ,ANMC_AK
Ibus ,ANMC_AK
Ibus ,YAVA_AZ
Ibus ,YAVA_AZ
Release upgrade(BE),ANMC_AK
OS upgrades ,LACJ_CA
OS upgrades ,LACJ_CA
OS upgrades ,HMH_CA
OS upgrades ,HMH_CA
OS upgrades ,HMH_CA
P2 ,CITY_CA
P2 ,CITY_CA
Code upgrade BE/FE,PALO_CA
Xenapp builds ,CDC_CA
Code upgrade BE/FE,WYOM_WY
Code upgrade BE/FE,WYOM_WY
Ibus ,AHSW_CA
Ibus ,DEAC_MT
Ibus ,DEAC_MT
Ibus ,SVCH_AZ
Ibus ,TORR_C
Ibus ,TORR_C
Ibus ,SVCH_AZ
Release upgrade(FE),ANMC_AK
CPDI,CHOC_CA
CPDI,CHOC_CA
CPDI,STVN_NM
CPDI,STVN_NM
Go-live support ,UNIV_UT
New Foot Print,HMH_CA
Xenapp builds ,NAH_AZ,HMH_CA
Xenapp builds ,CERN_RWX
Release upgrade(BE),PACF_CA
Release upgrade(BE),PACF_CA

 Second, while the word Help is used many ways, this list is intended
 to assist, i.e. you show that you have done some work and tell us
 where you are stuck and we are happy to give hints and pointers to
 help you get unstuck.  This list is not a we do everything for you
 list.  You should read the posting guide (link at the bottom of this
 and every post) and An Introduction to R.  Then show us what you
 have tried, what is not working for you, and what you would like to
 see.
 
 As it is, your question does not even have enough information to let
 us know what question(s) you are trying to answer.  There are many
 different plots to explore data in many different ways to answer
 different questions, your question does not narrow things down enough
 to give us a direction to point you.  See `fortune(122)`.

I would add that many people get the incorrect notion that Nabble is actually 
Rhelp. It's not, and many postings to Nabble are blocked by the ETHZ mailing 
list server.

-- 
David.
 
 
 
 On Tue, Feb 4, 2014 at 9:27 AM, ashrafali ashraf...@techie.com wrote:
 R_format.csv http://r.789695.n4.nabble.com/file/n4684711/R_format.csv
 
 Hi,
 
 I am new to R Programming and need help on categorizing and plotting the
 data in the attached excel file into tabular format. Please help.
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Categorizing-and-displaying-excel-data-in-tabular-format-tp4684711.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 
 -- 
 Gregory (Greg) L. Snow Ph.D.
 538...@gmail.com
 

David Winsemius
Alameda, CA, USA

__
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] Renumber series

2014-02-04 Thread arun
Hi,
Try:
set.seed(89)
 dat1 - within(data.frame(column1=LETTERS[1:5],column2=rnorm(5)),order1 - 
order(order(column2))+32)

 within(dat1,order2 - order(order(dat1$order1)))
 column1    column2 order1 order2
1   A -1.4516020 33  1
2   B  0.7081001 35  3
3   C  1.5930974 36  4
4   D -0.8375955 34  2
5   E  1.9294701 37  5

#or

(dat1$order1-33)+1
#[1] 1 3 4 2 5
A.K.




Hi, 

I have data with a column that is the order of my data, it starts with 33 and 
goes on but not one by one, for example like this: 

column1         column2       order 
…                  ….               33 
..                  …                36 
…                  …                45 
…                  …                 .. 

I want to make 33 equals to 1, and then it calculates for other numbers, like 
36 be 4 and so on. 
Is there a way to do thins in R? 

Thank you so much

__
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] Renumber series

2014-02-04 Thread Bert Gunter
???

What's wrong with simply order - 32  ??

-- Bert



Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom.
H. Gilbert Welch




On Tue, Feb 4, 2014 at 2:37 PM, arun smartpink...@yahoo.com wrote:
 Hi,
 Try:
 set.seed(89)
  dat1 - within(data.frame(column1=LETTERS[1:5],column2=rnorm(5)),order1 - 
 order(order(column2))+32)

  within(dat1,order2 - order(order(dat1$order1)))
  column1column2 order1 order2
 1   A -1.4516020 33  1
 2   B  0.7081001 35  3
 3   C  1.5930974 36  4
 4   D -0.8375955 34  2
 5   E  1.9294701 37  5

 #or

 (dat1$order1-33)+1
 #[1] 1 3 4 2 5
 A.K.




 Hi,

 I have data with a column that is the order of my data, it starts with 33 and 
 goes on but not one by one, for example like this:

 column1 column2   order
 …  ….   33
 ..  …36
 …  …45
 …  … ..

 I want to make 33 equals to 1, and then it calculates for other numbers, like 
 36 be 4 and so on.
 Is there a way to do thins in R?

 Thank you so much

 __
 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] Revolution blog: January 2014 roundup

2014-02-04 Thread David Smith
[Apologies if you already saw this on r-devel, email error on my behalf -- DMS]

Revolution Analytics staff write about R every weekday at the Revolutions blog:
 http://blog.revolutionanalytics.com
and every month I post a summary of articles from the previous month
of particular interest to readers of r-help.

In case you missed them, here are some articles related to R from the
month of January:

Princeton's Germán Rodríguez has published a useful Introduction to
R guide, with a focus on linear and logistic regression:
http://bit.ly/1c1bero

The rxDForest function in the RevoScaleR package fits random forests
of histogram-binning trees: http://bit.ly/1b08qAq

A tutorial on using the xts package to analyze http://bit.ly/1c1bc30
and plot time series data http://bit.ly/1c1bc31

In a video interview with Trevor Hastie, John Chambers recounts the
history of S and R: http://bit.ly/1c1bern

A review of Doing Data Science, a new book by Rachel Schutt and
Cathy O'Neil http://bit.ly/1c1berp

Hadley Wickham introduces the dplyr package, with its grammar of data
manipulation http://bit.ly/1c1bcje

The new choroplethr package makes it easier to create data maps in R:
http://bit.ly/1c1bcjf

A developer preview of SparkR, an interface between R and Apache
Spark, is now available: http://bit.ly/1c1berq

Joseph Rickert reviews the capabilities of R for topological data
analysis: http://bit.ly/1c1berr

In a recent survey of data scientists, R is the most-used software
tool other than SQL: http://bit.ly/1c1bers

A new JSS article on computing with massive data, and a change in
policy for acceptable JSS software licenses: http://bit.ly/1b08srV

Large scale optimization with the optim and rxDataStep functions:
http://bit.ly/1c1bert

Large enterprise software vendors with connections to R: http://bit.ly/1c1bcji

A preview of a forthcoming update to Max Kuhn's caret package, and an
interactive chart showing similarities amongst the 143 statistical and
machine learning models it supports: http://bit.ly/1c1beru

Simulation-based forecasts by combining expert opinion: http://bit.ly/1c1bcjj

Tips on getting R help: http://bit.ly/1c1bcjk

The top 10 posts on the Revolutions blog from 2013: http://bit.ly/1b08qAt

Some non-R stories in the past month included: levitation with sound
waves (http://bit.ly/1c1bcjl), the NYT's 4th Down Bot
(http://bit.ly/1c1berv), bird flight patterns (http://bit.ly/1c1bcjm),
camera magic on Vine (http://bit.ly/1c1berw), visualizing whisky
flavor profiles (http://bit.ly/1c1bcjn), the Cornsweet illusion
(http://bit.ly/1b08srW), and a one-sentence explanation of the Fourier
Transform (http://bit.ly/1c1berz).

Meeting times for local R user groups (http://bit.ly/eC5YQe) can be
found on the updated R Community Calendar at: http://bit.ly/bb3naW

If you're looking for more articles about R, you can find summaries
from previous months at http://blog.revolutionanalytics.com/roundups/.
You can receive daily blog posts via email using services like
blogtrottr.com, or join the Revolution Analytics mailing list at
http://revolutionanalytics.com/newsletter to be alerted to new
articles on a monthly basis.

As always, thanks for the comments and please keep sending suggestions
to me at da...@revolutionanalytics.com . Don't forget you can also
follow the blog using an RSS reader, or by following me on Twitter
(I'm @revodavid).

Cheers,
# David

-- 
David M Smith da...@revolutionanalytics.com
VP of Marketing, Revolution Analytics  http://blog.revolutionanalytics.com
Tel: +1 (650) 646-9523 (Seattle WA, USA)
Twitter: @revodavid

__
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] Categorizing and displaying excel data in tabular format

2014-02-04 Thread ashrafali
I have converted the excel file to csv and imported the data using R Studio. 

This is the file  R_format.xlsx
http://r.789695.n4.nabble.com/file/n4684737/R_format.xlsx  

I have coded the following:

list(R_format$Tasks)
list(R_format$Client.Mnemonic)
task.freq=table(R_format$Tasks)
task.freq
cbind(task.freq)


I am not sure how to categorize the things. In the excel sheet I have the
same tasks done for different client mnemonics. I want to categorize them
accordingly and display them in tabular format one after the other. 

The works are:
* Categorize according to Tasks
* Syntax for plotting the table with two columns Tasks and ClientMnemonics. 


thanks!!

Ashraf



--
View this message in context: 
http://r.789695.n4.nabble.com/Categorizing-and-displaying-excel-data-in-tabular-format-tp4684711p4684737.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] Not able to find files in working directory

2014-02-04 Thread Sschratz87
I have already done that. It was working and now it isn't. The program was
not closed or restarted. It just stopped working. 

 Squid-read.table(Squid.txt,header=T)

Error in file(file, rt) : cannot open the connection
In addition: Warning message:
In file(file, rt) :
  cannot open file 'Squid.txt': No such file or directory'

but the file is still in the same folder and has not moved. I am in a class
that is based off R. Still learning the basics.



--
View this message in context: 
http://r.789695.n4.nabble.com/Not-able-to-find-files-in-working-directory-tp4684710p4684736.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Adjusting the x axis range in effects plots

2014-02-04 Thread Mark Hovenden
G'day All,
I am having some difficulties with effects plots from the effects package. I am 
doing partial regression analyses of normal linear models and obtain lovely 
effect plots with a linear effect line and 95%CL. No problem so far.
The problem is that I want to overlay the actual datapoints on the plot and, 
when I do so, I find that several of them are falling off the edge of the plot. 
In other words the x-axis range is too narrow to show all the data points. When 
I try to adjust the plot using xlim, then nothing happens. I can adjust the 
plots with ylim, color etc but the range of the x axis seems to be set 
somewhere in the package, and xlim disabled, and as far as I can see that is a 
problem because the axis range doesn't always fit the actual data range.

It doesn't seem anyone else has posted about this problem.

Am I wasting my time trying to adjust the x range in plots from the effects 
package? If so, is there a way to output the partial regression + confidence 
limit lines so that I can just plot them up myself not using effects?

Thanks for any pointers.
Mark

A/Prof. Mark Hovenden   Locked Bag 55
School of Biological Sciences   Hobart Tas. 7001
University of Tasmania  Australia
phone: +61 3 6226 7874
fax: +61 3 6226 2698

__
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] Merging xts List created using panel data

2014-02-04 Thread Jairaj Gupta
Hi,

I have done the following:

library(foreign)
RNOM - read.dta(Return Panel without missing.dta)
library(PerformanceAnalytics)
RNOM_list-split(RNOM,RNOM$gvkey)
xtsList - lapply(RNOM_list, function(x) {
  attrCol - c(conm)
  numCol - c(gvkey,prccm,trfm, trt1m)
  y - xts(x[,numCol], as.Date(x$datadate,format=%d/%m/%Y))
  xtsAttributes(y) - as.list(x[1,attrCol])
  y
})

logreturns - lapply(xtsList, function(x) {
  Return.calculate(x$prccm, method = log)
} )

Now I get, xts List of logreturns and xtsList of my data. 

Can anyone please tell me, how can I merge logreturns with my original 
dataframe or xtsList; and export it as a csv/excel file for further regression 
analysis (after merging the file needs to look like panel data)?

The description of variables is as follows:
datadatelong   %d Data Date - Security Monthly
gvkey   str6   %6sGlobal Company Key - Security 
Monthly Descriptor
conmstr58  %58s   Company Name
prccm   double %20.0g Price - Close - Monthly
trfmdouble %8.0g  Monthly Total Return Factor
trt1m   double %8.0g  Monthly Total Return
gvkeynumlong   %8.0g   gvkeynum   Global Company Key - Security 
Monthly Descriptor

The data can be downloaded from here: 
https://drive.google.com/file/d/0B8usDJAPeV85ZG1MSHNDeFQtM28/edit?usp=sharing


Thanks  Regards,


Jairaj Gupta
PhD Finance Candidate
Hull University Business School
Student No. 201201551
Mobile: 00-44-(0)7795904913
SSRN Author: http://ssrn.com/author=1936478
Linkedin Profile: http://www.linkedin.com/pub/jairaj-gupta/54/13a/b61**
To view the terms under which this email is 
distributed, please go to 
http://www2.hull.ac.uk/legal/disclaimer.aspx
**__
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] Merging xts List created using panel data

2014-02-04 Thread Joshua Ulrich
This is related to:
http://stackoverflow.com/q/21393866/271616
http://stackoverflow.com/q/21484267/271616
--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com


On Tue, Feb 4, 2014 at 6:07 PM, Jairaj Gupta j.gu...@2012.hull.ac.uk wrote:
 Hi,

 I have done the following:

 library(foreign)
 RNOM - read.dta(Return Panel without missing.dta)
 library(PerformanceAnalytics)
 RNOM_list-split(RNOM,RNOM$gvkey)
 xtsList - lapply(RNOM_list, function(x) {
   attrCol - c(conm)
   numCol - c(gvkey,prccm,trfm, trt1m)
   y - xts(x[,numCol], as.Date(x$datadate,format=%d/%m/%Y))
   xtsAttributes(y) - as.list(x[1,attrCol])
   y
 })

 logreturns - lapply(xtsList, function(x) {
   Return.calculate(x$prccm, method = log)
 } )

 Now I get, xts List of logreturns and xtsList of my data.

 Can anyone please tell me, how can I merge logreturns with my original 
 dataframe or xtsList; and export it as a csv/excel file for further 
 regression analysis (after merging the file needs to look like panel data)?

 The description of variables is as follows:
 datadatelong   %d Data Date - Security Monthly
 gvkey   str6   %6sGlobal Company Key - Security 
 Monthly Descriptor
 conmstr58  %58s   Company Name
 prccm   double %20.0g Price - Close - Monthly
 trfmdouble %8.0g  Monthly Total Return Factor
 trt1m   double %8.0g  Monthly Total Return
 gvkeynumlong   %8.0g   gvkeynum   Global Company Key - Security 
 Monthly Descriptor

 The data can be downloaded from here: 
 https://drive.google.com/file/d/0B8usDJAPeV85ZG1MSHNDeFQtM28/edit?usp=sharing


 Thanks  Regards,


 Jairaj Gupta
 PhD Finance Candidate
 Hull University Business School
 Student No. 201201551
 Mobile: 00-44-(0)7795904913
 SSRN Author: http://ssrn.com/author=1936478
 Linkedin Profile: http://www.linkedin.com/pub/jairaj-gupta/54/13a/b61
 **
 To view the terms under which this email is
 distributed, please go to
 http://www2.hull.ac.uk/legal/disclaimer.aspx
 **
 __
 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] Running the Loop

2014-02-04 Thread arun
Hi Katherine,Not sure if this helps.  I was able to the result after making up 
some additional conditions into your function.

fun1 - function(x){
    lst1 - lapply(seq(n-1),function(i){
     with(x,if(maturity_period D[i]  maturity_period D[i+1]){
            
data.frame(N1=paste(curve,T[i],sep=_),N2=paste(curve,T[i+1],sep=_),PV1=mtm*root,PV2=(mtm)*(1-root))
                                }
           else if(maturity_period  D[i]) {
             
data.frame(N1=paste(curve,T[i],sep=_),N2=paste(curve,T[i],sep=_),PV1=mtm,PV2=0)
                        }
          else if(maturity_period D[i+1]) {
            
data.frame(N1=paste(curve,T[i],sep=_),N2=paste(curve,T[i],sep=_),PV1=0,PV2=mtm)
                        }
           )
                }
                )
    dat2 - cbind(id=x$id,do.call(rbind,lst1))
        indx - with(dat2,PV1!=0  PV2!=0)  
    dat2New- if(!any(indx)){
      dat2[1,]
        }
    else dat2[indx,]
    colnames(dat2New)[-1] 
-paste0(paste0(Risk_factor,rep(1:2,2)),rep(c(,_mtm),each=2))
    dat2New
   }             

 ddply(dat,.(id),fun1)
#  id Risk_factor1 Risk_factor2 Risk_factor1_mtm Risk_factor2_mtm
#1  1   USD_1m   USD_1m 1000    0
#2  2   USD_3m   USD_6m 2000 8000
#3  3  USD_12m  USD_5yr    74000    26000

A.K.







On Tuesday, February 4, 2014 7:22 AM, Katherine Gobin 
katherine_go...@yahoo.com wrote:
Dear R forum,

I have following data.frames

dat = data.frame(id = c(1:3), root = c(0.10, 0.20, 0.74), maturity_period = 
c(20, 155, 428), mtm = c(1000, 1, 10), curve = c(USD, USD, USD))


 dat
  id root maturity_period   mtm curve
1  1 0.10              20 1e+03   USD
2  2 0.20             155 1e+04   USD
3  3 0.74             428 1e+05   USD

standard_tenors = data.frame(T = c(1m, 3m, 6m, 12m, 5yr), D = c(30, 
91, 182, 365, 1825))


 standard_tenors
    T    D
1  1m   30
2  3m   91
3  6m  182
4 12m  365
5 5yr 1825

# 
.

library(plyr)


T = standard_tenors$T

D = standard_tenors$D
n = length(standard_tenors$T)


mtm_split_function = function(maturity_period, curve, root, mtm)

{

for(i in 1:(n-1))
{
if (maturity_period  D[i])


{
N1 = paste(curve, T[i], sep =_)
N2 = paste(curve, T[i], sep =_)
PV1 = mtm
PV2 = 0
}else

if (maturity_period  D[i]  maturity_period  D[i+1])

{
N1 = paste(curve, T[i], sep =_)
N2 = paste(curve, T[1+1], sep =_)
PV1 = (mtm)*root
PV2 = (mtm)*(1-root)
}else

if (maturity_period  D[i+1])
{
N1 = paste(curve, T[i], sep =_)
N2 = paste(curve, T[i], sep =_)
PV1 = 0
PV2 = mtm
}

}


return(data.frame(Risk_factor1 = N1, Risk_factor2 = N2, Risk_factor1_mtm = PV1,
Risk_factor2_mtm = PV2))
}

# 
.

splitted_mtm - ddply(.data = dat, .variables = id,
                .fun=function(x) mtm_split_function(maturity_period = 
x$maturity_period, curve = x$curve, root = x$root, mtm = x$mtm))

# OUTPUT I am getting

  id Risk_factor1 Risk_factor2 Risk_factor1_mtm Risk_factor2_mtm
1  1      USD_12m      USD_12m             1000                0
2  2      USD_12m      USD_12m            1                0
3  3      USD_12m       USD_3m            74000            26000




# My PROBLEM

However, My OUTPUT should be  

  id Risk_factor1 Risk_factor2 Risk_factor1_mtm Risk_factor2_mtm
1  1      USD_1m       USD_1m             1000                0
2  2      USD_3m       USD_6m             2000             8000
3  3      USD_12m      USD_5yr           74000            26000

Kindly guide

With warm regards

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


[R] Pubmed (XML) data to data.frame

2014-02-04 Thread Marc Marí Dell'Olmo
Dear all,

I would like to obtain a data.frame with some data selected from
pubmed information. For example, I would like to do an specific search
and obtain a data.frame with the title of each article and the
publication type.

Example of syntax:

 library(reutils)
 library(XML)

 pmid - esearch('Epidemiology [Journal]', pubmed, mindate=2013/01/01, 
 maxdate=paste(2013/12/31, sep=), retmax=1000)
Mensajes de aviso perdidos
NCBI requests that you provide an email address with each query to their API.
 Set the global option 'reutils.email' to your address to make this
message go away.

 articles - efetch(pmid, db=pubmed, retmax=1000)
Mensajes de aviso perdidos
NCBI requests that you provide an email address with each query to their API.
 Set the global option 'reutils.email' to your address to make this
message go away.

 journal - articles$xmlValue(//Title)


BUT HERE I HAVE THE PROBLEM

Each article (PMID) can have more than one type of publication.

 ptype - articles$xmlValue(//PublicationType)

With this syntax I can select the first type of publication
 ptype1 - articles$xmlValue(//PublicationTypeList//PublicationType[1])
 length(ptype1)
[1] 181


With this syntax I can select the second type of publication.

 ptype2 - articles$xmlValue(//PublicationTypeList//PublicationType[2])
 length(ptype2)
[1] 152


But I would like to obtain a vector of length 181 (as ptype1) with
NA's when there is no information of publication list

Therefore I cannot obtain a data.frame because I don't obtain a NA
when there is no data in ptype2
 df1 - data.frame(journal=journal, ptype1=ptype1, ptype2=ptype2 )
Error en data.frame(journal = journal, ptype1 = ptype1, ptype2 = ptype2) :
  arguments imply differing number of rows: 181, 152

How can I do this data.frame???

Best Regards,

Marc

__
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] Categorizing and displaying excel data in tabular format

2014-02-04 Thread David Winsemius

On Feb 4, 2014, at 1:40 PM, ashrafali wrote:

 I have converted the excel file to csv and imported the data using R Studio. 
 
 This is the file  R_format.xlsx
 http://r.789695.n4.nabble.com/file/n4684737/R_format.xlsx  
 
 I have coded the following:
 
 list(R_format$Tasks)
 list(R_format$Client.Mnemonic)
 task.freq=table(R_format$Tasks)
 task.freq
 cbind(task.freq)

I would have instead used the table function. 

 table(R_format$Tasks)
 table(R_format$Client.Mnemonic)
 with(R_format, table(Tasks,Client.Mnemonic )

You could, of course, assign them to object names.

 task.freq
 cbind(task.freq)

cbind is used to put two columns side by side. It doesn't make much sense to 
supply it with only one argument.

 
 
 I am not sure how to categorize the things. In the excel sheet I have the
 same tasks done for different client mnemonics. I want to categorize them
 accordingly and display them in tabular format one after the other. 
 
 The works are:
 * Categorize according to Tasks
 * Syntax for plotting the table with two columns Tasks and ClientMnemonics. 
 
Using table with two arguments may give you wnat you requested. 
 
 thanks!!
 
 Ashraf
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Categorizing-and-displaying-excel-data-in-tabular-format-tp4684711p4684737.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.

David Winsemius
Alameda, CA, USA

__
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] Obtain the hex code for a given character.

2014-02-04 Thread Rolf Turner



If I have a character such as £ stored in a object called xxx, how 
can I obtain the hex code representation of this character?  In this 
case I know that the hex code is \u00A3, but if I didn't, how would I 
find out?


I would like a function foo() such that foo(xxx) would return, say, 
the string 00A3.


I have googled and otherwise searched around and have come up with 
nothing that seemed at all helpful to me.  If I am missing something 
obvious, please point me at it.


(I have found a table on the web, which contains the information that I 
need, but it is only accessible by eye as far as I can discern.)


Supplementary question:  Suppose I have the string 00A3 stored in
an object called yyy.  How do I put that string together with \u
so as to obtain £?  I thought I could do

xxx - paste(\u,yyy,sep=)

but R won't let me use \u without hex digits.  How can I get around 
this?


Thanks.

cheers,

Rolf Turner

__
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] Adjusting the x axis range in effects plots

2014-02-04 Thread John Fox
Dear Mark,

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Mark Hovenden
 Sent: Tuesday, February 04, 2014 6:52 PM
 To: r-help@r-project.org
 Subject: [R] Adjusting the x axis range in effects plots
 
 G'day All,
 I am having some difficulties with effects plots from the effects
 package. I am doing partial regression analyses of normal linear models
 and obtain lovely effect plots with a linear effect line and 95%CL. No
 problem so far.
 The problem is that I want to overlay the actual datapoints on the plot
 and, when I do so, I find that several of them are falling off the edge
 of the plot. In other words the x-axis range is too narrow to show all
 the data points. When I try to adjust the plot using xlim, then nothing
 happens. I can adjust the plots with ylim, color etc but the range of
 the x axis seems to be set somewhere in the package, and xlim disabled,
 and as far as I can see that is a problem because the axis range
 doesn't always fit the actual data range.
 

See the xlevels argument to Effect() in ?Effect; you can set any values you
want for which the effect is evaluated.

 It doesn't seem anyone else has posted about this problem.
 
 Am I wasting my time trying to adjust the x range in plots from the
 effects package? If so, is there a way to output the partial
 regression + confidence limit lines so that I can just plot them up
 myself not using effects?
 

Yes, the object returned by Effect() includes components fit, upper, and
lower. See the description in ?Effect.

Additional comment: If there is more than one predictor in the model, it's
not obvious what points to plot, particularly if there is an interaction
between continuous predictors. The development version of the effects
package on R-Forge includes the ability to compute and plot partial
residuals for effects. Their definition isn't entirely straightforward, and
the implementation is preliminary, but if you want to try it, you can
install the package from R-Forge and see the partial.residuals argument in
?Effect.

I hope this helps,
 John

 Thanks for any pointers.
 Mark
 
 A/Prof. Mark Hovenden Locked Bag 55
 School of Biological Sciences Hobart Tas. 7001
 University of TasmaniaAustralia
 phone: +61 3 6226 7874
 fax: +61 3 6226 2698
 
 __
 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] GLM weights for the Poisson family

2014-02-04 Thread Rolf Turner


You should direct your inquiry to R-help, not to me personally.  I am 
taking the liberty of cc-ing my reply back to the list.


I really haven't the time at the moment to think the issue through 
thoroughly, but off the top of my head:  If you are going to use 
weighted log likelihoods then any comparison of models that you engage 
in should involve the *same* weights, otherwise you doing the good old 
apples-with-oranges thing.


So yes, the weights will change the log-likelihood and the AIC.  And so 
they should.  And if you use AIC to compare models which are 
meaningfully comparable (id est, have the same weights) this is not a 
problem.


As I say, this is off the top of my head.  Others older (???) and wiser 
than I may correct me.


cheers,

Rolf Turner

On 05/02/14 11:56, IamRandom wrote:

I am trying to do weighted Poisson regression.  I have count data.

Simple example:
set.seed(50)
x=seq(0,1,length=100)
y=numeric(100)
y[seq(1,100,by=2)]=round(exp(1.5*x[seq(1,100,by=2)]+rnorm(50,0,.1)),0)
y[seq(2,100,by=2)]=round(exp(1.5*x[seq(1,100,by=2)]+rnorm(50,0,1)),0)
weigh1=numeric(100)
weigh1[seq(1,100,by=2)]=rep(5,50)
weigh1[seq(2,100,by=2)]=rep(1,50)


The -2*loglikelihood of both of these regressions is the same with lm,
which makes sense. The scaling of the weights does not affect the
log-likelihood.
 -2*logLik( lm(y~x, weights=weigh1))[1]
 -2*logLik( lm(y~x, weights=weigh1/3))[1]

The -2*loglikelihood of these two regressions are different with glm:
  -2*logLik(glm(y~x, family=poisson, weights=weigh1))[1]
  -2*logLik(glm(y~x, family=poisson, weights=weigh1/3))[1]

This means that the AIC and other model comparison techniques with this
weighted Poisson regression are dependent on the scaling of the
weights.  So I assume I misunderstand what the weights are doing in
the glm function.

-Tracy



On 2/4/2014 12:56 PM, Rolf Turner wrote:


On 04/02/14 20:12, IamRandom wrote:


I am running a simple example of GLM.  If I include weights when
family=poisson then the weights are calculated iteratively and
$weights and $prior.weights return different values.  The $prior.weights
are what I supplied and $weights are the posterior weights of the
IWLS.  If I include weights with family=gaussian then the weights are
static and $weights and $prior.weights return the same values; it seems
to ignore IWLS algorithm procedure.  I really want the family=poisson
to behave like the family=gaussian and use the static weights.
Thoughts?


As far as I understand things, your desideratum makes no sense. The
prior weights and the just-plain-weights are very different creatures.
The reason they wind up being the same for the gaussian family is that
for the gaussian family the likelihood is maximized by least squares;
there is no need for iteration or for re-weighting.

The poisson family cannot behave like the gaussian family because for
the poisson family (or any family *other* than gaussian) iteration is
necessary in order to maximize the likelihood.

You might get some insight into what's going on if you were to read
Annette Dobson's book An Introduction to Generalized Linear Models
(Chapman and Hall, 1990).

cheers,

Rolf Turner







__
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] Obtain the hex code for a given character.

2014-02-04 Thread Duncan Murdoch

On 14-02-04 7:57 PM, Rolf Turner wrote:



If I have a character such as £ stored in a object called xxx, how
can I obtain the hex code representation of this character?  In this
case I know that the hex code is \u00A3, but if I didn't, how would I
find out?


charToRaw will give you the bytes used to store it:

 charToRaw(£)
[1] c2 a3

That was on MacOS, which uses UTF-8 encoding.  On Windows, using Latin1,

 charToRaw(£)
[1] a3

You won't see 00A3, because that's not an encoding that R uses, that's 
the Unicode code point.  It's not too hard to get to that from the 
UTF-8 encoding, but I don't know any R function that does it.




I would like a function foo() such that foo(xxx) would return, say,
the string 00A3.


I don't know how to get that string, but as.character(charToRaw(x)) will 
put the bytes for x in strings, e.g.


as.character(charToRaw(£))

gives

[1] c2 a3

on a Mac.



I have googled and otherwise searched around and have come up with
nothing that seemed at all helpful to me.  If I am missing something
obvious, please point me at it.

(I have found a table on the web, which contains the information that I
need, but it is only accessible by eye as far as I can discern.)

Supplementary question:  Suppose I have the string 00A3 stored in
an object called yyy.  How do I put that string together with \u
so as to obtain £?  I thought I could do

xxx - paste(\u,yyy,sep=)

but R won't let me use \u without hex digits.  How can I get around
this?


The \u notation with a code point is handled by the R parser, so you 
need to parse that string, which means putting it in quotes first, e.g.


xxx - eval(parse(text = paste0('\\u, yyy, ')))

That seems pretty excessive.  You'd probably be better off doing all of 
this in C instead...


Duncan Murdoch



Thanks.

cheers,

Rolf Turner

__
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] Justify axis labels in mosaic plot

2014-02-04 Thread Derickson, Ryan, VHACIN
Hello All, 

 

I'm trying to right-justify the y-axis labels in a mosaic plot from base
R. I've tried too many commands (adj specifically) to list here and
nothing works so far. I'm sure this could be done in the vcd or ggplot2
packages, but I would prefer to do it with mosaicplot in base R if at
all possible and I suspect it is possible. Illustration code is below-
I'm trying to make q, qwe, and qwertyqwerty right-justified
instead of left. The prop.table and order bits are unnecessary for the
sample but I need them for my actual analyses so I included them here in
case that somehow affects the code needed. I would be incredibly
appreciative of any help!

 

#demo

a-c(qwertyqwerty, qwertyqwerty, qwertyqwerty, qwe, qwe,
qwe, q, q, q)

b-c(1, 2, 3, 1, 1, 3, 2, 2, 3)

demo-data.frame(a, b)

y-table(demo)

y-as.table(y[order(rowSums(y)),])

y-prop.table(y)

plot(y, 

dir=c(h, v),

las=1)

 

Ryan Derickson

VHA NCOD

513-247-4294

 


[[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] Obtain the hex code for a given character.

2014-02-04 Thread Jim Lemon

On 02/05/2014 01:01 PM, Duncan Murdoch wrote:

On 14-02-04 7:57 PM, Rolf Turner wrote:



If I have a character such as £ stored in a object called xxx, how
can I obtain the hex code representation of this character? In this
case I know that the hex code is \u00A3, but if I didn't, how would I
find out?


charToRaw will give you the bytes used to store it:

  charToRaw(£)
[1] c2 a3

That was on MacOS, which uses UTF-8 encoding. On Windows, using Latin1,

  charToRaw(£)
[1] a3

You won't see 00A3, because that's not an encoding that R uses, that's
the Unicode code point. It's not too hard to get to that from the
UTF-8 encoding, but I don't know any R function that does it.



I would like a function foo() such that foo(xxx) would return, say,
the string 00A3.


I don't know how to get that string, but as.character(charToRaw(x)) will
put the bytes for x in strings, e.g.

as.character(charToRaw(£))

gives

[1] c2 a3

on a Mac.



I have googled and otherwise searched around and have come up with
nothing that seemed at all helpful to me. If I am missing something
obvious, please point me at it.

(I have found a table on the web, which contains the information that I
need, but it is only accessible by eye as far as I can discern.)

Supplementary question: Suppose I have the string 00A3 stored in
an object called yyy. How do I put that string together with \u
so as to obtain £? I thought I could do

xxx - paste(\u,yyy,sep=)

but R won't let me use \u without hex digits. How can I get around
this?


The \u notation with a code point is handled by the R parser, so you
need to parse that string, which means putting it in quotes first, e.g.

xxx - eval(parse(text = paste0('\\u, yyy, ')))

That seems pretty excessive. You'd probably be better off doing all of
this in C instead...


Hi Rolf,
I almost got it in Linux with:

x-\u00A3
paste(\\u,
 toupper(paste(as.character(charToRaw(x)),sep=,collapse=)),
 sep=,collapse=)
[1] \\uC2A3

But I couldn't get rid of the double backslash, so I must agree with 
Duncan. Also, I don't know how the C2 gets in there.


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] Obtain the hex code for a given character.

2014-02-04 Thread David Winsemius

On Feb 4, 2014, at 4:57 PM, Rolf Turner wrote:

 
 
 If I have a character such as £ stored in a object called xxx, how can I 
 obtain the hex code representation of this character?  In this case I know 
 that the hex code is \u00A3, but if I didn't, how would I find out?
 
 I would like a function foo() such that foo(xxx) would return, say, the 
 string 00A3.
 

Close:

 as.hexmode(utf8ToInt(£))
[1] a3


 I have googled and otherwise searched around and have come up with nothing 
 that seemed at all helpful to me.  If I am missing something obvious, please 
 point me at it.
 
 (I have found a table on the web, which contains the information that I need, 
 but it is only accessible by eye as far as I can discern.)
 
 Supplementary question:  Suppose I have the string 00A3 stored in
 an object called yyy.


 intToUtf8(as.hexmode('00A3'))
[1] £


  How do I put that string together with \u
 so as to obtain £?  I thought I could do
 
   xxx - paste(\u,yyy,sep=)
 
 but R won't let me use \u without hex digits.  How can I get around this?
 
 Thanks.
 
 cheers,
 
 Rolf Turner
 
 __
 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.

David Winsemius
Alameda, CA, USA

__
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] Obtain the hex code for a given character.

2014-02-04 Thread David Winsemius

On Feb 4, 2014, at 8:56 PM, David Winsemius wrote:

 
 On Feb 4, 2014, at 4:57 PM, Rolf Turner wrote:
 
 
 
 If I have a character such as £ stored in a object called xxx, how can I 
 obtain the hex code representation of this character?  In this case I know 
 that the hex code is \u00A3, but if I didn't, how would I find out?
 
 I would like a function foo() such that foo(xxx) would return, say, the 
 string 00A3.
 
 
 Close:
 
 as.hexmode(utf8ToInt(£))
 [1] a3
 

Looking at the help page again I realized that there was a `format.hexmode` to 
deliver as requested:

 format(as.hexmode(utf8ToInt(£)), width=4, upper=TRUE)
[1] 00A3

-- 
David.

 
 I have googled and otherwise searched around and have come up with nothing 
 that seemed at all helpful to me.  If I am missing something obvious, please 
 point me at it.
 
 (I have found a table on the web, which contains the information that I 
 need, but it is only accessible by eye as far as I can discern.)
 
 Supplementary question:  Suppose I have the string 00A3 stored in
 an object called yyy.
 
 
 intToUtf8(as.hexmode('00A3'))
 [1] £
 
 
 How do I put that string together with \u
 so as to obtain £?  I thought I could do
 
  xxx - paste(\u,yyy,sep=)
 
 but R won't let me use \u without hex digits.  How can I get around this?
 
 Thanks.
 
 cheers,
 
 Rolf Turner
 
 __
 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.
 
 David Winsemius
 Alameda, CA, USA
 
 __
 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.

David Winsemius
Alameda, CA, USA

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


Re: [R] creating an equivalent of r-help on r.stackexchange.com ? (was: Re: Should there be an R-beginners list?)

2014-02-04 Thread Liviu Andronic
Dear all,


On Sun, Feb 2, 2014 at 10:49 PM, Liviu Andronic landronim...@gmail.com wrote:
 It seems that StackOverflow is officially proposing user-generated
 content for download/mirroring:
 http://blog.stackoverflow.com/2014/01/stack-exchange-cc-data-now-hosted-by-the-internet-archive/?cb=1

 All community-contributed content on Stack Exchange is licensed under
 the Creative Commons BY-SA 3.0 license.  And it is currently being
 mirrored at least at the Internet Archive:
 https://archive.org/details/stackexchange

 So, in principle, it would be possible/desirable to:
 - spin the 'r' tag from StackOverflow and propose an r.stackexchange.com at
 http://area51.stackexchange.com/categories/8/technology . Such a SE
 site would be similar to http://mathematica.stackexchange.com/

As Duncan suggested earlier, tying R Core to StackExchange may or may
not be a good idea as it would make it somewhat dependent on external
corporate interests. (Personally I see both advantages and
disadvantages.)

So in the end my proposal is not necessarily for r-help to go to SE,
but more for R to have its own QA forum/wiki for helping R users.
This could perfectly take the form of setting up its own open-source
https://github.com/ialbert/biostar-central QA interface (a SE-like
web interface) on R Core's servers. In this case the website would
look like the following: http://www.biostars.org/ .

Regards,
Liviu


 - involve R Core to give blessing for using the R logo, if necessary.
 This would be similar to what Ubuntu does with AskUbuntu:
 http://meta.askubuntu.com/questions/5444/is-ask-ubuntu-official-ubuntu
 - set a mirror on r-project.org for all the user content that is
 produced by r.stackexchange.com , and thus allow R Core to keep the
 info publicly available at all times. The mirroring on Internet
 Archive would still hold.


 2.  I think an interface like StackOverflow is better than the mailing list
 interface, and will eventually win out.  R-help needs to do nothing, once
 someone puts together something like StackOverflow that attracts most of the
 people who give good answers, R-help will just fade away.

 The advantages for such a move are countless (especially wrt to
 efficiently organizing R-related knowledge and directing users to
 appropriate sources of info), so I won't go into that. I would only
 note that most 'r-sig-*' MLs would become obsolete in such a setup,
 and would be replaced by the much more efficient tagging system of the
 SE QA web interface (for example, all posts appropriate for r-sig-gui
 would simply be tagged with 'gui'; no need for duplicated efforts of
 monitoring multiple mailing lists).

 Opinions?

 Liviu

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



-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-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] error in building R-2.15.3: configure: error: linking to Fortran libraries from C fails

2014-02-04 Thread Dinesh
Hi, 

I am trying to build R-2.15.3 and get the following error in 

/configure --with-readline --enable-R-shlib
snip
checking for dummy main to link with Fortran 77 libraries... unknown
configure: error: in `/home/dinesh/R-build/R-2.15.3':
configure: error: linking to Fortran libraries from C fails


packages installed:
zypper in texinfo readline-devel xorg-x11-devel


Compilers:
GNU Fortran (SUSE Linux) 4.3.4 [gcc-4_3-branch revision 152973]
gcc (SUSE Linux) 4.3.4 [gcc-4_3-branch revision 152973]
g++ (SUSE Linux) 4.3.4 [gcc-4_3-branch revision 152973]


Linux:
Linux hanaserver 2.6.32.27-0.2-default #1 SMP 2010-12-29 15:03:02 +0100
x86_64 x86_64 x86_64 GNU/Linux


FROM config.log
configure:23444: checking for dummy main to link with Fortran 77 libraries
configure:23478: gcc -std=gnu99 -o conftest -g -O2 -I/usr/local/include
-L/usr/local/lib64 conftest.c -ldl -lm   -lgfortran -lm 5
/usr/lib64/gcc/x86_64-suse-linux/4.3/libgfortran.so: undefined reference to
`__gttf2@GCC_4.3.0'
/usr/lib64/gcc/x86_64-suse-linux/4.3/libgfortran.so: undefined reference to
`__netf2@GCC_4.3.0'
/usr/lib64/gcc/x86_64-suse-linux/4.3/libgfortran.so: undefined reference to
`__lttf2@GCC_4.3.0'
collect2: ld returned 1 exit status
configure:23478: $? = 1


Will greatly appreciate your help in working this out.

Regards
Dinesh

__
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] Justify axis labels in mosaic plot

2014-02-04 Thread Jim Lemon

On 02/05/2014 12:41 PM, Derickson, Ryan, VHACIN wrote:

Hello All,



I'm trying to right-justify the y-axis labels in a mosaic plot from base
R. I've tried too many commands (adj specifically) to list here and
nothing works so far. I'm sure this could be done in the vcd or ggplot2
packages, but I would prefer to do it with mosaicplot in base R if at
all possible and I suspect it is possible. Illustration code is below-
I'm trying to make q, qwe, and qwertyqwerty right-justified
instead of left. The prop.table and order bits are unnecessary for the
sample but I need them for my actual analyses so I included them here in
case that somehow affects the code needed. I would be incredibly
appreciative of any help!



#demo

a-c(qwertyqwerty, qwertyqwerty, qwertyqwerty, qwe, qwe,
qwe, q, q, q)

b-c(1, 2, 3, 1, 1, 3, 2, 2, 3)

demo-data.frame(a, b)

y-table(demo)

y-as.table(y[order(rowSums(y)),])

y-prop.table(y)

plot(y,

dir=c(h, v),

las=1)



Hi Ryan,
The only thing I can offer, and it is an awful kludge, is to overwrite 
the labels on the left:


plot(y,dir=c(h,v),las=1)
library(plotrix)
boxed.labels(rep(0.1,3),c(0.83,0.48,0.13),
 c( q,  qwerty,qwertyqwerty),
 adj=1,border=NA,cex=0.8,ypad=1.5)

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.