Re: [R] Splitting columns and forming new data files in R

2014-04-11 Thread Zilefac Elvis
Great. Thanks AK.

On Thursday, April 10, 2014 11:14 PM, arun smartpink...@yahoo.com wrote:
 
Hi,
Ok, In that case, 

change `lst1New`.  Also, in your files, there was no Sim column.  So, I 
changed the name.


lst1New - lapply(lst1,function(x) {lst2 - setNames(lapply(x,function(y) {dat 
- read.table(y,sep= ,header=TRUE, stringsAsFactors=FALSE);names(dat)[5] - 
Sim; dat[,1:5]}),names1); dat2 - do.call(cbind,lst2); indx - 
grepl(Sim,names(dat2)); dat3 - dat2[indx]; dat4 - dat2[!indx][,1:4]; 
names(dat4) - gsub(.*\\.,,names(dat4)); 
lapply(split(names(dat3),gsub(.*\\.,,names(dat3))),function(x) {dat5 - 
cbind(dat4,dat3[,x]);dat5$Tmean - -999.9; dat6 - 
dat5[,c(1:4,7:6,8,5)];colnames(dat6)[2:3] - 
format(Coord[match(unique(dat6$Site),Coord$Site),3:2],digits=4); dat7 - 
dat6[,-4]; mat1 - as.matrix(dat7); colnames(mat1)[-(2:3)] - ' '; mat1})}) 


A.K.




On Friday, April 11, 2014 12:12 AM, zilefacel...@yahoo.com 
zilefacel...@yahoo.com wrote:





Hi AK,  the program works perfect. I used a different data set and was unable 
to modify the program to suit the new data set. Attached.





The attached dataset has 5 columns instead of 104 columns for which the program 
was developed. I was unable to edit lst1NEW-.

-- Original Message --



From : arun
To : Zilefac Elvis;
Sent : 10-04-2014 22:02
Subject : Re: Re: Splitting columns and forming new data files in R
 
Hi Atem, It may be that the program slows with the size of the dataset.  On 
Thursday, April 10, 2014 11:13 PM, Zilefac Elvis  wrote: Hi AK,
Please apply this program of yours to my attached data set. I have been 
struggling for hours but did not succeed. I am learning faster than I expected 
but this one is more than me. Thanks,
Atem.
#---
dir.create(final)
list.files()
#[1] coordinates.csv final  Precip  Tmax   Tmin
Coord - 
read.csv(list.files(pattern=.csv),header=TRUE,stringsAsFactors=FALSE) # read 
coordinates (lat,long)
lfile - list.files()[!grepl(.csv|final,list.files())] # list other files 
except .csv and final
files -  paste(paste(getwd(),lfile,sep=/), list.files(lfile),sep=/)# getwd 
of these files/contents lst1 - 
split(files,gsub(.*\\/(.*)\\.csv,\\1,files)) 
names1 - gsub(.*\\/(.*)\\/.*\\.csv,\\1,lst1[[1]])
lst1New - lapply(lst1,function(x) {lst2 - setNames(lapply(x,function(y)   
{dat - read.table(y,sep= ,header=TRUE, stringsAsFactors=FALSE);
dat[,1:104]} ), names1); dat2 - do.call(cbind,lst2);   indx - 
grepl(Sim,names(dat2)); dat3 - dat2[indx];  dat4 - dat2[!indx][,1:4]; 
names(dat4) - gsub(.*\\.,,names(dat4));   
lapply(split(names(dat3),gsub(.*\\.,,names(dat3))),function(x)      {dat5 
- cbind(dat4,dat3[,x]); dat5$Tmean - -999.9;  dat6 - 
dat5[,c(1:4,7:6,8,5)];  colnames(dat6)[2:3] - 
format(Coord[match(unique(dat6$Site),Coord$Site),3:2],digits=4);  dat7 - 
dat6[,-4]; mat1 - as.matrix(dat7); colnames(mat1)[-(2:3)] - ' ';mat1})}) 
# Change dat to [,1:104] if you need all rows. lst2New - 
lapply(lst1New,function(x) {names(x) - NULL; x}) #head(lst2New[[1]][[1]],4)
#49.53 -96.77 
#[1,] 2000    1  1 -9.13 8.23 -999.9 0 
#[2,] 2000    1  2 -9.51 0.39 -999.9 0  lapply(names(lst2New),function(x)   
{nm1 - paste(x, names(lst1New[[x]]),sep=_);   nm2 - 
paste0(paste(paste0(getwd(),/final),nm1,sep=/),.csv);   
lapply(seq_along(lst1New[[x]]),function(i) {x1 - lst2New[[x]][[i]];    
   write.csv(x1, 
nm2[i],quote=FALSE,row.names=FALSE)})}) 
#-
On Wednesday, April 9, 2014 1:29 AM, arun  wrote: Hi Atem, No problem.  Glad it 
worked.  In the first instance, I should have used `[[` instead of `[` in the 
last line of code, which created the confusion. lapply(, lst2New[[x]][i]; 
write.table...) On Wednesday,
April 9, 2014 1:35 AM, Zilefac Elvis  wrote: Wow! You finally fixed it.
I appreciate your endless efforts.
Atem.
On Tuesday, April 8, 2014 11:26 PM, arun  wrote: Hi Atem, If you change 
colnames(mat1)[-(2:3)] - ' ' in 'lst1New' lst1New - lapply(lst1,function(x) 
{lst2 - setNames(lapply(x,function(y) {dat - read.table(y,sep= 
,header=TRUE, stringsAsFactors=FALSE); dat[,1:104]} ), names1); dat2
- do.call(cbind,lst2); indx - grepl(Sim,names(dat2)); dat3 -
dat2[indx];dat4 - dat2[!indx][,1:4]; names(dat4) - 
gsub(.*\\.,,names(dat4)); 
lapply(split(names(dat3),gsub(.*\\.,,names(dat3))),function(x)  {dat5 - 
cbind(dat4,dat3[,x]); dat5$Tmean - -999.9; dat6 - dat5[,c(1:4,7:6,8,5)]; 
colnames(dat6)[2:3] - 
format(Coord[match(unique(dat6$Site),Coord$Site),3:2],digits=4); dat7 - 
dat6[,-4]; mat1 - as.matrix(dat7); colnames(mat1)[-(2:3)] - ' ';mat1})})  
lst2New - lapply(lst1New,function(x) {names(x) - NULL; x}) 
head(lst2New[[1]][[1]],2) 49.53 -96.77 
#[1,] 2000 1  1 -9.13 8.23 -999.9 0 
#[2,] 2000 1  2 -9.51 0.39 -999.9 0  lapply(names(lst2New),function(x) 
{nm1 - paste(x,
names(lst1New[[x]]),sep=_); nm2 - 

Re: [R] print(cenfit object) to a data.frame

2014-04-11 Thread Massimo Bressan

thanks rui, it helps indeed..

at first, I've been trying to data.frame the output of mean (mycenfit) 
by the following:

my.df-as.data.frame(do.call(rbind, mean(mycenfit)))
and it worked out correctly!

...but because I also needed the information about n and n.cen, 
which are not provided by mean(mycenfit), I had to switch to 
print(mycenfit);
...but unfortunately, print(mycenfit) is not so easy (to me at least) to 
handle


now, I'm looking at a different possible ways to extract the same 
information directly from the object mycenfit (S4), which turned out 
to be quite hard (to me again)


any othe possible ideas?

cheers

__
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] Mean of values in different files

2014-04-11 Thread arun
Hi,
Try:
dir.create(final)
lst1 - 
split(list.files(pattern=.csv),gsub(\\_.*,,list.files(pattern=.csv))) 
lst2 -  lapply(lst1,function(x1) lapply(x1, function(x2) {lines1 - 
readLines(x2); header1 - lines1[1:2]; dat1 - 
read.table(text=lines1,header=FALSE,sep=,,stringsAsFactors=FALSE, skip=2); 
colnames(dat1) - Reduce(paste,strsplit(header1,,));dat1}))

lstYear - lapply(lst2,function(x) lapply(x, function(y) 
y[,1,drop=FALSE])[[1]]) 


lapply(seq_along(lst2),function(i) {lstN -lapply(lst2[[i]],function(x) 
x[,-1]); arr1 - 
array(unlist(lstN),dim=c(dim(lstN[[1]]),length(lstN)),dimnames=list(NULL,lapply(lstN,names)[[1]]));res
 - cbind(lstYear[[i]],rowMeans(arr1,dims=2,na.rm=TRUE)); names(res) - 
gsub(\\_$,,gsub( , _,names(res))); res[,1] - gsub( , ,res[,1]); 
write.csv(res,paste0(paste(getwd(),final,names(lst1)[[i]],sep=/),.csv),row.names=FALSE,quote=FALSE)
   }) 


A.K.

On Thursday, April 10, 2014 11:55 PM, Zilefac Elvis zilefacel...@yahoo.com 
wrote:

HI AK,
I have finished calculating my statistics and would like to merge the files 
into 1 files resulting from 100 simulations.

In the attached .zip file, I have 4 files for site G100_ and 4 for site G101_ 
identified by site code. I have 12000 (120 sites * 100 sims) such files to deal 
with but I have provided a sample only.

1) Replace any empty spaces (no values) with NA
2) Take the mean of values in each cell

Create a folder called final and store the results in it. For this sample, 
the folder final will have two files (G100 and G101). The contents of each 
file being the mean from 4 files. The headers, rows and columns of files in 
final are exactly the same as those of any file in sample.zip. Headers, rows 
and columns are the same for all files in sample.zip.

Thanks AK. Please do it at your convenience.
Regards,
Atem.

__
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] General Copula theory

2014-04-11 Thread Chris89
Hi everyone!

Firstly, let me specify that I an new to copula theory, so be gentle! 

I have two data sets containing wind data for 14 years, and I am to use
Gumbel marginals and a Gumbel copula. The question is, how will I generate
data from the marginals? 

I have 14 years of data (4 observations each day), so I have taken the
maximum of each year (eliminating seasonality) and then found the parameters
of the corresponding Gumbel distribution. But then what? Should I generate n
values of Gumbel distributed data, get uniform values by the inverse
cumulative, and then put these into the Gumbel copula?

I guess this have to be wrong, but I just can't seem to find a good
procedure on this topic.

Sincerely
Chris




--
View this message in context: 
http://r.789695.n4.nabble.com/General-Copula-theory-tp4688594.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] Variable names in plotCI

2014-04-11 Thread Mª Teresa Martinez Soriano

Hello to everyone, 
I would like to put the variable names in the x-axis of this plot instead of 
number 1:63:

plotCI(1:num_col_comp,med,2.06*des/sqrt(n),lwd=1,col=red,scol=seashell4,main=Intervalo
 de confianza,xlab=Variables clínicas,ylab=Intervalo de 
confianza)abline(h=0, col=yellowgreen,lwd=1.8)

I don't find the way to do it, I tried with xlab option but it doesn't work and 
I tried as well creatting a data.frame with the rownames of the variables and 
the values 1:63
Any idea will be very appreciated
Thanks a lot
An example of the data set could be:y-runif(10)
 err-runif(10)
 plotCI(1:10,y,err,main=Basic plotCI)
 plotCI(1:10,y,err,2*err,lwd=2,col=red,scol=blue,
  main=Add colors to the points and error bars)
  
