Re: [R] consolidate three function into one

2018-01-14 Thread Richard M. Heiberger
FAQ 7.22
You must print a ggplot object, for example with
print(m52.2cluster)

For the FAQ, run the line
   system.file("../../doc/FAQ")
in R on your computer.
Open up the resulting filepath in your favorite editor and scroll down to 7.22

On Sun, Jan 14, 2018 at 4:21 PM, Ding, Yuan Chun  wrote:
> Hi Bert,
>
> I am sorry to bother you on weekend.
>
> I am still struggling on defining a correct function.
>
> I first defined the function RFS (see below), then run it by provide the two 
> argument.
>
> m52.2cluster <-RFS(inputfile =allinfo_m52, N=2 )
>
> I do not get error message, but no figure displays on screen. I do not know 
> what is going on.
>
> Can you help me a little more on this issue?
>
> Thank you,
>
> Ding
>
> # function to generate RFS
> RFS <- function( inputfile, N ) {
>   cluster<- survfit(Surv(RFS_days2, OV_Had_a_Recurrence_CODE) ~ clusters,
>data = inputfile)
>
>  if( N==2) {palette <- c("red", "black")
>legend.labs <- c("Cluster1", "Cluster2")
> }
>
>   else if(N==3) {palette <- c("red", "black", "green")
>   legend.labs <- c("Cluster1", "Cluster2", "Cluster3")
> }
>
>  else {palette <- c("red", "black","green", "blue")
>legend.labs <- c("Cluster1", "Cluster2", 
> "Cluster3", "Cluster4")
>   }
>
>   ggsurvplot(cluster, data = inputfile, risk.table = F,
>  palette = palette,
>  ylim=c(0,1),ggtheme = theme_bw(),xlab="Relapse Free Suvival 
> (Days)",
>  main = "Survival curve",pval = TRUE,font.x =  16,font.y = 16,
>  font.tickslab = 14,font.legend =c(14,"plain","black"),
>  legend = "bottom",
>  legend.title = "Tree Cluster",
>  legend.labs = legend.labs,
>  lty=1, lwd=3)
> }
>
> From: Bert Gunter [mailto:bgunter.4...@gmail.com]
> Sent: Sunday, January 14, 2018 9:50 AM
> To: Ding, Yuan Chun 
> Subject: Re: [R] consolidate three function into one
>
> I have not looked at your code *at all*, so I am not sure what exactly you 
> mean by "consolidate."
> Is this what you are after?
>
> f1 <- function(...) { code 1}
> f2 <- function(...) { code 2}
> f3 <- function(...) { code 3}
> ## can be "consolidated as":
> f <- function( someargs, ...){
> if( expr(someargs)) f1(...)
> else if(expr2(someargs)) f2(...)
> else f3(...)
> }
> The "..." argument to f can soak up any named additional arguments you wish 
> to pass to f1, f2, or f3.
> My apologies if this is offbase or too vague, and feel free to ignore in that 
> case. I don't have the patience to go trough your code in detail. Others may 
> and give you what you want.
> Cheers,
> Bert
>
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and 
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Sun, Jan 14, 2018 at 9:17 AM, Ding, Yuan Chun 
> > wrote:
> HI R users,
>
> I construct dendrogram tree and cut the tree into different clusters, then 
> generate survival curves by the following three functions. All variables are 
> included in an inputfile.
>
> Can you help me to consolidate the following three function into one 
> functions?  I thought about using if  else function, but not sure how to do 
> it.
>
> Thank you,
>
> Ding
>
> # function to generate RFS
> RFS2cluster <- function( inputfile ) {
>   cluster2<- survfit(Surv(RFS_days, OV_Had_a_Recurrence_CODE) ~ clusters,
>data = inputfile)
>
>   ggsurvplot(cluster2, data = inputfile, risk.table = F,
>  palette = c("red", "black"),
>  ylim=c(0,1),
>  ggtheme = theme_bw(),
>  xlab="Relapse Free Suvival (Days)",
>  main = "Survival curve",
>  pval = TRUE,
>  font.x =  16,
>  font.y = 16,
>  font.tickslab = 14,
>  font.legend =c(14,"plain","black"),
>  legend = "bottom",
>  legend.title = "Tree Cluster",
>  legend.labs = c("Cluster1", "Cluster2"), lty=1, lwd=3)
> }
>
> RFS3cluster <- function( inputfile ) {
>   cluster3<- survfit(Surv(RFS_days, OV_Had_a_Recurrence_CODE) ~ clusters,
>  data = inputfile)
>
>   ggsurvplot(cluster3, data = inputfile, risk.table = F,
>  palette = c("red", "black", "green"),
>  ylim=c(0,1),
>  ggtheme = theme_bw(),
>  xlab="Relapse Free Suvival (Days)",
>  main = "Survival curve",
>  pval = TRUE,
>  font.x =  16,
>  font.y = 16,
>  font.tickslab = 14,
>  font.legend =c(14,"plain","black"),
>  legend = "bottom",
>  legend.title = 

Re: [R] consolidate three function into one

2018-01-14 Thread Ding, Yuan Chun
Hi Bert,

I am sorry to bother you on weekend.

I am still struggling on defining a correct function.

I first defined the function RFS (see below), then run it by provide the two 
argument.

m52.2cluster <-RFS(inputfile =allinfo_m52, N=2 )

I do not get error message, but no figure displays on screen. I do not know 
what is going on.

Can you help me a little more on this issue?

Thank you,

Ding

# function to generate RFS
RFS <- function( inputfile, N ) {
  cluster<- survfit(Surv(RFS_days2, OV_Had_a_Recurrence_CODE) ~ clusters,
   data = inputfile)

 if( N==2) {palette <- c("red", "black")
   legend.labs <- c("Cluster1", "Cluster2")
}

  else if(N==3) {palette <- c("red", "black", "green")
  legend.labs <- c("Cluster1", "Cluster2", "Cluster3")
}

 else {palette <- c("red", "black","green", "blue")
   legend.labs <- c("Cluster1", "Cluster2", "Cluster3", 
"Cluster4")
  }

  ggsurvplot(cluster, data = inputfile, risk.table = F,
 palette = palette,
 ylim=c(0,1),ggtheme = theme_bw(),xlab="Relapse Free Suvival 
(Days)",
 main = "Survival curve",pval = TRUE,font.x =  16,font.y = 16,
 font.tickslab = 14,font.legend =c(14,"plain","black"),
 legend = "bottom",
 legend.title = "Tree Cluster",
 legend.labs = legend.labs,
 lty=1, lwd=3)
}

From: Bert Gunter [mailto:bgunter.4...@gmail.com]
Sent: Sunday, January 14, 2018 9:50 AM
To: Ding, Yuan Chun 
Subject: Re: [R] consolidate three function into one

I have not looked at your code *at all*, so I am not sure what exactly you mean 
by "consolidate."
Is this what you are after?

f1 <- function(...) { code 1}
f2 <- function(...) { code 2}
f3 <- function(...) { code 3}
## can be "consolidated as":
f <- function( someargs, ...){
if( expr(someargs)) f1(...)
else if(expr2(someargs)) f2(...)
else f3(...)
}
The "..." argument to f can soak up any named additional arguments you wish to 
pass to f1, f2, or f3.
My apologies if this is offbase or too vague, and feel free to ignore in that 
case. I don't have the patience to go trough your code in detail. Others may 
and give you what you want.
Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and 
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sun, Jan 14, 2018 at 9:17 AM, Ding, Yuan Chun 
> wrote:
HI R users,

I construct dendrogram tree and cut the tree into different clusters, then 
generate survival curves by the following three functions. All variables are 
included in an inputfile.

Can you help me to consolidate the following three function into one functions? 
 I thought about using if  else function, but not sure how to do it.

Thank you,

Ding

# function to generate RFS
RFS2cluster <- function( inputfile ) {
  cluster2<- survfit(Surv(RFS_days, OV_Had_a_Recurrence_CODE) ~ clusters,
   data = inputfile)

  ggsurvplot(cluster2, data = inputfile, risk.table = F,
 palette = c("red", "black"),
 ylim=c(0,1),
 ggtheme = theme_bw(),
 xlab="Relapse Free Suvival (Days)",
 main = "Survival curve",
 pval = TRUE,
 font.x =  16,
 font.y = 16,
 font.tickslab = 14,
 font.legend =c(14,"plain","black"),
 legend = "bottom",
 legend.title = "Tree Cluster",
 legend.labs = c("Cluster1", "Cluster2"), lty=1, lwd=3)
}

RFS3cluster <- function( inputfile ) {
  cluster3<- survfit(Surv(RFS_days, OV_Had_a_Recurrence_CODE) ~ clusters,
 data = inputfile)

  ggsurvplot(cluster3, data = inputfile, risk.table = F,
 palette = c("red", "black", "green"),
 ylim=c(0,1),
 ggtheme = theme_bw(),
 xlab="Relapse Free Suvival (Days)",
 main = "Survival curve",
 pval = TRUE,
 font.x =  16,
 font.y = 16,
 font.tickslab = 14,
 font.legend =c(14,"plain","black"),
 legend = "bottom",
 legend.title = "Tree Cluster",
 legend.labs = c("Cluster1", "Cluster2", "Cluster3"), lty=1, lwd=3)
}

RFS4cluster <- function( inputfile ) {
  cluster4<- survfit(Surv(RFS_days, OV_Had_a_Recurrence_CODE) ~ clusters,
 data = inputfile)

  ggsurvplot(cluster4, data = inputfile, risk.table = F,
 palette = c("red", "black", "green", "blue"),
 ylim=c(0,1),
 ggtheme = theme_bw(),
 xlab="Relapse Free Suvival (Days)",
 main = "Survival curve",
 pval = TRUE,
 font.x =  

Re: [R] consolidate three function into one

2018-01-14 Thread Ding, Yuan Chun
Hi Bert,

Thank you, yes, you are right.  I want to consolidate the three functions into 
one functions by adding more arguments, adding flexibility  to accommodate  the 
number of clusters or  the number of Kaplan Meier  curves generated in one 
figure.  So, I just need to define one function.

Thanks,

Ding

From: Bert Gunter [mailto:bgunter.4...@gmail.com]
Sent: Sunday, January 14, 2018 9:50 AM
To: Ding, Yuan Chun 
Subject: Re: [R] consolidate three function into one

I have not looked at your code *at all*, so I am not sure what exactly you mean 
by "consolidate."
Is this what you are after?

f1 <- function(...) { code 1}
f2 <- function(...) { code 2}
f3 <- function(...) { code 3}
## can be "consolidated as":
f <- function( someargs, ...){
if( expr(someargs)) f1(...)
else if(expr2(someargs)) f2(...)
else f3(...)
}
The "..." argument to f can soak up any named additional arguments you wish to 
pass to f1, f2, or f3.
My apologies if this is offbase or too vague, and feel free to ignore in that 
case. I don't have the patience to go trough your code in detail. Others may 
and give you what you want.
Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and 
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sun, Jan 14, 2018 at 9:17 AM, Ding, Yuan Chun 
> wrote:
HI R users,

I construct dendrogram tree and cut the tree into different clusters, then 
generate survival curves by the following three functions. All variables are 
included in an inputfile.

Can you help me to consolidate the following three function into one functions? 
 I thought about using if  else function, but not sure how to do it.

Thank you,

Ding

# function to generate RFS
RFS2cluster <- function( inputfile ) {
  cluster2<- survfit(Surv(RFS_days, OV_Had_a_Recurrence_CODE) ~ clusters,
   data = inputfile)

  ggsurvplot(cluster2, data = inputfile, risk.table = F,
 palette = c("red", "black"),
 ylim=c(0,1),
 ggtheme = theme_bw(),
 xlab="Relapse Free Suvival (Days)",
 main = "Survival curve",
 pval = TRUE,
 font.x =  16,
 font.y = 16,
 font.tickslab = 14,
 font.legend =c(14,"plain","black"),
 legend = "bottom",
 legend.title = "Tree Cluster",
 legend.labs = c("Cluster1", "Cluster2"), lty=1, lwd=3)
}

RFS3cluster <- function( inputfile ) {
  cluster3<- survfit(Surv(RFS_days, OV_Had_a_Recurrence_CODE) ~ clusters,
 data = inputfile)

  ggsurvplot(cluster3, data = inputfile, risk.table = F,
 palette = c("red", "black", "green"),
 ylim=c(0,1),
 ggtheme = theme_bw(),
 xlab="Relapse Free Suvival (Days)",
 main = "Survival curve",
 pval = TRUE,
 font.x =  16,
 font.y = 16,
 font.tickslab = 14,
 font.legend =c(14,"plain","black"),
 legend = "bottom",
 legend.title = "Tree Cluster",
 legend.labs = c("Cluster1", "Cluster2", "Cluster3"), lty=1, lwd=3)
}

RFS4cluster <- function( inputfile ) {
  cluster4<- survfit(Surv(RFS_days, OV_Had_a_Recurrence_CODE) ~ clusters,
 data = inputfile)

  ggsurvplot(cluster4, data = inputfile, risk.table = F,
 palette = c("red", "black", "green", "blue"),
 ylim=c(0,1),
 ggtheme = theme_bw(),
 xlab="Relapse Free Suvival (Days)",
 main = "Survival curve",
 pval = TRUE,
 font.x =  16,
 font.y = 16,
 font.tickslab = 14,
 font.legend =c(14,"plain","black"),
 legend = "bottom",
 legend.title = "Tree Cluster",
 legend.labs = c("Cluster1", "Cluster2", "Cluster3", "Cluster4"), 
lty=1, lwd=3)
}

-Original Message-
From: R-help 
[mailto:r-help-boun...@r-project.org] On 
Behalf Of imane hajar
Sent: Friday, January 12, 2018 7:42 AM
To: r-help@r-project.org
Subject: [R] Help with packages (methods, stats, stats4)

[Attention: This email came from an external source. Do not open attachments or 
click on links from unknown senders or unexpected emails.]





hello,
Can you please give me a hand with this problem,well i can't install these
packages:
- stats
- methods
- stats4

when i tried the following command :  *library(help = "stats") * , it gave me 
this output (*see picture*), so i contacted the Maintainer of the package at 
(*r-c...@r-project.org 
>*) but he said that i write 
to the wrong place.

(i want to install those packages in order to use the "DVstats" package)

(i have the latest version of R (3.4.3 

Re: [R] consolidate three function into one

2018-01-14 Thread Ding, Yuan Chun
HI R users,

I construct dendrogram tree and cut the tree into different clusters, then 
generate survival curves by the following three functions. All variables are 
included in an inputfile. 

Can you help me to consolidate the following three function into one functions? 
 I thought about using if  else function, but not sure how to do it.

Thank you,

Ding

# function to generate RFS
RFS2cluster <- function( inputfile ) {
  cluster2<- survfit(Surv(RFS_days, OV_Had_a_Recurrence_CODE) ~ clusters,
   data = inputfile)
  
  ggsurvplot(cluster2, data = inputfile, risk.table = F,
 palette = c("red", "black"),
 ylim=c(0,1),
 ggtheme = theme_bw(),
 xlab="Relapse Free Suvival (Days)",
 main = "Survival curve",
 pval = TRUE,
 font.x =  16,
 font.y = 16,
 font.tickslab = 14,
 font.legend =c(14,"plain","black"),
 legend = "bottom", 
 legend.title = "Tree Cluster",
 legend.labs = c("Cluster1", "Cluster2"), lty=1, lwd=3)
}

RFS3cluster <- function( inputfile ) {
  cluster3<- survfit(Surv(RFS_days, OV_Had_a_Recurrence_CODE) ~ clusters,
 data = inputfile)
  
  ggsurvplot(cluster3, data = inputfile, risk.table = F,
 palette = c("red", "black", "green"),
 ylim=c(0,1),
 ggtheme = theme_bw(),
 xlab="Relapse Free Suvival (Days)",
 main = "Survival curve",
 pval = TRUE,
 font.x =  16,
 font.y = 16,
 font.tickslab = 14,
 font.legend =c(14,"plain","black"),
 legend = "bottom", 
 legend.title = "Tree Cluster",
 legend.labs = c("Cluster1", "Cluster2", "Cluster3"), lty=1, lwd=3)
}

RFS4cluster <- function( inputfile ) {
  cluster4<- survfit(Surv(RFS_days, OV_Had_a_Recurrence_CODE) ~ clusters,
 data = inputfile)
  
  ggsurvplot(cluster4, data = inputfile, risk.table = F,
 palette = c("red", "black", "green", "blue"),
 ylim=c(0,1),
 ggtheme = theme_bw(),
 xlab="Relapse Free Suvival (Days)",
 main = "Survival curve",
 pval = TRUE,
 font.x =  16,
 font.y = 16,
 font.tickslab = 14,
 font.legend =c(14,"plain","black"),
 legend = "bottom", 
 legend.title = "Tree Cluster",
 legend.labs = c("Cluster1", "Cluster2", "Cluster3", "Cluster4"), 
lty=1, lwd=3)
}

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of imane hajar
Sent: Friday, January 12, 2018 7:42 AM
To: r-help@r-project.org
Subject: [R] Help with packages (methods, stats, stats4)

[Attention: This email came from an external source. Do not open attachments or 
click on links from unknown senders or unexpected emails.]





hello,
Can you please give me a hand with this problem,well i can't install these
packages:
- stats
- methods
- stats4

when i tried the following command :  *library(help = "stats") * , it gave me 
this output (*see picture*), so i contacted the Maintainer of the package at 
(*r-c...@r-project.org *) but he said that i write to the 
wrong place.

(i want to install those packages in order to use the "DVstats" package)

(i have the latest version of R (3.4.3 ) and Rstudio(1.2.240) )

thank you
Regards


-
-SECURITY/CONFIDENTIALITY WARNING-
This message (and any attachments) are intended solely for the individual or 
entity to which they are addressed. This communication may contain information 
that is privileged, confidential, or exempt from disclosure under applicable 
law (e.g., personal health information, research data, financial information). 
Because this e-mail has been sent without encryption, individuals other than 
the intended recipient may be able to view the information, forward it to 
others or tamper with the information without the knowledge or consent of the 
sender. If you are not the intended recipient, or the employee or person 
responsible for delivering the message to the intended recipient, any 
dissemination, distribution or copying of the communication is strictly 
prohibited. If you received the communication in error, please notify the 
sender immediately by replying to this message and deleting the message and any 
accompanying files from your system. If, due to the security risks, you do not 
wish to r
 eceive further communications via e-mail, please reply to this message and 
inform the sender that you do not wish to receive further e-mail from the 
sender. (LCP301)
-

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

Re: [R] Clinical Trial data sets in public domain?

2018-01-14 Thread Michael Dewey

Dear Robert

This might seem more suited to the Open Data site in the Stack Exchange 
family. The answer must depend on what you mean by public domain as data 
sets are available from drug company sites on application but presumably 
with restrictions on re-publication.


Michael

On 13/01/2018 21:14, Robert Wilkins wrote:

Is anybody using R to do analysis of clinical trial datasets that have been
put in the public domain (which are super hard to find). Not only a single
data table, but the actual database, with a handful of data tables with
one-to-one or many-to-one relationships?

[ For example, "Adverse Events" and "Patient Info" are two datasets with a
many-to-one relationship, the "Patient Info" dataset has precisely one row
for each patient who received a dose of study drug.]

Robert Wilkins

[[alternative HTML version deleted]]

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



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

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


Re: [R] SpreadLevelPlot for more than one factor

2018-01-14 Thread Fox, John
Dear Ashim,

I’ll address your questions briefly but they’re really not appropriate for
this list, which is for questions about using R, not general statistical
questions. 

(1) The relevant distribution is within cells of the wool x tension
cross-classification because it’s the deviations from the cell means that
are supposed to be normally distributed with equal variance. In the
warpbreaks data there are only 9 cases per cell. If you examine all of
these deviations simultaneously, that’s equivalent to examining the
residuals from the two-way ANOVA model fit to the data.

(2) Yes, (d) and (e) visualize simple effects, and (a) and (b) visualize
main effects, the latter only because the data are balanced.

Best,
 John

-
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
Web: http://socserv.mcmaster.ca/jfox/




On 2018-01-09, 10:18 AM, "Ashim Kapoor"  wrote:

>Dear Sir,
>
>
>Many thanks for your reply.
>
>
>I have a query.
>
>
>
>I have a whole set of distributions which should be made normal /
>homoscedastic. Take for instance the warpbreaks data set.
>
>
>
>We have the following boxplots for the warpbreaks dataset:
>
>
>a. boxplot(breaks ~ wool)
>
>b. boxplot(breaks ~ tension)
>
>c. boxplot(breaks ~ interaction(wool,tension))
>d. boxplot(breaks ~ wool @ each level of tension)
>e. boxplot(breaks ~ tension @ each level of wool)
>
>
>Now should we not be making a-e normal and homoscedastic? Should we not
>make a giant collection of boxplots from a-e and use the SpreadLevelPlot
>on this entire collection?
>
>
>A second query : (d) and (e) are the distribution of the simple effects
>of factor wool and tension @ each level of the other. Is that correct?
>Are (a) and (b) the distribution of the main effect of wool and tension?
>Please confirm.
>
>
>
>Best Regards,
>Ashim
>
>
>
>
>
>
>
>
>
>On Sun, Jan 7, 2018 at 8:05 PM, Fox, John
> wrote:
>
>Dear Ashim,
>
>Try spreadLevelPlot(breaks ~ interaction(tension, wool), data=warpbreaks)
>.
>
>I hope this helps,
> John
>
>-
>John Fox, Professor Emeritus
>McMaster University
>Hamilton, Ontario, Canada
>Web: 
>socialsciences.mcmaster.ca/jfox/ 
>
>
>
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ashim
>> Kapoor
>> Sent: Sunday, January 7, 2018 12:08 AM
>> To: r-help@r-project.org
>> Subject: [R] SpreadLevelPlot for more than one factor
>>
>> Dear All,
>>
>> I want a transformation which will make the spread of the response at
>>all
>> combinations of  2 factors the same.
>>
>> See for example :
>>
>> boxplot(breaks ~ tension * wool, warpbreaks)
>>
>> The closest I  can do is :
>>
>> spreadLevelPlot(breaks ~tension , warpbreaks) spreadLevelPlot(breaks ~
>>wool ,
>> warpbreaks)
>>
>> I want to do :
>>
>> spreadLevelPlot(breaks ~tension * wool, warpbreaks)
>>
>> But I get :
>>
>> > spreadLevelPlot(breaks ~tension * wool , warpbreaks)
>> Error in spreadLevelPlot.formula(breaks ~ tension * wool, warpbreaks) :
>>   right-hand side of model has more than one variable
>>
>> What is the corresponding appropriate function for 2 factors ?
>>
>> Many thanks,
>> Ashim
>>
>>   [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 
>https://stat.ethz.ch/mailman/listinfo/r-help
>
>> PLEASE do read the posting guide
>http://www.R-project.org/posting- 
>> guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
>

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

Re: [R] How to programmatically save a web-page using R (mimicking Command+S)

2018-01-14 Thread Enrico Schumann
On Sat, 06 Jan 2018, Christofer Bogaso writes:

> Hi,
>
> I would appreciate if someone can give me a pointer on how to save a
> webpage programmatically using R.
>
> For example, let say I have this webpage open in my browser:
>
> http://www.bseindia.com/stock-share-price/dabur-india-ltd/dabur/500096/
>
> When manually I save this page, I just press Command+S (using Mac) and
> then this page get saved in hard-disk
>
> Now I want R to mimic this same job that I do using Command-S
>
> So far I have tried with readLines() however the output content is
> different than what I could achieve using Command+S
>
> Any help will be highly appreciated.
>
> Thanks for your time.
>

The command-line utility 'wget' can download websites,
including graphics, etc. Look for 'mirror' in its
documentation if you want to download the complete
site. It is usually available by default on Unix-style
systems; I am sure there is a version for Mac. If you
insist on using R, you could write a simple wrapper,
using ?system or ?system2.


-- 
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

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