[[alternative HTML version deleted]]

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


Re: [R] how to select an element from a vector based on a probability

2014-04-11 Thread Simone Gabbriellini
Dear Frede,

the initial question was to find probability proportional to the
values, so Rui, Dan and Boris are right...

I think I will go for Boris' solution...

best regards,
Simone

2014-04-11 7:29 GMT+02:00 Frede Aakmann Tøgersen fr...@vestas.com:
 I think you have calculated the wrong probabilities. Shouldn't it be

 x - c(2,2,6,2,1,1,1,3)
 MASS::fractions(table(x)/length(x))
 x
   1   2   3   6
 3/8 3/8 1/8 1/8


 Yours sincerely / Med venlig hilsen


 Frede Aakmann Tøgersen
 Specialist, M.Sc., Ph.D.
 Plant Performance  Modeling

 Technology  Service Solutions
 T +45 9730 5135
 M +45 2547 6050
 fr...@vestas.com
 http://www.vestas.com

 Company reg. name: Vestas Wind Systems A/S
 This e-mail is subject to our e-mail disclaimer statement.
 Please refer to www.vestas.com/legal/notice
 If you have received this e-mail in error please contact the sender.


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Nordlund, Dan (DSHS/RDA)
 Sent: 10. april 2014 22:04
 To: Simone Gabbriellini; Rui Barradas
 Cc: r-help@r-project.org
 Subject: Re: [R] how to select an element from a vector based on a
 probability

  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
  project.org] On Behalf Of Simone Gabbriellini
  Sent: Thursday, April 10, 2014 11:59 AM
  To: Rui Barradas
  Cc: r-help@r-project.org
  Subject: Re: [R] how to select an element from a vector based on a
  probability
 
  Hello, Rui,
 
  it does, indeed!
 
  thanks,
  Simone
 
  2014-04-10 20:55 GMT+02:00 Rui Barradas ruipbarra...@sapo.pt:
   Hello,
  
   Use ?sample.
  
   sample(x, 1, prob = x)
  

 Just be aware that, in using this method, the probability of selection of a
 particular value will also be a function of how frequent the value is.  For
 example,

 set.seed(7632)
 x - c(2,2,6,2,1,1,1,3)
 table(sample(x, 1, prob=x, replace=TRUE))

1236
 1664 3340 1696 3300


 The probability that a vector position with a value of 1 will be selected is 
 1/18
 (in this particular example).  However, the probability that a value of 1 
 will be
 selected is 1/6 since there are three 1's.  The probability of selecting the
 position with a value of 3 is 3/18.  But since there is only one position 
 with a
 value of 3, the probability of getting the value 1 on any given sample is 
 equal
 to the probability of getting the value 3.




   Hope this helps,
  
   Rui Barradas
  
   Em 10-04-2014 19:49, Simone Gabbriellini escreveu:
  
   Hello List,
  
   I have an array like:
  
   c(4, 3, 5, 4, 2, 2, 2, 4, 2, 6, 6, 7, 5, 5, 5, 10, 10, 11, 10,
   12, 10, 11, 9, 12, 10, 36, 35, 36, 36, 36, 35, 35, 36, 37, 35,
   35, 38, 35, 38, 36, 37, 36, 36, 37, 36, 35, 35, 36, 36, 35, 35,
   36, 35, 38, 35, 35, 35, 36, 35, 35, 35, 6, 5, 8, 6, 6, 7, 1,
   7, 7, 8, 9, 7, 8, 7, 7, 13, 13, 13, 14, 13, 13, 13, 14, 14, 15,
   15, 14, 13, 14, 39, 39, 39, 39, 39, 39, 41, 40, 39, 39, 39, 39,
   40, 39, 39, 41, 41, 40, 39, 40, 41, 40, 41, 40, 40, 40, 39, 41,
   39, 39, 39, 39, 40, 39, 39, 40, 40, 39, 39, 39, 1, 4, 3, 4)
  
   I would like to pick up an element with a probability proportional
  to
   the element value, thus higher values should be picked up more often
   than small values (i.e., picking up 38 should be more probable than
   picking up 3)
  
   Do you have any idea on how to code such a rich-get-richer
  mechanism?
  
   Best regards,
   Simone
  
  
 
 
 

 Dan

 Daniel J. Nordlund, PhD
 Research and Data Analysis Division
 Services  Enterprise Support Administration
 Washington State Department of Social and Health Services


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



-- 
-

Simone Gabbriellini, PhD

Post-doctoral Researcher
ANR founded research project DIFFCERAM
GEMASS, CNRS  Paris-Sorbonne.

mobile: +39 340 39 75 626
email: simone.gabbriell...@cnrs.fr

__
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] Variable names in plotCI

2014-04-11 Thread Pascal Oettli
Hello,

When posting, you are asked to provide a reproducible code (including
packages you are using) and to not post in HTML.

The following might help:

library(plotrix)
y-runif(10)
err-runif(10)
plotCI(1:10,y,err,main=Basic plotCI,xaxt='n',xlab='')
axis(1,1:10,LETTERS[1:10])

Regards,
Pascal

On Fri, Apr 11, 2014 at 6:59 PM, Mª Teresa Martinez Soriano
teresama...@hotmail.com wrote:

 Hello to everyone,
 I would like to put the variable names in the x-axis of this plot instead of 
 number 1:63:

 plotCI(1:num_col_comp,med,2.06*des/sqrt(n),lwd=1,col=red,scol=seashell4,main=Intervalo
  de confianza,xlab=Variables clínicas,ylab=Intervalo de 
 confianza)abline(h=0, col=yellowgreen,lwd=1.8)

 I don't find the way to do it, I tried with xlab option but it doesn't work 
 and I tried as well creatting a data.frame with the rownames of the variables 
 and the values 1:63
 Any idea will be very appreciated
 Thanks a lot
 An example of the data set could be:y-runif(10)
  err-runif(10)
  plotCI(1:10,y,err,main=Basic plotCI)
  plotCI(1:10,y,err,2*err,lwd=2,col=red,scol=blue,
   main=Add colors to the points and error bars)

 [[alternative HTML version deleted]]


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




-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

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


Re: [R] Variable names in plotCI

2014-04-11 Thread Jim Lemon

On 04/11/2014 07:59 PM, Mª Teresa Martinez Soriano wrote:


Hello to everyone,
I would like to put the variable names in the x-axis of this plot instead of 
number 1:63:

plotCI(1:num_col_comp,med,2.06*des/sqrt(n),lwd=1,col=red,scol=seashell4,main=Intervalo de 
confianza,xlab=Variables clínicas,ylab=Intervalo de confianza)abline(h=0, col=yellowgreen,lwd=1.8)

I don't find the way to do it, I tried with xlab option but it doesn't work and 
I tried as well creatting a data.frame with the rownames of the variables and 
the values 1:63
Any idea will be very appreciated
Thanks a lot
An example of the data set could be:y-runif(10)
  err-runif(10)
  plotCI(1:10,y,err,main=Basic plotCI)
  plotCI(1:10,y,err,2*err,lwd=2,col=red,scol=blue,
   main=Add colors to the points and error bars)


Hi Teresa,
Seems to be plotCI from plotrix, so try:

plotCI(1:10,y,err,main=Basic plotCI,xaxt=n)
xlabs-c(one,two,three,four,five,six,
seven,eight,nine,ten)
staxlab(1,at=1:10,labels=xlabs)

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] Meta-analysis of prevalence at the country level with mgcv/gamm4

2014-04-11 Thread Michael Dewey

At 13:17 10/04/2014, Julien Riou wrote:


 Message: 11
 Date: Wed, 09 Apr 2014 18:39:30 +0100
 From: Michael Dewey i...@aghmed.fsnet.co.uk
 To: Julien Riou julien.rio...@gmail.com, r-help@r-project.org
 Subject: Re: [R] Meta-analysis of prevalence at the country level with
 mgcv/gamm4
 Message-ID: zen-1wxwtl-0005q4...@smarthost01a.mail.zen.net.uk
 Content-Type: text/plain; charset=us-ascii; format=flowed



Hi Michael,

Thank you for taking the time to help me.

 So the first UK study with a median age of 25 is going to be used to
 estimate prevalence over a range of ages? You are going to have to
 make some very strong assumptions here which I personally would not
 want to make.


I'm a little confused by this. In my understanding, the mixed-effects model
does not do that. The slope of the relation between age and prevalence will
be estimated from the full pool of studies, and the country-level random
intercept will be estimated from all studies in the country. So the
assumption here is that the relation between age and incidence is the same
in every country, which is quite reasonable. Of course, there will be more
uncertainty with the estimation of the random intercept if there is few
studies in a country, or if there is a strong inter-study variance in a
country. This will influence the confidence interval of the random
intercept, and so the CI of the predicted prevalence for this country.


Your studies are ecological. You are estimating the relationship 
between prevalence and being in a study of median age X which is not 
necessarily the same as the relationship between prevalence and being 
a person of age X.





Is there any possibility that in the real dataset you can fit your
 model to those studies which do provide age-specific prevalences and
 then use that to impute?

 You do not say when these studies were published but I would ask the
 authors of the primary studies if they can make the information
 available to you. You may have already done that of course. I referee
 quite a few papers on systematic reviews and my impression is that
 some authors are amenable to doing the work for you. You mileage may
 vary of course.


Yes, it would be easier to have prevalence for age subgroups of studies,
but we did not have access to that information for most studies even after
contacting the authors.


 *Standard random-effect meta-analysis* with package meta.
 
 I used metaprop() to get a first estimate of the prevalence in each
 country
 without taking age into account, and to obtain weights. As expected,
 heterogeneity was very high, so I used weights from the random-effects
 model.

 Which will be nearly equal and so hardly worth using in my opinion
 but again your mileage may vary.


The weights from the random-effects method were actually far from equals,
as sample size was highly variable between studies. With the RE method,
small studies have much more impact.


 I am afraid that is the way with systematic reviews, you can only
 synthesise what you find, not what you would like to have found.
 Anyone who has done a review will sympathise with you, not that that
 is any consolation.


I'm not sure I'm following your point. My objective is to synthesise the
included studies, while taking the age factor into account, since it is
strongly linked to prevalence and very heterogeneous. The alternative is to
only include studies with low median age, but I would lose a lot of
information.

Thank you again,
Julien




[[alternative HTML version deleted]]


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

__
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] weights error in svyglm

2014-04-11 Thread Lee, Laura
Hi!

I am just learning the 'svyglm' package and have run into an error for which I 
have not found a solution. My data have been collected from a stratified random 
survey. Here is the code:

NB3-glm.nb(COLNUM~Year+Depth+MESH+offset(LogEffort),data=data)

dstrat - svydesign(id=~1, strata=~STRATA, weights = ~weight, data=data)

SNB3 - svyglm(NB3, design=dstrat)

The error that is returned is:

Error in model.frame.glm(formula = list(coefficients = c(-6.96858807641624,  :
  object '.survey.prob.weights' not found

I would appreciate any assistance in solving this problem.

Thanks,

Laura


[[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] grabbing GIS data from www

2014-04-11 Thread Milan Cisty
Dear list,

When I have this WWW page:

http://194.160.88.35:8008/geoexplorer/composer/#maps/1

in which you can select button Identify and then when you click on some
color dot in map, you see data for that point. Is it possible by means of R
to grab that data together with points coordinates by some R package?

Thanks,

Milan

 


[[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] Concave hull

2014-04-11 Thread davide.viggiano
Hi, I just want to add a possible solution to the problem in the special case
all the points must stay on the edge of the outline. THis is sometimes the
case when doing image analysis and you want to order the points along a
closed path.
In this specific case, you can use some algorithm like the traveling
salesman problem, which would give you the shortest path along all your
points.
In this scenario, if your points are xy, you may use the following:

library(TSP)
tsp - TSP(dist(xy))
tour - solve_TSP(tsp,method='farthest')
xy - xy[tour,]

THis may not be the most economical solution (and you might also want
contrains such as never to intersect the path) and is not valid if your
boundary is not supposed to pass through all points.




--
View this message in context: 
http://r.789695.n4.nabble.com/Concave-hull-tp863710p4688606.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] operating website through R

2014-04-11 Thread eliza botto
Dear Users of R,
I wanted to operate certain slots of this website 
(http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42_daily.2.shtml) 
through R. I wanted to operate Latitude, longitude section, plot type, begin 
and end year and ASCII Output Resolution. The filling of these slot will 
produce and output file with I want to D/L at a certain location in my PC. 
I have a matrix of 2 columns and 3000 rows which contain Latitude and Longitude 
information which i want to upload automatically in the slots of website. I 
tried to use certain web scarping techniques in R but to no use.
Is there a way of doing it in R.
thank you very much in advance,
Eliza

  
[[alternative HTML version deleted]]

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


Re: [R] operating website through R

2014-04-11 Thread Suzen, Mehmet
You just need to pass the parameters on Giovanni_cgi.pl with action=ASCII+Output

On 11 April 2014 17:19, eliza botto eliza_bo...@hotmail.com wrote:
 Dear Users of R,
 I wanted to operate certain slots of this website 
 (http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42_daily.2.shtml) 
 through R. I wanted to operate Latitude, longitude section, plot type, begin 
 and end year and ASCII Output Resolution. The filling of these slot will 
 produce and output file with I want to D/L at a certain location in my PC.
 I have a matrix of 2 columns and 3000 rows which contain Latitude and 
 Longitude information which i want to upload automatically in the slots of 
 website. I tried to use certain web scarping techniques in R but to no use.
 Is there a way of doing it in R.
 thank you very much in advance,
 Eliza


 [[alternative HTML version deleted]]

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

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


Re: [R] weights error in svyglm

2014-04-11 Thread Milan Bouchet-Valat
Le vendredi 11 avril 2014 à 13:38 +, Lee, Laura a écrit :
 Hi!
 
 I am just learning the 'svyglm' package and have run into an error for
 which I have not found a solution. My data have been collected from a
 stratified random survey. Here is the code:
 
 NB3-glm.nb(COLNUM~Year+Depth+MESH+offset(LogEffort),data=data)
 
 dstrat - svydesign(id=~1, strata=~STRATA, weights = ~weight,
 data=data)
 
 SNB3 - svyglm(NB3, design=dstrat)
 
 The error that is returned is:
 
 Error in model.frame.glm(formula = list(coefficients =
 c(-6.96858807641624,  :
   object '.survey.prob.weights' not found
 
 I would appreciate any assistance in solving this problem.
The error is somewhat strange, but you should not pass the result of
glm.nb() to svyglm (where have you found this idea?). Just do
SNB3 - svyglm(COLNUM ~ Year + Depth + MESH + offset(LogEffort), design=dstrat)


Regards

__
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] StatET and R 3.1.0

2014-04-11 Thread Jonathan Greenberg
R-helpers:

I posted a message to the statet listserv, but I thought I'd ask here
as well since it is one of the major R developer environments-- has
anyone gotten the StatET plugin for Eclipse working with R 3.1.0 yet?
Any tricks?  I did manage to get rj updated to 2.0 via:

install.packages(c(rj, rj.gd),
repos=http://download.walware.de/rj-2.0,type=source;)

But the plugin is throwing an error (using the last maintenance update
at http://download.walware.de/eclipse-4.3/testing):

Launching the R Console was cancelled, because it seems starting the R
engine failed.  Please make sure that R package 'rj' (1.1 or
compatible) is installed
and that the R library paths are set correctly for the R environment
configuration 'R'.

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
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] operating website through R

2014-04-11 Thread eliza botto
Dear Suzen,
I couldn't understand. Could you please elaborate it with a small example? 
:(
Thanks in advance.
Eliza

 Date: Fri, 11 Apr 2014 17:31:18 +0200
 Subject: Re: [R] operating website through R
 From: msu...@gmail.com
 To: eliza_bo...@hotmail.com
 CC: r-help@r-project.org
 
 You just need to pass the parameters on Giovanni_cgi.pl with 
 action=ASCII+Output
 
 On 11 April 2014 17:19, eliza botto eliza_bo...@hotmail.com wrote:
  Dear Users of R,
  I wanted to operate certain slots of this website 
  (http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42_daily.2.shtml) 
  through R. I wanted to operate Latitude, longitude section, plot type, 
  begin and end year and ASCII Output Resolution. The filling of these slot 
  will produce and output file with I want to D/L at a certain location in my 
  PC.
  I have a matrix of 2 columns and 3000 rows which contain Latitude and 
  Longitude information which i want to upload automatically in the slots of 
  website. I tried to use certain web scarping techniques in R but to no use.
  Is there a way of doing it in R.
  thank you very much in advance,
  Eliza
 
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
  
[[alternative HTML version deleted]]

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


[R] sink() and UTF-8 on non-UTF-8 systems

2014-04-11 Thread Milan Bouchet-Valat
Hi!

In the series dealing with encoding madness on hostile systems, I'm
looking for help as regards capturing R UTF-8 output on a system where
the locale is not using UTF-8, and where some characters cannot even be
represented using the locale encoding. The case I have in mind is
printing a character vector with Russian text to the R Commander output
window on an English/French (CP1252) Windows system.

Here's a code snippet illustrating the problem:
 \U41F
[1] П # OK
 con - file(open=w+, encoding=UTF-8)
 capture.output(cat(\U41F), file=con)
 readLines(con, encoding=UTF-8)
[1] U+041F # Not OK

(same result without specifying 'encoding')


Now I have read ?sink and it is quite explicit about how this works:
 If file is a character string, the file will be opened using the
 current encoding. If you want a different encoding (e.g. to represent
 strings which have been stored in UTF-8), use a file connection — but
 some ways to produce R output will already have converted such strings
 to the current encoding. 

The last words seem to apply to the case above, i.e. somewhere in the
process the UTF-8 string is converted to the locale encoding. Is there
any solution to get the correct output?


Thanks


 sessionInfo()
R Under development (unstable) (2014-04-10 r65396)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252   
[3] LC_MONETARY=French_France.1252 LC_NUMERIC=C  
[5] LC_TIME=French_France.1252

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

__
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] weights error in svyglm

2014-04-11 Thread Lee, Laura
Thanks! That worked. However, what error distribution is assumed? I was hoping 
to use a negative binomial.

-Original Message-
From: Milan Bouchet-Valat [mailto:nalimi...@club.fr] 
Sent: Friday, April 11, 2014 11:37 AM
To: Lee, Laura
Cc: r-help@r-project.org
Subject: Re: [R] weights error in svyglm

Le vendredi 11 avril 2014 à 13:38 +, Lee, Laura a écrit :
 Hi!
 
 I am just learning the 'svyglm' package and have run into an error for 
 which I have not found a solution. My data have been collected from a 
 stratified random survey. Here is the code:
 
 NB3-glm.nb(COLNUM~Year+Depth+MESH+offset(LogEffort),data=data)
 
 dstrat - svydesign(id=~1, strata=~STRATA, weights = ~weight,
 data=data)
 
 SNB3 - svyglm(NB3, design=dstrat)
 
 The error that is returned is:
 
 Error in model.frame.glm(formula = list(coefficients = 
 c(-6.96858807641624,  :
   object '.survey.prob.weights' not found
 
 I would appreciate any assistance in solving this problem.
The error is somewhat strange, but you should not pass the result of
glm.nb() to svyglm (where have you found this idea?). Just do
SNB3 - svyglm(COLNUM ~ Year + Depth + MESH + offset(LogEffort), design=dstrat)


Regards
__
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] Mean not working in function

2014-04-11 Thread arun
Hi,
Try:
mysummary - function(dataf){ for(name in names(dataf)){ cat (Variable name: 
, name, : Mean=, mean(dataf[,name],na.rm=TRUE),\n) }
} 

##Using some example data:

set.seed(48)
dat1 - as.data.frame(matrix(sample(c(NA,1:20),4*20,replace=TRUE),ncol=4)) 
mysummary(dat1)
#Variable name:  V1 : Mean= 11.64706
#Variable name:  V2 : Mean= 10.9
#Variable name:  V3 : Mean= 12.35 

#Variable name:  V4 : Mean= 10.52632 


#Another way would be:

mysummary2 - function(dataf){ cat(paste(paste(Variable name: , names(dataf), 
: Mean=, format(colMeans(dataf,na.rm=TRUE),digits=7),collapse=\n),\n))
}
mysummary2(dat1) 

#Variable name:  V1 : Mean= 11.64706
#Variable name:  V2 : Mean= 10.9
#Variable name:  V3 : Mean= 12.35000
#Variable name:  V4 : Mean= 10.52632 


A.K.


I am trying following function: mysummary - function(dataf){ for(name in 
names(dataf)){ cat (Variable name: , name, : Mean=, mean(name),\n) }
} The variable name is properly picked up but the mean is shows as NA. The 
command warnings() show:
In mean.default(name) : argument is not numeric or logical: returning NA

__
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 3.0.3, Windows 7: Problem installing XML package

2014-04-11 Thread Alpesh Pandya
Using install.package('XML') command produces this error:

trying URL
'
http://watson.nci.nih.gov/cran_mirror/bin/windows/contrib/3.0/XML_3.98-1.1.zip
'
Content type 'application/zip' length 4288136 bytes (4.1 Mb)
opened URL
downloaded 4.1 Mb

Error in read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) :
  cannot open the connection
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = wb, ...) :
  downloaded length 4276224 != reported length 4288136
2: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
3: In read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) :
  cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such
file or directory'


Upon receiving this error, I downloaded XML_3.98-1.1.zip directly from cran
site. But this zip file is not a valid archive (cannot open using winzip).
Also trying to install using this downloaded file produces the following
error:

Installing package into 'C:/Users/APandya/Documents/R/win-library/3.0'
(as 'lib' is unspecified)
Warning in install.packages :
  error 1 in extracting from zip file
Warning in install.packages :
  cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such
file or directory'
Error in install.packages : cannot open the connection

I  downloaded this zip file from multiple sources and tried to install with
same result.

-- 
Thanks and Regards
Alpesh

[[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] weights error in svyglm

2014-04-11 Thread Milan Bouchet-Valat
Le vendredi 11 avril 2014 à 15:54 +, Lee, Laura a écrit :
 Thanks! That worked. However, what error distribution is assumed? I
 was hoping to use a negative binomial.
Since svyglm() computes designed-based standard errors, you should be
able to simply pass family=poisson instead. See
books.google.fr/books?id=L96ludyhFBsCpg=SA10-PA44
and following sections.


Regards

__
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] calling in inverted commas

2014-04-11 Thread eliza botto
Dear useRs,
Here are three steps for downloading a file from a certain website in R. Here 
you see that in URL command (west=68.25north=24.75east=68.25south=24.75) 
are actually the first and second column values of 1st row of a matrix called 
df2 (300 rows and 2 columns). more precisely, df2[1,][1]=68.25, 
df2[1,][2]=24.75. 
Is there a way that I can make a loop so that remaining rows and columns get 
inculcated in the link as such and then get saved at the desired mentioned 
location in 300 different text files?
URL-(http://disc2.nascom.nasa.gov/daac-bin/Giovanni/tovas/Giovanni_cgi.pl?west=68.25north=24.75east=68.25south=24.75params=0%7C3B42_V7plot_type=Time+Plotbyr=1998bmo=01bdy=1eyr=2007emo=12edy=31begin_date=1998%2F01%2F01end_date=2014%2F01%2F31cbar=cdyncmin=cmax=yaxis=ydynymin=ymax=yint=ascres=0.25x0.25global_cfg=tovas.global.cfg.plinstance_id=TRMM_V7prod_id=3B42_dailyaction=ASCII+Output;)
destfile - C:\\Users\\Eliza\\Desktop\\AA\\love.txt
download.file(URL, destfile)

Any suggestion?
Thankyou very much in advance,
Eliza 
[[alternative HTML version deleted]]

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


[R] partitioning around medoids

2014-04-11 Thread Tomassini, Letizia
Hello
I am running some k-medoids analysis to see if that algorithm will work better 
on my dataset compared to the k-means I have been using so far.
When running k-means I used to specify the nstart option, equal to a certain 
number, depending on how many random sets of clusters I wanted.

Could anybody tell me if I need to use, or if there is, an equivalent option 
for the pam() function?

pam(x,5)   is what I have put together so far. Also, any suggestions for what I 
might implement there?

Thanks
Letizia Tomassini, DVM, MPVM, PhD Candidate
College of Veterinary Medicine
Washington State University



[[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] Save file as Fixed Width using sprintf()

2014-04-11 Thread Doran, Harold
I have working code to write a file out as fwf as shown below. I have one 
question to try and automate this I cannot get to work.

I am generating thousands of data files for a simulation to be run outside of R 
and each file varies in its dimensions. So I am trying to write code that can 
write the fwf based on the dimensions of each file generated as shown below. I 
have commented this code with an example to show where I am stuck.

### Create a sample data matrix
myMat - matrix(rnorm(9), 3,3)

### Create the vector of format strings to be equal to the length of the 
columns in myMat
aa - rep('%4f', ncol(myMat))
xx - paste(aa, sep='', collapse='')

### Now I could just do this below and it works
(out - sprintf(xx, myMat[, 1], myMat[, 2], myMat[, 3]) )
out - as.matrix(out) # convert to a character matrix
dimnames(out) - list(rep('', nrow(out)), '') # blank row and column names
noquote(out) ## sink this file to a directory

But, the fact that the dimensions of my matrix vary at each iteration means I 
need to automate this part in the sprint().

myMat[, 1], myMat[, 2], myMat[, 3])

I think that's needed because something like the following does not work

(out - sprintf(xx, myMat[, 1:3]) )


So, I thought about trying smoething like this
cols - paste(paste('myMat[, ', 1:ncol(myMat), sep=''), ']', sep='')
cols - paste(cols, collapse=', ')

But, this is a string with quotation marks, so I thought using cat() might 
work, but it does not

(out - sprintf(xx, cat(cols) ) )

Anyone have a suggestion for the right way to do this, this is getting messy.

Thank
Harold

[[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] Save file as Fixed Width using sprintf()

2014-04-11 Thread arun


Hi,
May be this helps:
xx - paste(aa, collapse=' ')
set.seed(14) 
myMat - matrix(rnorm(9), 3,3) 
sprintf(xx,myMat[,1],myMat[,2],myMat[,3])
# [1] -0.661850 1.497154 -0.064881
# 1.718954 -0.036141 1.068994
# [3] 2.121667 1.231945 -0.376965 

do.call(sprintf,c(xx,split(myMat,col(myMat 
#[1] -0.661850 1.497154 -0.064881 
#1.718954 -0.036141 1.068994 
#[3] 2.121667 1.231945 -0.376965 
A.K.



On Friday, April 11, 2014 3:56 PM, Doran, Harold hdo...@air.org wrote:
I have working code to write a file out as fwf as shown below. I have one 
question to try and automate this I cannot get to work.

I am generating thousands of data files for a simulation to be run outside of R 
and each file varies in its dimensions. So I am trying to write code that can 
write the fwf based on the dimensions of each file generated as shown below. I 
have commented this code with an example to show where I am stuck.

### Create a sample data matrix
myMat - matrix(rnorm(9), 3,3)

### Create the vector of format strings to be equal to the length of the 
columns in myMat
aa - rep('%4f', ncol(myMat))
xx - paste(aa, sep='', collapse='')

### Now I could just do this below and it works
(out - sprintf(xx, myMat[, 1], myMat[, 2], myMat[, 3]) )
out - as.matrix(out) # convert to a character matrix
dimnames(out) - list(rep('', nrow(out)), '') # blank row and column names
noquote(out) ## sink this file to a directory

But, the fact that the dimensions of my matrix vary at each iteration means I 
need to automate this part in the sprint().

myMat[, 1], myMat[, 2], myMat[, 3])

I think that's needed because something like the following does not work

(out - sprintf(xx, myMat[, 1:3]) )


So, I thought about trying smoething like this
cols - paste(paste('myMat[, ', 1:ncol(myMat), sep=''), ']', sep='')
cols - paste(cols, collapse=', ')

But, this is a string with quotation marks, so I thought using cat() might 
work, but it does not

(out - sprintf(xx, cat(cols) ) )

Anyone have a suggestion for the right way to do this, this is getting messy.

Thank
Harold

    [[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] Save file as Fixed Width using sprintf()

2014-04-11 Thread jim holtman
Try this.  It creates a 'list' that are the parameters for sprintf.  It
writes out the file that I attach as the dump:

### Create a sample data matrix
myMat - matrix(rnorm(9), 3,3)

# create the format required -- make sure it is wide enough
# for 'fixed' width
xx - paste(rep(%8.2f, ncol(myMat)), collapse = '')
# create a list for 'do.call(sprintf'
callList - vector('list', ncol(myMat) + 1)
callList[[1]] - xx  # store in the format

# add the columns to the list
for (i in seq(ncol(myMat))) callList[[i + 1L]] - myMat[, i]
callList  # print it out

result - do.call(sprintf, callList)

# write out the data to a file
writeLines(result, '/temp/file.txt')


Here is what is in the file:

   -0.390.45   -0.44
   -0.82   -0.68   -0.43
2.05   -0.850.61



Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Fri, Apr 11, 2014 at 2:48 PM, Doran, Harold hdo...@air.org wrote:

 I have working code to write a file out as fwf as shown below. I have one
 question to try and automate this I cannot get to work.

 I am generating thousands of data files for a simulation to be run outside
 of R and each file varies in its dimensions. So I am trying to write code
 that can write the fwf based on the dimensions of each file generated as
 shown below. I have commented this code with an example to show where I am
 stuck.

 ### Create a sample data matrix
 myMat - matrix(rnorm(9), 3,3)

 ### Create the vector of format strings to be equal to the length of the
 columns in myMat
 aa - rep('%4f', ncol(myMat))
 xx - paste(aa, sep='', collapse='')

 ### Now I could just do this below and it works
 (out - sprintf(xx, myMat[, 1], myMat[, 2], myMat[, 3]) )
 out - as.matrix(out) # convert to a character matrix
 dimnames(out) - list(rep('', nrow(out)), '') # blank row and column names
 noquote(out) ## sink this file to a directory

 But, the fact that the dimensions of my matrix vary at each iteration
 means I need to automate this part in the sprint().

 myMat[, 1], myMat[, 2], myMat[, 3])

 I think that's needed because something like the following does not work

 (out - sprintf(xx, myMat[, 1:3]) )


 So, I thought about trying smoething like this
 cols - paste(paste('myMat[, ', 1:ncol(myMat), sep=''), ']', sep='')
 cols - paste(cols, collapse=', ')

 But, this is a string with quotation marks, so I thought using cat() might
 work, but it does not

 (out - sprintf(xx, cat(cols) ) )

 Anyone have a suggestion for the right way to do this, this is getting
 messy.

 Thank
 Harold

 [[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] adding a frequency variable to a data frame

2014-04-11 Thread Michael Friendly
I'm sure this is pretty simple, but it's Friday afternoon, and I just 
don't see it...


In a data frame with a categorical/character factor, I want to add another
column giving, for each observation, the frequency of that factor level.

An example, where the variable of interest is family:

 data(Donner, package=vcdExtra)
 str(Donner)
'data.frame':   90 obs. of  5 variables:
 $ family  : Factor w/ 10 levels Breen,Donner,..: 9 1 1 1 1 1 1 1 1 
1 ...

 $ age : int  23 13 1 5 14 40 51 9 3 8 ...
 $ sex : Factor w/ 2 levels Female,Male: 2 2 1 2 2 1 2 2 2 2 ...
 $ survived: int  0 1 1 1 1 1 1 1 1 1 ...
 $ death   : POSIXct, format: 1846-12-29 NA ...
 table(Donner$family)

BreenDonner  Eddy  FosdWolfGraves  Keseberg McCutchen 
MurFosPik

914 4 410 4 312
Other  Reed
   23 7


Here, I want to create a new variable, family.size,   where all the 
Breens have 9,

the Donners, 14,  and so on...

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
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] adding a frequency variable to a data frame

2014-04-11 Thread Andrija Djurovic
Hi. Here is one solution:

table(Donner$family)[Donner$family]

Andrija


On Fri, Apr 11, 2014 at 10:40 PM, Michael Friendly frien...@yorku.cawrote:

 I'm sure this is pretty simple, but it's Friday afternoon, and I just
 don't see it...

 In a data frame with a categorical/character factor, I want to add another
 column giving, for each observation, the frequency of that factor level.

 An example, where the variable of interest is family:

  data(Donner, package=vcdExtra)
  str(Donner)
 'data.frame':   90 obs. of  5 variables:
  $ family  : Factor w/ 10 levels Breen,Donner,..: 9 1 1 1 1 1 1 1 1 1
 ...
  $ age : int  23 13 1 5 14 40 51 9 3 8 ...
  $ sex : Factor w/ 2 levels Female,Male: 2 2 1 2 2 1 2 2 2 2 ...
  $ survived: int  0 1 1 1 1 1 1 1 1 1 ...
  $ death   : POSIXct, format: 1846-12-29 NA ...
  table(Donner$family)

 BreenDonner  Eddy  FosdWolfGraves  Keseberg McCutchen
 MurFosPik
 914 4 410 4 312
 Other  Reed
23 7
 

 Here, I want to create a new variable, family.size,   where all the Breens
 have 9,
 the Donners, 14,  and so on...

 --
 Michael Friendly Email: friendly AT yorku DOT ca
 Professor, Psychology Dept.  Chair, Quantitative Methods
 York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
 4700 Keele StreetWeb:   http://www.datavis.ca
 Toronto, ONT  M3J 1P3 CANADA

 __
 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] adding a frequency variable to a data frame

2014-04-11 Thread Andrija Djurovic
another:

ave(as.numeric(Donner$family), Donner$family, FUN=length)


On Fri, Apr 11, 2014 at 10:51 PM, Andrija Djurovic djandr...@gmail.comwrote:

 Hi. Here is one solution:

 table(Donner$family)[Donner$family]

 Andrija


 On Fri, Apr 11, 2014 at 10:40 PM, Michael Friendly frien...@yorku.cawrote:

 I'm sure this is pretty simple, but it's Friday afternoon, and I just
 don't see it...

 In a data frame with a categorical/character factor, I want to add another
 column giving, for each observation, the frequency of that factor level.

 An example, where the variable of interest is family:

  data(Donner, package=vcdExtra)
  str(Donner)
 'data.frame':   90 obs. of  5 variables:
  $ family  : Factor w/ 10 levels Breen,Donner,..: 9 1 1 1 1 1 1 1 1 1
 ...
  $ age : int  23 13 1 5 14 40 51 9 3 8 ...
  $ sex : Factor w/ 2 levels Female,Male: 2 2 1 2 2 1 2 2 2 2 ...
  $ survived: int  0 1 1 1 1 1 1 1 1 1 ...
  $ death   : POSIXct, format: 1846-12-29 NA ...
  table(Donner$family)

 BreenDonner  Eddy  FosdWolfGraves  Keseberg McCutchen
 MurFosPik
 914 4 410 4 312
 Other  Reed
23 7
 

 Here, I want to create a new variable, family.size,   where all the
 Breens have 9,
 the Donners, 14,  and so on...

 --
 Michael Friendly Email: friendly AT yorku DOT ca
 Professor, Psychology Dept.  Chair, Quantitative Methods
 York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
 4700 Keele StreetWeb:   http://www.datavis.ca
 Toronto, ONT  M3J 1P3 CANADA

 __
 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] R, RStudio, and a server for my iPad.

2014-04-11 Thread John Sorkin
I bemoan the fact that I can not run R or Rstudio on my iPad. A possible work 
around would be to set up a server (probably under Linux), and get the server 
to present a web page that to would allow me to run R on the server. I have 
searched the web for a clear, simple answer on how to do this but can not find 
one. There are answers, but not for someone who has not built a Linux server. 
Can someone provide either a reference to, or a short explanation of how I can 
build the server, get R or RStudio to run on it, and get the server and its R 
or RStudio program available to me on my iPad? I can probably find guidance on 
how to build an Apache server under Linux.
Thank you,
John 

 
 

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information.  
Any unauthorized use, disclosure or distribution is prohibited.  If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R, RStudio, and a server for my iPad.

2014-04-11 Thread Steve Lianoglou
Hi,

On Fri, Apr 11, 2014 at 2:00 PM, John Sorkin
jsor...@grecc.umaryland.edu wrote:
 I bemoan the fact that I can not run R or Rstudio on my iPad.

I feel like this is something I'm not missing much, at all, but
different strokes ... :-)

 A possible work around would be to set up a server (probably under Linux), 
 and get the server to present a web page that to would allow me to run R on 
 the server. I have searched the web for a clear, simple answer on how to do 
 this but can not find one. There are answers, but not for someone who has not 
 built a Linux server. Can someone provide either a reference to, or a short 
 explanation of how I can build the server, get R or RStudio to run on it, and 
 get the server and its R or RStudio program available to me on my iPad? I can 
 probably find guidance on how to build an Apache server under Linux.

You might try to follow the instructions to get RStudio Server running:

https://www.rstudio.com/ide/docs/server/getting_started

It seems like they have packages built for many popular linux distros:

https://www.rstudio.com/ide/download/server

Once your linux server is set up, you should be able to access the
server with any client via a web browser, although I have no idea if
any of the iOS browsers are up to the task of dealing with the RStudio
web interface, but you can try and find out. RStudio's support forum
is more likely to be helpful here, for instance:

https://support.rstudio.com/hc/en-us/search?utf8=✓query=ioscommit=Search

HTH,
-steve

-- 
Steve Lianoglou
Computational Biologist
Genentech

__
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] adding a frequency variable to a data frame

2014-04-11 Thread Michael Friendly

Bingo! That's exactly the idiom I was looking for.
Thanks, Andrija.
-Michael


On 4/11/2014 4:57 PM, Andrija Djurovic wrote:

another:

ave(as.numeric(Donner$family), Donner$family, FUN=length)




--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.  Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [R] R, RStudio, and a server for my iPad.

2014-04-11 Thread John Sorkin
Steve, 
Thank you for your help.
I have seen the material you have sent me to, but do not fully
understand it. Do I have to build a linux server first? If so does it
have to run Apache or some other web server? Is RStudio server run under
Apache, if so how? On the other hand, do I simply need a box running a
flavor of Linux (without Apache)., and then simply download RStudio
server? Perhaps I am over thinking this . . .
Thanks,
John

 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 Steve Lianoglou lianoglou.st...@gene.com 4/11/2014 5:23 PM 
Hi,

On Fri, Apr 11, 2014 at 2:00 PM, John Sorkin
jsor...@grecc.umaryland.edu wrote:
 I bemoan the fact that I can not run R or Rstudio on my iPad.

I feel like this is something I'm not missing much, at all, but
different strokes ... :-)

 A possible work around would be to set up a server (probably under
Linux), and get the server to present a web page that to would allow me
to run R on the server. I have searched the web for a clear, simple
answer on how to do this but can not find one. There are answers, but
not for someone who has not built a Linux server. Can someone provide
either a reference to, or a short explanation of how I can build the
server, get R or RStudio to run on it, and get the server and its R or
RStudio program available to me on my iPad? I can probably find guidance
on how to build an Apache server under Linux.

You might try to follow the instructions to get RStudio Server
running:

https://www.rstudio.com/ide/docs/server/getting_started

It seems like they have packages built for many popular linux distros:

https://www.rstudio.com/ide/download/server

Once your linux server is set up, you should be able to access the
server with any client via a web browser, although I have no idea if
any of the iOS browsers are up to the task of dealing with the RStudio
web interface, but you can try and find out. RStudio's support forum
is more likely to be helpful here, for instance:

https://support.rstudio.com/hc/en-us/search?utf8=✓query=ioscommit=Search

HTH,
-steve

-- 
Steve Lianoglou
Computational Biologist
Genentech


Confidentiality Statement:
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information.  Any unauthorized use, disclosure or distribution is
prohibited.  If you are not the intended recipient, please contact the
sender by reply email and destroy all copies of the original message. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R, RStudio, and a server for my iPad.

2014-04-11 Thread Steve Lianoglou
I see. You might indeed be over thinking it ... since everything is
installable by the package manager for the flavor of linux you choose,
it should actually be relatively straightfoward (although if this is
your first time setting up a linux box, it can take a few tries).

I'll assume you are using an ubuntu server. There are two things you
can do to get one

(1) Get yourself a spare CPU. Blow out the OS on it, and setup
vanilla ubuntu; or
(2) Rent an ubuntu server from somewhere like linode.com

Then:

(a) Install R on it, by following the instructions here:
http://cran.rstudio.com/bin/linux/ubuntu/README.html

Which boils down to basically:
(i) adding the appropriate line to your `/etc/apt/sources.list` given
the version of ubuntu you installed (saucy, quantal, etc) ; and
(ii) Running the following from the terminal:

   sudo apt-get update
   sudo apt-get install r-base
   sudo apt-get install r-base-dev

(b) Install RStudio Server. Start from the Download and Install
section here (since you already installed R):
https://www.rstudio.com/ide/download/server

Then go here:
https://www.rstudio.com/ide/docs/server/getting_started

If you've set this up on your own machine (option (1) from above) then
you have to figure out how to connect it to the internet if you want
to use it from anywhere outside of your LAN.

It might seem like a lot of work, but as mentioned above -- since
these packages are available by the system's package manager, all of
the dependencies (like apache (if you need it)) will be installed for
you if you follow the (presumably correct) installation instructions
from RStudio.

=== An even easier setup ===

Just realized that there is  3rd route. You can save yourself a lot of
time by using an already built amazon machine instance that the
bioconductor folks have setup for you. Look at the instructions here:

http://www.bioconductor.org/help/bioconductor-cloud-ami/

If you follow along (you'll need an amazon account), you can rent a
machine and have it loaded w/ RStudio Server as well as some
bioconductor-specific libraries to get you started (by using the
bioconductor AMI). Once you have that up, you can connect to the
server running on Amazon's cloud via your web browser on both your CPU
(to make sure it all worked) then using an iOS device.

This would be a very easy way for you to see if taking one of the 2
avenues of setting up RStudio Server yourself would be worth the pain.

HTH,
-steve

On Fri, Apr 11, 2014 at 2:34 PM, John Sorkin
jsor...@grecc.umaryland.edu wrote:
 Steve,
 Thank you for your help.
 I have seen the material you have sent me to, but do not fully
 understand it. Do I have to build a linux server first? If so does it
 have to run Apache or some other web server? Is RStudio server run under
 Apache, if so how? On the other hand, do I simply need a box running a
 flavor of Linux (without Apache)., and then simply download RStudio
 server? Perhaps I am over thinking this . . .
 Thanks,
 John


 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)
 Steve Lianoglou lianoglou.st...@gene.com 4/11/2014 5:23 PM 
 Hi,

 On Fri, Apr 11, 2014 at 2:00 PM, John Sorkin
 jsor...@grecc.umaryland.edu wrote:
 I bemoan the fact that I can not run R or Rstudio on my iPad.

 I feel like this is something I'm not missing much, at all, but
 different strokes ... :-)

 A possible work around would be to set up a server (probably under
 Linux), and get the server to present a web page that to would allow me
 to run R on the server. I have searched the web for a clear, simple
 answer on how to do this but can not find one. There are answers, but
 not for someone who has not built a Linux server. Can someone provide
 either a reference to, or a short explanation of how I can build the
 server, get R or RStudio to run on it, and get the server and its R or
 RStudio program available to me on my iPad? I can probably find guidance
 on how to build an Apache server under Linux.

 You might try to follow the instructions to get RStudio Server
 running:

 https://www.rstudio.com/ide/docs/server/getting_started

 It seems like they have packages built for many popular linux distros:

 https://www.rstudio.com/ide/download/server

 Once your linux server is set up, you should be able to access the
 server with any client via a web browser, although I have no idea if
 any of the iOS browsers are up to the task of dealing with the RStudio
 web interface, but you can try and find out. RStudio's support forum
 is more likely to be helpful here, for instance:

 https://support.rstudio.com/hc/en-us/search?utf8=✓query=ioscommit=Search

 HTH,
 -steve

 --
 Steve Lianoglou
 Computational Biologist
 

Re: [R] R, RStudio, and a server for my iPad.

2014-04-11 Thread Hadley Wickham
Even if you do get Rstudio running on a server, unfortunately it won't
help. The ipad doesn't support quite enough html to get a fully
functional Rstudio interface - almost everything works but you can't
type anything :/  It would be possible to fix this, but fundamentally
we don't believe that the Rstudio interface is the right choice for an
ipad.

Hadley

On Fri, Apr 11, 2014 at 5:00 PM, John Sorkin
jsor...@grecc.umaryland.edu wrote:
 I bemoan the fact that I can not run R or Rstudio on my iPad. A possible work 
 around would be to set up a server (probably under Linux), and get the server 
 to present a web page that to would allow me to run R on the server. I have 
 searched the web for a clear, simple answer on how to do this but can not 
 find one. There are answers, but not for someone who has not built a Linux 
 server. Can someone provide either a reference to, or a short explanation of 
 how I can build the server, get R or RStudio to run on it, and get the server 
 and its R or RStudio program available to me on my iPad? I can probably find 
 guidance on how to build an Apache server under Linux.
 Thank you,
 John




 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)

 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:19}}

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


Re: [R] R, RStudio, and a server for my iPad.

2014-04-11 Thread John Sorkin
Steve,
Are you suggesting that all I need to is build a Linux box (easily
done, I have done many) and them simply use the package manager to
install RStudio server? This would mean I don't need to build an Apache
Server with a LAMP stack, hooray!
John

 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 Steve Lianoglou lianoglou.st...@gene.com 4/11/2014 5:51 PM 
I see. You might indeed be over thinking it ... since everything is
installable by the package manager for the flavor of linux you choose,
it should actually be relatively straightfoward (although if this is
your first time setting up a linux box, it can take a few tries).

I'll assume you are using an ubuntu server. There are two things you
can do to get one

(1) Get yourself a spare CPU. Blow out the OS on it, and setup
vanilla ubuntu; or
(2) Rent an ubuntu server from somewhere like linode.com

Then:

(a) Install R on it, by following the instructions here:
http://cran.rstudio.com/bin/linux/ubuntu/README.html

Which boils down to basically:
(i) adding the appropriate line to your `/etc/apt/sources.list` given
the version of ubuntu you installed (saucy, quantal, etc) ; and
(ii) Running the following from the terminal:

   sudo apt-get update
   sudo apt-get install r-base
   sudo apt-get install r-base-dev

(b) Install RStudio Server. Start from the Download and Install
section here (since you already installed R):
https://www.rstudio.com/ide/download/server

Then go here:
https://www.rstudio.com/ide/docs/server/getting_started

If you've set this up on your own machine (option (1) from above) then
you have to figure out how to connect it to the internet if you want
to use it from anywhere outside of your LAN.

It might seem like a lot of work, but as mentioned above -- since
these packages are available by the system's package manager, all of
the dependencies (like apache (if you need it)) will be installed for
you if you follow the (presumably correct) installation instructions
from RStudio.

=== An even easier setup ===

Just realized that there is  3rd route. You can save yourself a lot of
time by using an already built amazon machine instance that the
bioconductor folks have setup for you. Look at the instructions here:

http://www.bioconductor.org/help/bioconductor-cloud-ami/

If you follow along (you'll need an amazon account), you can rent a
machine and have it loaded w/ RStudio Server as well as some
bioconductor-specific libraries to get you started (by using the
bioconductor AMI). Once you have that up, you can connect to the
server running on Amazon's cloud via your web browser on both your CPU
(to make sure it all worked) then using an iOS device.

This would be a very easy way for you to see if taking one of the 2
avenues of setting up RStudio Server yourself would be worth the pain.

HTH,
-steve

On Fri, Apr 11, 2014 at 2:34 PM, John Sorkin
jsor...@grecc.umaryland.edu wrote:
 Steve,
 Thank you for your help.
 I have seen the material you have sent me to, but do not fully
 understand it. Do I have to build a linux server first? If so does
it
 have to run Apache or some other web server? Is RStudio server run
under
 Apache, if so how? On the other hand, do I simply need a box running
a
 flavor of Linux (without Apache)., and then simply download RStudio
 server? Perhaps I am over thinking this . . .
 Thanks,
 John


 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology
and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)
 Steve Lianoglou lianoglou.st...@gene.com 4/11/2014 5:23 PM 
 Hi,

 On Fri, Apr 11, 2014 at 2:00 PM, John Sorkin
 jsor...@grecc.umaryland.edu wrote:
 I bemoan the fact that I can not run R or Rstudio on my iPad.

 I feel like this is something I'm not missing much, at all, but
 different strokes ... :-)

 A possible work around would be to set up a server (probably under
 Linux), and get the server to present a web page that to would allow
me
 to run R on the server. I have searched the web for a clear, simple
 answer on how to do this but can not find one. There are answers,
but
 not for someone who has not built a Linux server. Can someone
provide
 either a reference to, or a short explanation of how I can build the
 server, get R or RStudio to run on it, and get the server and its R
or
 RStudio program available to me on my iPad? I can probably find
guidance
 on how to build an Apache server under Linux.

 You might try to follow the instructions 

Re: [R] Label axis tick marks with a simple function of axis value

2014-04-11 Thread MacQueen, Don
You're on the right track, I think.

Try this example:

plot(21:30, xaxt='n')
labs - paste(1:10,'units',sep='\n')
axis(1, at=1:10, labels=labs, mgp=c(3, 1.75, 0) )

Documentation for the mgp option is found in
  ?par
and it's not something that I would expect someone new to R to find easily.

In my opinion, the philosophy of R is that a lot of basic tools are
provided, and from them the user is expected to customize and construct
precisely what they want. Although, many of the R packages available from
CRAN exist because someone wanted to pre-write some fancy options for
users to choose from.

Of course, since all the units are the same in my example, it might make
more sense to put the units in the axis label, such as:

  plot(21:30, xlab='Units')

Note a little trick in that in the above example that might be
unexpected. I didn't supply both x and y. When only one of them is
supplied, it is interpreted as being y values. Since there are 10 of them,
it is as if it were:
  plot(1:10, 21:30)

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 4/9/14 6:17 PM, Hurr hill0...@umn.edu wrote:

What we've covered so far is of great value.
For a neater plot,
the next step will be to learn how to put
numbers with units at each tick mark.
I suppose I can form the number-unit string myself in
separate code and put the tickmark in a place that
I calculate in separate code.
But I need to learn the plotting code.




--
View this message in context:
http://r.789695.n4.nabble.com/Label-axis-tick-marks-with-a-simple-function
-of-axis-value-tp4687917p4688498.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] R, RStudio, and a server for my iPad.

2014-04-11 Thread John Sorkin
Hadley,
First, thank you for replying to my question. Are you saying that the iPad 
browser will not allow me to type the character string :/ into a browser 
window? I am not sure exactly what you are trying to tell me. Please forgive my 
lack of insight! Can you explain a but further?
Do you have any suggestions for a solution that will allow me to access R on my 
iPad?
John

 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 Hadley Wickham h.wick...@gmail.com 4/11/2014 6:01 PM 
Even if you do get Rstudio running on a server, unfortunately it won't
help. The ipad doesn't support quite enough html to get a fully
functional Rstudio interface - almost everything works but you can't
type anything :/  It would be possible to fix this, but fundamentally
we don't believe that the Rstudio interface is the right choice for an
ipad.

Hadley

On Fri, Apr 11, 2014 at 5:00 PM, John Sorkin
jsor...@grecc.umaryland.edu wrote:
 I bemoan the fact that I can not run R or Rstudio on my iPad. A possible work 
 around would be to set up a server (probably under Linux), and get the server 
 to present a web page that to would allow me to run R on the server. I have 
 searched the web for a clear, simple answer on how to do this but can not 
 find one. There are answers, but not for someone who has not built a Linux 
 server. Can someone provide either a reference to, or a short explanation of 
 how I can build the server, get R or RStudio to run on it, and get the server 
 and its R or RStudio program available to me on my iPad? I can probably find 
 guidance on how to build an Apache server under Linux.
 Thank you,
 John




 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)

 Confidentiality Statement:
 This email message, including any attachments, is for the sole use of the 
 intended recipient(s) and may contain confidential and privileged 
 information.  Any unauthorized use, disclosure or distribution is prohibited. 
  If you are not the intended recipient, please contact the sender by reply 
 email and destroy all copies of the original message.

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




-- 
http://had.co.nz/


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information.  
Any unauthorized use, disclosure or distribution is prohibited.  If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R, RStudio, and a server for my iPad.

2014-04-11 Thread Hadley Wickham
You can not type _anything_ into Rstudio if you connect to it on the
ipad. In other words, Rstudio is not currently usable on the ipad.
Hadley

On Fri, Apr 11, 2014 at 6:08 PM, John Sorkin
jsor...@grecc.umaryland.edu wrote:
 Hadley,
 First, thank you for replying to my question. Are you saying that the iPad
 browser will not allow me to type the character string :/ into a browser
 window? I am not sure exactly what you are trying to tell me. Please forgive
 my lack of insight! Can you explain a but further?
 Do you have any suggestions for a solution that will allow me to access R on
 my iPad?
 John


 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)
 Hadley Wickham h.wick...@gmail.com 4/11/2014 6:01 PM 

 Even if you do get Rstudio running on a server, unfortunately it won't
 help. The ipad doesn't support quite enough html to get a fully
 functional Rstudio interface - almost everything works but you can't
 type anything :/  It would be possible to fix this, but fundamentally
 we don't believe that the Rstudio interface is the right choice for an
 ipad.

 Hadley

 On Fri, Apr 11, 2014 at 5:00 PM, John Sorkin
 jsor...@grecc.umaryland.edu wrote:
 I bemoan the fact that I can not run R or Rstudio on my iPad. A possible
 work around would be to set up a server (probably under Linux), and get the
 server to present a web page that to would allow me to run R on the server.
 I have searched the web for a clear, simple answer on how to do this but can
 not find one. There are answers, but not for someone who has not built a
 Linux server. Can someone provide either a reference to, or a short
 explanation of how I can build the server, get R or RStudio to run on it,
 and get the server and its R or RStudio program available to me on my iPad?
 I can probably find guidance on how to build an Apache server under Linux.
 Thank you,
 John




 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)

 Confidentiality Statement:
 This email message, including any attachments, is for the sole use of the
 intended recipient(s) and may contain confidential and privileged
 information.  Any unauthorized use, disclosure or distribution is
 prohibited.  If you are not the intended recipient, please contact the
 sender by reply email and destroy all copies of the original message.

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




 --
 http://had.co.nz/


 Confidentiality Statement:

 This email message, including any attachments, is for ...{{dropped:11}}

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


Re: [R] R, RStudio, and a server for my iPad.

2014-04-11 Thread John Sorkin
Hadley,
Thank you for the clarification! This is too bad as I had thought that given 
that RStudio server followed a web-based rather than a client-server paradigm 
that I could use my iPad to access an RStudio server and thus have access to R. 
Perhaps I wasted a loot of   on my iPad . . .
John 

 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 Hadley Wickham h.wick...@gmail.com 4/11/2014 6:10 PM 
You can not type _anything_ into Rstudio if you connect to it on the
ipad. In other words, Rstudio is not currently usable on the ipad.
Hadley

On Fri, Apr 11, 2014 at 6:08 PM, John Sorkin
jsor...@grecc.umaryland.edu wrote:
 Hadley,
 First, thank you for replying to my question. Are you saying that the iPad
 browser will not allow me to type the character string :/ into a browser
 window? I am not sure exactly what you are trying to tell me. Please forgive
 my lack of insight! Can you explain a but further?
 Do you have any suggestions for a solution that will allow me to access R on
 my iPad?
 John


 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)
 Hadley Wickham h.wick...@gmail.com 4/11/2014 6:01 PM 

 Even if you do get Rstudio running on a server, unfortunately it won't
 help. The ipad doesn't support quite enough html to get a fully
 functional Rstudio interface - almost everything works but you can't
 type anything :/  It would be possible to fix this, but fundamentally
 we don't believe that the Rstudio interface is the right choice for an
 ipad.

 Hadley

 On Fri, Apr 11, 2014 at 5:00 PM, John Sorkin
 jsor...@grecc.umaryland.edu wrote:
 I bemoan the fact that I can not run R or Rstudio on my iPad. A possible
 work around would be to set up a server (probably under Linux), and get the
 server to present a web page that to would allow me to run R on the server.
 I have searched the web for a clear, simple answer on how to do this but can
 not find one. There are answers, but not for someone who has not built a
 Linux server. Can someone provide either a reference to, or a short
 explanation of how I can build the server, get R or RStudio to run on it,
 and get the server and its R or RStudio program available to me on my iPad?
 I can probably find guidance on how to build an Apache server under Linux.
 Thank you,
 John




 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)

 Confidentiality Statement:
 This email message, including any attachments, is for the sole use of the
 intended recipient(s) and may contain confidential and privileged
 information.  Any unauthorized use, disclosure or distribution is
 prohibited.  If you are not the intended recipient, please contact the
 sender by reply email and destroy all copies of the original message.

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




 --
 http://had.co.nz/


 Confidentiality Statement:

 This email message, including any attachments, is for the sole use of the
 intended recipient(s) and may contain confidential and privileged
 information. Any unauthorized use, disclosure or distribution is prohibited.
 If you are not the intended recipient, please contact the sender by reply
 email and destroy all copies of the original message.



-- 
http://had.co.nz/


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information.  
Any unauthorized use, disclosure or distribution is prohibited.  If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
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, 

Re: [R] R 3.0.3, Windows 7: Problem installing XML package

2014-04-11 Thread Uwe Ligges

Works for me.

Best,
Uwe Ligges



On 11.04.2014 17:10, Alpesh Pandya wrote:

Using install.package('XML') command produces this error:

trying URL
'
http://watson.nci.nih.gov/cran_mirror/bin/windows/contrib/3.0/XML_3.98-1.1.zip
'
Content type 'application/zip' length 4288136 bytes (4.1 Mb)
opened URL
downloaded 4.1 Mb

Error in read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) :
   cannot open the connection
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = wb, ...) :
   downloaded length 4276224 != reported length 4288136
2: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
3: In read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) :
   cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such
file or directory'


Upon receiving this error, I downloaded XML_3.98-1.1.zip directly from cran
site. But this zip file is not a valid archive (cannot open using winzip).
Also trying to install using this downloaded file produces the following
error:

Installing package into 'C:/Users/APandya/Documents/R/win-library/3.0'
(as 'lib' is unspecified)
Warning in install.packages :
   error 1 in extracting from zip file
Warning in install.packages :
   cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such
file or directory'
Error in install.packages : cannot open the connection

I  downloaded this zip file from multiple sources and tried to install with
same result.



__
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] invalid multibyte string at 'b0C'

2014-04-11 Thread Fisher Dennis
R 3.0.2
OS X Mavericks

Colleagues

I have a file that I converted from SAS (sas7bdat) to CSV (filename: 
ORIGINAL.csv).  I try to read it with read.csv and I receive the error message:
Error in type.convert(data[[i]], as.is = as.is[i], dec = dec, 
na.strings = character(0L)) : 
  invalid multibyte string at 'b0C’
The problem resolves if I delete a single character from each of lines 2 and 4 
of the file (filename: FIXED.csv)

readLines can read both files without problem and displays the offending 
character as:
\xb0
which appears to be a degree sign.

I also tried:
read.csv(textConnection(readLines(“ORIGINAL.csv”)))
and encountered the same error message.

In the past, I have encountered the same problem with Greek symbols (e.g., mu) 
and other special characters.

Short of editing the input file, is there a simple solution within R so that I 
can read the input data into a dataframe?
One possible (but ugly) solution would be:
TEMP- readLines(FILENAME)
TEMP- gsub(offendingcharacter, replacementcharacter, TEMP)
However, this would require that I find all possible offending characters and 
the corresponding replacements.

The files are available for inspection at:
http://www.plessthan.com/FILES/ARCHIVE.zip

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.


Re: [R] R, RStudio, and a server for my iPad.

2014-04-11 Thread David Winsemius

On Apr 11, 2014, at 2:00 PM, John Sorkin wrote:

 I bemoan the fact that I can not run R or Rstudio on my iPad. A possible work 
 around would be to set up a server (probably under Linux), and get the server 
 to present a web page that to would allow me to run R on the server.


I fear that the response so far has been focussing on RStudio when the desire 
at its minimum was to run interactive R session on an iPad. Why not use an SSH 
client to connect to a machine that recognizes the security keys?

https://itunes.apple.com/us/app/server-auditor-ssh-client/id549039908?mt=8

I think RServe could be the server end, but I do not know how graphics devices 
would be handled. Maybe just create pdfs on the server? Is there a sendfile 
function that an SSH client could receive and allow the iPad user to open? I 
think the stats-rosuda-devel mailing list might be the place to find 
experienced users of such techniques.

-- 
David.


 I have searched the web for a clear, simple answer on how to do this but can 
 not find one. There are answers, but not for someone who has not built a 
 Linux server. Can someone provide either a reference to, or a short 
 explanation of how I can build the server, get R or RStudio to run on it, and 
 get the server and its R or RStudio program available to me on my iPad? I can 
 probably find guidance on how to build an Apache server under Linux.
 Thank you,
 John 
 
 
 
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 
 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:15}}

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


Re: [R] R, RStudio, and a server for my iPad.

2014-04-11 Thread John Sorkin
David,
Thank you for your assistance. 
I have, in fact been able to get things to work, at least when my iPad is on my 
local network. I had to do the following:
(1) install Linux (I used linux Mint) on a computer on my LAN
(2) install R on the linux box (accomplished using the Mint package manager)
(3) install Rstudio and RStudio server on the linux box (accomplished using the 
Mint package manager)
(4) obtain the linux computer's internal IP address (obtained using ifconfig 
command entered at a terminal). The internal IP address was 192.168.0.101
(5) use a browser on my iPad (I used google chrome, I believe firefox would 
also work) to connect to the linux box, requesting a connection using port 8787
In the brower I entered http://192.168.0.101:8787
This works like a charm; I can now control RStudio, which runs on the Linux 
box, by typing on my iPad. I thus gain access to RStudio on my iPad, RStudio 
works exactly as if it were running directly on my iPad, hooray!
 
My remaining problem is to determine how I can gain access to the linux box 
from outside my LAN. I know the IP address of my cable router xx.xx.xx.xx 
(forgive me I am not listing my external IP address for security reasons), but 
I don't know how I can address the linux box from outside my LAN. Clearly I 
can't use 192.168.0.101 as it is an internal IP address, and I can't use the 
external IP address, xx.xx.xx.xx as it is the address of my cable box, not the 
address of the Linux box behind the cable modem. If I can figure how to address 
the linux box from outside my LAN my problem will be solved! If anyone can help 
me with this last problem I would be grateful. I know it is not strictly an R 
question, but in my case it is related to running R, at least on my iPad.
John


 
 
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 David Winsemius dwinsem...@comcast.net 4/11/2014 9:06 PM 

On Apr 11, 2014, at 2:00 PM, John Sorkin wrote:

 I bemoan the fact that I can not run R or Rstudio on my iPad. A possible work 
 around would be to set up a server (probably under Linux), and get the server 
 to present a web page that to would allow me to run R on the server.


I fear that the response so far has been focussing on RStudio when the desire 
at its minimum was to run interactive R session on an iPad. Why not use an SSH 
client to connect to a machine that recognizes the security keys?

https://itunes.apple.com/us/app/server-auditor-ssh-client/id549039908?mt=8

I think RServe could be the server end, but I do not know how graphics devices 
would be handled. Maybe just create pdfs on the server? Is there a sendfile 
function that an SSH client could receive and allow the iPad user to open? I 
think the stats-rosuda-devel mailing list might be the place to find 
experienced users of such techniques.

-- 
David.


 I have searched the web for a clear, simple answer on how to do this but can 
 not find one. There are answers, but not for someone who has not built a 
 Linux server. Can someone provide either a reference to, or a short 
 explanation of how I can build the server, get R or RStudio to run on it, and 
 get the server and its R or RStudio program available to me on my iPad? I can 
 probably find guidance on how to build an Apache server under Linux.
 Thank you,
 John 
 
 
 
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 
 Confidentiality Statement:
 This email message, including any attachments, is for the sole use of the 
 intended recipient(s) and may contain confidential and privileged 
 information.  Any unauthorized use, disclosure or distribution is prohibited. 
  If you are not the intended recipient, please contact the sender by reply 
 email and destroy all copies of the original message. 
 __
 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



Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information.  
Any unauthorized use, disclosure or distribution is prohibited.  If you are not 
the intended recipient, please contact 

Re: [R] R, RStudio, and a server for my iPad.

2014-04-11 Thread Roy Mendelssohn
GIYF - Google VPN and iPad.

-Roy

On Apr 11, 2014, at 6:34 PM, John Sorkin jsor...@grecc.umaryland.edu wrote:

 David,
 Thank you for your assistance. 
 I have, in fact been able to get things to work, at least when my iPad is on 
 my local network. I had to do the following:
 (1) install Linux (I used linux Mint) on a computer on my LAN
 (2) install R on the linux box (accomplished using the Mint package manager)
 (3) install Rstudio and RStudio server on the linux box (accomplished using 
 the Mint package manager)
 (4) obtain the linux computer's internal IP address (obtained using ifconfig 
 command entered at a terminal). The internal IP address was 192.168.0.101
 (5) use a browser on my iPad (I used google chrome, I believe firefox would 
 also work) to connect to the linux box, requesting a connection using port 
 8787
 In the brower I entered http://192.168.0.101:8787
 This works like a charm; I can now control RStudio, which runs on the Linux 
 box, by typing on my iPad. I thus gain access to RStudio on my iPad, RStudio 
 works exactly as if it were running directly on my iPad, hooray!
 
 My remaining problem is to determine how I can gain access to the linux box 
 from outside my LAN. I know the IP address of my cable router xx.xx.xx.xx 
 (forgive me I am not listing my external IP address for security reasons), 
 but I don't know how I can address the linux box from outside my LAN. Clearly 
 I can't use 192.168.0.101 as it is an internal IP address, and I can't use 
 the external IP address, xx.xx.xx.xx as it is the address of my cable box, 
 not the address of the Linux box behind the cable modem. If I can figure how 
 to address the linux box from outside my LAN my problem will be solved! If 
 anyone can help me with this last problem I would be grateful. I know it is 
 not strictly an R question, but in my case it is related to running R, at 
 least on my iPad.
 John
 
 
 
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 David Winsemius dwinsem...@comcast.net 4/11/2014 9:06 PM 
 
 On Apr 11, 2014, at 2:00 PM, John Sorkin wrote:
 
 I bemoan the fact that I can not run R or Rstudio on my iPad. A possible 
 work around would be to set up a server (probably under Linux), and get the 
 server to present a web page that to would allow me to run R on the server.
 
 
 I fear that the response so far has been focussing on RStudio when the desire 
 at its minimum was to run interactive R session on an iPad. Why not use an 
 SSH client to connect to a machine that recognizes the security keys?
 
 https://itunes.apple.com/us/app/server-auditor-ssh-client/id549039908?mt=8
 
 I think RServe could be the server end, but I do not know how graphics 
 devices would be handled. Maybe just create pdfs on the server? Is there a 
 sendfile function that an SSH client could receive and allow the iPad user to 
 open? I think the stats-rosuda-devel mailing list might be the place to find 
 experienced users of such techniques.
 
 -- 
 David.
 
 
 I have searched the web for a clear, simple answer on how to do this but can 
 not find one. There are answers, but not for someone who has not built a 
 Linux server. Can someone provide either a reference to, or a short 
 explanation of how I can build the server, get R or RStudio to run on it, 
 and get the server and its R or RStudio program available to me on my iPad? 
 I can probably find guidance on how to build an Apache server under Linux.
 Thank you,
 John 
 
 
 
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 
 Confidentiality Statement:
 This email message, including any attachments, is for the sole use of the 
 intended recipient(s) and may contain confidential and privileged 
 information.  Any unauthorized use, disclosure or distribution is 
 prohibited.  If you are not the intended recipient, please contact the 
 sender by reply email and destroy all copies of the original message. 
 __
 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
 
 
 
 Confidentiality Statement:
 This email message, including any attachments, is for the sole use of the 
 intended 

Re: [R] calling in inverted commas

2014-04-11 Thread arun
HI,

Not sure if this helps:
df2 - data.frame(Col1=c(68.25, 68.75, 69.25), Col2=c(24.75, 25.25, 25.75)) 


Url1 - 
http://disc2.nascom.nasa.gov/daac-bin/Giovanni/tovas/Giovanni_cgi.pl?west=68.25north=24.75east=68.25south=24.75¶ms=0%7C3B42_V7plot_type=Time+Plotbyr=1998bmo=01bdy=1eyr=2007emo=12edy=31begin_date=1998%2F01%2F01end_date=2014%2F01%2F31cbar=cdyncmin=cmax=yaxis=ydynymin=ymax=yint=ascres=0.25x0.25global_cfg=tovas.global.cfg.plinstance_id=TRMM_V7prod_id=3B42_dailyaction=ASCII+Output;
 


toreplace - gsub(.*\\.pl\\?(west\\=.*south=.*)\\¶ms.*,\\1,Url1)
begin - gsub((.*\\.pl\\?).*,\\1,Url1)
end - gsub(.*south=.*(\\¶ms.*),\\1,Url1)

vec2 - strsplit(toreplace,)[[1]] 

##replace .csv with .txt and use write.table() if you need as text files.


lapply(seq_len(nrow(df2)),function(i) { val1 - 
as.vector(rep(unlist(df2[i,]),2));replaced 
-do.call(paste,list(lapply(seq_along(vec2),function(i) 
gsub([-+]?(\\d*[.])?\\d+,val1[i],vec2[i])),collapse=)); UrlNew - 
paste0(begin,replaced,end); res 
-read.csv(UrlNew,header=TRUE,stringsAsFactors=FALSE,skip=4,sep=,check.names=FALSE);
 
write.csv(res,file=paste0(file_,paste(val1[1:2],collapse=_),.csv),row.names=FALSE,quote=FALSE)})

sapply(list.files(pattern=file_),function(x) {x1 
-read.csv(x,header=TRUE,stringsAsFactors=FALSE,check.names=FALSE); dim(x1)[1]})
#file_68.25_24.75.csv file_68.75_25.25.csv file_69.25_25.75.csv 

#3652 3652 3652

### reading the downloaded file

lapply(list.files(pattern=file_),function(x) {x1 
-read.csv(x,header=TRUE,stringsAsFactors=FALSE,check.names=FALSE); x1[5:7,]}) 

#[[1]] 

#  Time(year:month:day) AccRain 

#5   1998:01:05   0.000 

#6   1998:01:06   0.000
#7   1998:01:07   0.984 

# 

#[[2]] 

#  Time(year:month:day) AccRain
#5   1998:01:05  0.
#6   1998:01:06  0.0925
#7   1998:01:07  0.2643
#
#[[3]] 

#  Time(year:month:day) AccRain
#5   1998:01:05  0.
#6   1998:01:06  0.7043 

#7   1998:01:07  0.5340 



A.K.


On Friday, April 11, 2014 2:38 PM, eliza botto eliza_bo...@hotmail.com wrote:
Dear useRs,
Here are three steps for downloading a file from a certain website in R. Here 
you see that in URL command (west=68.25north=24.75east=68.25south=24.75) 
are actually the first and second column values of 1st row of a matrix called 
df2 (300 rows and 2 columns). more precisely, df2[1,][1]=68.25, 
df2[1,][2]=24.75. 
Is there a way that I can make a loop so that remaining rows and columns get 
inculcated in the link as such and then get saved at the desired mentioned 
location in 300 different text files?
URL-(http://disc2.nascom.nasa.gov/daac-bin/Giovanni/tovas/Giovanni_cgi.pl?west=68.25north=24.75east=68.25south=24.75¶ms=0%7C3B42_V7plot_type=Time+Plotbyr=1998bmo=01bdy=1eyr=2007emo=12edy=31begin_date=1998%2F01%2F01end_date=2014%2F01%2F31cbar=cdyncmin=cmax=yaxis=ydynymin=ymax=yint=ascres=0.25x0.25global_cfg=tovas.global.cfg.plinstance_id=TRMM_V7prod_id=3B42_dailyaction=ASCII+Output;)
destfile - C:\\Users\\Eliza\\Desktop\\AA\\love.txt
download.file(URL, destfile)

Any suggestion?
Thankyou very much in advance,
Eliza                           
    [[alternative HTML version deleted]]

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


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


Re: [R] calling in inverted commas

2014-04-11 Thread arun
Hi,
I noticed some special characters after sending.
It should be:
toreplace - gsub(.*\\.pl\\?(west\\=.*south=.*)\\params.*,\\1,Url1)
end - gsub(.*south=.*(\\params.*),\\1,Url1) 


A.K.


On Saturday, April 12, 2014 1:06 AM, arun smartpink...@yahoo.com wrote:
HI,

Not sure if this helps:
df2 - data.frame(Col1=c(68.25, 68.75, 69.25), Col2=c(24.75, 25.25, 25.75)) 


Url1 - 
http://disc2.nascom.nasa.gov/daac-bin/Giovanni/tovas/Giovanni_cgi.pl?west=68.25north=24.75east=68.25south=24.75¶ms=0%7C3B42_V7plot_type=Time+Plotbyr=1998bmo=01bdy=1eyr=2007emo=12edy=31begin_date=1998%2F01%2F01end_date=2014%2F01%2F31cbar=cdyncmin=cmax=yaxis=ydynymin=ymax=yint=ascres=0.25x0.25global_cfg=tovas.global.cfg.plinstance_id=TRMM_V7∏_id=3B42_dailyaction=ASCII+Output;
 


toreplace - gsub(.*\\.pl\\?(west\\=.*south=.*)\\¶ms.*,\\1,Url1)
begin - gsub((.*\\.pl\\?).*,\\1,Url1)
end - gsub(.*south=.*(\\¶ms.*),\\1,Url1)

vec2 - strsplit(toreplace,)[[1]] 

##replace .csv with .txt and use write.table() if you need as text files.


lapply(seq_len(nrow(df2)),function(i) { val1 - 
as.vector(rep(unlist(df2[i,]),2));replaced 
-do.call(paste,list(lapply(seq_along(vec2),function(i) 
gsub([-+]?(\\d*[.])?\\d+,val1[i],vec2[i])),collapse=)); UrlNew - 
paste0(begin,replaced,end); res 
-read.csv(UrlNew,header=TRUE,stringsAsFactors=FALSE,skip=4,sep=,check.names=FALSE);
 
write.csv(res,file=paste0(file_,paste(val1[1:2],collapse=_),.csv),row.names=FALSE,quote=FALSE)})

sapply(list.files(pattern=file_),function(x) {x1 
-read.csv(x,header=TRUE,stringsAsFactors=FALSE,check.names=FALSE); dim(x1)[1]})
#file_68.25_24.75.csv file_68.75_25.25.csv file_69.25_25.75.csv 

#                3652                 3652                 3652

### reading the downloaded file

lapply(list.files(pattern=file_),function(x) {x1 
-read.csv(x,header=TRUE,stringsAsFactors=FALSE,check.names=FALSE); x1[5:7,]}) 

#[[1]] 

#  Time(year:month:day) AccRain 

#5           1998:01:05   0.000 

#6           1998:01:06   0.000
#7           1998:01:07   0.984 

# 

#[[2]] 

#  Time(year:month:day) AccRain
#5           1998:01:05  0.
#6           1998:01:06  0.0925
#7           1998:01:07  0.2643
#
#[[3]] 

#  Time(year:month:day) AccRain
#5           1998:01:05  0.
#6           1998:01:06  0.7043 

#7           1998:01:07  0.5340 



A.K.


On Friday, April 11, 2014 2:38 PM, eliza botto eliza_bo...@hotmail.com wrote:
Dear useRs,
Here are three steps for downloading a file from a certain website in R. Here 
you see that in URL command (west=68.25north=24.75east=68.25south=24.75) 
are actually the first and second column values of 1st row of a matrix called 
df2 (300 rows and 2 columns). more precisely, df2[1,][1]=68.25, 
df2[1,][2]=24.75. 
Is there a way that I can make a loop so that remaining rows and columns get 
inculcated in the link as such and then get saved at the desired mentioned 
location in 300 different text files?
URL-(http://disc2.nascom.nasa.gov/daac-bin/Giovanni/tovas/Giovanni_cgi.pl?west=68.25north=24.75east=68.25south=24.75¶ms=0%7C3B42_V7plot_type=Time+Plotbyr=1998bmo=01bdy=1eyr=2007emo=12edy=31begin_date=1998%2F01%2F01end_date=2014%2F01%2F31cbar=cdyncmin=cmax=yaxis=ydynymin=ymax=yint=ascres=0.25x0.25global_cfg=tovas.global.cfg.plinstance_id=TRMM_V7∏_id=3B42_dailyaction=ASCII+Output;)

destfile - C:\\Users\\Eliza\\Desktop\\AA\\love.txt
download.file(URL, destfile)

Any suggestion?
Thankyou very much in advance,
Eliza                       
    [[alternative HTML version deleted]]

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


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