Re: [R] Output of tapply function as data frame: Problem Fixed

2024-03-29 Thread Ogbos Okike
This is great!
Many thanks to all for helping to further resolve the problem.
Best wishes
Ogbos

On Fri, Mar 29, 2024 at 6:39 AM Rui Barradas  wrote:

> Às 01:43 de 29/03/2024, Ogbos Okike escreveu:
> > Dear Rui,
> > Thanks again for resolving this. I have already started using the version
> > that works for me.
> >
> > But to clarify the second part, please let me paste the what I did and
> the
> > error message:
> >
> >> set.seed(2024)
> >> data <- data.frame(
> > +Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
> > + TRUE),
> > +count = sample(10L, 100L, TRUE)
> > + )
> >>
> >> # coerce tapply's result to class "data.frame"
> >> res <- with(data, tapply(count, Date, mean)) |> as.data.frame()
> > Error: unexpected '>' in "res <- with(data, tapply(count, Date, mean))
> |>"
> >> # assign a dates column from the row names
> >> res$Date <- row.names(res)
> > Error in row.names(res) : object 'res' not found
> >> # cosmetics
> >> names(res)[2:1] <- names(data)
> > Error in names(res)[2:1] <- names(data) : object 'res' not found
> >> # note that the row names are still tapply's names vector
> >> # and that the columns order is not Date/count. Both are fixed
> >> # after the calculations.
> >> res
> >
> > You can see that the error message is on the pipe. Please, let me know
> > where I am missing it.
> > Thanks.
> >
> > On Wed, Mar 27, 2024 at 10:45 PM Rui Barradas 
> wrote:
> >
> >> Às 08:58 de 27/03/2024, Ogbos Okike escreveu:
> >>> Dear Rui,
> >>> Nice to hear from you!
> >>>
> >>> I am sorry for the omission and I have taken note.
> >>>
> >>> Many thanks for responding. The second solution looks elegant as it
> >> quickly
> >>> resolved the problem.
> >>>
> >>> Please, take a second look at the first solution. It refused to run.
> >> Looks
> >>> as if the pipe is not properly positioned. Efforts to correct it and
> get
> >> it
> >>> run failed. If you can look further, it would be great. If time does
> not
> >>> permit, I am fine too.
> >>>
> >>> But having the too solutions will certainly make the subject more
> >>> interesting.
> >>> Thank you so much.
> >>> With warmest regards from
> >>> Ogbos
> >>>
> >>> On Wed, Mar 27, 2024 at 8:44 AM Rui Barradas 
> >> wrote:
> >>>
>  Às 04:30 de 27/03/2024, Ogbos Okike escreveu:
> > Warm greetings to you all.
> >
> > Using the tapply function below:
> > data<-read.table("FD1month",col.names = c("Dates","count"))
> > x=data$count
> > f<-factor(data$Dates)
> > AB<- tapply(x,f,mean)
> >
> >
> > I made a simple calculation. The result, stored in AB, is of the form
> > below. But an effort to write AB to a file as a data frame fails.
> When
> >> I
> > use the write table, it only produces the count column and strip of
> the
> > first column (date).
> >
> > 2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
> > 2006-05-01
> > -4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
> > -4.430705
> > 2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
> > 2006-12-01
> > -3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
> > -10.072579
> > 2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
> > 2007-07-01
> > -5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
> > -4.127980
> > 2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
> > 2008-02-01
> > -3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
> > -4.183578
> > 2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
> > 2008-09-01
> > -4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
> > -4.347428
> > 2008-10-01 2008-11-01 2008-12-01
> > -4.029918  -4.260326  -4.454224
> >
> > But the normal format I wish to display only appears on the terminal,
> > leading me to copy it and paste into a text file. That is, when I
> enter
>  AB
> > on the terminal, it returns a format in the form:
> >
> > 008-02-01  -4.183578
> > 2008-03-01  -4.336969
> > 2008-04-01  -3.813306
> > 2008-05-01  -4.296579
> > 2008-06-01  -4.575095
> > 2008-07-01  -4.036036
> > 2008-08-01  -4.727994
> > 2008-09-01  -4.347428
> > 2008-10-01  -4.029918
> > 2008-11-01  -4.260326
> > 2008-12-01  -4.454224
> >
> > Now, my question: How do I write out two columns displayed by AB on
> the
> > terminal to a file?
> >
> > I have tried using AB<-data.frame(AB) but it doesn't work either.
> >
> > Many thanks for your time.
> > Ogbos
> >
> > [[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
> 

Re: [R] Output of tapply function as data frame: Problem Fixed

2024-03-28 Thread Rui Barradas

Às 01:43 de 29/03/2024, Ogbos Okike escreveu:

Dear Rui,
Thanks again for resolving this. I have already started using the version
that works for me.

But to clarify the second part, please let me paste the what I did and the
error message:


set.seed(2024)
data <- data.frame(

+Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
+ TRUE),
+count = sample(10L, 100L, TRUE)
+ )


# coerce tapply's result to class "data.frame"
res <- with(data, tapply(count, Date, mean)) |> as.data.frame()

Error: unexpected '>' in "res <- with(data, tapply(count, Date, mean)) |>"

# assign a dates column from the row names
res$Date <- row.names(res)

Error in row.names(res) : object 'res' not found

# cosmetics
names(res)[2:1] <- names(data)

Error in names(res)[2:1] <- names(data) : object 'res' not found

# note that the row names are still tapply's names vector
# and that the columns order is not Date/count. Both are fixed
# after the calculations.
res


You can see that the error message is on the pipe. Please, let me know
where I am missing it.
Thanks.

On Wed, Mar 27, 2024 at 10:45 PM Rui Barradas  wrote:


Às 08:58 de 27/03/2024, Ogbos Okike escreveu:

Dear Rui,
Nice to hear from you!

I am sorry for the omission and I have taken note.

Many thanks for responding. The second solution looks elegant as it

quickly

resolved the problem.

Please, take a second look at the first solution. It refused to run.

Looks

as if the pipe is not properly positioned. Efforts to correct it and get

it

run failed. If you can look further, it would be great. If time does not
permit, I am fine too.

But having the too solutions will certainly make the subject more
interesting.
Thank you so much.
With warmest regards from
Ogbos

On Wed, Mar 27, 2024 at 8:44 AM Rui Barradas 

wrote:



Às 04:30 de 27/03/2024, Ogbos Okike escreveu:

Warm greetings to you all.

Using the tapply function below:
data<-read.table("FD1month",col.names = c("Dates","count"))
x=data$count
f<-factor(data$Dates)
AB<- tapply(x,f,mean)


I made a simple calculation. The result, stored in AB, is of the form
below. But an effort to write AB to a file as a data frame fails. When

I

use the write table, it only produces the count column and strip of the
first column (date).

2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
2006-05-01
-4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
-4.430705
2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
2006-12-01
-3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
-10.072579
2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
2007-07-01
-5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
-4.127980
2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
2008-02-01
-3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
-4.183578
2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
2008-09-01
-4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
-4.347428
2008-10-01 2008-11-01 2008-12-01
-4.029918  -4.260326  -4.454224

But the normal format I wish to display only appears on the terminal,
leading me to copy it and paste into a text file. That is, when I enter

AB

on the terminal, it returns a format in the form:

008-02-01  -4.183578
2008-03-01  -4.336969
2008-04-01  -3.813306
2008-05-01  -4.296579
2008-06-01  -4.575095
2008-07-01  -4.036036
2008-08-01  -4.727994
2008-09-01  -4.347428
2008-10-01  -4.029918
2008-11-01  -4.260326
2008-12-01  -4.454224

Now, my question: How do I write out two columns displayed by AB on the
terminal to a file?

I have tried using AB<-data.frame(AB) but it doesn't work either.

Many thanks for your time.
Ogbos

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

Hello,

The main trick is to pipe to as.data.frame. But the result will have one
column only, you must assign the dates from the df's row names.
I also include an aggregate solution.



# create a test data set
set.seed(2024)
data <- data.frame(
 Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
TRUE),
 count = sample(10L, 100L, TRUE)
)

# coerce tapply's result to class "data.frame"
res <- with(data, tapply(count, Date, mean)) |> as.data.frame()
# assign a dates column from the row names
res$Date <- row.names(res)
# cosmetics
names(res)[2:1] <- names(data)
# note that the row names are still tapply's names vector
# and that the columns order is not Date/count. Both are fixed
# after the calculations.
res
#>   count   Date
#> 2024-03-22 5.416667 2024-03-22
#> 2024-03-23 5.50 2024-03-23
#> 2024-03-24 6.00 

Re: [R] Output of tapply function as data frame: Problem Fixed

2024-03-28 Thread Jeff Newmiller via R-help
I would guess your version of R is earlier than 4.1, when the built-in pipe was 
introduced to the language

On March 28, 2024 6:43:05 PM PDT, Ogbos Okike  wrote:
>Dear Rui,
>Thanks again for resolving this. I have already started using the version
>that works for me.
>
>But to clarify the second part, please let me paste the what I did and the
>error message:
>
>> set.seed(2024)
>> data <- data.frame(
>+Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
>+ TRUE),
>+count = sample(10L, 100L, TRUE)
>+ )
>>
>> # coerce tapply's result to class "data.frame"
>> res <- with(data, tapply(count, Date, mean)) |> as.data.frame()
>Error: unexpected '>' in "res <- with(data, tapply(count, Date, mean)) |>"
>> # assign a dates column from the row names
>> res$Date <- row.names(res)
>Error in row.names(res) : object 'res' not found
>> # cosmetics
>> names(res)[2:1] <- names(data)
>Error in names(res)[2:1] <- names(data) : object 'res' not found
>> # note that the row names are still tapply's names vector
>> # and that the columns order is not Date/count. Both are fixed
>> # after the calculations.
>> res
>
>You can see that the error message is on the pipe. Please, let me know
>where I am missing it.
>Thanks.
>
>On Wed, Mar 27, 2024 at 10:45 PM Rui Barradas  wrote:
>
>> Às 08:58 de 27/03/2024, Ogbos Okike escreveu:
>> > Dear Rui,
>> > Nice to hear from you!
>> >
>> > I am sorry for the omission and I have taken note.
>> >
>> > Many thanks for responding. The second solution looks elegant as it
>> quickly
>> > resolved the problem.
>> >
>> > Please, take a second look at the first solution. It refused to run.
>> Looks
>> > as if the pipe is not properly positioned. Efforts to correct it and get
>> it
>> > run failed. If you can look further, it would be great. If time does not
>> > permit, I am fine too.
>> >
>> > But having the too solutions will certainly make the subject more
>> > interesting.
>> > Thank you so much.
>> > With warmest regards from
>> > Ogbos
>> >
>> > On Wed, Mar 27, 2024 at 8:44 AM Rui Barradas 
>> wrote:
>> >
>> >> Às 04:30 de 27/03/2024, Ogbos Okike escreveu:
>> >>> Warm greetings to you all.
>> >>>
>> >>> Using the tapply function below:
>> >>> data<-read.table("FD1month",col.names = c("Dates","count"))
>> >>> x=data$count
>> >>>f<-factor(data$Dates)
>> >>> AB<- tapply(x,f,mean)
>> >>>
>> >>>
>> >>> I made a simple calculation. The result, stored in AB, is of the form
>> >>> below. But an effort to write AB to a file as a data frame fails. When
>> I
>> >>> use the write table, it only produces the count column and strip of the
>> >>> first column (date).
>> >>>
>> >>> 2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
>> >>> 2006-05-01
>> >>>-4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
>> >>>-4.430705
>> >>> 2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
>> >>> 2006-12-01
>> >>>-3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
>> >>> -10.072579
>> >>> 2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
>> >>> 2007-07-01
>> >>>-5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
>> >>>-4.127980
>> >>> 2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
>> >>> 2008-02-01
>> >>>-3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
>> >>>-4.183578
>> >>> 2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
>> >>> 2008-09-01
>> >>>-4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
>> >>>-4.347428
>> >>> 2008-10-01 2008-11-01 2008-12-01
>> >>>-4.029918  -4.260326  -4.454224
>> >>>
>> >>> But the normal format I wish to display only appears on the terminal,
>> >>> leading me to copy it and paste into a text file. That is, when I enter
>> >> AB
>> >>> on the terminal, it returns a format in the form:
>> >>>
>> >>> 008-02-01  -4.183578
>> >>> 2008-03-01  -4.336969
>> >>> 2008-04-01  -3.813306
>> >>> 2008-05-01  -4.296579
>> >>> 2008-06-01  -4.575095
>> >>> 2008-07-01  -4.036036
>> >>> 2008-08-01  -4.727994
>> >>> 2008-09-01  -4.347428
>> >>> 2008-10-01  -4.029918
>> >>> 2008-11-01  -4.260326
>> >>> 2008-12-01  -4.454224
>> >>>
>> >>> Now, my question: How do I write out two columns displayed by AB on the
>> >>> terminal to a file?
>> >>>
>> >>> I have tried using AB<-data.frame(AB) but it doesn't work either.
>> >>>
>> >>> Many thanks for your time.
>> >>> Ogbos
>> >>>
>> >>>[[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.
>> >> Hello,
>> >>
>> >> The main trick is to pipe to as.data.frame. But the result will have one
>> >> column only, you must assign 

Re: [R] Output of tapply function as data frame

2024-03-28 Thread Ogbos Okike
Dear Deepayan,
Thanks for your kind response.
Regards
Ogbos

On Thu, Mar 28, 2024 at 3:40 AM Deepayan Sarkar 
wrote:

> For more complicated examples, the (relatively new) array2DF()
> function is also useful:
>
> > with(data, tapply(count, Date, mean)) |> array2DF()
> Var1Value
> 1 2024-03-23 5.416667
> 2 2024-03-24 5.50
> 3 2024-03-25 6.00
> 4 2024-03-26 4.476190
> 5 2024-03-27 6.538462
> 6 2024-03-28 5.20
>
> or
>
> > tapply(data, ~ Date, with, mean(count)) |> array2DF(responseName =
> "count")
> Datecount
> 1 2024-03-23 5.416667
> 2 2024-03-24 5.50
> 3 2024-03-25 6.00
> 4 2024-03-26 4.476190
> 5 2024-03-27 6.538462
> 6 2024-03-28 5.20
>
> Best,
> -Deepayan
>
> On Wed, 27 Mar 2024 at 13:15, Rui Barradas  wrote:
> >
> > Às 04:30 de 27/03/2024, Ogbos Okike escreveu:
> > > Warm greetings to you all.
> > >
> > > Using the tapply function below:
> > > data<-read.table("FD1month",col.names = c("Dates","count"))
> > > x=data$count
> > >   f<-factor(data$Dates)
> > > AB<- tapply(x,f,mean)
> > >
> > >
> > > I made a simple calculation. The result, stored in AB, is of the form
> > > below. But an effort to write AB to a file as a data frame fails. When
> I
> > > use the write table, it only produces the count column and strip of the
> > > first column (date).
> > >
> > > 2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
> > > 2006-05-01
> > >   -4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
> > >   -4.430705
> > > 2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
> > > 2006-12-01
> > >   -3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
> > > -10.072579
> > > 2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
> > > 2007-07-01
> > >   -5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
> > >   -4.127980
> > > 2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
> > > 2008-02-01
> > >   -3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
> > >   -4.183578
> > > 2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
> > > 2008-09-01
> > >   -4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
> > >   -4.347428
> > > 2008-10-01 2008-11-01 2008-12-01
> > >   -4.029918  -4.260326  -4.454224
> > >
> > > But the normal format I wish to display only appears on the terminal,
> > > leading me to copy it and paste into a text file. That is, when I
> enter AB
> > > on the terminal, it returns a format in the form:
> > >
> > > 008-02-01  -4.183578
> > > 2008-03-01  -4.336969
> > > 2008-04-01  -3.813306
> > > 2008-05-01  -4.296579
> > > 2008-06-01  -4.575095
> > > 2008-07-01  -4.036036
> > > 2008-08-01  -4.727994
> > > 2008-09-01  -4.347428
> > > 2008-10-01  -4.029918
> > > 2008-11-01  -4.260326
> > > 2008-12-01  -4.454224
> > >
> > > Now, my question: How do I write out two columns displayed by AB on the
> > > terminal to a file?
> > >
> > > I have tried using AB<-data.frame(AB) but it doesn't work either.
> > >
> > > Many thanks for your time.
> > > Ogbos
> > >
> > >   [[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.
> > Hello,
> >
> > The main trick is to pipe to as.data.frame. But the result will have one
> > column only, you must assign the dates from the df's row names.
> > I also include an aggregate solution.
> >
> >
> >
> > # create a test data set
> > set.seed(2024)
> > data <- data.frame(
> >Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
> > TRUE),
> >count = sample(10L, 100L, TRUE)
> > )
> >
> > # coerce tapply's result to class "data.frame"
> > res <- with(data, tapply(count, Date, mean)) |> as.data.frame()
> > # assign a dates column from the row names
> > res$Date <- row.names(res)
> > # cosmetics
> > names(res)[2:1] <- names(data)
> > # note that the row names are still tapply's names vector
> > # and that the columns order is not Date/count. Both are fixed
> > # after the calculations.
> > res
> > #>   count   Date
> > #> 2024-03-22 5.416667 2024-03-22
> > #> 2024-03-23 5.50 2024-03-23
> > #> 2024-03-24 6.00 2024-03-24
> > #> 2024-03-25 4.476190 2024-03-25
> > #> 2024-03-26 6.538462 2024-03-26
> > #> 2024-03-27 5.20 2024-03-27
> >
> > # fix the columns' order
> > res <- res[2:1]
> >
> >
> >
> > # better all in one instruction
> > aggregate(count ~ Date, data, mean)
> > #> Datecount
> > #> 1 2024-03-22 5.416667
> > #> 2 2024-03-23 5.50
> > #> 3 2024-03-24 6.00
> > #> 4 2024-03-25 4.476190
> > #> 5 2024-03-26 6.538462
> > #> 6 2024-03-27 5.20
> >
> >
> >
> > Also,
> > I'm glad to help as always but Ogbos, you have been 

Re: [R] Output of tapply function as data frame: Problem Fixed

2024-03-28 Thread Ogbos Okike
Dear Rui,
Thanks again for resolving this. I have already started using the version
that works for me.

But to clarify the second part, please let me paste the what I did and the
error message:

> set.seed(2024)
> data <- data.frame(
+Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
+ TRUE),
+count = sample(10L, 100L, TRUE)
+ )
>
> # coerce tapply's result to class "data.frame"
> res <- with(data, tapply(count, Date, mean)) |> as.data.frame()
Error: unexpected '>' in "res <- with(data, tapply(count, Date, mean)) |>"
> # assign a dates column from the row names
> res$Date <- row.names(res)
Error in row.names(res) : object 'res' not found
> # cosmetics
> names(res)[2:1] <- names(data)
Error in names(res)[2:1] <- names(data) : object 'res' not found
> # note that the row names are still tapply's names vector
> # and that the columns order is not Date/count. Both are fixed
> # after the calculations.
> res

You can see that the error message is on the pipe. Please, let me know
where I am missing it.
Thanks.

On Wed, Mar 27, 2024 at 10:45 PM Rui Barradas  wrote:

> Às 08:58 de 27/03/2024, Ogbos Okike escreveu:
> > Dear Rui,
> > Nice to hear from you!
> >
> > I am sorry for the omission and I have taken note.
> >
> > Many thanks for responding. The second solution looks elegant as it
> quickly
> > resolved the problem.
> >
> > Please, take a second look at the first solution. It refused to run.
> Looks
> > as if the pipe is not properly positioned. Efforts to correct it and get
> it
> > run failed. If you can look further, it would be great. If time does not
> > permit, I am fine too.
> >
> > But having the too solutions will certainly make the subject more
> > interesting.
> > Thank you so much.
> > With warmest regards from
> > Ogbos
> >
> > On Wed, Mar 27, 2024 at 8:44 AM Rui Barradas 
> wrote:
> >
> >> Às 04:30 de 27/03/2024, Ogbos Okike escreveu:
> >>> Warm greetings to you all.
> >>>
> >>> Using the tapply function below:
> >>> data<-read.table("FD1month",col.names = c("Dates","count"))
> >>> x=data$count
> >>>f<-factor(data$Dates)
> >>> AB<- tapply(x,f,mean)
> >>>
> >>>
> >>> I made a simple calculation. The result, stored in AB, is of the form
> >>> below. But an effort to write AB to a file as a data frame fails. When
> I
> >>> use the write table, it only produces the count column and strip of the
> >>> first column (date).
> >>>
> >>> 2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
> >>> 2006-05-01
> >>>-4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
> >>>-4.430705
> >>> 2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
> >>> 2006-12-01
> >>>-3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
> >>> -10.072579
> >>> 2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
> >>> 2007-07-01
> >>>-5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
> >>>-4.127980
> >>> 2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
> >>> 2008-02-01
> >>>-3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
> >>>-4.183578
> >>> 2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
> >>> 2008-09-01
> >>>-4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
> >>>-4.347428
> >>> 2008-10-01 2008-11-01 2008-12-01
> >>>-4.029918  -4.260326  -4.454224
> >>>
> >>> But the normal format I wish to display only appears on the terminal,
> >>> leading me to copy it and paste into a text file. That is, when I enter
> >> AB
> >>> on the terminal, it returns a format in the form:
> >>>
> >>> 008-02-01  -4.183578
> >>> 2008-03-01  -4.336969
> >>> 2008-04-01  -3.813306
> >>> 2008-05-01  -4.296579
> >>> 2008-06-01  -4.575095
> >>> 2008-07-01  -4.036036
> >>> 2008-08-01  -4.727994
> >>> 2008-09-01  -4.347428
> >>> 2008-10-01  -4.029918
> >>> 2008-11-01  -4.260326
> >>> 2008-12-01  -4.454224
> >>>
> >>> Now, my question: How do I write out two columns displayed by AB on the
> >>> terminal to a file?
> >>>
> >>> I have tried using AB<-data.frame(AB) but it doesn't work either.
> >>>
> >>> Many thanks for your time.
> >>> Ogbos
> >>>
> >>>[[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.
> >> Hello,
> >>
> >> The main trick is to pipe to as.data.frame. But the result will have one
> >> column only, you must assign the dates from the df's row names.
> >> I also include an aggregate solution.
> >>
> >>
> >>
> >> # create a test data set
> >> set.seed(2024)
> >> data <- data.frame(
> >> Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
> >> TRUE),
> >> count = sample(10L, 100L, TRUE)
> 

Re: [R] Output of tapply function as data frame

2024-03-27 Thread Deepayan Sarkar
For more complicated examples, the (relatively new) array2DF()
function is also useful:

> with(data, tapply(count, Date, mean)) |> array2DF()
Var1Value
1 2024-03-23 5.416667
2 2024-03-24 5.50
3 2024-03-25 6.00
4 2024-03-26 4.476190
5 2024-03-27 6.538462
6 2024-03-28 5.20

or

> tapply(data, ~ Date, with, mean(count)) |> array2DF(responseName = "count")
Datecount
1 2024-03-23 5.416667
2 2024-03-24 5.50
3 2024-03-25 6.00
4 2024-03-26 4.476190
5 2024-03-27 6.538462
6 2024-03-28 5.20

Best,
-Deepayan

On Wed, 27 Mar 2024 at 13:15, Rui Barradas  wrote:
>
> Às 04:30 de 27/03/2024, Ogbos Okike escreveu:
> > Warm greetings to you all.
> >
> > Using the tapply function below:
> > data<-read.table("FD1month",col.names = c("Dates","count"))
> > x=data$count
> >   f<-factor(data$Dates)
> > AB<- tapply(x,f,mean)
> >
> >
> > I made a simple calculation. The result, stored in AB, is of the form
> > below. But an effort to write AB to a file as a data frame fails. When I
> > use the write table, it only produces the count column and strip of the
> > first column (date).
> >
> > 2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
> > 2006-05-01
> >   -4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
> >   -4.430705
> > 2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
> > 2006-12-01
> >   -3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
> > -10.072579
> > 2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
> > 2007-07-01
> >   -5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
> >   -4.127980
> > 2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
> > 2008-02-01
> >   -3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
> >   -4.183578
> > 2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
> > 2008-09-01
> >   -4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
> >   -4.347428
> > 2008-10-01 2008-11-01 2008-12-01
> >   -4.029918  -4.260326  -4.454224
> >
> > But the normal format I wish to display only appears on the terminal,
> > leading me to copy it and paste into a text file. That is, when I enter AB
> > on the terminal, it returns a format in the form:
> >
> > 008-02-01  -4.183578
> > 2008-03-01  -4.336969
> > 2008-04-01  -3.813306
> > 2008-05-01  -4.296579
> > 2008-06-01  -4.575095
> > 2008-07-01  -4.036036
> > 2008-08-01  -4.727994
> > 2008-09-01  -4.347428
> > 2008-10-01  -4.029918
> > 2008-11-01  -4.260326
> > 2008-12-01  -4.454224
> >
> > Now, my question: How do I write out two columns displayed by AB on the
> > terminal to a file?
> >
> > I have tried using AB<-data.frame(AB) but it doesn't work either.
> >
> > Many thanks for your time.
> > Ogbos
> >
> >   [[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.
> Hello,
>
> The main trick is to pipe to as.data.frame. But the result will have one
> column only, you must assign the dates from the df's row names.
> I also include an aggregate solution.
>
>
>
> # create a test data set
> set.seed(2024)
> data <- data.frame(
>Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
> TRUE),
>count = sample(10L, 100L, TRUE)
> )
>
> # coerce tapply's result to class "data.frame"
> res <- with(data, tapply(count, Date, mean)) |> as.data.frame()
> # assign a dates column from the row names
> res$Date <- row.names(res)
> # cosmetics
> names(res)[2:1] <- names(data)
> # note that the row names are still tapply's names vector
> # and that the columns order is not Date/count. Both are fixed
> # after the calculations.
> res
> #>   count   Date
> #> 2024-03-22 5.416667 2024-03-22
> #> 2024-03-23 5.50 2024-03-23
> #> 2024-03-24 6.00 2024-03-24
> #> 2024-03-25 4.476190 2024-03-25
> #> 2024-03-26 6.538462 2024-03-26
> #> 2024-03-27 5.20 2024-03-27
>
> # fix the columns' order
> res <- res[2:1]
>
>
>
> # better all in one instruction
> aggregate(count ~ Date, data, mean)
> #> Datecount
> #> 1 2024-03-22 5.416667
> #> 2 2024-03-23 5.50
> #> 3 2024-03-24 6.00
> #> 4 2024-03-25 4.476190
> #> 5 2024-03-26 6.538462
> #> 6 2024-03-27 5.20
>
>
>
> Also,
> I'm glad to help as always but Ogbos, you have been an R-Help
> contributor for quite a while, please post data in dput format. Given
> the problem the output of the following is more than enough.
>
>
> dput(head(data, 20L))
>
>
> Hope this helps,
>
> Rui Barradas
>
>
> --
> Este e-mail foi analisado pelo software antivírus AVG para verificar a 
> presença de vírus.
> www.avg.com
>
> __
> R-help@r-project.org mailing list -- 

Re: [R] Output of tapply function as data frame: Problem Fixed

2024-03-27 Thread Rui Barradas

Às 08:58 de 27/03/2024, Ogbos Okike escreveu:

Dear Rui,
Nice to hear from you!

I am sorry for the omission and I have taken note.

Many thanks for responding. The second solution looks elegant as it quickly
resolved the problem.

Please, take a second look at the first solution. It refused to run. Looks
as if the pipe is not properly positioned. Efforts to correct it and get it
run failed. If you can look further, it would be great. If time does not
permit, I am fine too.

But having the too solutions will certainly make the subject more
interesting.
Thank you so much.
With warmest regards from
Ogbos

On Wed, Mar 27, 2024 at 8:44 AM Rui Barradas  wrote:


Às 04:30 de 27/03/2024, Ogbos Okike escreveu:

Warm greetings to you all.

Using the tapply function below:
data<-read.table("FD1month",col.names = c("Dates","count"))
x=data$count
   f<-factor(data$Dates)
AB<- tapply(x,f,mean)


I made a simple calculation. The result, stored in AB, is of the form
below. But an effort to write AB to a file as a data frame fails. When I
use the write table, it only produces the count column and strip of the
first column (date).

2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
2006-05-01
   -4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
   -4.430705
2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
2006-12-01
   -3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
-10.072579
2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
2007-07-01
   -5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
   -4.127980
2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
2008-02-01
   -3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
   -4.183578
2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
2008-09-01
   -4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
   -4.347428
2008-10-01 2008-11-01 2008-12-01
   -4.029918  -4.260326  -4.454224

But the normal format I wish to display only appears on the terminal,
leading me to copy it and paste into a text file. That is, when I enter

AB

on the terminal, it returns a format in the form:

008-02-01  -4.183578
2008-03-01  -4.336969
2008-04-01  -3.813306
2008-05-01  -4.296579
2008-06-01  -4.575095
2008-07-01  -4.036036
2008-08-01  -4.727994
2008-09-01  -4.347428
2008-10-01  -4.029918
2008-11-01  -4.260326
2008-12-01  -4.454224

Now, my question: How do I write out two columns displayed by AB on the
terminal to a file?

I have tried using AB<-data.frame(AB) but it doesn't work either.

Many thanks for your time.
Ogbos

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

Hello,

The main trick is to pipe to as.data.frame. But the result will have one
column only, you must assign the dates from the df's row names.
I also include an aggregate solution.



# create a test data set
set.seed(2024)
data <- data.frame(
Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
TRUE),
count = sample(10L, 100L, TRUE)
)

# coerce tapply's result to class "data.frame"
res <- with(data, tapply(count, Date, mean)) |> as.data.frame()
# assign a dates column from the row names
res$Date <- row.names(res)
# cosmetics
names(res)[2:1] <- names(data)
# note that the row names are still tapply's names vector
# and that the columns order is not Date/count. Both are fixed
# after the calculations.
res
#>   count   Date
#> 2024-03-22 5.416667 2024-03-22
#> 2024-03-23 5.50 2024-03-23
#> 2024-03-24 6.00 2024-03-24
#> 2024-03-25 4.476190 2024-03-25
#> 2024-03-26 6.538462 2024-03-26
#> 2024-03-27 5.20 2024-03-27

# fix the columns' order
res <- res[2:1]



# better all in one instruction
aggregate(count ~ Date, data, mean)
#> Datecount
#> 1 2024-03-22 5.416667
#> 2 2024-03-23 5.50
#> 3 2024-03-24 6.00
#> 4 2024-03-25 4.476190
#> 5 2024-03-26 6.538462
#> 6 2024-03-27 5.20



Also,
I'm glad to help as always but Ogbos, you have been an R-Help
contributor for quite a while, please post data in dput format. Given
the problem the output of the following is more than enough.


dput(head(data, 20L))


Hope this helps,

Rui Barradas


--
Este e-mail foi analisado pelo software antivírus AVG para verificar a
presença de vírus.
www.avg.com




Hello,

This pipe?


with(data, tapply(count, Date, mean)) |> as.data.frame()


I am not seeing anything wrong with it. I have tried it again just now 
and it runs with no problems, like it had before.

A solution is not to pipe, separate the instructions.


res <- with(data, tapply(count, Date, mean))
res <- as.data.frame(res)


But this should be equivalent to the pipe, I cannot 

[R] Output of tapply function as data frame: Problem Fixed

2024-03-27 Thread Ogbos Okike
Dear Rui,
Nice to hear from you!

I am sorry for the omission and I have taken note.

Many thanks for responding. The second solution looks elegant as it quickly
resolved the problem.

Please, take a second look at the first solution. It refused to run. Looks
as if the pipe is not properly positioned. Efforts to correct it and get it
run failed. If you can look further, it would be great. If time does not
permit, I am fine too.

But having the too solutions will certainly make the subject more
interesting.
Thank you so much.
With warmest regards from
Ogbos

On Wed, Mar 27, 2024 at 8:44 AM Rui Barradas  wrote:

> Às 04:30 de 27/03/2024, Ogbos Okike escreveu:
> > Warm greetings to you all.
> >
> > Using the tapply function below:
> > data<-read.table("FD1month",col.names = c("Dates","count"))
> > x=data$count
> >   f<-factor(data$Dates)
> > AB<- tapply(x,f,mean)
> >
> >
> > I made a simple calculation. The result, stored in AB, is of the form
> > below. But an effort to write AB to a file as a data frame fails. When I
> > use the write table, it only produces the count column and strip of the
> > first column (date).
> >
> > 2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
> > 2006-05-01
> >   -4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
> >   -4.430705
> > 2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
> > 2006-12-01
> >   -3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
> > -10.072579
> > 2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
> > 2007-07-01
> >   -5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
> >   -4.127980
> > 2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
> > 2008-02-01
> >   -3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
> >   -4.183578
> > 2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
> > 2008-09-01
> >   -4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
> >   -4.347428
> > 2008-10-01 2008-11-01 2008-12-01
> >   -4.029918  -4.260326  -4.454224
> >
> > But the normal format I wish to display only appears on the terminal,
> > leading me to copy it and paste into a text file. That is, when I enter
> AB
> > on the terminal, it returns a format in the form:
> >
> > 008-02-01  -4.183578
> > 2008-03-01  -4.336969
> > 2008-04-01  -3.813306
> > 2008-05-01  -4.296579
> > 2008-06-01  -4.575095
> > 2008-07-01  -4.036036
> > 2008-08-01  -4.727994
> > 2008-09-01  -4.347428
> > 2008-10-01  -4.029918
> > 2008-11-01  -4.260326
> > 2008-12-01  -4.454224
> >
> > Now, my question: How do I write out two columns displayed by AB on the
> > terminal to a file?
> >
> > I have tried using AB<-data.frame(AB) but it doesn't work either.
> >
> > Many thanks for your time.
> > Ogbos
> >
> >   [[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.
> Hello,
>
> The main trick is to pipe to as.data.frame. But the result will have one
> column only, you must assign the dates from the df's row names.
> I also include an aggregate solution.
>
>
>
> # create a test data set
> set.seed(2024)
> data <- data.frame(
>Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
> TRUE),
>count = sample(10L, 100L, TRUE)
> )
>
> # coerce tapply's result to class "data.frame"
> res <- with(data, tapply(count, Date, mean)) |> as.data.frame()
> # assign a dates column from the row names
> res$Date <- row.names(res)
> # cosmetics
> names(res)[2:1] <- names(data)
> # note that the row names are still tapply's names vector
> # and that the columns order is not Date/count. Both are fixed
> # after the calculations.
> res
> #>   count   Date
> #> 2024-03-22 5.416667 2024-03-22
> #> 2024-03-23 5.50 2024-03-23
> #> 2024-03-24 6.00 2024-03-24
> #> 2024-03-25 4.476190 2024-03-25
> #> 2024-03-26 6.538462 2024-03-26
> #> 2024-03-27 5.20 2024-03-27
>
> # fix the columns' order
> res <- res[2:1]
>
>
>
> # better all in one instruction
> aggregate(count ~ Date, data, mean)
> #> Datecount
> #> 1 2024-03-22 5.416667
> #> 2 2024-03-23 5.50
> #> 3 2024-03-24 6.00
> #> 4 2024-03-25 4.476190
> #> 5 2024-03-26 6.538462
> #> 6 2024-03-27 5.20
>
>
>
> Also,
> I'm glad to help as always but Ogbos, you have been an R-Help
> contributor for quite a while, please post data in dput format. Given
> the problem the output of the following is more than enough.
>
>
> dput(head(data, 20L))
>
>
> Hope this helps,
>
> Rui Barradas
>
>
> --
> Este e-mail foi analisado pelo software antivírus AVG para verificar a
> presença de vírus.
> www.avg.com
>

[[alternative HTML version deleted]]


Re: [R] Output of tapply function as data frame

2024-03-27 Thread Rui Barradas

Às 04:30 de 27/03/2024, Ogbos Okike escreveu:

Warm greetings to you all.

Using the tapply function below:
data<-read.table("FD1month",col.names = c("Dates","count"))
x=data$count
  f<-factor(data$Dates)
AB<- tapply(x,f,mean)


I made a simple calculation. The result, stored in AB, is of the form
below. But an effort to write AB to a file as a data frame fails. When I
use the write table, it only produces the count column and strip of the
first column (date).

2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
2006-05-01
  -4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
  -4.430705
2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
2006-12-01
  -3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
-10.072579
2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
2007-07-01
  -5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
  -4.127980
2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
2008-02-01
  -3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
  -4.183578
2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
2008-09-01
  -4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
  -4.347428
2008-10-01 2008-11-01 2008-12-01
  -4.029918  -4.260326  -4.454224

But the normal format I wish to display only appears on the terminal,
leading me to copy it and paste into a text file. That is, when I enter AB
on the terminal, it returns a format in the form:

008-02-01  -4.183578
2008-03-01  -4.336969
2008-04-01  -3.813306
2008-05-01  -4.296579
2008-06-01  -4.575095
2008-07-01  -4.036036
2008-08-01  -4.727994
2008-09-01  -4.347428
2008-10-01  -4.029918
2008-11-01  -4.260326
2008-12-01  -4.454224

Now, my question: How do I write out two columns displayed by AB on the
terminal to a file?

I have tried using AB<-data.frame(AB) but it doesn't work either.

Many thanks for your time.
Ogbos

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

Hello,

The main trick is to pipe to as.data.frame. But the result will have one 
column only, you must assign the dates from the df's row names.

I also include an aggregate solution.



# create a test data set
set.seed(2024)
data <- data.frame(
  Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L, 
TRUE),

  count = sample(10L, 100L, TRUE)
)

# coerce tapply's result to class "data.frame"
res <- with(data, tapply(count, Date, mean)) |> as.data.frame()
# assign a dates column from the row names
res$Date <- row.names(res)
# cosmetics
names(res)[2:1] <- names(data)
# note that the row names are still tapply's names vector
# and that the columns order is not Date/count. Both are fixed
# after the calculations.
res
#>   count   Date
#> 2024-03-22 5.416667 2024-03-22
#> 2024-03-23 5.50 2024-03-23
#> 2024-03-24 6.00 2024-03-24
#> 2024-03-25 4.476190 2024-03-25
#> 2024-03-26 6.538462 2024-03-26
#> 2024-03-27 5.20 2024-03-27

# fix the columns' order
res <- res[2:1]



# better all in one instruction
aggregate(count ~ Date, data, mean)
#> Datecount
#> 1 2024-03-22 5.416667
#> 2 2024-03-23 5.50
#> 3 2024-03-24 6.00
#> 4 2024-03-25 4.476190
#> 5 2024-03-26 6.538462
#> 6 2024-03-27 5.20



Also,
I'm glad to help as always but Ogbos, you have been an R-Help 
contributor for quite a while, please post data in dput format. Given 
the problem the output of the following is more than enough.



dput(head(data, 20L))


Hope this helps,

Rui Barradas


--
Este e-mail foi analisado pelo software antivírus AVG para verificar a presença 
de vírus.
www.avg.com

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


[R] Output of tapply function as data frame

2024-03-26 Thread Ogbos Okike
Warm greetings to you all.

Using the tapply function below:
data<-read.table("FD1month",col.names = c("Dates","count"))
x=data$count
 f<-factor(data$Dates)
AB<- tapply(x,f,mean)


I made a simple calculation. The result, stored in AB, is of the form
below. But an effort to write AB to a file as a data frame fails. When I
use the write table, it only produces the count column and strip of the
first column (date).

2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
2006-05-01
 -4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
 -4.430705
2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
2006-12-01
 -3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
-10.072579
2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
2007-07-01
 -5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
 -4.127980
2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
2008-02-01
 -3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
 -4.183578
2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
2008-09-01
 -4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
 -4.347428
2008-10-01 2008-11-01 2008-12-01
 -4.029918  -4.260326  -4.454224

But the normal format I wish to display only appears on the terminal,
leading me to copy it and paste into a text file. That is, when I enter AB
on the terminal, it returns a format in the form:

008-02-01  -4.183578
2008-03-01  -4.336969
2008-04-01  -3.813306
2008-05-01  -4.296579
2008-06-01  -4.575095
2008-07-01  -4.036036
2008-08-01  -4.727994
2008-09-01  -4.347428
2008-10-01  -4.029918
2008-11-01  -4.260326
2008-12-01  -4.454224

Now, my question: How do I write out two columns displayed by AB on the
terminal to a file?

I have tried using AB<-data.frame(AB) but it doesn't work either.

Many thanks for your time.
Ogbos

[[alternative HTML version deleted]]

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


Re: [R] output from R to simple html

2020-07-09 Thread Jim Lemon
Hi Marc,
The "htmlize" function in the prettyR package might be what you are looking for.

Jim

On Thu, Jul 9, 2020 at 5:02 AM Marc Roos  wrote:
>
>
>
> I would like to parse some input to an R script and use its result
> output (maybe in json) on a web page. I think this shiny framework is a
> bit over kill. What is the simplest to implement this?
>
> __
> 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] output from R to simple html

2020-07-08 Thread Jeff Newmiller
Perhaps an answer as simple as using the rmarkdown package to generate a 
standalone html file is all the OP needs?

On July 8, 2020 4:19:37 PM PDT, Michael Hannon  
wrote:
>I can't tell what kind of structure you want to output, but one simple
>thing that I've done along these lines is to use knitr::kable to
>output a dataframe in either HTML or LaTeX format (for direct
>inclusion on a web page or to convert to PDF for other uses).
>
>-- Mike
>
>On Wed, Jul 8, 2020 at 12:02 PM Marc Roos 
>wrote:
>>
>>
>>
>> I would like to parse some input to an R script and use its result
>> output (maybe in json) on a web page. I think this shiny framework is
>a
>> bit over kill. What is the simplest to implement this?
>>
>> __
>> 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.

-- 
Sent from my phone. Please excuse my brevity.

__
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] output from R to simple html

2020-07-08 Thread Michael Hannon
I can't tell what kind of structure you want to output, but one simple
thing that I've done along these lines is to use knitr::kable to
output a dataframe in either HTML or LaTeX format (for direct
inclusion on a web page or to convert to PDF for other uses).

-- Mike

On Wed, Jul 8, 2020 at 12:02 PM Marc Roos  wrote:
>
>
>
> I would like to parse some input to an R script and use its result
> output (maybe in json) on a web page. I think this shiny framework is a
> bit over kill. What is the simplest to implement this?
>
> __
> 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] output from R to simple html

2020-07-08 Thread Bert Gunter
This might be helpful:

https://cran.r-project.org/web/views/WebTechnologies.html

Cheers,
Bert

On Wed, Jul 8, 2020 at 12:02 PM Marc Roos  wrote:

>
>
> I would like to parse some input to an R script and use its result
> output (maybe in json) on a web page. I think this shiny framework is a
> bit over kill. What is the simplest to implement this?
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] output from R to simple html

2020-07-08 Thread Marc Roos



I would like to parse some input to an R script and use its result 
output (maybe in json) on a web page. I think this shiny framework is a 
bit over kill. What is the simplest to implement this? 

__
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] Output multiple sheets to Excel files with openxlsx::write.xlsx

2020-05-27 Thread Jeff Newmiller
give the function a list of data frames.

On May 26, 2020 11:21:58 PM PDT, John  wrote:
>Hi,
>
>This is my code a few years ago. I was able to output multiple sheet to
>an excel file. Nevertheless, the "append" argument appears to be
>obsolete.
>Now I see only one sheet, the latest added sheet, in the output. Is
>there
>any other way to do it with openxlsx::write.xlsx or other
>functions/packages?
>
>
>openxlsx::write.xlsx(df1, file=fl_out, sheetName="a",
>col.names=TRUE, row.names=FALSE, append=TRUE, showNA=FALSE)
>
>openxlsx::write.xlsx(df2, file=fl_out, sheetName="b",
> col.names=TRUE, row.names=FALSE,
>append=TRUE, showNA=FALSE)
>
>Thanks!!
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

__
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] Output multiple sheets to Excel files with openxlsx::write.xlsx

2020-05-27 Thread Ivan Calandra
Hi,

Rather than creating a workbook as suggested by Enrico, you can simply
supply a list to write.xlsx(); each element will be saved in a separate
sheet:
write.xlsx(list(a = df1, b = df2), file = fl_out)

That is not really appending, but that might work for you.

HTH,
Ivan

--
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

On 27/05/2020 9:15, Enrico Schumann wrote:
> On Wed, 27 May 2020, John writes:
>
>> Hi,
>>
>>This is my code a few years ago. I was able to output multiple sheet to
>> an excel file. Nevertheless, the "append" argument appears to be obsolete.
>> Now I see only one sheet, the latest added sheet, in the output. Is there
>> any other way to do it with openxlsx::write.xlsx or other
>> functions/packages?
>>
>>
>> openxlsx::write.xlsx(df1, file=fl_out, sheetName="a",
>>  col.names=TRUE, row.names=FALSE, append=TRUE, showNA=FALSE)
>>
>> openxlsx::write.xlsx(df2, file=fl_out, sheetName="b",
>>  col.names=TRUE, row.names=FALSE,
>> append=TRUE, showNA=FALSE)
>>
>> Thanks!!
>>
> I think you need to create a workbook first, then add
> the sheets, and finally write the workbook to a file.
> Something like this:
>
> df <- data.frame(a = 1:3,
>  b = 4:6)
> 
> library("openxlsx")
> wb <- createWorkbook()
> 
> sheet <- "sheet1"
> addWorksheet(wb, sheet)
> writeData(wb, sheet = sheet, x = df)
> 
> sheet <- "sheet2"
> addWorksheet(wb, sheet)
> writeData(wb, sheet = sheet, x = df + 1)
> 
> saveWorkbook(wb, file = "~/Desktop/two_sheets.xlsx")
>
>
>

__
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] Output multiple sheets to Excel files with openxlsx::write.xlsx

2020-05-27 Thread Enrico Schumann
On Wed, 27 May 2020, John writes:

> Hi,
>
>This is my code a few years ago. I was able to output multiple sheet to
> an excel file. Nevertheless, the "append" argument appears to be obsolete.
> Now I see only one sheet, the latest added sheet, in the output. Is there
> any other way to do it with openxlsx::write.xlsx or other
> functions/packages?
>
>
> openxlsx::write.xlsx(df1, file=fl_out, sheetName="a",
>  col.names=TRUE, row.names=FALSE, append=TRUE, showNA=FALSE)
>
> openxlsx::write.xlsx(df2, file=fl_out, sheetName="b",
>  col.names=TRUE, row.names=FALSE,
> append=TRUE, showNA=FALSE)
>
> Thanks!!
>

I think you need to create a workbook first, then add
the sheets, and finally write the workbook to a file.
Something like this:

df <- data.frame(a = 1:3,
 b = 4:6)

library("openxlsx")
wb <- createWorkbook()

sheet <- "sheet1"
addWorksheet(wb, sheet)
writeData(wb, sheet = sheet, x = df)

sheet <- "sheet2"
addWorksheet(wb, sheet)
writeData(wb, sheet = sheet, x = df + 1)

saveWorkbook(wb, file = "~/Desktop/two_sheets.xlsx")



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


[R] Output multiple sheets to Excel files with openxlsx::write.xlsx

2020-05-27 Thread John
Hi,

   This is my code a few years ago. I was able to output multiple sheet to
an excel file. Nevertheless, the "append" argument appears to be obsolete.
Now I see only one sheet, the latest added sheet, in the output. Is there
any other way to do it with openxlsx::write.xlsx or other
functions/packages?


openxlsx::write.xlsx(df1, file=fl_out, sheetName="a",
 col.names=TRUE, row.names=FALSE, append=TRUE, showNA=FALSE)

openxlsx::write.xlsx(df2, file=fl_out, sheetName="b",
 col.names=TRUE, row.names=FALSE,
append=TRUE, showNA=FALSE)

Thanks!!

[[alternative HTML version deleted]]

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


[R] output of bounds function (ldbounds package)

2020-03-13 Thread Sorkin, John
I am trying to get information about the output produced by the bounds 
function. Code that runs the package along with sample output is below.

Questions (1) Do the values given under boundaries, lower and upper
(Boundaries:
   TimeLower   UpperExit pr.   Diff. pr.
1  0.10  -6.9913  6.9913  2.7227e-12  2.7227e-12
2  0.33  -3.7308  3.7308  1.9097e-04  1.9097e-04
3  1.00  -1.9605  1.9605  5.e-02  4.9809e-02)
represent values of z-scores which an analysis must exceed to declare the 
analysis significant (after accounting for multiple looks)?

(2) The Exit pr. is described in the documentation as
exit.pr
the vector of cumulative exit probabilities at each analysis.
What is meant by "exit probabilites"

(3) Diff. pr. is described in the documentation as
diff.pr
the vector of exit probabilities accumulated at each analysis.
What is meant by "exit probabilities accumulated"?

Thank you,
John


install.packages("ldbounds")
library(ldbounds)
t2 <- c(0.10,0.33,1)
t2
obf.bd <- bounds(t2,iuse=c(1,1),alpha=c(0.025,0.025))
summary(obf.bd)
plot(obf.bd)

Lan-DeMets bounds for a given spending function

n =  3
Overall alpha:  0.05

Type: Two-Sided Symmetric Bounds
Lower alpha:  0.025
Upper alpha:  0.025
Spending function:  O'Brien-Fleming

Boundaries:
   TimeLower   UpperExit pr.   Diff. pr.
1  0.10  -6.9913  6.9913  2.7227e-12  2.7227e-12
2  0.33  -3.7308  3.7308  1.9097e-04  1.9097e-04
3  1.00  -1.9605  1.9605  5.e-02  4.9809e-02




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)


[[alternative HTML version deleted]]

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


Re: [R] Output for pasting multiple vectors

2019-06-27 Thread Spencer Brackett
On Thu, Jun 27, 2019 at 10:48 AM Spencer Brackett <
spbracket...@saintjosephhs.com> wrote:

> Hello,
>
> Was that helpful in clarifying?
>
> Best,
>
> Spencer
>
> On Tue, Jun 25, 2019 at 5:14 PM Spencer Brackett <
> spbracket...@saintjosephhs.com> wrote:
>
>> Thank you! The following is the result of the corrected code using
>> >cnames 
>>
>> > cnames
>>  [1] "sample.NA.NA.NANA"  "TCGA.27.1832.01.NA.NA.NANA"
>> "TCGA.27.1831.01.NA.NA.NANA"
>>  [4] "TCGA.28.5216.01.NA.NA.NANA" "TCGA.16.0846.01.NA.NA.NANA"
>> "TCGA.28.5218.01.NA.NA.NANA"
>>  [7] "TCGA.06.0178.01.NA.NA.NANA" "TCGA.06.0238.01.NA.NA.NANA"
>> "TCGA.06.0125.01.NA.NA.NANA"
>> [10] "TCGA.06.0219.01.NA.NA.NANA"
>>
>> And then the first 2 lines of the output for the corrected paste() bit of
>> the original coding...
>>
>> [[1]]
>> [1] "sample.NA.NA.NA"
>>
>> [[2]]
>> [1] "TCGA.27.1832.01.NA.NA.NANA"
>>
>> I would have to reconvene with my instructor who wrote the original code
>> to determine what his desired output for the data would be, but from what I
>> can tell, this bit of coding is formatting the given dataset(s) that we are
>> working with, prepping them for what will be a Linear regression model of
>> the protein expression datatype contained with the larger dataset. Sorry, I
>> know that this explanation doesn't really narrow things down.
>>
>> For reference, here are the proceeding few lines of code following the
>> paste() function portion; specifically after the "})" ...
>>
>> exp = read.table(file =
>> "/rsrch1/bcb/kchen_group/v_mohanty/data/TCGA/RNAseq/GBM.txt", sep = "\t",
>> header = T, row.names = 1)
>> exp = as.matrix(exp)
>> c = intersect(colnames(exp),colnames(meth))
>> exp = exp[,c]
>> meth = meth[,c]
>> m = apply(meth, 1, function(i){
>>   log2(i/(1-i))
>> })
>>
>> Best,
>>
>> Spencer Brackett
>>
>> On Tue, Jun 25, 2019 at 4:54 PM Rui Barradas 
>> wrote:
>>
>>> Hello,
>>>
>>> The following works.
>>> First, get the colnames you have posted in a format that R can process.
>>> in your code you would skip this.
>>>
>>> cnames <- scan(what = character(), text = '
>>> "sample.NA.NA.NANA"
>>> "TCGA.27.1832.01.NA.NA.NANA"
>>> "TCGA.27.1831.01.NA.NA.NANA"
>>> "TCGA.28.5216.01.NA.NA.NANA"
>>> "TCGA.16.0846.01.NA.NA.NANA"
>>> "TCGA.28.5218.01.NA.NA.NANA"
>>> "TCGA.06.0178.01.NA.NA.NANA"
>>> "TCGA.06.0238.01.NA.NA.NANA"
>>> "TCGA.06.0125.01.NA.NA.NANA"
>>> "TCGA.06.0219.01.NA.NA.NANA"
>>> ')
>>> cnames
>>>
>>>
>>> Now your code corrected. I do not understand the output you are
>>> expecting. Can you give an example of the expected output of, say, the
>>> first 2 or 3 strings?
>>>
>>> lapply(cnames, function(i){
>>>c1 <- strsplit(i, split = '\\.')[[1]]
>>>c1[4] <- paste(strsplit(c1[4], split = "",fixed = T)[[1]][1:2],
>>> collapse =  "")
>>>paste(c1, collapse = ".")
>>> })
>>>
>>>
>>> Hope this helps,
>>>
>>> Rui Barradas
>>>
>>> Às 20:24 de 25/06/19, Spencer Brackett escreveu:
>>> > Mr. Barradas,
>>> >
>>> > Oh haha my mistake. The following is the output you requested
>>> >
>>> > [1] "sample.NA.NA.NANA"
>>> >   [2] "TCGA.27.1832.01.NA.NA.NANA"
>>> >   [3] "TCGA.27.1831.01.NA.NA.NANA"
>>> >   [4] "TCGA.28.5216.01.NA.NA.NANA"
>>> >   [5] "TCGA.16.0846.01.NA.NA.NANA"
>>> >   [6] "TCGA.28.5218.01.NA.NA.NANA"
>>> >   [7] "TCGA.06.0178.01.NA.NA.NANA"
>>> >   [8] "TCGA.06.0238.01.NA.NA.NANA"
>>> >   [9] "TCGA.06.0125.01.NA.NA.NANA"
>>> > [10] "TCGA.06.0219.01.NA.NA.NANA"
>>> >
>>> > Best,
>>> >
>>> > Spencer
>>> >
>>> > On Tue, Jun 25, 2019 at 2:50 PM Rui Barradas >> > > wrote:
>>> >
>>> > Hello,
>>> >
>>> > No, you have not understood, post the colnames, not the row.names.
>>> >
>>> > Run
>>> >
>>> > colnames(meth)[1:10]
>>> >
>>> > and post the output of that code line.
>>> >
>>> > Hope this helps,
>>> >
>>> > Rui Barradas
>>> >
>>> > Às 19:31 de 25/06/19, Spencer Brackett escreveu:
>>> >  > The requested reprex
>>> >  >
>>> >  > Rendering reprex...
>>> >  > Error in parse(text = x, keep.source = TRUE) :
>>> >  >:26:2: unexpected ')'
>>> >  > 25:
>>> >  > 26: 2)
>>> >  >   ^
>>> >  >
>>> >  > And the subset of the data
>>> >  >
>>> >  >   row.names = c(NA, 6L), class = "data.frame")
>>> >  >
>>> >  > Best,
>>> >  >
>>> >  > Spencer
>>> >  >
>>> >  >
>>> >  > On Tue, Jun 25, 2019 at 2:25 PM Rui Barradas
>>> > mailto:ruipbarra...@sapo.pt>
>>> >  > >>
>>> wrote:
>>> >  >
>>> >  > Hello,
>>> >  >
>>> >  > No I wasn't expecting a very large file.
>>> >  > Try to make a reproducible example. If the problem seems to
>>> > be with the
>>> >  > sapply/strsplit post a subset of the data like just some of
>>> the
>>> >  > colnames:
>>> >  >
>>> >  > colnames(meth)[1:10]
>>> >  >
>>> >  >
>>> >  > This would allow us to run the code 

Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Spencer Brackett
Noted. Thank you as well! :)

On Tue, Jun 25, 2019 at 5:05 PM Richard O'Keefe  wrote:

> This has nothing to do with your problem, but given the heavy use of "="
> to bind keyword parameters in R, I find the use of "=" for assignment as
> well confusing.  It makes code harder to read than it needs to be.
> The historic " <- " assignment makes the distinction obvious.
>
>
> On Wed, 26 Jun 2019 at 03:12, Spencer Brackett <
> spbracket...@saintjosephhs.com> wrote:
>
>> Hello,
>>
>> The following is the bit of code I was having trouble with reproducing;
>> (meth) being the set matrix of the dataset I am working within R...
>>
>> colnames(meth) = sapply(colnames(meth), function(i){
>>   c1 = strsplit(i,split ='.', fixed = T)[[1]]
>>   c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse =
>>  "")
>>   paste(c1,collapse = ".")
>>
>> And this is the reprex () that R generated...
>>
>> Error in parse(text = x, keep.source = TRUE) :
>>   :28:0: unexpected end of input
>> 26:
>> 27:
>>^
>>
>> Does this perhaps make my question clearer? Or should I provide a more
>> extensive reprex of my work for background?
>>
>> P.S. Above text should be formatted correctly this time (according to the
>> posting guide rules), if not, I will try resetting my client email again.
>>
>> Best,
>>
>> Spencer
>>
>>
>> On Tue, Jun 25, 2019 at 9:29 AM Spencer Brackett <
>> spbracket...@saintjosephhs.com> wrote:
>>
>> > Mr. Barradas,
>> >
>> >   My apologies for the delayed response. No, (meth) is not a dataset
>> > within CRAN. I’m not sure why my supervisor wrote that in as the object
>> for
>> > the bit of script I shared previously. Assuming that the correct object
>> for
>> > this particular command is to be a data, the one with which we are
>> working
>> > is a TCGA dataset containing Glioblastoma data. We are attempting to
>> > analyze available methylation information.
>> >
>> > Best,
>> >
>> > Spencer
>> >
>> >
>> > On Sat, Jun 22, 2019 at 3:08 AM Rui Barradas 
>> wrote:
>> >
>> >> Hello,
>> >>
>> >> I cannot find the dataset. meth is a (CRAN) package dataset?
>> >>
>> >> Rui barradas
>> >>
>> >> Às 02:11 de 22/06/19, Spencer Brackett escreveu:
>> >> > Hello,
>> >> >
>> >> > I am attempting to paste multiple vectors using the paste() function
>> >> for a
>> >> > dataset that  I'm working with. Shouldn't I be receiving some kind of
>> >> > output as a result of the following?
>> >> >
>> >> >   meth=as.matrix(meth)
>> >> >> colnames(meth) = sapply(colnames(meth), function(i){
>> >> > + c1 = strsplit(i,split ='.', fixed = T)[[1]]
>> >> > + c1[4] = paste(strsplit(c1[4],split = "",fixed =
>> T)[[1]][1:2],collapse
>> >> =
>> >> >   "")
>> >> > + paste(c1,collapse = ".")
>> >> > + {
>> >> >
>> >> > Best,
>> >> >
>> >> > Spencer Brackett
>> >> >
>> >> >   [[alternative HTML version deleted]]
>> >> >
>> >> > __
>> >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> >> > https://stat.ethz.ch/mailman/listinfo/r-help
>> >> > PLEASE do read the posting guide
>> >> http://www.R-project.org/posting-guide.html
>> >> > and provide commented, minimal, self-contained, reproducible code.
>> >> >
>> >>
>> >
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

[[alternative HTML version deleted]]

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


Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Spencer Brackett
Thank you! The following is the result of the corrected code using >cnames


> cnames
 [1] "sample.NA.NA.NANA"  "TCGA.27.1832.01.NA.NA.NANA"
"TCGA.27.1831.01.NA.NA.NANA"
 [4] "TCGA.28.5216.01.NA.NA.NANA" "TCGA.16.0846.01.NA.NA.NANA"
"TCGA.28.5218.01.NA.NA.NANA"
 [7] "TCGA.06.0178.01.NA.NA.NANA" "TCGA.06.0238.01.NA.NA.NANA"
"TCGA.06.0125.01.NA.NA.NANA"
[10] "TCGA.06.0219.01.NA.NA.NANA"

And then the first 2 lines of the output for the corrected paste() bit of
the original coding...

[[1]]
[1] "sample.NA.NA.NA"

[[2]]
[1] "TCGA.27.1832.01.NA.NA.NANA"

I would have to reconvene with my instructor who wrote the original code to
determine what his desired output for the data would be, but from what I
can tell, this bit of coding is formatting the given dataset(s) that we are
working with, prepping them for what will be a Linear regression model of
the protein expression datatype contained with the larger dataset. Sorry, I
know that this explanation doesn't really narrow things down.

For reference, here are the proceeding few lines of code following the
paste() function portion; specifically after the "})" ...

exp = read.table(file =
"/rsrch1/bcb/kchen_group/v_mohanty/data/TCGA/RNAseq/GBM.txt", sep = "\t",
header = T, row.names = 1)
exp = as.matrix(exp)
c = intersect(colnames(exp),colnames(meth))
exp = exp[,c]
meth = meth[,c]
m = apply(meth, 1, function(i){
  log2(i/(1-i))
})

Best,

Spencer Brackett

On Tue, Jun 25, 2019 at 4:54 PM Rui Barradas  wrote:

> Hello,
>
> The following works.
> First, get the colnames you have posted in a format that R can process.
> in your code you would skip this.
>
> cnames <- scan(what = character(), text = '
> "sample.NA.NA.NANA"
> "TCGA.27.1832.01.NA.NA.NANA"
> "TCGA.27.1831.01.NA.NA.NANA"
> "TCGA.28.5216.01.NA.NA.NANA"
> "TCGA.16.0846.01.NA.NA.NANA"
> "TCGA.28.5218.01.NA.NA.NANA"
> "TCGA.06.0178.01.NA.NA.NANA"
> "TCGA.06.0238.01.NA.NA.NANA"
> "TCGA.06.0125.01.NA.NA.NANA"
> "TCGA.06.0219.01.NA.NA.NANA"
> ')
> cnames
>
>
> Now your code corrected. I do not understand the output you are
> expecting. Can you give an example of the expected output of, say, the
> first 2 or 3 strings?
>
> lapply(cnames, function(i){
>c1 <- strsplit(i, split = '\\.')[[1]]
>c1[4] <- paste(strsplit(c1[4], split = "",fixed = T)[[1]][1:2],
> collapse =  "")
>paste(c1, collapse = ".")
> })
>
>
> Hope this helps,
>
> Rui Barradas
>
> Às 20:24 de 25/06/19, Spencer Brackett escreveu:
> > Mr. Barradas,
> >
> > Oh haha my mistake. The following is the output you requested
> >
> > [1] "sample.NA.NA.NANA"
> >   [2] "TCGA.27.1832.01.NA.NA.NANA"
> >   [3] "TCGA.27.1831.01.NA.NA.NANA"
> >   [4] "TCGA.28.5216.01.NA.NA.NANA"
> >   [5] "TCGA.16.0846.01.NA.NA.NANA"
> >   [6] "TCGA.28.5218.01.NA.NA.NANA"
> >   [7] "TCGA.06.0178.01.NA.NA.NANA"
> >   [8] "TCGA.06.0238.01.NA.NA.NANA"
> >   [9] "TCGA.06.0125.01.NA.NA.NANA"
> > [10] "TCGA.06.0219.01.NA.NA.NANA"
> >
> > Best,
> >
> > Spencer
> >
> > On Tue, Jun 25, 2019 at 2:50 PM Rui Barradas  > > wrote:
> >
> > Hello,
> >
> > No, you have not understood, post the colnames, not the row.names.
> >
> > Run
> >
> > colnames(meth)[1:10]
> >
> > and post the output of that code line.
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> > Às 19:31 de 25/06/19, Spencer Brackett escreveu:
> >  > The requested reprex
> >  >
> >  > Rendering reprex...
> >  > Error in parse(text = x, keep.source = TRUE) :
> >  >:26:2: unexpected ')'
> >  > 25:
> >  > 26: 2)
> >  >   ^
> >  >
> >  > And the subset of the data
> >  >
> >  >   row.names = c(NA, 6L), class = "data.frame")
> >  >
> >  > Best,
> >  >
> >  > Spencer
> >  >
> >  >
> >  > On Tue, Jun 25, 2019 at 2:25 PM Rui Barradas
> > mailto:ruipbarra...@sapo.pt>
> >  > >>
> wrote:
> >  >
> >  > Hello,
> >  >
> >  > No I wasn't expecting a very large file.
> >  > Try to make a reproducible example. If the problem seems to
> > be with the
> >  > sapply/strsplit post a subset of the data like just some of
> the
> >  > colnames:
> >  >
> >  > colnames(meth)[1:10]
> >  >
> >  >
> >  > This would allow us to run the code you are having trouble
> with.
> >  >
> >  >
> >  > Hope this helps,
> >  >
> >  > Rui Barradas
> >  >
> >  > Às 17:36 de 25/06/19, Spencer Brackett escreveu:
> >  >  > The result of dput(head(meth)) is a very large data
> > table/listing of
> >  >  > data by category of what I presume to be the data from the
> two
> >  > TCGA .txt
> >  >  > files I referenced previously. Is this the output you were
> > expecting?
> >  >  >
> >  >  > On Tue, Jun 25, 2019 at 12:19 PM Rui Barradas
> >  > 

Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Richard O'Keefe
This has nothing to do with your problem, but given the heavy use of "="
to bind keyword parameters in R, I find the use of "=" for assignment as
well confusing.  It makes code harder to read than it needs to be.
The historic " <- " assignment makes the distinction obvious.


On Wed, 26 Jun 2019 at 03:12, Spencer Brackett <
spbracket...@saintjosephhs.com> wrote:

> Hello,
>
> The following is the bit of code I was having trouble with reproducing;
> (meth) being the set matrix of the dataset I am working within R...
>
> colnames(meth) = sapply(colnames(meth), function(i){
>   c1 = strsplit(i,split ='.', fixed = T)[[1]]
>   c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse =
>  "")
>   paste(c1,collapse = ".")
>
> And this is the reprex () that R generated...
>
> Error in parse(text = x, keep.source = TRUE) :
>   :28:0: unexpected end of input
> 26:
> 27:
>^
>
> Does this perhaps make my question clearer? Or should I provide a more
> extensive reprex of my work for background?
>
> P.S. Above text should be formatted correctly this time (according to the
> posting guide rules), if not, I will try resetting my client email again.
>
> Best,
>
> Spencer
>
>
> On Tue, Jun 25, 2019 at 9:29 AM Spencer Brackett <
> spbracket...@saintjosephhs.com> wrote:
>
> > Mr. Barradas,
> >
> >   My apologies for the delayed response. No, (meth) is not a dataset
> > within CRAN. I’m not sure why my supervisor wrote that in as the object
> for
> > the bit of script I shared previously. Assuming that the correct object
> for
> > this particular command is to be a data, the one with which we are
> working
> > is a TCGA dataset containing Glioblastoma data. We are attempting to
> > analyze available methylation information.
> >
> > Best,
> >
> > Spencer
> >
> >
> > On Sat, Jun 22, 2019 at 3:08 AM Rui Barradas 
> wrote:
> >
> >> Hello,
> >>
> >> I cannot find the dataset. meth is a (CRAN) package dataset?
> >>
> >> Rui barradas
> >>
> >> Às 02:11 de 22/06/19, Spencer Brackett escreveu:
> >> > Hello,
> >> >
> >> > I am attempting to paste multiple vectors using the paste() function
> >> for a
> >> > dataset that  I'm working with. Shouldn't I be receiving some kind of
> >> > output as a result of the following?
> >> >
> >> >   meth=as.matrix(meth)
> >> >> colnames(meth) = sapply(colnames(meth), function(i){
> >> > + c1 = strsplit(i,split ='.', fixed = T)[[1]]
> >> > + c1[4] = paste(strsplit(c1[4],split = "",fixed =
> T)[[1]][1:2],collapse
> >> =
> >> >   "")
> >> > + paste(c1,collapse = ".")
> >> > + {
> >> >
> >> > Best,
> >> >
> >> > Spencer Brackett
> >> >
> >> >   [[alternative HTML version deleted]]
> >> >
> >> > __
> >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> > https://stat.ethz.ch/mailman/listinfo/r-help
> >> > PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> > and provide commented, minimal, self-contained, reproducible code.
> >> >
> >>
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Rui Barradas

Hello,

The following works.
First, get the colnames you have posted in a format that R can process. 
in your code you would skip this.


cnames <- scan(what = character(), text = '
"sample.NA.NA.NANA"
"TCGA.27.1832.01.NA.NA.NANA"
"TCGA.27.1831.01.NA.NA.NANA"
"TCGA.28.5216.01.NA.NA.NANA"
"TCGA.16.0846.01.NA.NA.NANA"
"TCGA.28.5218.01.NA.NA.NANA"
"TCGA.06.0178.01.NA.NA.NANA"
"TCGA.06.0238.01.NA.NA.NANA"
"TCGA.06.0125.01.NA.NA.NANA"
"TCGA.06.0219.01.NA.NA.NANA"
')
cnames


Now your code corrected. I do not understand the output you are 
expecting. Can you give an example of the expected output of, say, the 
first 2 or 3 strings?


lapply(cnames, function(i){
  c1 <- strsplit(i, split = '\\.')[[1]]
  c1[4] <- paste(strsplit(c1[4], split = "",fixed = T)[[1]][1:2], 
collapse =  "")

  paste(c1, collapse = ".")
})


Hope this helps,

Rui Barradas

Às 20:24 de 25/06/19, Spencer Brackett escreveu:

Mr. Barradas,

Oh haha my mistake. The following is the output you requested

[1] "sample.NA.NA.NANA"
  [2] "TCGA.27.1832.01.NA.NA.NANA"
  [3] "TCGA.27.1831.01.NA.NA.NANA"
  [4] "TCGA.28.5216.01.NA.NA.NANA"
  [5] "TCGA.16.0846.01.NA.NA.NANA"
  [6] "TCGA.28.5218.01.NA.NA.NANA"
  [7] "TCGA.06.0178.01.NA.NA.NANA"
  [8] "TCGA.06.0238.01.NA.NA.NANA"
  [9] "TCGA.06.0125.01.NA.NA.NANA"
[10] "TCGA.06.0219.01.NA.NA.NANA"

Best,

Spencer

On Tue, Jun 25, 2019 at 2:50 PM Rui Barradas > wrote:


Hello,

No, you have not understood, post the colnames, not the row.names.

Run

colnames(meth)[1:10]

and post the output of that code line.

Hope this helps,

Rui Barradas

Às 19:31 de 25/06/19, Spencer Brackett escreveu:
 > The requested reprex
 >
 > Rendering reprex...
 > Error in parse(text = x, keep.source = TRUE) :
 >    :26:2: unexpected ')'
 > 25:
 > 26: 2)
 >       ^
 >
 > And the subset of the data
 >
 >   row.names = c(NA, 6L), class = "data.frame")
 >
 > Best,
 >
 > Spencer
 >
 >
 > On Tue, Jun 25, 2019 at 2:25 PM Rui Barradas
mailto:ruipbarra...@sapo.pt>
 > >> wrote:
 >
 >     Hello,
 >
 >     No I wasn't expecting a very large file.
 >     Try to make a reproducible example. If the problem seems to
be with the
 >     sapply/strsplit post a subset of the data like just some of the
 >     colnames:
 >
 >     colnames(meth)[1:10]
 >
 >
 >     This would allow us to run the code you are having trouble with.
 >
 >
 >     Hope this helps,
 >
 >     Rui Barradas
 >
 >     Às 17:36 de 25/06/19, Spencer Brackett escreveu:
 >      > The result of dput(head(meth)) is a very large data
table/listing of
 >      > data by category of what I presume to be the data from the two
 >     TCGA .txt
 >      > files I referenced previously. Is this the output you were
expecting?
 >      >
 >      > On Tue, Jun 25, 2019 at 12:19 PM Rui Barradas
 >     mailto:ruipbarra...@sapo.pt>
>
 >      > 
      >
 >      >     Hello,
 >      >
 >      >     1) That error comes from not closing }) after the paste()
 >     instruction.
 >      >     The complete statement would be
 >      >
 >      >
 >      >     colnames(meth) = sapply(colnames(meth), function(i){
 >      >         c1 = strsplit(i, split ='\\', fixed = T)[[1]]
 >      >         c1[4] = paste(strsplit(c1[4],split = "",fixed =
 >      >     T)[[1]][1:2],collapse
 >      >     =  "")
 >      >         paste(c1,collapse = ".")
 >      >     })
 >      >
 >      >
 >      >     2) Can you post the output of the following?
 >      >
 >      >     dput(head(meth))
 >      >
 >      >
 >      >     Hope this helps,
 >      >
 >      >     Rui Barradas
 >      >
 >      >     Às 16:58 de 25/06/19, Spencer Brackett escreveu:
 >      >      > The following is what I have implemented thus far...
 >      >      >
 >      >      > The file object for the two files listed in lines
1-2 was
 >     set in my
 >      >      > working directory, and are under the folder
"Vakul's GBM
 >     Code"...
 >      >     hence
 >      >      > the source of the odd 'prefix' for .txt files shown
 >      >      >
 >      >      >  >library(data.table)>.anno =
as.data.frame(fread(file =
 >      >     "~Vakul's GBM
 >      >      > Code/mapper.txt", sep ="\t", header = T))
 >      >      >  >meth = read.table(file = "~Vakul's GBM Code/GBM.txt",
 >     sep  ="\t",
 >      >      > header = T, row.names = 1)
 >      >      >  

Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Spencer Brackett
Doing so results in the following subset of my data...

>colnames(meth)[1:10]
 [1] "sample.NA.NA.NANA"  "TCGA.27.1832.01.NA.NA.NANA"
"TCGA.27.1831.01.NA.NA.NANA"
 [4] "TCGA.28.5216.01.NA.NA.NANA" "TCGA.16.0846.01.NA.NA.NANA"
"TCGA.28.5218.01.NA.NA.NANA"
 [7] "TCGA.06.0178.01.NA.NA.NANA" "TCGA.06.0238.01.NA.NA.NANA"
"TCGA.06.0125.01.NA.NA.NANA"
[10] "TCGA.06.0219.01.NA.NA.NANA"

On Tue, Jun 25, 2019 at 3:32 PM Spencer Brackett <
spbracket...@saintjosephhs.com> wrote:

> So I can run the suggested `stringsAsFactors=FALSE` argument following
> the  'colnames(meth)[1:10]' one I just used?
>
> Best,
>
> Spencer
>
> On Tue, Jun 25, 2019 at 3:28 PM Jeff Newmiller 
> wrote:
>
>> A "very large" output from dput(head(meth)) may just mean that"meth" has
>> factors instead of character columns. I recommend using the
>> `stringsAsFactors=FALSE` argument if the data frame is being loaded using
>> read.table or one of its variants. It almost always makes better sense to
>> create factors explicitly after the data has been reviewed for validity.
>>
>> On June 25, 2019 11:50:30 AM PDT, Rui Barradas 
>> wrote:
>> >Hello,
>> >
>> >No, you have not understood, post the colnames, not the row.names.
>> >
>> >Run
>> >
>> >colnames(meth)[1:10]
>> >
>> >and post the output of that code line.
>> >
>> >Hope this helps,
>> >
>> >Rui Barradas
>> >
>> >Às 19:31 de 25/06/19, Spencer Brackett escreveu:
>> >> The requested reprex
>> >>
>> >> Rendering reprex...
>> >> Error in parse(text = x, keep.source = TRUE) :
>> >>:26:2: unexpected ')'
>> >> 25:
>> >> 26: 2)
>> >>   ^
>> >>
>> >> And the subset of the data
>> >>
>> >>   row.names = c(NA, 6L), class = "data.frame")
>> >>
>> >> Best,
>> >>
>> >> Spencer
>> >>
>> >>
>> >> On Tue, Jun 25, 2019 at 2:25 PM Rui Barradas > >> > wrote:
>> >>
>> >> Hello,
>> >>
>> >> No I wasn't expecting a very large file.
>> >> Try to make a reproducible example. If the problem seems to be
>> >with the
>> >> sapply/strsplit post a subset of the data like just some of the
>> >> colnames:
>> >>
>> >> colnames(meth)[1:10]
>> >>
>> >>
>> >> This would allow us to run the code you are having trouble with.
>> >>
>> >>
>> >> Hope this helps,
>> >>
>> >> Rui Barradas
>> >>
>> >> Às 17:36 de 25/06/19, Spencer Brackett escreveu:
>> >>  > The result of dput(head(meth)) is a very large data
>> >table/listing of
>> >>  > data by category of what I presume to be the data from the two
>> >> TCGA .txt
>> >>  > files I referenced previously. Is this the output you were
>> >expecting?
>> >>  >
>> >>  > On Tue, Jun 25, 2019 at 12:19 PM Rui Barradas
>> >> mailto:ruipbarra...@sapo.pt>
>> >>  > >>
>> >wrote:
>> >>  >
>> >>  > Hello,
>> >>  >
>> >>  > 1) That error comes from not closing }) after the paste()
>> >> instruction.
>> >>  > The complete statement would be
>> >>  >
>> >>  >
>> >>  > colnames(meth) = sapply(colnames(meth), function(i){
>> >>  > c1 = strsplit(i, split ='\\', fixed = T)[[1]]
>> >>  > c1[4] = paste(strsplit(c1[4],split = "",fixed =
>> >>  > T)[[1]][1:2],collapse
>> >>  > =  "")
>> >>  > paste(c1,collapse = ".")
>> >>  > })
>> >>  >
>> >>  >
>> >>  > 2) Can you post the output of the following?
>> >>  >
>> >>  > dput(head(meth))
>> >>  >
>> >>  >
>> >>  > Hope this helps,
>> >>  >
>> >>  > Rui Barradas
>> >>  >
>> >>  > Às 16:58 de 25/06/19, Spencer Brackett escreveu:
>> >>  >  > The following is what I have implemented thus far...
>> >>  >  >
>> >>  >  > The file object for the two files listed in lines 1-2
>> >was
>> >> set in my
>> >>  >  > working directory, and are under the folder "Vakul's
>> >GBM
>> >> Code"...
>> >>  > hence
>> >>  >  > the source of the odd 'prefix' for .txt files shown
>> >>  >  >
>> >>  >  >  >library(data.table)>.anno = as.data.frame(fread(file
>> >=
>> >>  > "~Vakul's GBM
>> >>  >  > Code/mapper.txt", sep ="\t", header = T))
>> >>  >  >  >meth = read.table(file = "~Vakul's GBM Code/GBM.txt",
>> >> sep  ="\t",
>> >>  >  > header = T, row.names = 1)
>> >>  >  >  >meth = as.matrix(meth)
>> >>  >  >
>> >>  >  > ##  the loop just formats the methylation column names
>> >to
>> >> match
>> >>  > format ##
>> >>  >  > colnames(meth) = sapply(colnames(meth), function(i){
>> >>  >  >c1 = strsplit(i,split ='\\', fixed = T)[[1]]
>> >>  >  >c1[4] = paste(strsplit(c1[4],split = "",fixed =
>> >>  > T)[[1]][1:2],collapse
>> >>  >  > =  "")
>> >>  >  >paste(c1,collapse = ".")
>> >>  >  >
>> >>  >  > Rendering reprex...
>> 

Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Spencer Brackett
So I can run the suggested `stringsAsFactors=FALSE` argument following the
'colnames(meth)[1:10]' one I just used?

Best,

Spencer

On Tue, Jun 25, 2019 at 3:28 PM Jeff Newmiller 
wrote:

> A "very large" output from dput(head(meth)) may just mean that"meth" has
> factors instead of character columns. I recommend using the
> `stringsAsFactors=FALSE` argument if the data frame is being loaded using
> read.table or one of its variants. It almost always makes better sense to
> create factors explicitly after the data has been reviewed for validity.
>
> On June 25, 2019 11:50:30 AM PDT, Rui Barradas 
> wrote:
> >Hello,
> >
> >No, you have not understood, post the colnames, not the row.names.
> >
> >Run
> >
> >colnames(meth)[1:10]
> >
> >and post the output of that code line.
> >
> >Hope this helps,
> >
> >Rui Barradas
> >
> >Às 19:31 de 25/06/19, Spencer Brackett escreveu:
> >> The requested reprex
> >>
> >> Rendering reprex...
> >> Error in parse(text = x, keep.source = TRUE) :
> >>:26:2: unexpected ')'
> >> 25:
> >> 26: 2)
> >>   ^
> >>
> >> And the subset of the data
> >>
> >>   row.names = c(NA, 6L), class = "data.frame")
> >>
> >> Best,
> >>
> >> Spencer
> >>
> >>
> >> On Tue, Jun 25, 2019 at 2:25 PM Rui Barradas  >> > wrote:
> >>
> >> Hello,
> >>
> >> No I wasn't expecting a very large file.
> >> Try to make a reproducible example. If the problem seems to be
> >with the
> >> sapply/strsplit post a subset of the data like just some of the
> >> colnames:
> >>
> >> colnames(meth)[1:10]
> >>
> >>
> >> This would allow us to run the code you are having trouble with.
> >>
> >>
> >> Hope this helps,
> >>
> >> Rui Barradas
> >>
> >> Às 17:36 de 25/06/19, Spencer Brackett escreveu:
> >>  > The result of dput(head(meth)) is a very large data
> >table/listing of
> >>  > data by category of what I presume to be the data from the two
> >> TCGA .txt
> >>  > files I referenced previously. Is this the output you were
> >expecting?
> >>  >
> >>  > On Tue, Jun 25, 2019 at 12:19 PM Rui Barradas
> >> mailto:ruipbarra...@sapo.pt>
> >>  > >>
> >wrote:
> >>  >
> >>  > Hello,
> >>  >
> >>  > 1) That error comes from not closing }) after the paste()
> >> instruction.
> >>  > The complete statement would be
> >>  >
> >>  >
> >>  > colnames(meth) = sapply(colnames(meth), function(i){
> >>  > c1 = strsplit(i, split ='\\', fixed = T)[[1]]
> >>  > c1[4] = paste(strsplit(c1[4],split = "",fixed =
> >>  > T)[[1]][1:2],collapse
> >>  > =  "")
> >>  > paste(c1,collapse = ".")
> >>  > })
> >>  >
> >>  >
> >>  > 2) Can you post the output of the following?
> >>  >
> >>  > dput(head(meth))
> >>  >
> >>  >
> >>  > Hope this helps,
> >>  >
> >>  > Rui Barradas
> >>  >
> >>  > Às 16:58 de 25/06/19, Spencer Brackett escreveu:
> >>  >  > The following is what I have implemented thus far...
> >>  >  >
> >>  >  > The file object for the two files listed in lines 1-2
> >was
> >> set in my
> >>  >  > working directory, and are under the folder "Vakul's
> >GBM
> >> Code"...
> >>  > hence
> >>  >  > the source of the odd 'prefix' for .txt files shown
> >>  >  >
> >>  >  >  >library(data.table)>.anno = as.data.frame(fread(file
> >=
> >>  > "~Vakul's GBM
> >>  >  > Code/mapper.txt", sep ="\t", header = T))
> >>  >  >  >meth = read.table(file = "~Vakul's GBM Code/GBM.txt",
> >> sep  ="\t",
> >>  >  > header = T, row.names = 1)
> >>  >  >  >meth = as.matrix(meth)
> >>  >  >
> >>  >  > ##  the loop just formats the methylation column names
> >to
> >> match
> >>  > format ##
> >>  >  > colnames(meth) = sapply(colnames(meth), function(i){
> >>  >  >c1 = strsplit(i,split ='\\', fixed = T)[[1]]
> >>  >  >c1[4] = paste(strsplit(c1[4],split = "",fixed =
> >>  > T)[[1]][1:2],collapse
> >>  >  > =  "")
> >>  >  >paste(c1,collapse = ".")
> >>  >  >
> >>  >  > Rendering reprex...
> >>  >  > Error in parse(text = x, keep.source = TRUE) :
> >>  >  >:28:0: unexpected end of input
> >>  >  >
> >>  >  > Best,
> >>  >  >
> >>  >  > Spencer
> >>  >  >
> >>  >  >
> >>  >  >
> >>  >  > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
> >>  >  >  >> 
> >>  >  >> >
> >>  >  >> 
> >>  > 

Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Jeff Newmiller
A "very large" output from dput(head(meth)) may just mean that"meth" has 
factors instead of character columns. I recommend using the 
`stringsAsFactors=FALSE` argument if the data frame is being loaded using 
read.table or one of its variants. It almost always makes better sense to 
create factors explicitly after the data has been reviewed for validity.

On June 25, 2019 11:50:30 AM PDT, Rui Barradas  wrote:
>Hello,
>
>No, you have not understood, post the colnames, not the row.names.
>
>Run
>
>colnames(meth)[1:10]
>
>and post the output of that code line.
>
>Hope this helps,
>
>Rui Barradas
>
>Às 19:31 de 25/06/19, Spencer Brackett escreveu:
>> The requested reprex
>> 
>> Rendering reprex...
>> Error in parse(text = x, keep.source = TRUE) :
>>    :26:2: unexpected ')'
>> 25:
>> 26: 2)
>>       ^
>> 
>> And the subset of the data
>> 
>>   row.names = c(NA, 6L), class = "data.frame")
>> 
>> Best,
>> 
>> Spencer
>> 
>> 
>> On Tue, Jun 25, 2019 at 2:25 PM Rui Barradas > > wrote:
>> 
>> Hello,
>> 
>> No I wasn't expecting a very large file.
>> Try to make a reproducible example. If the problem seems to be
>with the
>> sapply/strsplit post a subset of the data like just some of the
>> colnames:
>> 
>> colnames(meth)[1:10]
>> 
>> 
>> This would allow us to run the code you are having trouble with.
>> 
>> 
>> Hope this helps,
>> 
>> Rui Barradas
>> 
>> Às 17:36 de 25/06/19, Spencer Brackett escreveu:
>>  > The result of dput(head(meth)) is a very large data
>table/listing of
>>  > data by category of what I presume to be the data from the two
>> TCGA .txt
>>  > files I referenced previously. Is this the output you were
>expecting?
>>  >
>>  > On Tue, Jun 25, 2019 at 12:19 PM Rui Barradas
>> mailto:ruipbarra...@sapo.pt>
>>  > >>
>wrote:
>>  >
>>  >     Hello,
>>  >
>>  >     1) That error comes from not closing }) after the paste()
>> instruction.
>>  >     The complete statement would be
>>  >
>>  >
>>  >     colnames(meth) = sapply(colnames(meth), function(i){
>>  >         c1 = strsplit(i, split ='\\', fixed = T)[[1]]
>>  >         c1[4] = paste(strsplit(c1[4],split = "",fixed =
>>  >     T)[[1]][1:2],collapse
>>  >     =  "")
>>  >         paste(c1,collapse = ".")
>>  >     })
>>  >
>>  >
>>  >     2) Can you post the output of the following?
>>  >
>>  >     dput(head(meth))
>>  >
>>  >
>>  >     Hope this helps,
>>  >
>>  >     Rui Barradas
>>  >
>>  >     Às 16:58 de 25/06/19, Spencer Brackett escreveu:
>>  >      > The following is what I have implemented thus far...
>>  >      >
>>  >      > The file object for the two files listed in lines 1-2
>was
>> set in my
>>  >      > working directory, and are under the folder "Vakul's
>GBM
>> Code"...
>>  >     hence
>>  >      > the source of the odd 'prefix' for .txt files shown
>>  >      >
>>  >      >  >library(data.table)>.anno = as.data.frame(fread(file
>=
>>  >     "~Vakul's GBM
>>  >      > Code/mapper.txt", sep ="\t", header = T))
>>  >      >  >meth = read.table(file = "~Vakul's GBM Code/GBM.txt",
>> sep  ="\t",
>>  >      > header = T, row.names = 1)
>>  >      >  >meth = as.matrix(meth)
>>  >      >
>>  >      > ##  the loop just formats the methylation column names
>to
>> match
>>  >     format ##
>>  >      > colnames(meth) = sapply(colnames(meth), function(i){
>>  >      >    c1 = strsplit(i,split ='\\', fixed = T)[[1]]
>>  >      >    c1[4] = paste(strsplit(c1[4],split = "",fixed =
>>  >     T)[[1]][1:2],collapse
>>  >      > =  "")
>>  >      >    paste(c1,collapse = ".")
>>  >      >
>>  >      > Rendering reprex...
>>  >      > Error in parse(text = x, keep.source = TRUE) :
>>  >      >    :28:0: unexpected end of input
>>  >      >
>>  >      > Best,
>>  >      >
>>  >      > Spencer
>>  >      >
>>  >      >
>>  >      >
>>  >      > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
>>  >      > > 
>>  >     > >
>>  >     > 
>>  >     > >  >      > wrote:
>>  >      >
>>  >      >     Mr. Barradas,
>>  >      >
>>  >      >     I got the same "output" as before, which is the +
>> indicating that
>>  >      >     the expression is incomplete (according to some R
>users
>>  >     response in
>>  >      >     this chain).
>>  >      >
>>  >      >     Should the argument 

Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Spencer Brackett
Mr. Barradas,

Oh haha my mistake. The following is the output you requested

[1] "sample.NA.NA.NANA"
 [2] "TCGA.27.1832.01.NA.NA.NANA"
 [3] "TCGA.27.1831.01.NA.NA.NANA"
 [4] "TCGA.28.5216.01.NA.NA.NANA"
 [5] "TCGA.16.0846.01.NA.NA.NANA"
 [6] "TCGA.28.5218.01.NA.NA.NANA"
 [7] "TCGA.06.0178.01.NA.NA.NANA"
 [8] "TCGA.06.0238.01.NA.NA.NANA"
 [9] "TCGA.06.0125.01.NA.NA.NANA"
[10] "TCGA.06.0219.01.NA.NA.NANA"

Best,

Spencer

On Tue, Jun 25, 2019 at 2:50 PM Rui Barradas  wrote:

> Hello,
>
> No, you have not understood, post the colnames, not the row.names.
>
> Run
>
> colnames(meth)[1:10]
>
> and post the output of that code line.
>
> Hope this helps,
>
> Rui Barradas
>
> Às 19:31 de 25/06/19, Spencer Brackett escreveu:
> > The requested reprex
> >
> > Rendering reprex...
> > Error in parse(text = x, keep.source = TRUE) :
> >:26:2: unexpected ')'
> > 25:
> > 26: 2)
> >   ^
> >
> > And the subset of the data
> >
> >   row.names = c(NA, 6L), class = "data.frame")
> >
> > Best,
> >
> > Spencer
> >
> >
> > On Tue, Jun 25, 2019 at 2:25 PM Rui Barradas  > > wrote:
> >
> > Hello,
> >
> > No I wasn't expecting a very large file.
> > Try to make a reproducible example. If the problem seems to be with
> the
> > sapply/strsplit post a subset of the data like just some of the
> > colnames:
> >
> > colnames(meth)[1:10]
> >
> >
> > This would allow us to run the code you are having trouble with.
> >
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> > Às 17:36 de 25/06/19, Spencer Brackett escreveu:
> >  > The result of dput(head(meth)) is a very large data table/listing
> of
> >  > data by category of what I presume to be the data from the two
> > TCGA .txt
> >  > files I referenced previously. Is this the output you were
> expecting?
> >  >
> >  > On Tue, Jun 25, 2019 at 12:19 PM Rui Barradas
> > mailto:ruipbarra...@sapo.pt>
> >  > >>
> wrote:
> >  >
> >  > Hello,
> >  >
> >  > 1) That error comes from not closing }) after the paste()
> > instruction.
> >  > The complete statement would be
> >  >
> >  >
> >  > colnames(meth) = sapply(colnames(meth), function(i){
> >  > c1 = strsplit(i, split ='\\', fixed = T)[[1]]
> >  > c1[4] = paste(strsplit(c1[4],split = "",fixed =
> >  > T)[[1]][1:2],collapse
> >  > =  "")
> >  > paste(c1,collapse = ".")
> >  > })
> >  >
> >  >
> >  > 2) Can you post the output of the following?
> >  >
> >  > dput(head(meth))
> >  >
> >  >
> >  > Hope this helps,
> >  >
> >  > Rui Barradas
> >  >
> >  > Às 16:58 de 25/06/19, Spencer Brackett escreveu:
> >  >  > The following is what I have implemented thus far...
> >  >  >
> >  >  > The file object for the two files listed in lines 1-2 was
> > set in my
> >  >  > working directory, and are under the folder "Vakul's GBM
> > Code"...
> >  > hence
> >  >  > the source of the odd 'prefix' for .txt files shown
> >  >  >
> >  >  >  >library(data.table)>.anno = as.data.frame(fread(file =
> >  > "~Vakul's GBM
> >  >  > Code/mapper.txt", sep ="\t", header = T))
> >  >  >  >meth = read.table(file = "~Vakul's GBM Code/GBM.txt",
> > sep  ="\t",
> >  >  > header = T, row.names = 1)
> >  >  >  >meth = as.matrix(meth)
> >  >  >
> >  >  > ##  the loop just formats the methylation column names to
> > match
> >  > format ##
> >  >  > colnames(meth) = sapply(colnames(meth), function(i){
> >  >  >c1 = strsplit(i,split ='\\', fixed = T)[[1]]
> >  >  >c1[4] = paste(strsplit(c1[4],split = "",fixed =
> >  > T)[[1]][1:2],collapse
> >  >  > =  "")
> >  >  >paste(c1,collapse = ".")
> >  >  >
> >  >  > Rendering reprex...
> >  >  > Error in parse(text = x, keep.source = TRUE) :
> >  >  >:28:0: unexpected end of input
> >  >  >
> >  >  > Best,
> >  >  >
> >  >  > Spencer
> >  >  >
> >  >  >
> >  >  >
> >  >  > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
> >  >  >  > 
> >  >  > >
> >  >  > 
> >  >  >  >  >  > wrote:
> >  >  >
> >  >  > Mr. Barradas,
> >  >  >
> >  >  > I got the same "output" as before, which is the +
> > indicating that
> >  >  

Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Rui Barradas

Hello,

No, you have not understood, post the colnames, not the row.names.

Run

colnames(meth)[1:10]

and post the output of that code line.

Hope this helps,

Rui Barradas

Às 19:31 de 25/06/19, Spencer Brackett escreveu:

The requested reprex

Rendering reprex...
Error in parse(text = x, keep.source = TRUE) :
   :26:2: unexpected ')'
25:
26: 2)
      ^

And the subset of the data

  row.names = c(NA, 6L), class = "data.frame")

Best,

Spencer


On Tue, Jun 25, 2019 at 2:25 PM Rui Barradas > wrote:


Hello,

No I wasn't expecting a very large file.
Try to make a reproducible example. If the problem seems to be with the
sapply/strsplit post a subset of the data like just some of the
colnames:

colnames(meth)[1:10]


This would allow us to run the code you are having trouble with.


Hope this helps,

Rui Barradas

Às 17:36 de 25/06/19, Spencer Brackett escreveu:
 > The result of dput(head(meth)) is a very large data table/listing of
 > data by category of what I presume to be the data from the two
TCGA .txt
 > files I referenced previously. Is this the output you were expecting?
 >
 > On Tue, Jun 25, 2019 at 12:19 PM Rui Barradas
mailto:ruipbarra...@sapo.pt>
 > >> wrote:
 >
 >     Hello,
 >
 >     1) That error comes from not closing }) after the paste()
instruction.
 >     The complete statement would be
 >
 >
 >     colnames(meth) = sapply(colnames(meth), function(i){
 >         c1 = strsplit(i, split ='\\', fixed = T)[[1]]
 >         c1[4] = paste(strsplit(c1[4],split = "",fixed =
 >     T)[[1]][1:2],collapse
 >     =  "")
 >         paste(c1,collapse = ".")
 >     })
 >
 >
 >     2) Can you post the output of the following?
 >
 >     dput(head(meth))
 >
 >
 >     Hope this helps,
 >
 >     Rui Barradas
 >
 >     Às 16:58 de 25/06/19, Spencer Brackett escreveu:
 >      > The following is what I have implemented thus far...
 >      >
 >      > The file object for the two files listed in lines 1-2 was
set in my
 >      > working directory, and are under the folder "Vakul's GBM
Code"...
 >     hence
 >      > the source of the odd 'prefix' for .txt files shown
 >      >
 >      >  >library(data.table)>.anno = as.data.frame(fread(file =
 >     "~Vakul's GBM
 >      > Code/mapper.txt", sep ="\t", header = T))
 >      >  >meth = read.table(file = "~Vakul's GBM Code/GBM.txt",
sep  ="\t",
 >      > header = T, row.names = 1)
 >      >  >meth = as.matrix(meth)
 >      >
 >      > ##  the loop just formats the methylation column names to
match
 >     format ##
 >      > colnames(meth) = sapply(colnames(meth), function(i){
 >      >    c1 = strsplit(i,split ='\\', fixed = T)[[1]]
 >      >    c1[4] = paste(strsplit(c1[4],split = "",fixed =
 >     T)[[1]][1:2],collapse
 >      > =  "")
 >      >    paste(c1,collapse = ".")
 >      >
 >      > Rendering reprex...
 >      > Error in parse(text = x, keep.source = TRUE) :
 >      >    :28:0: unexpected end of input
 >      >
 >      > Best,
 >      >
 >      > Spencer
 >      >
 >      >
 >      >
 >      > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
 >      > mailto:spbracket...@saintjosephhs.com>
 >     >
 >     
 >           > wrote:
 >      >
 >      >     Mr. Barradas,
 >      >
 >      >     I got the same "output" as before, which is the +
indicating that
 >      >     the expression is incomplete (according to some R users
 >     response in
 >      >     this chain).
 >      >
 >      >     Should the argument perhaps be c1 = strsplit(i, split
= '\\',
 >     fixed
 >      >     = T)[[1]]  thereby eliminating the "." ?
 >      >     The reprex and error message as the result of this is
the same as
 >      >     the previous one I sent.
 >      >
 >      >     I will send a more detailed description of what code I
have
 >     done so
 >      >     far for context.
 >      >
 >      >     Best,
 >      >
 >      >     Spencer
 >      >
 >      >     On Tue, Jun 25, 2019 at 11:30 AM Rui Barradas
 >     mailto:ruipbarra...@sapo.pt>
>
 >      >           wrote:
  

Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Spencer Brackett
The requested reprex

Rendering reprex...
Error in parse(text = x, keep.source = TRUE) :
  :26:2: unexpected ')'
25:
26: 2)
 ^

And the subset of the data

 row.names = c(NA, 6L), class = "data.frame")

Best,

Spencer


On Tue, Jun 25, 2019 at 2:25 PM Rui Barradas  wrote:

> Hello,
>
> No I wasn't expecting a very large file.
> Try to make a reproducible example. If the problem seems to be with the
> sapply/strsplit post a subset of the data like just some of the colnames:
>
> colnames(meth)[1:10]
>
>
> This would allow us to run the code you are having trouble with.
>
>
> Hope this helps,
>
> Rui Barradas
>
> Às 17:36 de 25/06/19, Spencer Brackett escreveu:
> > The result of dput(head(meth)) is a very large data table/listing of
> > data by category of what I presume to be the data from the two TCGA .txt
> > files I referenced previously. Is this the output you were expecting?
> >
> > On Tue, Jun 25, 2019 at 12:19 PM Rui Barradas  > > wrote:
> >
> > Hello,
> >
> > 1) That error comes from not closing }) after the paste()
> instruction.
> > The complete statement would be
> >
> >
> > colnames(meth) = sapply(colnames(meth), function(i){
> > c1 = strsplit(i, split ='\\', fixed = T)[[1]]
> > c1[4] = paste(strsplit(c1[4],split = "",fixed =
> > T)[[1]][1:2],collapse
> > =  "")
> > paste(c1,collapse = ".")
> > })
> >
> >
> > 2) Can you post the output of the following?
> >
> > dput(head(meth))
> >
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> > Às 16:58 de 25/06/19, Spencer Brackett escreveu:
> >  > The following is what I have implemented thus far...
> >  >
> >  > The file object for the two files listed in lines 1-2 was set in
> my
> >  > working directory, and are under the folder "Vakul's GBM Code"...
> > hence
> >  > the source of the odd 'prefix' for .txt files shown
> >  >
> >  >  >library(data.table)>.anno = as.data.frame(fread(file =
> > "~Vakul's GBM
> >  > Code/mapper.txt", sep ="\t", header = T))
> >  >  >meth = read.table(file = "~Vakul's GBM Code/GBM.txt", sep
>  ="\t",
> >  > header = T, row.names = 1)
> >  >  >meth = as.matrix(meth)
> >  >
> >  > ##  the loop just formats the methylation column names to match
> > format ##
> >  > colnames(meth) = sapply(colnames(meth), function(i){
> >  >c1 = strsplit(i,split ='\\', fixed = T)[[1]]
> >  >c1[4] = paste(strsplit(c1[4],split = "",fixed =
> > T)[[1]][1:2],collapse
> >  > =  "")
> >  >paste(c1,collapse = ".")
> >  >
> >  > Rendering reprex...
> >  > Error in parse(text = x, keep.source = TRUE) :
> >  >:28:0: unexpected end of input
> >  >
> >  > Best,
> >  >
> >  > Spencer
> >  >
> >  >
> >  >
> >  > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
> >  >  > 
> >  > >>
> >  > wrote:
> >  >
> >  > Mr. Barradas,
> >  >
> >  > I got the same "output" as before, which is the + indicating
> that
> >  > the expression is incomplete (according to some R users
> > response in
> >  > this chain).
> >  >
> >  > Should the argument perhaps be c1 = strsplit(i, split = '\\',
> > fixed
> >  > = T)[[1]]  thereby eliminating the "." ?
> >  > The reprex and error message as the result of this is the
> same as
> >  > the previous one I sent.
> >  >
> >  > I will send a more detailed description of what code I have
> > done so
> >  > far for context.
> >  >
> >  > Best,
> >  >
> >  > Spencer
> >  >
> >  > On Tue, Jun 25, 2019 at 11:30 AM Rui Barradas
> > mailto:ruipbarra...@sapo.pt>
> >  > >>
> > wrote:
> >  >
> >  > Hello,
> >  >
> >  > Maybe with
> >  >
> >  > c1 = strsplit(i, split = '\\.', fixed = T)[[1]]
> >  >
> >  > instead of split = '.'
> >  >
> >  > The dot is a metacharacter that matches any character so
> > it has
> >  > to be
> >  > escaped.
> >  >
> >  > Hope this helps,
> >  >
> >  > Rui Barradas
> >  >
> >  > Às 16:11 de 25/06/19, Spencer Brackett escreveu:
> >  >  > c1 = strsplit(i,split ='.', fixed = T)[[1]]
> >  >
> >
>

[[alternative HTML version deleted]]

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

Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Rui Barradas

Hello,

No I wasn't expecting a very large file.
Try to make a reproducible example. If the problem seems to be with the 
sapply/strsplit post a subset of the data like just some of the colnames:


colnames(meth)[1:10]


This would allow us to run the code you are having trouble with.


Hope this helps,

Rui Barradas

Às 17:36 de 25/06/19, Spencer Brackett escreveu:
The result of dput(head(meth)) is a very large data table/listing of 
data by category of what I presume to be the data from the two TCGA .txt 
files I referenced previously. Is this the output you were expecting?


On Tue, Jun 25, 2019 at 12:19 PM Rui Barradas > wrote:


Hello,

1) That error comes from not closing }) after the paste() instruction.
The complete statement would be


colnames(meth) = sapply(colnames(meth), function(i){
    c1 = strsplit(i, split ='\\', fixed = T)[[1]]
    c1[4] = paste(strsplit(c1[4],split = "",fixed =
T)[[1]][1:2],collapse
=  "")
    paste(c1,collapse = ".")
})


2) Can you post the output of the following?

dput(head(meth))


Hope this helps,

Rui Barradas

Às 16:58 de 25/06/19, Spencer Brackett escreveu:
 > The following is what I have implemented thus far...
 >
 > The file object for the two files listed in lines 1-2 was set in my
 > working directory, and are under the folder "Vakul's GBM Code"...
hence
 > the source of the odd 'prefix' for .txt files shown
 >
 >  >library(data.table)>.anno = as.data.frame(fread(file =
"~Vakul's GBM
 > Code/mapper.txt", sep ="\t", header = T))
 >  >meth = read.table(file = "~Vakul's GBM Code/GBM.txt", sep  ="\t",
 > header = T, row.names = 1)
 >  >meth = as.matrix(meth)
 >
 > ##  the loop just formats the methylation column names to match
format ##
 > colnames(meth) = sapply(colnames(meth), function(i){
 >    c1 = strsplit(i,split ='\\', fixed = T)[[1]]
 >    c1[4] = paste(strsplit(c1[4],split = "",fixed =
T)[[1]][1:2],collapse
 > =  "")
 >    paste(c1,collapse = ".")
 >
 > Rendering reprex...
 > Error in parse(text = x, keep.source = TRUE) :
 >    :28:0: unexpected end of input
 >
 > Best,
 >
 > Spencer
 >
 >
 >
 > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
 > mailto:spbracket...@saintjosephhs.com>
>>
 > wrote:
 >
 >     Mr. Barradas,
 >
 >     I got the same "output" as before, which is the + indicating that
 >     the expression is incomplete (according to some R users
response in
 >     this chain).
 >
 >     Should the argument perhaps be c1 = strsplit(i, split = '\\',
fixed
 >     = T)[[1]]  thereby eliminating the "." ?
 >     The reprex and error message as the result of this is the same as
 >     the previous one I sent.
 >
 >     I will send a more detailed description of what code I have
done so
 >     far for context.
 >
 >     Best,
 >
 >     Spencer
 >
 >     On Tue, Jun 25, 2019 at 11:30 AM Rui Barradas
mailto:ruipbarra...@sapo.pt>
 >     >>
wrote:
 >
 >         Hello,
 >
 >         Maybe with
 >
 >         c1 = strsplit(i, split = '\\.', fixed = T)[[1]]
 >
 >         instead of split = '.'
 >
 >         The dot is a metacharacter that matches any character so
it has
 >         to be
 >         escaped.
 >
 >         Hope this helps,
 >
 >         Rui Barradas
 >
 >         Às 16:11 de 25/06/19, Spencer Brackett escreveu:
 >          > c1 = strsplit(i,split ='.', fixed = T)[[1]]
 >



__
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] Output for pasting multiple vectors

2019-06-25 Thread Spencer Brackett
The result of  dput(head(meth)) is a very large data table/listing of data
by category of what I presume to be the data from the two TCGA .txt files I
referenced previously. Is this the output you were expecting?

On Tue, Jun 25, 2019 at 12:19 PM Rui Barradas  wrote:

> Hello,
>
> 1) That error comes from not closing }) after the paste() instruction.
> The complete statement would be
>
>
> colnames(meth) = sapply(colnames(meth), function(i){
>c1 = strsplit(i, split ='\\', fixed = T)[[1]]
>c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse
> =  "")
>paste(c1,collapse = ".")
> })
>
>
> 2) Can you post the output of the following?
>
> dput(head(meth))
>
>
> Hope this helps,
>
> Rui Barradas
>
> Às 16:58 de 25/06/19, Spencer Brackett escreveu:
> > The following is what I have implemented thus far...
> >
> > The file object for the two files listed in lines 1-2 was set in my
> > working directory, and are under the folder "Vakul's GBM Code"... hence
> > the source of the odd 'prefix' for .txt files shown
> >
> >  >library(data.table)>.anno = as.data.frame(fread(file = "~Vakul's GBM
> > Code/mapper.txt", sep ="\t", header = T))
> >  >meth = read.table(file = "~Vakul's GBM Code/GBM.txt", sep  ="\t",
> > header = T, row.names = 1)
> >  >meth = as.matrix(meth)
> >
> > ##  the loop just formats the methylation column names to match format ##
> > colnames(meth) = sapply(colnames(meth), function(i){
> >c1 = strsplit(i,split ='\\', fixed = T)[[1]]
> >c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse
> > =  "")
> >paste(c1,collapse = ".")
> >
> > Rendering reprex...
> > Error in parse(text = x, keep.source = TRUE) :
> >:28:0: unexpected end of input
> >
> > Best,
> >
> > Spencer
> >
> >
> >
> > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
> > mailto:spbracket...@saintjosephhs.com>>
>
> > wrote:
> >
> > Mr. Barradas,
> >
> > I got the same "output" as before, which is the + indicating that
> > the expression is incomplete (according to some R users response in
> > this chain).
> >
> > Should the argument perhaps be c1 = strsplit(i, split = '\\', fixed
> > = T)[[1]]  thereby eliminating the "." ?
> > The reprex and error message as the result of this is the same as
> > the previous one I sent.
> >
> > I will send a more detailed description of what code I have done so
> > far for context.
> >
> > Best,
> >
> > Spencer
> >
> > On Tue, Jun 25, 2019 at 11:30 AM Rui Barradas  > > wrote:
> >
> > Hello,
> >
> > Maybe with
> >
> > c1 = strsplit(i, split = '\\.', fixed = T)[[1]]
> >
> > instead of split = '.'
> >
> > The dot is a metacharacter that matches any character so it has
> > to be
> > escaped.
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> > Às 16:11 de 25/06/19, Spencer Brackett escreveu:
> >  > c1 = strsplit(i,split ='.', fixed = T)[[1]]
> >
>

[[alternative HTML version deleted]]

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


Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Rui Barradas

Hello,

1) That error comes from not closing }) after the paste() instruction.
The complete statement would be


colnames(meth) = sapply(colnames(meth), function(i){
  c1 = strsplit(i, split ='\\', fixed = T)[[1]]
  c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse 
=  "")

  paste(c1,collapse = ".")
})


2) Can you post the output of the following?

dput(head(meth))


Hope this helps,

Rui Barradas

Às 16:58 de 25/06/19, Spencer Brackett escreveu:

The following is what I have implemented thus far...

The file object for the two files listed in lines 1-2 was set in my 
working directory, and are under the folder "Vakul's GBM Code"... hence 
the source of the odd 'prefix' for .txt files shown


 >library(data.table)>.anno = as.data.frame(fread(file = "~Vakul's GBM 
Code/mapper.txt", sep ="\t", header = T))
 >meth = read.table(file = "~Vakul's GBM Code/GBM.txt", sep  ="\t", 
header = T, row.names = 1)

 >meth = as.matrix(meth)

##  the loop just formats the methylation column names to match format ##
colnames(meth) = sapply(colnames(meth), function(i){
   c1 = strsplit(i,split ='\\', fixed = T)[[1]]
   c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse 
=  "")

   paste(c1,collapse = ".")

Rendering reprex...
Error in parse(text = x, keep.source = TRUE) :
   :28:0: unexpected end of input

Best,

Spencer



On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett 
mailto:spbracket...@saintjosephhs.com>> 
wrote:


Mr. Barradas,

I got the same "output" as before, which is the + indicating that
the expression is incomplete (according to some R users response in
this chain).

Should the argument perhaps be c1 = strsplit(i, split = '\\', fixed
= T)[[1]]  thereby eliminating the "." ?
The reprex and error message as the result of this is the same as
the previous one I sent.

I will send a more detailed description of what code I have done so
far for context.

Best,

Spencer

On Tue, Jun 25, 2019 at 11:30 AM Rui Barradas mailto:ruipbarra...@sapo.pt>> wrote:

Hello,

Maybe with

c1 = strsplit(i, split = '\\.', fixed = T)[[1]]

instead of split = '.'

The dot is a metacharacter that matches any character so it has
to be
escaped.

Hope this helps,

Rui Barradas

Às 16:11 de 25/06/19, Spencer Brackett escreveu:
 > c1 = strsplit(i,split ='.', fixed = T)[[1]]



__
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] Output for pasting multiple vectors

2019-06-25 Thread Spencer Brackett
The following is what I have implemented thus far...

The file object for the two files listed in lines 1-2 was set in my working
directory, and are under the folder "Vakul's GBM Code"... hence the source
of the odd 'prefix' for .txt files shown

>library(data.table)>.anno = as.data.frame(fread(file = "~Vakul's GBM
Code/mapper.txt", sep ="\t", header = T))
>meth = read.table(file = "~Vakul's GBM Code/GBM.txt", sep  ="\t", header =
T, row.names = 1)
>meth = as.matrix(meth)

##  the loop just formats the methylation column names to match format ##
colnames(meth) = sapply(colnames(meth), function(i){
  c1 = strsplit(i,split ='\\', fixed = T)[[1]]
  c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse =
 "")
  paste(c1,collapse = ".")

Rendering reprex...
Error in parse(text = x, keep.source = TRUE) :
  :28:0: unexpected end of input

Best,

Spencer



On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett <
spbracket...@saintjosephhs.com> wrote:

> Mr. Barradas,
>
> I got the same "output" as before, which is the + indicating that the
> expression is incomplete (according to some R users response in this
> chain).
>
> Should the argument perhaps be c1 = strsplit(i, split = '\\', fixed =
> T)[[1]]  thereby eliminating the "." ?
> The reprex and error message as the result of this is the same as the
> previous one I sent.
>
> I will send a more detailed description of what code I have done so far
> for context.
>
> Best,
>
> Spencer
>
> On Tue, Jun 25, 2019 at 11:30 AM Rui Barradas 
> wrote:
>
>> Hello,
>>
>> Maybe with
>>
>> c1 = strsplit(i, split = '\\.', fixed = T)[[1]]
>>
>> instead of split = '.'
>>
>> The dot is a metacharacter that matches any character so it has to be
>> escaped.
>>
>> Hope this helps,
>>
>> Rui Barradas
>>
>> Às 16:11 de 25/06/19, Spencer Brackett escreveu:
>> > c1 = strsplit(i,split ='.', fixed = T)[[1]]
>>
>

[[alternative HTML version deleted]]

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


Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Spencer Brackett
Mr. Barradas,

I got the same "output" as before, which is the + indicating that the
expression is incomplete (according to some R users response in this
chain).

Should the argument perhaps be c1 = strsplit(i, split = '\\', fixed =
T)[[1]]  thereby eliminating the "." ?
The reprex and error message as the result of this is the same as the
previous one I sent.

I will send a more detailed description of what code I have done so far for
context.

Best,

Spencer

On Tue, Jun 25, 2019 at 11:30 AM Rui Barradas  wrote:

> Hello,
>
> Maybe with
>
> c1 = strsplit(i, split = '\\.', fixed = T)[[1]]
>
> instead of split = '.'
>
> The dot is a metacharacter that matches any character so it has to be
> escaped.
>
> Hope this helps,
>
> Rui Barradas
>
> Às 16:11 de 25/06/19, Spencer Brackett escreveu:
> > c1 = strsplit(i,split ='.', fixed = T)[[1]]
>

[[alternative HTML version deleted]]

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


Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Rui Barradas

Hello,

Maybe with

c1 = strsplit(i, split = '\\.', fixed = T)[[1]]

instead of split = '.'

The dot is a metacharacter that matches any character so it has to be 
escaped.


Hope this helps,

Rui Barradas

Às 16:11 de 25/06/19, Spencer Brackett escreveu:

c1 = strsplit(i,split ='.', fixed = T)[[1]]


__
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] Output for pasting multiple vectors

2019-06-25 Thread David Winsemius



On 6/25/19 6:29 AM, Spencer Brackett wrote:

Mr. Barradas,

   My apologies for the delayed response. No, (meth) is not a dataset within
CRAN. I’m not sure why my supervisor wrote that in as the object for the
bit of script I shared previously. Assuming that the correct object for
this particular command is to be a data, the one with which we are working
is a TCGA dataset containing Glioblastoma data. We are attempting to
analyze available methylation information.


In that case, you should be able to use `read.table` to pull the dataset 
in from the TCGA archive and show what code you have used so far. Then 
you can describe in detail what further transformations are desired.



You could have also tried to offer the output of dput(head(meth)) (but 
do so before transforming to matrix. Transfoming to matrix will screw up 
a lot of the information in any dataset that is not entirely numeric.


--

David.



Best,

Spencer


On Sat, Jun 22, 2019 at 3:08 AM Rui Barradas  wrote:


Hello,

I cannot find the dataset. meth is a (CRAN) package dataset?

Rui barradas

Às 02:11 de 22/06/19, Spencer Brackett escreveu:

Hello,

I am attempting to paste multiple vectors using the paste() function for

a

dataset that  I'm working with. Shouldn't I be receiving some kind of
output as a result of the following?

   meth=as.matrix(meth)

colnames(meth) = sapply(colnames(meth), function(i){

+ c1 = strsplit(i,split ='.', fixed = T)[[1]]
+ c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse =
   "")
+ paste(c1,collapse = ".")
+ {

Best,

Spencer Brackett

   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


__
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] Output for pasting multiple vectors

2019-06-25 Thread Spencer Brackett
Hello,

The following is the bit of code I was having trouble with reproducing;
(meth) being the set matrix of the dataset I am working within R...

colnames(meth) = sapply(colnames(meth), function(i){
  c1 = strsplit(i,split ='.', fixed = T)[[1]]
  c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse =
 "")
  paste(c1,collapse = ".")

And this is the reprex () that R generated...

Error in parse(text = x, keep.source = TRUE) :
  :28:0: unexpected end of input
26:
27:
   ^

Does this perhaps make my question clearer? Or should I provide a more
extensive reprex of my work for background?

P.S. Above text should be formatted correctly this time (according to the
posting guide rules), if not, I will try resetting my client email again.

Best,

Spencer


On Tue, Jun 25, 2019 at 9:29 AM Spencer Brackett <
spbracket...@saintjosephhs.com> wrote:

> Mr. Barradas,
>
>   My apologies for the delayed response. No, (meth) is not a dataset
> within CRAN. I’m not sure why my supervisor wrote that in as the object for
> the bit of script I shared previously. Assuming that the correct object for
> this particular command is to be a data, the one with which we are working
> is a TCGA dataset containing Glioblastoma data. We are attempting to
> analyze available methylation information.
>
> Best,
>
> Spencer
>
>
> On Sat, Jun 22, 2019 at 3:08 AM Rui Barradas  wrote:
>
>> Hello,
>>
>> I cannot find the dataset. meth is a (CRAN) package dataset?
>>
>> Rui barradas
>>
>> Às 02:11 de 22/06/19, Spencer Brackett escreveu:
>> > Hello,
>> >
>> > I am attempting to paste multiple vectors using the paste() function
>> for a
>> > dataset that  I'm working with. Shouldn't I be receiving some kind of
>> > output as a result of the following?
>> >
>> >   meth=as.matrix(meth)
>> >> colnames(meth) = sapply(colnames(meth), function(i){
>> > + c1 = strsplit(i,split ='.', fixed = T)[[1]]
>> > + c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse
>> =
>> >   "")
>> > + paste(c1,collapse = ".")
>> > + {
>> >
>> > Best,
>> >
>> > Spencer Brackett
>> >
>> >   [[alternative HTML version deleted]]
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>

[[alternative HTML version deleted]]

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


Re: [R] Output for pasting multiple vectors

2019-06-25 Thread Spencer Brackett
Mr. Barradas,

  My apologies for the delayed response. No, (meth) is not a dataset within
CRAN. I’m not sure why my supervisor wrote that in as the object for the
bit of script I shared previously. Assuming that the correct object for
this particular command is to be a data, the one with which we are working
is a TCGA dataset containing Glioblastoma data. We are attempting to
analyze available methylation information.

Best,

Spencer


On Sat, Jun 22, 2019 at 3:08 AM Rui Barradas  wrote:

> Hello,
>
> I cannot find the dataset. meth is a (CRAN) package dataset?
>
> Rui barradas
>
> Às 02:11 de 22/06/19, Spencer Brackett escreveu:
> > Hello,
> >
> > I am attempting to paste multiple vectors using the paste() function for
> a
> > dataset that  I'm working with. Shouldn't I be receiving some kind of
> > output as a result of the following?
> >
> >   meth=as.matrix(meth)
> >> colnames(meth) = sapply(colnames(meth), function(i){
> > + c1 = strsplit(i,split ='.', fixed = T)[[1]]
> > + c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse =
> >   "")
> > + paste(c1,collapse = ".")
> > + {
> >
> > Best,
> >
> > Spencer Brackett
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>

[[alternative HTML version deleted]]

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


Re: [R] Output for pasting multiple vectors

2019-06-22 Thread Rui Barradas

Hello,

I cannot find the dataset. meth is a (CRAN) package dataset?

Rui barradas

Às 02:11 de 22/06/19, Spencer Brackett escreveu:

Hello,

I am attempting to paste multiple vectors using the paste() function for a
dataset that  I'm working with. Shouldn't I be receiving some kind of
output as a result of the following?

  meth=as.matrix(meth)

colnames(meth) = sapply(colnames(meth), function(i){

+ c1 = strsplit(i,split ='.', fixed = T)[[1]]
+ c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse =
  "")
+ paste(c1,collapse = ".")
+ {

Best,

Spencer Brackett

[[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] Output for pasting multiple vectors

2019-06-21 Thread Jeff Newmiller
Note that just editing in R (or RStudio, or Notepad, or whatever) will not 
solve the problem... you MUST learn how to use your email client to set the 
format to send at least your R-help emails in plain text. If you don't do that, 
the email program will just screw up your hard work.

I do think using the reprex package to test your example for reproducibility 
will improve the clarity of your questions.

On June 21, 2019 9:10:53 PM PDT, David Winsemius  wrote:
>
>
>Sent from my iPhone
>
>> On Jun 21, 2019, at 6:48 PM, Spencer Brackett
> wrote:
>> 
>> My apologies. Is there a way to edit this within R? 
>
>Most people use an editor or an IDE to work on their code. The code you
>presented didn’t seem be doing what you were describing. You should put
>together a small example and the show what your goals are. 
>
>— 
>David. 
>>> On Fri, Jun 21, 2019 at 9:47 PM David Winsemius
> wrote:
>>> All the +-signs are telling you that the expression is not complete.
>Please read the posting guide. I’m pretty sure you’ve already been
>warned NOT to use html. 
>>> 
>>> — 
>>> David. 
>>> 
>>> Sent from my iPhone
>>> 
>>> > On Jun 21, 2019, at 6:11 PM, Spencer Brackett
> wrote:
>>> > 
>>> > Hello,
>>> > 
>>> > I am attempting to paste multiple vectors using the paste()
>function for a
>>> > dataset that  I'm working with. Shouldn't I be receiving some kind
>of
>>> > output as a result of the following?
>>> > 
>>> > meth=as.matrix(meth)
>>> >> colnames(meth) = sapply(colnames(meth), function(i){
>>> > + c1 = strsplit(i,split ='.', fixed = T)[[1]]
>>> > + c1[4] = paste(strsplit(c1[4],split = "",fixed =
>T)[[1]][1:2],collapse =
>>> > "")
>>> > + paste(c1,collapse = ".")
>>> > + {
>>> > 
>>> > Best,
>>> > 
>>> > Spencer Brackett
>>> > 
>>> >[[alternative HTML version deleted]]
>>> > 
>>> > __
>>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> > https://stat.ethz.ch/mailman/listinfo/r-help
>>> > PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>>> > and provide commented, minimal, self-contained, reproducible code.
>>> 
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

__
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] Output for pasting multiple vectors

2019-06-21 Thread David Winsemius



Sent from my iPhone

> On Jun 21, 2019, at 6:48 PM, Spencer Brackett 
>  wrote:
> 
> My apologies. Is there a way to edit this within R? 

Most people use an editor or an IDE to work on their code. The code you 
presented didn’t seem be doing what you were describing. You should put 
together a small example and the show what your goals are. 

— 
David. 
>> On Fri, Jun 21, 2019 at 9:47 PM David Winsemius  
>> wrote:
>> All the +-signs are telling you that the expression is not complete. Please 
>> read the posting guide. I’m pretty sure you’ve already been warned NOT to 
>> use html. 
>> 
>> — 
>> David. 
>> 
>> Sent from my iPhone
>> 
>> > On Jun 21, 2019, at 6:11 PM, Spencer Brackett 
>> >  wrote:
>> > 
>> > Hello,
>> > 
>> > I am attempting to paste multiple vectors using the paste() function for a
>> > dataset that  I'm working with. Shouldn't I be receiving some kind of
>> > output as a result of the following?
>> > 
>> > meth=as.matrix(meth)
>> >> colnames(meth) = sapply(colnames(meth), function(i){
>> > + c1 = strsplit(i,split ='.', fixed = T)[[1]]
>> > + c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse =
>> > "")
>> > + paste(c1,collapse = ".")
>> > + {
>> > 
>> > Best,
>> > 
>> > Spencer Brackett
>> > 
>> >[[alternative HTML version deleted]]
>> > 
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide 
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> 

[[alternative HTML version deleted]]

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


Re: [R] Output for pasting multiple vectors

2019-06-21 Thread David Winsemius
All the +-signs are telling you that the expression is not complete. Please 
read the posting guide. I’m pretty sure you’ve already been warned NOT to use 
html. 

— 
David. 

Sent from my iPhone

> On Jun 21, 2019, at 6:11 PM, Spencer Brackett 
>  wrote:
> 
> Hello,
> 
> I am attempting to paste multiple vectors using the paste() function for a
> dataset that  I'm working with. Shouldn't I be receiving some kind of
> output as a result of the following?
> 
> meth=as.matrix(meth)
>> colnames(meth) = sapply(colnames(meth), function(i){
> + c1 = strsplit(i,split ='.', fixed = T)[[1]]
> + c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse =
> "")
> + paste(c1,collapse = ".")
> + {
> 
> Best,
> 
> Spencer Brackett
> 
>[[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] Output for pasting multiple vectors

2019-06-21 Thread Spencer Brackett
My apologies. Is there a way to edit this within R?

On Fri, Jun 21, 2019 at 9:47 PM David Winsemius 
wrote:

> All the +-signs are telling you that the expression is not complete.
> Please read the posting guide. I’m pretty sure you’ve already been warned
> NOT to use html.
>
> —
> David.
>
> Sent from my iPhone
>
> > On Jun 21, 2019, at 6:11 PM, Spencer Brackett <
> spbracket...@saintjosephhs.com> wrote:
> >
> > Hello,
> >
> > I am attempting to paste multiple vectors using the paste() function for
> a
> > dataset that  I'm working with. Shouldn't I be receiving some kind of
> > output as a result of the following?
> >
> > meth=as.matrix(meth)
> >> colnames(meth) = sapply(colnames(meth), function(i){
> > + c1 = strsplit(i,split ='.', fixed = T)[[1]]
> > + c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse =
> > "")
> > + paste(c1,collapse = ".")
> > + {
> >
> > Best,
> >
> > Spencer Brackett
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

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


Re: [R] Output for pasting multiple vectors

2019-06-21 Thread Spencer Brackett
Would output <-paste() be part of the solution perhaps? Reading up on the
matter now.

Best,

Spencer

On Fri, Jun 21, 2019 at 9:11 PM Spencer Brackett <
spbracket...@saintjosephhs.com> wrote:

> Hello,
>
> I am attempting to paste multiple vectors using the paste() function for a
> dataset that  I'm working with. Shouldn't I be receiving some kind of
> output as a result of the following?
>
>  meth=as.matrix(meth)
> > colnames(meth) = sapply(colnames(meth), function(i){
> + c1 = strsplit(i,split ='.', fixed = T)[[1]]
> + c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse =
>  "")
> + paste(c1,collapse = ".")
> + {
>
> Best,
>
> Spencer Brackett
>

[[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] Output for pasting multiple vectors

2019-06-21 Thread Spencer Brackett
Hello,

I am attempting to paste multiple vectors using the paste() function for a
dataset that  I'm working with. Shouldn't I be receiving some kind of
output as a result of the following?

 meth=as.matrix(meth)
> colnames(meth) = sapply(colnames(meth), function(i){
+ c1 = strsplit(i,split ='.', fixed = T)[[1]]
+ c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse =
 "")
+ paste(c1,collapse = ".")
+ {

Best,

Spencer Brackett

[[alternative HTML version deleted]]

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


Re: [R] interpretation of R output for exact permutation test

2019-06-07 Thread Patrick (Malone Quantitative)
I suspect Massimo meant to refer to the output z as "critical ratio,"
vs. "critical value." But I agree with Massimo there's no
interpretation of it with an exact test. The p-value is the meaningful
output.

Pat


On Fri, Jun 7, 2019 at 5:40 AM Duncan Murdoch  wrote:
>
> On 07/06/2019 3:08 a.m., massimo bressan wrote:
> > given this reproucible example
> >
> > library(coin)
> >
> > independence_test(asat ~ group, data = asat, ## exact null distribution
> > distribution = "exact")
> >
> > I'm wondering why the default results are reporting also the critical value
> > Z by considering that this method is supposed to be "exact", i.e. computing
> > the direct probability:
>
> I don't think that is the critical value, I think it is the observed
> value of the statistic being used.
> >
> > pvalue(independence_test(asat ~ group, data = asat, ## exact null
> > distribution distribution = "exact"))
> >
> > my question is: what is the correct interpretation (if it exists at all) of
> > the Z value printed out by the 'plain' function 'independence_test' when it
> > is asked for an 'exact' test?
>
> Simply the value of the the statistic.  I don't know its formula, but
> presumably one of the references in the help page ?independence_test
> would give it.
>
> The p-value is the probability of such a value or a more extreme one
> (possibly with some sort of continuity correction; you'd have to check
> the references).  The "exact" argument says to use the exact permutation
> distribution for the statistic when calculating that probability.
>
> Duncan Murdoch
>
>
> >
> > am I completely out of track?
> >
> > sorry but I'm here missing the point somewhere, somehow...
> >
> > thank you for the feedback
> >
> >   [[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.

__
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] interpretation of R output for exact permutation test

2019-06-07 Thread Duncan Murdoch

On 07/06/2019 3:08 a.m., massimo bressan wrote:

given this reproucible example

library(coin)

independence_test(asat ~ group, data = asat, ## exact null distribution
distribution = "exact")

I'm wondering why the default results are reporting also the critical value
Z by considering that this method is supposed to be "exact", i.e. computing
the direct probability:


I don't think that is the critical value, I think it is the observed 
value of the statistic being used.


pvalue(independence_test(asat ~ group, data = asat, ## exact null
distribution distribution = "exact"))

my question is: what is the correct interpretation (if it exists at all) of
the Z value printed out by the 'plain' function 'independence_test' when it
is asked for an 'exact' test?


Simply the value of the the statistic.  I don't know its formula, but 
presumably one of the references in the help page ?independence_test 
would give it.


The p-value is the probability of such a value or a more extreme one 
(possibly with some sort of continuity correction; you'd have to check 
the references).  The "exact" argument says to use the exact permutation 
distribution for the statistic when calculating that probability.


Duncan Murdoch




am I completely out of track?

sorry but I'm here missing the point somewhere, somehow...

thank you for the feedback

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


[R] interpretation of R output for exact permutation test

2019-06-07 Thread massimo bressan
given this reproucible example

library(coin)

independence_test(asat ~ group, data = asat, ## exact null distribution
distribution = "exact")

I'm wondering why the default results are reporting also the critical value
Z by considering that this method is supposed to be "exact", i.e. computing
the direct probability:

pvalue(independence_test(asat ~ group, data = asat, ## exact null
distribution distribution = "exact"))

my question is: what is the correct interpretation (if it exists at all) of
the Z value printed out by the 'plain' function 'independence_test' when it
is asked for an 'exact' test?

am I completely out of track?

sorry but I'm here missing the point somewhere, somehow...

thank you for the feedback

[[alternative HTML version deleted]]

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


Re: [R] Output of arima

2018-11-14 Thread Ashim Kapoor
Dear Eric,

Many thanks for your reply.

Best Regards,
Ashim

On Wed, Nov 14, 2018 at 4:05 PM Eric Berger  wrote:

> Hi Ashim,
> Per the help page for arima(), it fits an ARIMA model to the specified
> time series - but the caller has to specify the order - i.e. (p,d,q) - of
> the model.
> The default order is (0,0,0) (per the help page). Hence your two calls are
> different. The first call is equivalent to order=c(0,0,0) and the second
> specifies order=c(1,0,0).
> In the first, since there is no auto-regression, all the variance is
> "assigned" to the innovations, hence sigma^2 = 5.233.
> The second case you understand.
> A clue that this was happening is that the first call only returns a
> single coefficient (where is the autoregressive coefficient? - not there
> because you didn't ask for it).
> The second call returns two coefficients, as requested/expected.
>
> HTH,
> Eric
>
>
> On Wed, Nov 14, 2018 at 12:08 PM Ashim Kapoor 
> wrote:
>
>> Dear Eric and William,
>>
>> Why do the 1st and 2nd incantation of arima return sigma^2 as 5.233 vs
>> .?
>> The help for arima says  --->  sigma2: the MLE of the innovations
>> variance.
>> By that account the 1st result is incorrect. I am a little confused.
>>
>> set.seed(123)
>> b <- arima.sim(list(order = c(1,0,0),ar= .9),n=100,sd=1)
>>
>> # Variance of the innovations, e_t = 1
>>
>> # Variance of b = Var(e_t)/(1-Phi^2) = 1 / (1-.81) = 5.263158
>>
>> arima(b)
>>
>> > arima(b)
>>
>> Call:
>> arima(x = b)
>>
>> Coefficients:
>>   intercept
>> -0.0051
>> s.e. 0.0023
>>
>> sigma^2 estimated as 5.233:  log likelihood = -2246450,  aic = 4492903
>> >
>>
>>
>> arima(b,order= c(1,0,0))
>>
>> Call:
>> arima(x = b, order = c(1, 0, 0))
>>
>> Coefficients:
>>  ar1  intercept
>>   0.8994-0.0051
>> s.e.  0.0004 0.0099
>>
>> sigma^2 estimated as 0.:  log likelihood = -1418870,  aic = 2837747
>> >
>>
>> On Tue, Nov 13, 2018 at 11:07 PM William Dunlap 
>> wrote:
>>
>> > Try supplying the order argument to arima.  It looks like the default is
>> > to estimate only the mean.
>> >
>> > > arima(b, order=c(1,0,0))
>> >
>> > Call:
>> > arima(x = b, order = c(1, 0, 0))
>> >
>> > Coefficients:
>> >  ar1  intercept
>> >   0.8871 0.2369
>> > s.e.  0.0145 0.2783
>> >
>> > sigma^2 estimated as 1.002:  log likelihood = -1420.82,  aic = 2847.63
>> >
>> >
>> > Bill Dunlap
>> > TIBCO Software
>> > wdunlap tibco.com
>> >
>> > On Tue, Nov 13, 2018 at 4:02 AM, Ashim Kapoor 
>> > wrote:
>> >
>> >> Dear All,
>> >>
>> >> Here is a reprex:
>> >>
>> >> set.seed(123)
>> >> b <- arima.sim(list(order = c(1,0,0),ar= .9),n=1000,sd=1)
>> >> arima(b)
>> >>
>> >> Call:
>> >> arima(x = b)
>> >>
>> >> Coefficients:
>> >>   intercept
>> >>  0.2250
>> >> s.e. 0.0688
>> >>
>> >> sigma^2 estimated as 4.735:  log likelihood = -2196.4,  aic = 4396.81
>> >> >
>> >>
>> >> Should sigma^2 not be equal to 1 ? Where do I misunderstand ?
>> >>
>> >> 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.
>> >>
>> >
>> >
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

[[alternative HTML version deleted]]

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


Re: [R] Output of arima

2018-11-14 Thread Eric Berger
Hi Ashim,
Per the help page for arima(), it fits an ARIMA model to the specified time
series - but the caller has to specify the order - i.e. (p,d,q) - of the
model.
The default order is (0,0,0) (per the help page). Hence your two calls are
different. The first call is equivalent to order=c(0,0,0) and the second
specifies order=c(1,0,0).
In the first, since there is no auto-regression, all the variance is
"assigned" to the innovations, hence sigma^2 = 5.233.
The second case you understand.
A clue that this was happening is that the first call only returns a single
coefficient (where is the autoregressive coefficient? - not there because
you didn't ask for it).
The second call returns two coefficients, as requested/expected.

HTH,
Eric


On Wed, Nov 14, 2018 at 12:08 PM Ashim Kapoor  wrote:

> Dear Eric and William,
>
> Why do the 1st and 2nd incantation of arima return sigma^2 as 5.233 vs
> .?
> The help for arima says  --->  sigma2: the MLE of the innovations variance.
> By that account the 1st result is incorrect. I am a little confused.
>
> set.seed(123)
> b <- arima.sim(list(order = c(1,0,0),ar= .9),n=100,sd=1)
>
> # Variance of the innovations, e_t = 1
>
> # Variance of b = Var(e_t)/(1-Phi^2) = 1 / (1-.81) = 5.263158
>
> arima(b)
>
> > arima(b)
>
> Call:
> arima(x = b)
>
> Coefficients:
>   intercept
> -0.0051
> s.e. 0.0023
>
> sigma^2 estimated as 5.233:  log likelihood = -2246450,  aic = 4492903
> >
>
>
> arima(b,order= c(1,0,0))
>
> Call:
> arima(x = b, order = c(1, 0, 0))
>
> Coefficients:
>  ar1  intercept
>   0.8994-0.0051
> s.e.  0.0004 0.0099
>
> sigma^2 estimated as 0.:  log likelihood = -1418870,  aic = 2837747
> >
>
> On Tue, Nov 13, 2018 at 11:07 PM William Dunlap  wrote:
>
> > Try supplying the order argument to arima.  It looks like the default is
> > to estimate only the mean.
> >
> > > arima(b, order=c(1,0,0))
> >
> > Call:
> > arima(x = b, order = c(1, 0, 0))
> >
> > Coefficients:
> >  ar1  intercept
> >   0.8871 0.2369
> > s.e.  0.0145 0.2783
> >
> > sigma^2 estimated as 1.002:  log likelihood = -1420.82,  aic = 2847.63
> >
> >
> > Bill Dunlap
> > TIBCO Software
> > wdunlap tibco.com
> >
> > On Tue, Nov 13, 2018 at 4:02 AM, Ashim Kapoor 
> > wrote:
> >
> >> Dear All,
> >>
> >> Here is a reprex:
> >>
> >> set.seed(123)
> >> b <- arima.sim(list(order = c(1,0,0),ar= .9),n=1000,sd=1)
> >> arima(b)
> >>
> >> Call:
> >> arima(x = b)
> >>
> >> Coefficients:
> >>   intercept
> >>  0.2250
> >> s.e. 0.0688
> >>
> >> sigma^2 estimated as 4.735:  log likelihood = -2196.4,  aic = 4396.81
> >> >
> >>
> >> Should sigma^2 not be equal to 1 ? Where do I misunderstand ?
> >>
> >> 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.
> >>
> >
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Output of arima

2018-11-14 Thread Ashim Kapoor
Dear Eric and William,

Why do the 1st and 2nd incantation of arima return sigma^2 as 5.233 vs
.?
The help for arima says  --->  sigma2: the MLE of the innovations variance.
By that account the 1st result is incorrect. I am a little confused.

set.seed(123)
b <- arima.sim(list(order = c(1,0,0),ar= .9),n=100,sd=1)

# Variance of the innovations, e_t = 1

# Variance of b = Var(e_t)/(1-Phi^2) = 1 / (1-.81) = 5.263158

arima(b)

> arima(b)

Call:
arima(x = b)

Coefficients:
  intercept
-0.0051
s.e. 0.0023

sigma^2 estimated as 5.233:  log likelihood = -2246450,  aic = 4492903
>


arima(b,order= c(1,0,0))

Call:
arima(x = b, order = c(1, 0, 0))

Coefficients:
 ar1  intercept
  0.8994-0.0051
s.e.  0.0004 0.0099

sigma^2 estimated as 0.:  log likelihood = -1418870,  aic = 2837747
>

On Tue, Nov 13, 2018 at 11:07 PM William Dunlap  wrote:

> Try supplying the order argument to arima.  It looks like the default is
> to estimate only the mean.
>
> > arima(b, order=c(1,0,0))
>
> Call:
> arima(x = b, order = c(1, 0, 0))
>
> Coefficients:
>  ar1  intercept
>   0.8871 0.2369
> s.e.  0.0145 0.2783
>
> sigma^2 estimated as 1.002:  log likelihood = -1420.82,  aic = 2847.63
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Tue, Nov 13, 2018 at 4:02 AM, Ashim Kapoor 
> wrote:
>
>> Dear All,
>>
>> Here is a reprex:
>>
>> set.seed(123)
>> b <- arima.sim(list(order = c(1,0,0),ar= .9),n=1000,sd=1)
>> arima(b)
>>
>> Call:
>> arima(x = b)
>>
>> Coefficients:
>>   intercept
>>  0.2250
>> s.e. 0.0688
>>
>> sigma^2 estimated as 4.735:  log likelihood = -2196.4,  aic = 4396.81
>> >
>>
>> Should sigma^2 not be equal to 1 ? Where do I misunderstand ?
>>
>> 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.
>>
>
>

[[alternative HTML version deleted]]

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


Re: [R] Output of arima

2018-11-13 Thread William Dunlap via R-help
Try supplying the order argument to arima.  It looks like the default is to
estimate only the mean.

> arima(b, order=c(1,0,0))

Call:
arima(x = b, order = c(1, 0, 0))

Coefficients:
 ar1  intercept
  0.8871 0.2369
s.e.  0.0145 0.2783

sigma^2 estimated as 1.002:  log likelihood = -1420.82,  aic = 2847.63


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Nov 13, 2018 at 4:02 AM, Ashim Kapoor  wrote:

> Dear All,
>
> Here is a reprex:
>
> set.seed(123)
> b <- arima.sim(list(order = c(1,0,0),ar= .9),n=1000,sd=1)
> arima(b)
>
> Call:
> arima(x = b)
>
> Coefficients:
>   intercept
>  0.2250
> s.e. 0.0688
>
> sigma^2 estimated as 4.735:  log likelihood = -2196.4,  aic = 4396.81
> >
>
> Should sigma^2 not be equal to 1 ? Where do I misunderstand ?
>
> 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.
>

[[alternative HTML version deleted]]

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


Re: [R] Output of arima

2018-11-13 Thread Eric Berger
Try google'ing for 'variance of an AR(1) process'.
With the same seed, if you set n=100, you will get something that will
compare well with what you discover from your search.

On Tue, Nov 13, 2018 at 2:04 PM Ashim Kapoor  wrote:

> Dear All,
>
> Here is a reprex:
>
> set.seed(123)
> b <- arima.sim(list(order = c(1,0,0),ar= .9),n=1000,sd=1)
> arima(b)
>
> Call:
> arima(x = b)
>
> Coefficients:
>   intercept
>  0.2250
> s.e. 0.0688
>
> sigma^2 estimated as 4.735:  log likelihood = -2196.4,  aic = 4396.81
> >
>
> Should sigma^2 not be equal to 1 ? Where do I misunderstand ?
>
> 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.
>

[[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] Output of arima

2018-11-13 Thread Ashim Kapoor
Dear All,

Here is a reprex:

set.seed(123)
b <- arima.sim(list(order = c(1,0,0),ar= .9),n=1000,sd=1)
arima(b)

Call:
arima(x = b)

Coefficients:
  intercept
 0.2250
s.e. 0.0688

sigma^2 estimated as 4.735:  log likelihood = -2196.4,  aic = 4396.81
>

Should sigma^2 not be equal to 1 ? Where do I misunderstand ?

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.


Re: [R] [FORGED] How to write an estimated seasonal ARIMA model from R output?

2017-06-20 Thread Rolf Turner

On 20/06/17 17:21, Y S wrote:

I'm trying to use the following command.
arima (x, order = c(p,d,q), seasonal =list(order=c(P,D,Q), period=s)

How can I write an estimated seasonal ARIMA model from the outputs. To be 
specifically, which sign to use? I know R uses a different signs from S plus.

Is it correct that the model is:
(1-ar1*B-ar2*B^2-...)(1-sar1*B^s-sar2*B^2s-)(1-B)^d(1-B^s)^D 
X_t=(1+ma1*B+ma2*B^2+...)(1+sma1*B^s+sma2*B^2s+) a_t

For example:

m1=arima(koeps,order=c(0,1,1),seasonal=list(order=c(0,1,1),period=4))
m1

Call:
arima(x = koeps, order = c(0, 1, 1), seasonal = list(order = c(0, 1, 1), period 
= 4))
Coefficients:
   ma1 sma1
   -0.4096  -0.8203
s.e.   0.0866   0.0743

Should the estimated model be written as:
(1-B)(1-B^4) X_t=(1-0.4096B)(1-0.8203B^4) a_t
or (1-B)(1-B^4) X_t=(1+0.4096B)(1+0.8203B^4) a_t

Thanks!


Please do not post in html, although this doesn't seem to have messed 
things up too badly in this instance.


The help for arima() says:


The definition used here has

X[t] = a[1]X[t-1] + … + a[p]X[t-p] + e[t] + b[1]e[t-1] + … + b[q]e[t-q]


so your first possibility, i.e.

(1-B)(1-B^4) X_t=(1-0.4096B)(1-0.8203B^4) a_t

is the correct one.

This stuff *does* get confusing; parity errors keep creeping in!

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

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

[R] How to write an estimated seasonal ARIMA model from R output?

2017-06-20 Thread Y S
I'm trying to use the following command.
arima (x, order = c(p,d,q), seasonal =list(order=c(P,D,Q), period=s)

How can I write an estimated seasonal ARIMA model from the outputs. To be 
specifically, which sign to use? I know R uses a different signs from S plus.

Is it correct that the model is:
(1-ar1*B-ar2*B^2-...)(1-sar1*B^s-sar2*B^2s-)(1-B)^d(1-B^s)^D 
X_t=(1+ma1*B+ma2*B^2+...)(1+sma1*B^s+sma2*B^2s+) a_t

For example:
> m1=arima(koeps,order=c(0,1,1),seasonal=list(order=c(0,1,1),period=4))
> m1
Call:
arima(x = koeps, order = c(0, 1, 1), seasonal = list(order = c(0, 1, 1), period 
= 4))
Coefficients:
  ma1 sma1
  -0.4096  -0.8203
s.e.   0.0866   0.0743

Should the estimated model be written as:
(1-B)(1-B^4) X_t=(1-0.4096B)(1-0.8203B^4) a_t
or (1-B)(1-B^4) X_t=(1+0.4096B)(1+0.8203B^4) a_t

Thanks!


[[alternative HTML version deleted]]

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


[R] output of filled.contour

2017-04-15 Thread 宓辰羲
Dear all:

 I used the argument of filled.contour for drawing. I just wonder how to 
shorten 
the spacing between the key and the picture?


Attached below is the output. Thanks very much for the kind help!


Best Cheers
  Chenxi  
__
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] output

2017-01-17 Thread Marc Schwartz
Hi Val,

Presuming that the Excel file that you are trying to read has a second 
worksheet, which is what the read.xls() command you are using is trying to do, 
the problem may be that XLSX file support has not been installed for the gdata 
package, which is what I presume you are using. You do not explicitly indicate 
that, so I am guessing here.

In case there is any misunderstanding, I do not have any support for reading 
Excel files in WriteXLS.

If you look at the help for ?read.xls in Greg's gdata package, there is a 
reference to using ?xlsFormats, which tests as to whether or not you have 
support for XLSX formats installed for that package. If that latter function 
only returns "XLS" and not both "XLS" and "XLSX", then you need to use 
?installXLSXsupport to install additional Perl modules so that Greg's functions 
can read XLSX format files.

Alternatively, there are other Excel file I/O packages available on CRAN if you 
would prefer to consider other options as well. They will typically require 
Java being installed, rather than Perl, as I and Greg do.

Regards,

Marc


> On Jan 17, 2017, at 2:36 PM, Val  wrote:
> 
> Hi Marc and all,
> 
> Last time you suggest me to use  WriteXLS  function to write more than
> 65,000  row in excel.  Creating the file worked fine.  Now I wanted to
> read it using the WriteXLS   function but have a problem,. The file
> has more than  one sheets.  Here is the script and the error message.
> 
> datx <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }
> dat <-data.frame(datx(11,10,2))
> WriteXLS(dat, "test5.xlsx", row.names=FALSE)
> I created several sheets  by copying the first sheet
> 
> t1<- read.xls("Test6.xlsx",2, stringsAsFactors=FALSE)
> 
> I am getting an error message of
> Error in read.table(file = file, header = header, sep = sep, quote = quote,  :
>  no lines available in input
> 
> Thank you in advance
> 
> 
> On Tue, Dec 13, 2016 at 5:07 PM, Val  wrote:
>> Marc,
>> Thank you so much! That was helpful comment.
>> 
>> 
>> On Mon, Dec 12, 2016 at 10:09 PM, Marc Schwartz  wrote:
>>> Hi,
>>> 
>>> With the WriteXLS() function, from the package of the same name, if you 
>>> specify '.xlsx' for the file name extension, the function will create an 
>>> Excel 2007 compatible file, which can handle worksheets of up to 1,048,576 
>>> rows by 16,384 columns.
>>> 
>>> Thus:
>>> 
>>>  WriteXLS(dat, "test4.xlsx", row.names = FALSE)
>>> 
>>> That is all described in the help file for the function.
>>> 
>>> Regards,
>>> 
>>> Marc Schwartz
>>> 
>>> 
 On Dec 12, 2016, at 6:51 PM, Val  wrote:
 
 Hi all,
 
 I have a data frame with more than 100,000 rows.
 
 datx <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }
 dat <- datx(11,10,2)
 
 1)
 WriteXLS(dat, "test4.xls", row.names=FALSE)
 Error in WriteXLS(dat, "test4.xls", row.names = FALSE) :
 One or more of the data frames named in 'x' exceeds 65,535 rows or 256 
 columns
 
 I noticed that *.xls has  row and column limitations.
 
 How can I take the excess row to the next sheet?
 
 2) I also tried to use xlsx and have a problem
 
 write.xlsx(dat, "test3.xlsx",sheetName="sheet1", row.names=FALSE)
 Error in .jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook") :
 java.lang.OutOfMemoryError: Java heap
 space.jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook")>>> class "jobjRef">
 
 Any help ?
 Thank you in advance
 
 __
 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] output

2017-01-17 Thread Val
Hi Marc and all,

Last time you suggest me to use  WriteXLS  function to write more than
65,000  row in excel.  Creating the file worked fine.  Now I wanted to
read it using the WriteXLS   function but have a problem,. The file
has more than  one sheets.  Here is the script and the error message.

datx <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }
dat <-data.frame(datx(11,10,2))
WriteXLS(dat, "test5.xlsx", row.names=FALSE)
 I created several sheets  by copying the first sheet

t1<- read.xls("Test6.xlsx",2, stringsAsFactors=FALSE)

I am getting an error message of
Error in read.table(file = file, header = header, sep = sep, quote = quote,  :
  no lines available in input

Thank you in advance


On Tue, Dec 13, 2016 at 5:07 PM, Val  wrote:
> Marc,
> Thank you so much! That was helpful comment.
>
>
> On Mon, Dec 12, 2016 at 10:09 PM, Marc Schwartz  wrote:
>> Hi,
>>
>> With the WriteXLS() function, from the package of the same name, if you 
>> specify '.xlsx' for the file name extension, the function will create an 
>> Excel 2007 compatible file, which can handle worksheets of up to 1,048,576 
>> rows by 16,384 columns.
>>
>> Thus:
>>
>>   WriteXLS(dat, "test4.xlsx", row.names = FALSE)
>>
>> That is all described in the help file for the function.
>>
>> Regards,
>>
>> Marc Schwartz
>>
>>
>>> On Dec 12, 2016, at 6:51 PM, Val  wrote:
>>>
>>> Hi all,
>>>
>>> I have a data frame with more than 100,000 rows.
>>>
>>> datx <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }
>>> dat <- datx(11,10,2)
>>>
>>> 1)
>>> WriteXLS(dat, "test4.xls", row.names=FALSE)
>>> Error in WriteXLS(dat, "test4.xls", row.names = FALSE) :
>>>  One or more of the data frames named in 'x' exceeds 65,535 rows or 256 
>>> columns
>>>
>>> I noticed that *.xls has  row and column limitations.
>>>
>>> How can I take the excess row to the next sheet?
>>>
>>> 2) I also tried to use xlsx and have a problem
>>>
>>> write.xlsx(dat, "test3.xlsx",sheetName="sheet1", row.names=FALSE)
>>> Error in .jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook") :
>>>  java.lang.OutOfMemoryError: Java heap
>>> space.jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook")>> class "jobjRef">
>>>
>>> Any help ?
>>> Thank you in advance
>>>
>>> __
>>> 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] [FORGED] Export R output in Excel

2016-12-30 Thread John McKown
On Thu, Dec 29, 2016 at 4:32 PM, Erich Subscriptions <
erich.s...@neuwirth.priv.at> wrote:

> Just a very brief footnote.
> I is easy to write badly structured spreadsheets.
> But if people dong this would not have spreadsheets
> and be forded to write code, they probably also
> would write badly structured code.
>

​Very true. ​There is a very old quote: "You can write FORTRAN in any
language." Basically FORTRAN was, I think, the very first "high level"
language (1957 - COBOL was in 1959) and it had very poor (NO) structuring.
Coding it in is much like writing a bad mathematical proof (yes, I know
FORTRAN). When better languages came along, the original programmers wrote
code in the "if it were only FORTRAN" mode.

ref: https://en.wikiquote.org/wiki/Fortran




>
> There is a lot of bad R code around also!
>
>

-- 
Heisenberg may have been here.

http://xkcd.com/1770/

Maranatha! <><
John McKown

[[alternative HTML version deleted]]

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

Re: [R] [FORGED] Export R output in Excel

2016-12-29 Thread Erich Subscriptions
Just a very brief footnote.
I is easy to write badly structured spreadsheets.
But if people dong this would not have spreadsheets 
and be forded to write code, they probably also
would write badly structured code.

There is a lot of bad R code around also!



> On Dec 29, 2016, at 15:40, Bert Gunter  wrote:
> 
> (Private -- as this is just my personal opinion and not really helpful).
> 
> I found your comments informative. Thank you.
> 
> My own experience with scientific colleagues -- biologists mostly --
> who use Excel in the way that you describe is that the "haptic" (great
> word!) ease with which they manipulate the data almost inevitably
> results in errors. That is, the *lack* of enforced structure in Excel
> allows them to do things that they shouldn't or don't mean to do,
> typically without raising any flags, typically causing downstream
> errors that can be hard to trace. Irreproducibility follows.
> 
> My point is that the structure that you consider burdensome -- at
> least initially -- is desirable exactly because it forces them to
> think more carefully about what they are doing. Debugging, or worse
> yet, failure to realize that debugging is needed, takes far more time
> and is far more consequential.
> 
> As I said, just my opinion, no reply necessary, and I do appreciate
> your thoughtful remarks.
> 
> Best,
> Bert Gunter
> 
> 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 Thu, Dec 29, 2016 at 2:16 AM, Erich Subscriptions
>  wrote:
>> Well, my few cents again.
>> the packages
>> openxslx and xlsx allow to write dataframes as Excel sheets.
>> (xlsx is Java based, so it has more requirements to run than openxlsx,
>> which is just C++ based)
>> 
>> On Windows, R tools for Visual Studio allows Excel export.
>> For Windows, there also is our Excel add-in RExcel allowing
>> to use R from within Excel, and the R package rcom
>> which also allows to interact with Excel from R (more than just writing 
>> Excel workbooks).
>> Our products (rcom and RExcel), however, are not unter a FOSS license.
>> 
>> And a more general remark: There are a lot of things where R is a much 
>> better choice than Excel,
>> but there are a few things where it really makes sense  to use spreadsheets.
>> 
>> Spreadsheets offer a totally different paradigm to work with data, or more 
>> generally,
>> numbers and formulas.
>> One can interact with the data directly, not hide them behind variable names.
>> And, the interaction is haptic, gesture based, not expressed as a language.
>> 
>> Rearranging the layout of a pivot table by dragging variable “blocks”
>> is very intuitive and something which R itself doe not offer
>> (in fact, I wrote an add-in for R Commander to implement it).
>> 
>> Of course, Excel is not a good chice for a polished reproducible workflow.
>> But I think quite a few people (including me), when starting a new project,
>> are not ready immediately to set up this “perfect” workflow,
>> and it is much easier to experiment with the data with a spreadsheet based
>> interface.
>> 
>> For me, working with spreadsheets is more like improvising some Jazz,
>> and writing R code is like writing a score for a composition.
>> 
>> 
>> 
>> 
>> 
>>> On 29 Dec 2016, at 00:15, Rolf Turner  wrote:
>>> 
>>> On 29/12/16 10:45, Bryan Mac wrote:
 Hi,
 
 How do I export results from R to Excel in a format-friendly way? For
 example, when I copy and paste my results into excel, the formatting
 is messed up.
>>> 
>>> 
>>> Short answer:  *Don't*.  ("Friends don't let friends use excel for 
>>> statistics.")
>>> 
>>> Longer answer:  Googling on "export R data to excel" yields lots of 
>>> "useful" hits --- "useful" given the (false) assertion that it is useful to 
>>> export things to excel.
>>> 
>>> cheers,
>>> 
>>> Rolf Turner
>>> 
>>> --
>>> Technical Editor ANZJS
>>> Department of Statistics
>>> University of Auckland
>>> Phone: +64-9-373-7599 ext. 88276
>>> 
>>> __
>>> 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.

__
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 

Re: [R] Export R output in Excel

2016-12-29 Thread William Michels via R-help
Hi Bryan (and Petr),

If you want to write tsv-style data from R to clipboard on a Mac (e.g.
for pasting into Numbers), you should do:

> x1 <- matrix(1:6, nrow =2)

> clip <- pipe("pbcopy", "w")
> write.table(x1, file=clip, sep = "\t", row.names = FALSE, fileEncoding = 
> "UTF-8" )
> close(clip)
> gc()

> ?write.table
> ?connections

Adding an extra call to gc() (garbage collection) after writing to
clipboard will
close all unused connections (useful if a connection has been entered
incorrectly).

HTH,

Bill
William Michels, Ph.D.

http://stackoverflow.com/questions/14547069/how-to-write-from-r-to-the-clipboard-on-a-mac
http://stackoverflow.com/questions/30445875/what-exactly-is-a-connection-in-r


On Wed, Dec 28, 2016 at 11:14 PM, PIKAL Petr <petr.pi...@precheza.cz> wrote:
> Hi
>
> For rectangular data
>
> write.table(tab, "clipboard", sep = "\t", row.names = F)
> followed by Ctrl-V in Excel
>
> or
> write.table(tab, "somefile.xls", sep = "\t", row.names = F)
>
> For free format output like summary(somefit) I prefer to copy it to Word and 
> use font like  Courier New with monospaced letters
>
> Cheers
> Petr
>
>
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bryan Mac
>> Sent: Wednesday, December 28, 2016 10:45 PM
>> To: R-help@r-project.org
>> Subject: [R] Export R output in Excel
>>
>> Hi,
>>
>> How do I export results from R to Excel in a format-friendly way? For
>> example, when I copy and paste my results into excel, the formatting is
>> messed up.
>>
>> Thanks.
>>
>> Bryan Mac
>> bryanmac...@gmail.com
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-
>> guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> 
> Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou 
> určeny pouze jeho adresátům.
> Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
> jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
> svého systému.
> Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
> jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
> Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
> zpožděním přenosu e-mailu.
>
> V případě, že je tento e-mail součástí obchodního jednání:
> - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, 
> a to z jakéhokoliv důvodu i bez uvedení důvodu.
> - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
> Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany 
> příjemce s dodatkem či odchylkou.
> - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
> dosažením shody na všech jejích náležitostech.
> - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
> žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
> pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu 
> případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je 
> adresátovi či osobě jím zastoupené známá.
>
> This e-mail and any documents attached to it may be confidential and are 
> intended only for its intended recipients.
> If you received this e-mail by mistake, please immediately inform its sender. 
> Delete the contents of this e-mail with all attachments and its copies from 
> your system.
> If you are not the intended recipient of this e-mail, you are not authorized 
> to use, disseminate, copy or disclose this e-mail in any manner.
> The sender of this e-mail shall not be liable for any possible damage caused 
> by modifications of the e-mail or by delay with transfer of the email.
>
> In case that this e-mail forms part of business dealings:
> - the sender reserves the right to end negotiations about entering into a 
> contract in any time, for any reason, and without stating any reasoning.
> - if the e-mail contains an offer, the recipient is entitled to immediately 
> accept such offer; The sender of this e-mail (offer) excludes any acceptance 
> of the offer on the part of the recipient containing any amendment or 
> variation.
> - the sender insists on that the respective contract is concluded only upon 
> an express mutual agreement on all its aspects.

Re: [R] [FORGED] Export R output in Excel

2016-12-29 Thread Bert Gunter
Oh nuts! I replied all. I apologize for the noise!

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 Thu, Dec 29, 2016 at 6:40 AM, Bert Gunter  wrote:
> (Private -- as this is just my personal opinion and not really helpful).
>
> I found your comments informative. Thank you.
>
> My own experience with scientific colleagues -- biologists mostly --
> who use Excel in the way that you describe is that the "haptic" (great
> word!) ease with which they manipulate the data almost inevitably
> results in errors. That is, the *lack* of enforced structure in Excel
> allows them to do things that they shouldn't or don't mean to do,
> typically without raising any flags, typically causing downstream
> errors that can be hard to trace. Irreproducibility follows.
>
> My point is that the structure that you consider burdensome -- at
> least initially -- is desirable exactly because it forces them to
> think more carefully about what they are doing. Debugging, or worse
> yet, failure to realize that debugging is needed, takes far more time
> and is far more consequential.
>
> As I said, just my opinion, no reply necessary, and I do appreciate
> your thoughtful remarks.
>
> Best,
> Bert Gunter
>
> 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 Thu, Dec 29, 2016 at 2:16 AM, Erich Subscriptions
>  wrote:
>> Well, my few cents again.
>> the packages
>> openxslx and xlsx allow to write dataframes as Excel sheets.
>> (xlsx is Java based, so it has more requirements to run than openxlsx,
>> which is just C++ based)
>>
>> On Windows, R tools for Visual Studio allows Excel export.
>> For Windows, there also is our Excel add-in RExcel allowing
>> to use R from within Excel, and the R package rcom
>> which also allows to interact with Excel from R (more than just writing 
>> Excel workbooks).
>> Our products (rcom and RExcel), however, are not unter a FOSS license.
>>
>> And a more general remark: There are a lot of things where R is a much 
>> better choice than Excel,
>> but there are a few things where it really makes sense  to use spreadsheets.
>>
>> Spreadsheets offer a totally different paradigm to work with data, or more 
>> generally,
>> numbers and formulas.
>> One can interact with the data directly, not hide them behind variable names.
>> And, the interaction is haptic, gesture based, not expressed as a language.
>>
>> Rearranging the layout of a pivot table by dragging variable “blocks”
>> is very intuitive and something which R itself doe not offer
>> (in fact, I wrote an add-in for R Commander to implement it).
>>
>> Of course, Excel is not a good chice for a polished reproducible workflow.
>> But I think quite a few people (including me), when starting a new project,
>> are not ready immediately to set up this “perfect” workflow,
>> and it is much easier to experiment with the data with a spreadsheet based
>> interface.
>>
>> For me, working with spreadsheets is more like improvising some Jazz,
>> and writing R code is like writing a score for a composition.
>>
>>
>>
>>
>>
>>> On 29 Dec 2016, at 00:15, Rolf Turner  wrote:
>>>
>>> On 29/12/16 10:45, Bryan Mac wrote:
 Hi,

 How do I export results from R to Excel in a format-friendly way? For
 example, when I copy and paste my results into excel, the formatting
 is messed up.
>>>
>>>
>>> Short answer:  *Don't*.  ("Friends don't let friends use excel for 
>>> statistics.")
>>>
>>> Longer answer:  Googling on "export R data to excel" yields lots of 
>>> "useful" hits --- "useful" given the (false) assertion that it is useful to 
>>> export things to excel.
>>>
>>> cheers,
>>>
>>> Rolf Turner
>>>
>>> --
>>> Technical Editor ANZJS
>>> Department of Statistics
>>> University of Auckland
>>> Phone: +64-9-373-7599 ext. 88276
>>>
>>> __
>>> 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.

__
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 

Re: [R] [FORGED] Export R output in Excel

2016-12-29 Thread Bert Gunter
(Private -- as this is just my personal opinion and not really helpful).

I found your comments informative. Thank you.

My own experience with scientific colleagues -- biologists mostly --
who use Excel in the way that you describe is that the "haptic" (great
word!) ease with which they manipulate the data almost inevitably
results in errors. That is, the *lack* of enforced structure in Excel
allows them to do things that they shouldn't or don't mean to do,
typically without raising any flags, typically causing downstream
errors that can be hard to trace. Irreproducibility follows.

My point is that the structure that you consider burdensome -- at
least initially -- is desirable exactly because it forces them to
think more carefully about what they are doing. Debugging, or worse
yet, failure to realize that debugging is needed, takes far more time
and is far more consequential.

As I said, just my opinion, no reply necessary, and I do appreciate
your thoughtful remarks.

Best,
Bert Gunter

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 Thu, Dec 29, 2016 at 2:16 AM, Erich Subscriptions
 wrote:
> Well, my few cents again.
> the packages
> openxslx and xlsx allow to write dataframes as Excel sheets.
> (xlsx is Java based, so it has more requirements to run than openxlsx,
> which is just C++ based)
>
> On Windows, R tools for Visual Studio allows Excel export.
> For Windows, there also is our Excel add-in RExcel allowing
> to use R from within Excel, and the R package rcom
> which also allows to interact with Excel from R (more than just writing Excel 
> workbooks).
> Our products (rcom and RExcel), however, are not unter a FOSS license.
>
> And a more general remark: There are a lot of things where R is a much better 
> choice than Excel,
> but there are a few things where it really makes sense  to use spreadsheets.
>
> Spreadsheets offer a totally different paradigm to work with data, or more 
> generally,
> numbers and formulas.
> One can interact with the data directly, not hide them behind variable names.
> And, the interaction is haptic, gesture based, not expressed as a language.
>
> Rearranging the layout of a pivot table by dragging variable “blocks”
> is very intuitive and something which R itself doe not offer
> (in fact, I wrote an add-in for R Commander to implement it).
>
> Of course, Excel is not a good chice for a polished reproducible workflow.
> But I think quite a few people (including me), when starting a new project,
> are not ready immediately to set up this “perfect” workflow,
> and it is much easier to experiment with the data with a spreadsheet based
> interface.
>
> For me, working with spreadsheets is more like improvising some Jazz,
> and writing R code is like writing a score for a composition.
>
>
>
>
>
>> On 29 Dec 2016, at 00:15, Rolf Turner  wrote:
>>
>> On 29/12/16 10:45, Bryan Mac wrote:
>>> Hi,
>>>
>>> How do I export results from R to Excel in a format-friendly way? For
>>> example, when I copy and paste my results into excel, the formatting
>>> is messed up.
>>
>>
>> Short answer:  *Don't*.  ("Friends don't let friends use excel for 
>> statistics.")
>>
>> Longer answer:  Googling on "export R data to excel" yields lots of "useful" 
>> hits --- "useful" given the (false) assertion that it is useful to export 
>> things to excel.
>>
>> cheers,
>>
>> Rolf Turner
>>
>> --
>> Technical Editor ANZJS
>> Department of Statistics
>> University of Auckland
>> Phone: +64-9-373-7599 ext. 88276
>>
>> __
>> 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.

__
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] Export R output in Excel

2016-12-29 Thread Bryan Mac
Hi Jim,

Your assumption is correct. When running the analyses in R and want to export 
the output that appears in the console window to Excel(.csv) file.
I believe it is easier to do if the export it done to an Excel (.CSV) file.

So is there a way to export the analyses in the console window to a .CSV file 
with the good formatting ?
I am looking to export the whole output if possible. 

I found this code, but it doesn’t cover the whole output of the console. 

write.csv(coef(summary(test)), file=“test.csv”)

My whole output consists of descriptives and regressions. 

Best,

Bryan Mac
bryanmac...@gmail.com



> On Dec 28, 2016, at 6:33 PM, Jim Lemon  wrote:
> 
> Hi Bryan,
> When I have to do something like this, I usually go through HTML
> output and import it into MS Word. I am not suggesting that this is
> the best thing to do, but it might get you out of trouble. I'm not
> sure whether importing HTML into Excel will work as well. I assume
> that you are running analyses in R and want to export the output that
> appears in the console window. If so, try producing HTML output with
> the prettyR or R2HTML packages and importing it. There are other ways
> to do this, but the learning curve is steep and you might not want to
> climb it right now.
> 
> Jim
> 
> 
> On Thu, Dec 29, 2016 at 8:45 AM, Bryan Mac  wrote:
>> Hi,
>> 
>> How do I export results from R to Excel in a format-friendly way? For 
>> example, when I copy and paste my results into excel, the formatting is 
>> messed up.
>> 
>> Thanks.
>> 
>> Bryan Mac
>> bryanmac...@gmail.com
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

__
R-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] Export R output in Excel

2016-12-29 Thread Spencer Graves
  The "writeFindFn2xls" function in the sos package include 3 
different ways to write an Excel workbook, depending on which packages, 
etc., you have installed.  I wrote that, because I could not find one 
contributed package that as easy to install on every operating system.  
This writes an Excel workbook with 3 sheets. That may not be what you 
want, but it might provide other options.



Spencer Graves

On 2016-12-29 3:19 AM, Jim Lemon wrote:

Hi Bryan,
What functions like "htmlize" (prettyR) do is format the basic R
output into HTML tables with the option of interspersed graphics.
While I usually stop at the HTML stage, the output files can be
imported into Word for those who cannot work out how to open them with
an HTML browser. I just tried the example for "htmlize" and it imports
into Libre Office Writer fine, but doesn't fit so well into Libre
Office Calc, which does not bode well for an import into Excel. At
best you will get formatted output, but you cannot play with the
numbers as you would in a spreadsheet. Petr's suggestion, which I just
read, is an alternative that may be more useful to you.

Jim


On Thu, Dec 29, 2016 at 2:58 PM, Bryan Mac <bryanmac...@gmail.com> wrote:

Hi Jim,

Your assumption is correct. When running the analyses in R and want to export 
the output that appears in the console window to Excel(.csv) file.
I believe it is easier to do if the export it done to an Excel (.CSV) file.

So is there a way to export the analyses in the console window to a .CSV file 
with the good formatting ?
I am looking to export the whole output if possible.

I found this code, but it doesn’t cover the whole output of the console.

write.csv(coef(summary(test)), file=“test.csv”)

My whole output consists of descriptives and regressions.

Best,

Bryan Mac
bryanmac...@gmail.com




On Dec 28, 2016, at 6:33 PM, Jim Lemon <drjimle...@gmail.com> wrote:

Hi Bryan,
When I have to do something like this, I usually go through HTML
output and import it into MS Word. I am not suggesting that this is
the best thing to do, but it might get you out of trouble. I'm not
sure whether importing HTML into Excel will work as well. I assume
that you are running analyses in R and want to export the output that
appears in the console window. If so, try producing HTML output with
the prettyR or R2HTML packages and importing it. There are other ways
to do this, but the learning curve is steep and you might not want to
climb it right now.

Jim


On Thu, Dec 29, 2016 at 8:45 AM, Bryan Mac <bryanmac...@gmail.com> wrote:

Hi,

How do I export results from R to Excel in a format-friendly way? For example, 
when I copy and paste my results into excel, the formatting is messed up.

Thanks.

Bryan Mac
bryanmac...@gmail.com

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

__
R-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] [FORGED] Export R output in Excel

2016-12-29 Thread peter dalgaard
I don't really disagree with the below, but part of the issue is that analyses 
do not typically output results in data frame like formats (neither in the 
textual form or as R objects). Some people have attacked this issue by 
wrangling output into data frames, check the "broom" package.

(The ideology of sweeping much of the flexibility of R away by turning all data 
structures into data sets strikes me a bit much like reinventing SAS, but this 
might be a spot where it comes in useful.)

-pd

> On 29 Dec 2016, at 01:05 , Rolf Turner <r.tur...@auckland.ac.nz> wrote:
> 
> On 29/12/16 12:48, Bryan Mac wrote:
>> Hi Rolf,
>> 
>> I wanted to export the output/results of R to an Excel file for
>> easier comparisons/reporting. When I tried to copy and paste my
>> output to an excel file the formatting was off. I want to export my
>> descriptive stats and the linear regression.
> 
> This makes little to no sense to me.  Spreadsheets are for use in storing 
> data, not for displaying the output of analyses.  (I know that Excel users do 
> this sort of thing, but then people do all sorts of irrational things.)
> 
>> I googled “Export R output to excel” but did not find most of the
>> hints “useful”. if anything, it got me more confused.
>> 
>> Thanks.
> 
> (1) The best advice is still "*Don't*."
> 
> (2) You do not need Excel to make comparisons and report.  In fact it is a 
> handicap.  Re-think your strategy.
> 
> (3) If you insist in proceeding in a wrong-headed manner, isn't the item 
> about XLConnect (3rd answer, 1st hit) "useful"?
> 
> cheers,
> 
> Rolf Turner
> 
> -- 
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
> 
> __
> 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

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

Re: [R] [FORGED] Export R output in Excel

2016-12-29 Thread Erich Subscriptions
Well, my few cents again.
the packages
openxslx and xlsx allow to write dataframes as Excel sheets.
(xlsx is Java based, so it has more requirements to run than openxlsx,
which is just C++ based)

On Windows, R tools for Visual Studio allows Excel export.
For Windows, there also is our Excel add-in RExcel allowing
to use R from within Excel, and the R package rcom
which also allows to interact with Excel from R (more than just writing Excel 
workbooks).
Our products (rcom and RExcel), however, are not unter a FOSS license.

And a more general remark: There are a lot of things where R is a much better 
choice than Excel,
but there are a few things where it really makes sense  to use spreadsheets.

Spreadsheets offer a totally different paradigm to work with data, or more 
generally,
numbers and formulas. 
One can interact with the data directly, not hide them behind variable names.
And, the interaction is haptic, gesture based, not expressed as a language.

Rearranging the layout of a pivot table by dragging variable “blocks”
is very intuitive and something which R itself doe not offer
(in fact, I wrote an add-in for R Commander to implement it).

Of course, Excel is not a good chice for a polished reproducible workflow.
But I think quite a few people (including me), when starting a new project,
are not ready immediately to set up this “perfect” workflow,
and it is much easier to experiment with the data with a spreadsheet based
interface.

For me, working with spreadsheets is more like improvising some Jazz,
and writing R code is like writing a score for a composition.





> On 29 Dec 2016, at 00:15, Rolf Turner  wrote:
> 
> On 29/12/16 10:45, Bryan Mac wrote:
>> Hi,
>> 
>> How do I export results from R to Excel in a format-friendly way? For
>> example, when I copy and paste my results into excel, the formatting
>> is messed up.
> 
> 
> Short answer:  *Don't*.  ("Friends don't let friends use excel for 
> statistics.")
> 
> Longer answer:  Googling on "export R data to excel" yields lots of "useful" 
> hits --- "useful" given the (false) assertion that it is useful to export 
> things to excel.
> 
> cheers,
> 
> Rolf Turner
> 
> -- 
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
> 
> __
> 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] Export R output in Excel

2016-12-29 Thread Jim Lemon
Hi Bryan,
What functions like "htmlize" (prettyR) do is format the basic R
output into HTML tables with the option of interspersed graphics.
While I usually stop at the HTML stage, the output files can be
imported into Word for those who cannot work out how to open them with
an HTML browser. I just tried the example for "htmlize" and it imports
into Libre Office Writer fine, but doesn't fit so well into Libre
Office Calc, which does not bode well for an import into Excel. At
best you will get formatted output, but you cannot play with the
numbers as you would in a spreadsheet. Petr's suggestion, which I just
read, is an alternative that may be more useful to you.

Jim


On Thu, Dec 29, 2016 at 2:58 PM, Bryan Mac <bryanmac...@gmail.com> wrote:
> Hi Jim,
>
> Your assumption is correct. When running the analyses in R and want to export 
> the output that appears in the console window to Excel(.csv) file.
> I believe it is easier to do if the export it done to an Excel (.CSV) file.
>
> So is there a way to export the analyses in the console window to a .CSV file 
> with the good formatting ?
> I am looking to export the whole output if possible.
>
> I found this code, but it doesn’t cover the whole output of the console.
>
> write.csv(coef(summary(test)), file=“test.csv”)
>
> My whole output consists of descriptives and regressions.
>
> Best,
>
> Bryan Mac
> bryanmac...@gmail.com
>
>
>
>> On Dec 28, 2016, at 6:33 PM, Jim Lemon <drjimle...@gmail.com> wrote:
>>
>> Hi Bryan,
>> When I have to do something like this, I usually go through HTML
>> output and import it into MS Word. I am not suggesting that this is
>> the best thing to do, but it might get you out of trouble. I'm not
>> sure whether importing HTML into Excel will work as well. I assume
>> that you are running analyses in R and want to export the output that
>> appears in the console window. If so, try producing HTML output with
>> the prettyR or R2HTML packages and importing it. There are other ways
>> to do this, but the learning curve is steep and you might not want to
>> climb it right now.
>>
>> Jim
>>
>>
>> On Thu, Dec 29, 2016 at 8:45 AM, Bryan Mac <bryanmac...@gmail.com> wrote:
>>> Hi,
>>>
>>> How do I export results from R to Excel in a format-friendly way? For 
>>> example, when I copy and paste my results into excel, the formatting is 
>>> messed up.
>>>
>>> Thanks.
>>>
>>> Bryan Mac
>>> bryanmac...@gmail.com
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>

__
R-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] Export R output in Excel

2016-12-29 Thread John Dougherty
On Wed, 28 Dec 2016 13:45:25 -0800
Bryan Mac <bryanmac...@gmail.com> wrote:

> Hi,
> 
> How do I export results from R to Excel in a format-friendly way? For
> example, when I copy and paste my results into excel, the formatting
> is messed up.
> 
> Thanks.
>  
> Bryan Mac
> bryanmac...@gmail.com
>
Your purpose is not clear.  If you are planning to do MORE statistical
work with excel using R output, don't do it.  Learn the R equivalents.
There's nothing that you can do in Excel that can't be done in R.  And,
while Microsoft has made great strides in the reliability of it's
numbers and calculating routines, it is still a spreadsheet.

If you want to add tabular data to a word file from R, out
put it to a csv or tab delimited format and then copy into Word or
LibreOffice Writer. From there you can select the text of the table and
transform it into a table using the table menu. If you want formatted
statistical output, you can sink() the output to an asscii or utf
text file, paste it into Word and then convert the font of the pasted
segment to a fixed pitch font.  R output tends to follow the old-time
typewriter approach to formatting (spaces and tabs), meaning that kerned
fonts behave in horrible ways, fonts are rubbery, etc.


-- 

John

__
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] Export R output in Excel

2016-12-28 Thread PIKAL Petr
Hi

For rectangular data

write.table(tab, "clipboard", sep = "\t", row.names = F)
followed by Ctrl-V in Excel

or
write.table(tab, "somefile.xls", sep = "\t", row.names = F)

For free format output like summary(somefit) I prefer to copy it to Word and 
use font like  Courier New with monospaced letters

Cheers
Petr


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bryan Mac
> Sent: Wednesday, December 28, 2016 10:45 PM
> To: R-help@r-project.org
> Subject: [R] Export R output in Excel
>
> Hi,
>
> How do I export results from R to Excel in a format-friendly way? For
> example, when I copy and paste my results into excel, the formatting is
> messed up.
>
> Thanks.
>
> Bryan Mac
> bryanmac...@gmail.com
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


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

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

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

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Export R output in Excel

2016-12-28 Thread Omar André Gonzáles Díaz
use "write.csv("you-df", "name-of-file.csv", row.names = FALSE).

And Google please, as others have suggested.

2016-12-28 21:33 GMT-05:00 Jim Lemon :

> Hi Bryan,
> When I have to do something like this, I usually go through HTML
> output and import it into MS Word. I am not suggesting that this is
> the best thing to do, but it might get you out of trouble. I'm not
> sure whether importing HTML into Excel will work as well. I assume
> that you are running analyses in R and want to export the output that
> appears in the console window. If so, try producing HTML output with
> the prettyR or R2HTML packages and importing it. There are other ways
> to do this, but the learning curve is steep and you might not want to
> climb it right now.
>
> Jim
>
>
> On Thu, Dec 29, 2016 at 8:45 AM, Bryan Mac  wrote:
> > Hi,
> >
> > How do I export results from R to Excel in a format-friendly way? For
> example, when I copy and paste my results into excel, the formatting is
> messed up.
> >
> > Thanks.
> >
> > Bryan Mac
> > bryanmac...@gmail.com
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Export R output in Excel

2016-12-28 Thread Jim Lemon
Hi Bryan,
When I have to do something like this, I usually go through HTML
output and import it into MS Word. I am not suggesting that this is
the best thing to do, but it might get you out of trouble. I'm not
sure whether importing HTML into Excel will work as well. I assume
that you are running analyses in R and want to export the output that
appears in the console window. If so, try producing HTML output with
the prettyR or R2HTML packages and importing it. There are other ways
to do this, but the learning curve is steep and you might not want to
climb it right now.

Jim


On Thu, Dec 29, 2016 at 8:45 AM, Bryan Mac  wrote:
> Hi,
>
> How do I export results from R to Excel in a format-friendly way? For 
> example, when I copy and paste my results into excel, the formatting is 
> messed up.
>
> Thanks.
>
> Bryan Mac
> bryanmac...@gmail.com
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-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] [FORGED] Export R output in Excel

2016-12-28 Thread Bryan Mac
Hi Rolf,

I wanted to export the output/results of R to an Excel file for easier 
comparisons/reporting. When I tried to copy and paste my output to an excel 
file the formatting was off.
I want to export my descriptive stats and the linear regression.

I googled “Export R output to excel” but did not find most of the hints 
“useful”. if anything, it got me more confused. 

Thanks.

Bryan Mac
bryanmac...@gmail.com



> On Dec 28, 2016, at 3:15 PM, Rolf Turner <r.tur...@auckland.ac.nz> wrote:
> 
> On 29/12/16 10:45, Bryan Mac wrote:
>> Hi,
>> 
>> How do I export results from R to Excel in a format-friendly way? For
>> example, when I copy and paste my results into excel, the formatting
>> is messed up.
> 
> 
> Short answer:  *Don't*.  ("Friends don't let friends use excel for 
> statistics.")
> 
> Longer answer:  Googling on "export R data to excel" yields lots of "useful" 
> hits --- "useful" given the (false) assertion that it is useful to export 
> things to excel.
> 
> cheers,
> 
> Rolf Turner
> 
> -- 
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Export R output in Excel

2016-12-28 Thread Rolf Turner

On 29/12/16 12:48, Bryan Mac wrote:

Hi Rolf,

I wanted to export the output/results of R to an Excel file for
easier comparisons/reporting. When I tried to copy and paste my
output to an excel file the formatting was off. I want to export my
descriptive stats and the linear regression.


This makes little to no sense to me.  Spreadsheets are for use in 
storing data, not for displaying the output of analyses.  (I know that 
Excel users do this sort of thing, but then people do all sorts of 
irrational things.)



I googled “Export R output to excel” but did not find most of the
hints “useful”. if anything, it got me more confused.

Thanks.


(1) The best advice is still "*Don't*."

(2) You do not need Excel to make comparisons and report.  In fact it is 
a handicap.  Re-think your strategy.


(3) If you insist in proceeding in a wrong-headed manner, isn't the item 
about XLConnect (3rd answer, 1st hit) "useful"?


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Export R output in Excel

2016-12-28 Thread Rolf Turner

On 29/12/16 10:45, Bryan Mac wrote:

Hi,

How do I export results from R to Excel in a format-friendly way? For
example, when I copy and paste my results into excel, the formatting
is messed up.



Short answer:  *Don't*.  ("Friends don't let friends use excel for 
statistics.")


Longer answer:  Googling on "export R data to excel" yields lots of 
"useful" hits --- "useful" given the (false) assertion that it is useful 
to export things to excel.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Export R output in Excel

2016-12-28 Thread Bryan Mac
Hi,

How do I export results from R to Excel in a format-friendly way? For example, 
when I copy and paste my results into excel, the formatting is messed up.

Thanks.
 
Bryan Mac
bryanmac...@gmail.com

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


Re: [R] output

2016-12-12 Thread Marc Schwartz
Hi,

With the WriteXLS() function, from the package of the same name, if you specify 
'.xlsx' for the file name extension, the function will create an Excel 2007 
compatible file, which can handle worksheets of up to 1,048,576 rows by 16,384 
columns.

Thus:

  WriteXLS(dat, "test4.xlsx", row.names = FALSE)

That is all described in the help file for the function.

Regards,

Marc Schwartz


> On Dec 12, 2016, at 6:51 PM, Val  wrote:
> 
> Hi all,
> 
> I have a data frame with more than 100,000 rows.
> 
> datx <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }
> dat <- datx(11,10,2)
> 
> 1)
> WriteXLS(dat, "test4.xls", row.names=FALSE)
> Error in WriteXLS(dat, "test4.xls", row.names = FALSE) :
>  One or more of the data frames named in 'x' exceeds 65,535 rows or 256 
> columns
> 
> I noticed that *.xls has  row and column limitations.
> 
> How can I take the excess row to the next sheet?
> 
> 2) I also tried to use xlsx and have a problem
> 
> write.xlsx(dat, "test3.xlsx",sheetName="sheet1", row.names=FALSE)
> Error in .jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook") :
>  java.lang.OutOfMemoryError: Java heap
> space.jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook") class "jobjRef">
> 
> Any help ?
> Thank you in advance
> 
> __
> 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] output

2016-12-12 Thread Jeff Newmiller
1) I recommend against using xls for very large data sets. (Not that xlsx is 
really that much better.) If you really think this is necessary you will 
probably need to split the data frame and write each element of the resulting 
list. See ?split.

2) Google tells me (as it could have told you) that you could choose another 
package or increase your memory allocation to java. [1] If you encounter bugs 
in packages, don't forget to use the maintainer() function as mentioned in the 
Posting Guide. 

[1] http://stackoverflow.com/questions/19147884/importing-a-big-xlsx-file-into-r
-- 
Sent from my phone. Please excuse my brevity.

On December 12, 2016 4:51:24 PM PST, Val  wrote:
>Hi all,
>
>I have a data frame with more than 100,000 rows.
>
>datx <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }
>dat <- datx(11,10,2)
>
>1)
>WriteXLS(dat, "test4.xls", row.names=FALSE)
>Error in WriteXLS(dat, "test4.xls", row.names = FALSE) :
>One or more of the data frames named in 'x' exceeds 65,535 rows or 256
>columns
>
>I noticed that *.xls has  row and column limitations.
>
>How can I take the excess row to the next sheet?
>
>2) I also tried to use xlsx and have a problem
>
>write.xlsx(dat, "test3.xlsx",sheetName="sheet1", row.names=FALSE)
>Error in .jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook") :
>  java.lang.OutOfMemoryError: Java heap
>space.jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook")class "jobjRef">
>
>Any help ?
>Thank you in advance
>
>__
>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.


[R] output

2016-12-12 Thread Val
Hi all,

I have a data frame with more than 100,000 rows.

datx <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }
dat <- datx(11,10,2)

1)
WriteXLS(dat, "test4.xls", row.names=FALSE)
Error in WriteXLS(dat, "test4.xls", row.names = FALSE) :
  One or more of the data frames named in 'x' exceeds 65,535 rows or 256 columns

I noticed that *.xls has  row and column limitations.

How can I take the excess row to the next sheet?

2) I also tried to use xlsx and have a problem

write.xlsx(dat, "test3.xlsx",sheetName="sheet1", row.names=FALSE)
Error in .jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook") :
  java.lang.OutOfMemoryError: Java heap
space.jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook")

Any help ?
Thank you in advance

__
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] Output formatting in PDF

2016-10-11 Thread Duncan Mackay
Hi

There is also the basic option of using the grid package and viewports.
You can then place the plots where you want and annotate them

pdf(file= paste0("01", ".pdf"),
height  = 3.5,
width   = 7,
paper   = "special",
onefile = TRUE,
family  = "Helvetica",
pointsize = 12,
colormodel = "rgb")

vpl <- viewport(x = 0.25, y = 0.5, width = 0.45, height = 0.9)
pushViewport(vpl)
grid.rect(gp = gpar(lty = "dashed"))
popViewport()

vpr <- viewport(x = 0.75, y = 0.5, width = 0.45, height = 0.9)
pushViewport(vpr)
grid.rect(gp = gpar(lty = "dashed"))
grid.circle(x = 0.6, y = 0.4, r = 0.3)
popViewport()

dev.off()

In your case you may need to have a viewport of the whole page

see  http://www.amstat.org/publications/jse/v18n3/zhou.pdf for examples

also have a look at the grid.clip function

Regards

Duncan Mackay

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Preetam Pal
Sent: Tuesday, 11 October 2016 19:14
To: r-help@r-project.org
Subject: [R] Output formatting in PDF

Hi,

Can you please help me with the following output formatting:
I am planning to include 2 plots and some general description in a one-page
PDF document, such that

   - I'll leave some appropriate margin on the PDF- say, 1.5 inches
   top,right, bottom and left (will decide based on overall appearance)
   - the 2 plots are placed side-by-side (looks best for comparison)
   - the margins for each plot can be 4 lines on the top and the bottom &
2 lines on the left and the right
   - each of these 2 plots would have time (0 to 260) along x-axis and two
   time-series (daily USD-GBP and USD-EUR FX rates) on the y-axis, i.e. 2
   time-series would be plotted on each of the 2 graphs. I would need a
   different color for each plot to demarcate them
   - I need to add some text (eg: "Independent analysis of Exchange Rate
   dynamics") with reduced font size (not high priority though-just good to
   have a different size)
   - The general discussion (may be a paragraph) would come right below the
   2 plots - I can specify this text as an argument in a function, may be. I
   am not sure how to arrange the entire PDF as per the format I mentioned
   above

I shall really appreciate any help with this - the time series analysis is
not difficult, I can manage that - however, I don't know how to manage the
formatting part though, so that the 1-pager output looks decently
presentable. Thanks.

Regards,
Preetam

[[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] Output formatting in PDF

2016-10-11 Thread Dominik Schneider
You may be able to do everything you need with the cowplot package.

On Tue, Oct 11, 2016 at 4:26 AM, Preetam Pal  wrote:

> Hey Enrico,
> LaTex is not possible actually.
>
> On Tue, Oct 11, 2016 at 2:29 PM, Enrico Schumann 
> wrote:
>
> > On Tue, 11 Oct 2016, Preetam Pal  writes:
> >
> > > Hi,
> > >
> > > Can you please help me with the following output formatting:
> > > I am planning to include 2 plots and some general description in a
> > one-page
> > > PDF document, such that
> > >
> > >- I'll leave some appropriate margin on the PDF- say, 1.5 inches
> > >top,right, bottom and left (will decide based on overall appearance)
> > >- the 2 plots are placed side-by-side (looks best for comparison)
> > >- the margins for each plot can be 4 lines on the top and the
> bottom &
> > > 2 lines on the left and the right
> > >- each of these 2 plots would have time (0 to 260) along x-axis and
> > two
> > >time-series (daily USD-GBP and USD-EUR FX rates) on the y-axis,
> i.e. 2
> > >time-series would be plotted on each of the 2 graphs. I would need a
> > >different color for each plot to demarcate them
> > >- I need to add some text (eg: "Independent analysis of Exchange
> Rate
> > >dynamics") with reduced font size (not high priority though-just
> good
> > to
> > >have a different size)
> > >- The general discussion (may be a paragraph) would come right below
> > the
> > >2 plots - I can specify this text as an argument in a function, may
> > be. I
> > >am not sure how to arrange the entire PDF as per the format I
> > mentioned
> > >above
> > >
> > > I shall really appreciate any help with this - the time series analysis
> > is
> > > not difficult, I can manage that - however, I don't know how to manage
> > the
> > > formatting part though, so that the 1-pager output looks decently
> > > presentable. Thanks.
> > >
> > > Regards,
> > > Preetam
> >
> > If using LaTeX is an option, I would suggest
> > ?Sweave. There are many tutorials on the web that
> > should get you started.
> >
> >
> > --
> > Enrico Schumann
> > Lucerne, Switzerland
> > http://enricoschumann.net
> >
>
>
>
> --
> Preetam Pal
> (+91)-9432212774
> M-Stat 2nd Year, Room No. N-114
> Statistics Division,   C.V.Raman
> Hall
> Indian Statistical Institute, B.H.O.S.
> Kolkata.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Output formatting in PDF

2016-10-11 Thread Preetam Pal
Hey Enrico,
LaTex is not possible actually.

On Tue, Oct 11, 2016 at 2:29 PM, Enrico Schumann 
wrote:

> On Tue, 11 Oct 2016, Preetam Pal  writes:
>
> > Hi,
> >
> > Can you please help me with the following output formatting:
> > I am planning to include 2 plots and some general description in a
> one-page
> > PDF document, such that
> >
> >- I'll leave some appropriate margin on the PDF- say, 1.5 inches
> >top,right, bottom and left (will decide based on overall appearance)
> >- the 2 plots are placed side-by-side (looks best for comparison)
> >- the margins for each plot can be 4 lines on the top and the bottom &
> > 2 lines on the left and the right
> >- each of these 2 plots would have time (0 to 260) along x-axis and
> two
> >time-series (daily USD-GBP and USD-EUR FX rates) on the y-axis, i.e. 2
> >time-series would be plotted on each of the 2 graphs. I would need a
> >different color for each plot to demarcate them
> >- I need to add some text (eg: "Independent analysis of Exchange Rate
> >dynamics") with reduced font size (not high priority though-just good
> to
> >have a different size)
> >- The general discussion (may be a paragraph) would come right below
> the
> >2 plots - I can specify this text as an argument in a function, may
> be. I
> >am not sure how to arrange the entire PDF as per the format I
> mentioned
> >above
> >
> > I shall really appreciate any help with this - the time series analysis
> is
> > not difficult, I can manage that - however, I don't know how to manage
> the
> > formatting part though, so that the 1-pager output looks decently
> > presentable. Thanks.
> >
> > Regards,
> > Preetam
>
> If using LaTeX is an option, I would suggest
> ?Sweave. There are many tutorials on the web that
> should get you started.
>
>
> --
> Enrico Schumann
> Lucerne, Switzerland
> http://enricoschumann.net
>



-- 
Preetam Pal
(+91)-9432212774
M-Stat 2nd Year, Room No. N-114
Statistics Division,   C.V.Raman
Hall
Indian Statistical Institute, B.H.O.S.
Kolkata.

[[alternative HTML version deleted]]

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


Re: [R] Output formatting in PDF

2016-10-11 Thread Jeff Newmiller
Or package "knitr". Note that knitr can be used with LaTeX or markdown syntax, 
but from your description the former would be advised. 
-- 
Sent from my phone. Please excuse my brevity.

On October 11, 2016 1:59:59 AM PDT, Enrico Schumann  
wrote:
>On Tue, 11 Oct 2016, Preetam Pal  writes:
>
>> Hi,
>>
>> Can you please help me with the following output formatting:
>> I am planning to include 2 plots and some general description in a
>one-page
>> PDF document, such that
>>
>>- I'll leave some appropriate margin on the PDF- say, 1.5 inches
>>top,right, bottom and left (will decide based on overall
>appearance)
>>- the 2 plots are placed side-by-side (looks best for comparison)
>>- the margins for each plot can be 4 lines on the top and the
>bottom &
>> 2 lines on the left and the right
>>- each of these 2 plots would have time (0 to 260) along x-axis
>and two
>>time-series (daily USD-GBP and USD-EUR FX rates) on the y-axis,
>i.e. 2
>>time-series would be plotted on each of the 2 graphs. I would need
>a
>>different color for each plot to demarcate them
>>- I need to add some text (eg: "Independent analysis of Exchange
>Rate
>>dynamics") with reduced font size (not high priority though-just
>good to
>>have a different size)
>>- The general discussion (may be a paragraph) would come right
>below the
>>2 plots - I can specify this text as an argument in a function,
>may be. I
>>am not sure how to arrange the entire PDF as per the format I
>mentioned
>>above
>>
>> I shall really appreciate any help with this - the time series
>analysis is
>> not difficult, I can manage that - however, I don't know how to
>manage the
>> formatting part though, so that the 1-pager output looks decently
>> presentable. Thanks.
>>
>> Regards,
>> Preetam
>
>If using LaTeX is an option, I would suggest
>?Sweave. There are many tutorials on the web that
>should get you started.

__
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] Output formatting in PDF

2016-10-11 Thread Enrico Schumann
On Tue, 11 Oct 2016, Preetam Pal  writes:

> Hi,
>
> Can you please help me with the following output formatting:
> I am planning to include 2 plots and some general description in a one-page
> PDF document, such that
>
>- I'll leave some appropriate margin on the PDF- say, 1.5 inches
>top,right, bottom and left (will decide based on overall appearance)
>- the 2 plots are placed side-by-side (looks best for comparison)
>- the margins for each plot can be 4 lines on the top and the bottom &
> 2 lines on the left and the right
>- each of these 2 plots would have time (0 to 260) along x-axis and two
>time-series (daily USD-GBP and USD-EUR FX rates) on the y-axis, i.e. 2
>time-series would be plotted on each of the 2 graphs. I would need a
>different color for each plot to demarcate them
>- I need to add some text (eg: "Independent analysis of Exchange Rate
>dynamics") with reduced font size (not high priority though-just good to
>have a different size)
>- The general discussion (may be a paragraph) would come right below the
>2 plots - I can specify this text as an argument in a function, may be. I
>am not sure how to arrange the entire PDF as per the format I mentioned
>above
>
> I shall really appreciate any help with this - the time series analysis is
> not difficult, I can manage that - however, I don't know how to manage the
> formatting part though, so that the 1-pager output looks decently
> presentable. Thanks.
>
> Regards,
> Preetam

If using LaTeX is an option, I would suggest
?Sweave. There are many tutorials on the web that
should get you started.


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


[R] Output formatting in PDF

2016-10-11 Thread Preetam Pal
Hi,

Can you please help me with the following output formatting:
I am planning to include 2 plots and some general description in a one-page
PDF document, such that

   - I'll leave some appropriate margin on the PDF- say, 1.5 inches
   top,right, bottom and left (will decide based on overall appearance)
   - the 2 plots are placed side-by-side (looks best for comparison)
   - the margins for each plot can be 4 lines on the top and the bottom &
2 lines on the left and the right
   - each of these 2 plots would have time (0 to 260) along x-axis and two
   time-series (daily USD-GBP and USD-EUR FX rates) on the y-axis, i.e. 2
   time-series would be plotted on each of the 2 graphs. I would need a
   different color for each plot to demarcate them
   - I need to add some text (eg: "Independent analysis of Exchange Rate
   dynamics") with reduced font size (not high priority though-just good to
   have a different size)
   - The general discussion (may be a paragraph) would come right below the
   2 plots - I can specify this text as an argument in a function, may be. I
   am not sure how to arrange the entire PDF as per the format I mentioned
   above

I shall really appreciate any help with this - the time series analysis is
not difficult, I can manage that - however, I don't know how to manage the
formatting part though, so that the 1-pager output looks decently
presentable. Thanks.

Regards,
Preetam

[[alternative HTML version deleted]]

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


Re: [R] output my results into Excel

2016-03-02 Thread Dalthorp, Daniel
Sorry, I was assuming your data was a matrix (as you indicated in your
question).

Try:

write.table(as.matrix(PRdist), file = 'clipboard', sep = '\t', row.names =
F, col.names = F)

-Dan

On Wed, Mar 2, 2016 at 1:01 PM, Michael <elopomo...@hotmail.com> wrote:

> I got an error message.
>
>
> > write.table(PRdist, file = 'clipboard', sep = '\t', row.names = F,
> col.names = F)
> Error in as.data.frame.default(x[[i]], optional = TRUE) :
>   cannot coerce class ""dist"" to a data.frame
>
> I think because my PRdist is a value, not a data frame.  However, I am not
> sure.  Any advice?
>
>
> Thanks for your help.
>
>
> Mike
>
>
> --
> *From:* Dalthorp, Daniel <ddalth...@usgs.gov>
> *Sent:* Wednesday, March 2, 2016 3:50 PM
> *To:* Michael
> *Cc:* r-help@r-project.org
> *Subject:* Re: [R] output my results into Excel
>
> Hi Michael,
> If you are working in Windows:
>
> # You can put the matrix directly into the clipboard
> write.table(PRdist, file = 'clipboard', sep = '\t', row.names = F,
> col.names = F)
>
> The "sep" argument tells what character to use for separating columns.
> Default for Excel is tab (i.e. '\t')
>
> Default for write.table on a matrix or 2-d array is to write column names
> (as "V1", "V2", etc.) and row names ("1", "2", etc.). If you don't want
> those added to your matrix, tell R via row.names = FALSE, col.names = FALSE
>
>
>
> -Dan
>
> On Wed, Mar 2, 2016 at 12:31 PM, Michael <elopomo...@hotmail.com> wrote:
>
>> I can get R to calculate the distance that I want between my data
>> points.  However, I am stuck trying to get R to output the data so I can
>> paste it into Excel.  Instead, R outputs a matrix mess in the console.
>>
>> Below are the steps I am taking to calculate the distance between my
>> data.  Also, I have 42 different data points.
>>
>> # Calculate the Euclidean distance between each datapoint using
>> # the function dist()
>>
>> PRdist = dist(my_data) ;  PRdist
>>
>> I would greatly appreciate if someone can tell me how to output my matrix
>> from the dist function into something I can paste into Excel.
>>
>> Mike
>>
>>
>>
>>
>> [[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.
>>
>
>
>
> --
> Dan Dalthorp, PhD
> USGS Forest and Rangeland Ecosystem Science Center
> Forest Sciences Lab, Rm 189
> 3200 SW Jefferson Way
> Corvallis, OR 97331
> ph: 541-750-0953
> ddalth...@usgs.gov
>
>


-- 
Dan Dalthorp, PhD
USGS Forest and Rangeland Ecosystem Science Center
Forest Sciences Lab, Rm 189
3200 SW Jefferson Way
Corvallis, OR 97331
ph: 541-750-0953
ddalth...@usgs.gov

[[alternative HTML version deleted]]

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


Re: [R] output my results into Excel

2016-03-02 Thread Dalthorp, Daniel
Hi Michael,
If you are working in Windows:

# You can put the matrix directly into the clipboard
write.table(PRdist, file = 'clipboard', sep = '\t', row.names = F,
col.names = F)

The "sep" argument tells what character to use for separating columns.
Default for Excel is tab (i.e. '\t')

Default for write.table on a matrix or 2-d array is to write column names
(as "V1", "V2", etc.) and row names ("1", "2", etc.). If you don't want
those added to your matrix, tell R via row.names = FALSE, col.names = FALSE



-Dan

On Wed, Mar 2, 2016 at 12:31 PM, Michael  wrote:

> I can get R to calculate the distance that I want between my data points.
> However, I am stuck trying to get R to output the data so I can paste it
> into Excel.  Instead, R outputs a matrix mess in the console.
>
> Below are the steps I am taking to calculate the distance between my
> data.  Also, I have 42 different data points.
>
> # Calculate the Euclidean distance between each datapoint using
> # the function dist()
>
> PRdist = dist(my_data) ;  PRdist
>
> I would greatly appreciate if someone can tell me how to output my matrix
> from the dist function into something I can paste into Excel.
>
> Mike
>
>
>
>
> [[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.
>



-- 
Dan Dalthorp, PhD
USGS Forest and Rangeland Ecosystem Science Center
Forest Sciences Lab, Rm 189
3200 SW Jefferson Way
Corvallis, OR 97331
ph: 541-750-0953
ddalth...@usgs.gov

[[alternative HTML version deleted]]

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


Re: [R] output my results into Excel

2016-03-02 Thread Sarah Goslee
Hi Michael,

Googling "export R data to Excel" gives LOTS of advice, including
packages that can write your data directly to Excel spreadsheets.

I don't use Excel, so I haven't tried any of those, but using
write.csv() to export your data will create something that my
colleagues who use Excel have no trouble opening.

Printing to the console, as you did by typing the object name, is not
intended to be an export method.

Sarah

On Wed, Mar 2, 2016 at 3:31 PM, Michael  wrote:
> I can get R to calculate the distance that I want between my data points.  
> However, I am stuck trying to get R to output the data so I can paste it into 
> Excel.  Instead, R outputs a matrix mess in the console.
>
> Below are the steps I am taking to calculate the distance between my data.  
> Also, I have 42 different data points.
>
> # Calculate the Euclidean distance between each datapoint using
> # the function dist()
>
> PRdist = dist(my_data) ;  PRdist
>
> I would greatly appreciate if someone can tell me how to output my matrix 
> from the dist function into something I can paste into Excel.
>
> Mike
>
>
--

__
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] output my results into Excel

2016-03-02 Thread Michael
I can get R to calculate the distance that I want between my data points.  
However, I am stuck trying to get R to output the data so I can paste it into 
Excel.  Instead, R outputs a matrix mess in the console.

Below are the steps I am taking to calculate the distance between my data.  
Also, I have 42 different data points.

# Calculate the Euclidean distance between each datapoint using
# the function dist()

PRdist = dist(my_data) ;  PRdist

I would greatly appreciate if someone can tell me how to output my matrix from 
the dist function into something I can paste into Excel.

Mike




[[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] r output as html or pdf without rstudio

2016-01-08 Thread Ragia .
dear group,
is there a way to write my outputs to any kind of files ( the output contains 
text and graph) using R only without installing rstudio and using rmd  files.
thanks in advance
Ragia 
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] r output as html or pdf without rstudio

2016-01-08 Thread Greg Snow
Yes, you can use the knitr package directly (that is what Rstudio
uses, but it is its own package).

On Fri, Jan 8, 2016 at 1:16 PM, Ragia .  wrote:
> dear group,
> is there a way to write my outputs to any kind of files ( the output contains 
> text and graph) using R only without installing rstudio and using rmd  files.
> thanks in advance
> Ragia
> __
> 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.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

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


Re: [R] Johansen Test of Cointegration:How to access rows in R output

2015-10-05 Thread Pfaff, Bernhard Dr.
RTFM: help("ca.jo-class")

library(urca)
example(ca.jo)
class(sjf.vecm)
slotNames(sjf.vecm)
slot(sjf.vecm, "cval")
slot(sjf.vecm, "teststat")
slot(sjf.vecm, "V")
slot(sjf.vecm, "Vorg")

Best,
Bernhard

-Ursprüngliche Nachricht-
Von: R-help [mailto:r-help-boun...@r-project.org] Im Auftrag von Preetam Pal
Gesendet: Sonntag, 4. Oktober 2015 18:43
An: r-help@r-project.org
Betreff: [R] Johansen Test of Cointegration:How to access rows in R output

Hi guys,

I ran ca.jo(data,type="trace", ecdet="none",k=2) i.e. Johansen's Trace test on 
R-Studio (package: "urca")and got the output below:

I have 3 questions about this:

A> How do I programmatically access the columns("test", "10pct" etc) in 
A> any
row corresponding to, say, r < = 1 in the output?  I mean, I shall only provide 
the r-value as an input and all the (column name, column value) pairs will be 
outputted to me.

B> How do I write a code that will check if the null hypotheses for r 
B> =0,
<= 1, <= 2 and so on  (in this order) are rejected or not; and in case one of 
them is rejected, it checks the next higher value of r and gives the final 
inference , something like "Null not rejected for r <= *appropriate r-value 
from this table* " or "All nulls rejected" or "No null rejected'.

C> Also, I need to extract the eigen vectors from the Cointegration 
C> Matrix
below to get the cointegrated transfoms.

I have attached the data for your perusal. If I need to provide anything more, 
please let me know.

Regards,
Preetam

##
# Johansen-Procedure #
##

Test type: trace statistic , with linear trend in cointegration

Eigenvalues (lambda):
[1] 7.935953e-01 5.444372e-01 4.985327e-01 2.562245e-01 5.551115e-16

Values of teststatistic and critical values of test:

  test 10pct  5pct  1pct
r <= 3 |  6.81 10.49 12.25 16.26
r <= 2 | 22.68 22.76 25.32 30.45
r <= 1 | 40.77 39.06 42.44 48.45
r = 0  | 77.06 59.14 62.99 70.05

Eigenvectors, normalised to first column:
(These are the cointegration relations)

   GDP.l2 HPA.l2   FX.l2Y.l2   trend.l2
GDP.l21.0  1.000  1.  1.  1.000
HPA.l22.52550  0.1569079  0.08077351 -0.22777550 -0.9178250
FX.l2-8.643729121 -2.5815150  0.17158404 -0.47053012 -4.8528875
Y.l2  0.805229998 -1.4241546  0.07767540  0.02303305  0.5213294
trend.l2  0.006283314  0.0385276 -0.01512016  0.01986813 -0.9516072

Weights W:
(This is the loading matrix)

   GDP.l2  HPA.l2  FX.l2Y.l2  trend.l2
GDP.d  0.03055313 -0.04681978 -0.8376985 -0.04220534 -1.271960e-17 HPA.d 
-0.22649596 -0.24287691 -1.6358880  2.03813569 -8.002467e-17
FX.d   0.10327579  0.15150469 -0.1649066  0.37449910 -2.570250e-18
Y.d   -0.35200485  0.56808024 -5.7829738  0.01000965  1.730461e-16
*
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*
__
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] Johansen Test of Cointegration:How to access rows in R output

2015-10-04 Thread Preetam Pal
Hi guys,

I ran ca.jo(data,type="trace", ecdet="none",k=2) i.e. Johansen's Trace test
on R-Studio (package: "urca")and got the output below:

I have 3 questions about this:

A> How do I programmatically access the columns("test", "10pct" etc) in any
row corresponding to, say, r < = 1 in the output?  I mean, I shall only
provide the r-value as an input and all the (column name, column value)
pairs will be outputted to me.

B> How do I write a code that will check if the null hypotheses for r =0,
<= 1, <= 2 and so on  (in this order) are rejected or not; and in case one
of them is rejected, it checks the next higher value of r and gives the
final inference , something like "Null not rejected for r <= *appropriate
r-value from this table* " or "All nulls rejected" or "No null rejected'.

C> Also, I need to extract the eigen vectors from the Cointegration Matrix
below to get the cointegrated transfoms.

I have attached the data for your perusal. If I need to provide anything
more, please let me know.

Regards,
Preetam

##
# Johansen-Procedure #
##

Test type: trace statistic , with linear trend in cointegration

Eigenvalues (lambda):
[1] 7.935953e-01 5.444372e-01 4.985327e-01 2.562245e-01 5.551115e-16

Values of teststatistic and critical values of test:

  test 10pct  5pct  1pct
r <= 3 |  6.81 10.49 12.25 16.26
r <= 2 | 22.68 22.76 25.32 30.45
r <= 1 | 40.77 39.06 42.44 48.45
r = 0  | 77.06 59.14 62.99 70.05

Eigenvectors, normalised to first column:
(These are the cointegration relations)

   GDP.l2 HPA.l2   FX.l2Y.l2   trend.l2
GDP.l21.0  1.000  1.  1.  1.000
HPA.l22.52550  0.1569079  0.08077351 -0.22777550 -0.9178250
FX.l2-8.643729121 -2.5815150  0.17158404 -0.47053012 -4.8528875
Y.l2  0.805229998 -1.4241546  0.07767540  0.02303305  0.5213294
trend.l2  0.006283314  0.0385276 -0.01512016  0.01986813 -0.9516072

Weights W:
(This is the loading matrix)

   GDP.l2  HPA.l2  FX.l2Y.l2  trend.l2
GDP.d  0.03055313 -0.04681978 -0.8376985 -0.04220534 -1.271960e-17
HPA.d -0.22649596 -0.24287691 -1.6358880  2.03813569 -8.002467e-17
FX.d   0.10327579  0.15150469 -0.1649066  0.37449910 -2.570250e-18
Y.d   -0.35200485  0.56808024 -5.7829738  0.01000965  1.730461e-16
GDP HPA FX  Y
0.514662421 0.635997077 1.37802145  1.773342598
0.9367223.127683176 1.391916535 3.709809052
0.101482324 1.270555421 0.831157511 0.226267793
0.017548634 2.456061547 1.003945759 9.510258161
0.236462416 0.988324147 0.223682679 5.026671536
0.372005149 2.177631629 0.904226065 4.219235789
0.153915709 4.620341653 0.033410743 3.17396006
0.524887329 1.050861084 0.518201484 7.950098612
0.776616937 0.503349512 0.666089868 3.320938471
0.760074361 3.635853456 0.470220952 6.380945175
0.802986662 1.260738545 0.452674872 1.036040804
0.375145127 0.20035625  1.837306306 6.486871565
0.002568896 3.532359526 0.556752154 8.536594244
0.754309276 3.952381767 0.247402168 8.559081716
0.585966577 4.01463047  1.184382133 0.148121669
0.39767356  1.553753452 0.983129422 5.378373676
0.859898623 4.73191381  0.828795696 3.367809329
0.741376169 4.993350692 1.758051281 5.516460988
0.329240391 3.465836416 1.701655508 1.249497907
0.078661064 3.298298811 0.04575857  5.132921426
0.270971873 0.46627043  1.739487411 4.94697541
0.731072625 0.940642982 0.728747166 7.583041122
0.385038046 3.51048946  0.021866584 7.361148458
0.530760376 1.204422978 0.415530715 1.163503483
0.555323667 4.12592 1.844184811 8.596644394
__
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] Output In R

2015-08-22 Thread Marc Schwartz

 On Aug 22, 2015, at 8:49 AM, John Kane jrkrid...@inbox.com wrote:
 
 We are talking at cross-purposes here because SAS and R are radically 
 different beasts. Just about everything you did in SAS does not work / is 
 wrong / is illegal / is immoral / and possibly fattening.


Fortune candidate!

:-)

Regards,

Marc Schwartz


 
 If you have not seen it, you may find Bob Muenchen's pdf and/or the expanded 
 book R FOR SAS AND SPSS USERS ( 
 https://science.nature.nps.gov/im/datamgmt/statistics/R/documents/R_for_SAS_SPSS_users.pdf
  ) useful.
 
 It is very easy to create the data set you want. You just need to think in 
 R's somewhat twisted way.  Well if twisted my mind for the first 6 weeks that 
 I used it. 
 
 Let's say you are doing some analysis. Don't send the data to the console. 
 Instead save it in a R object (not sure if this is the correct term--I am 
 sure the purists will correct me.) 
 
 
 I am going to create a data.frame called dat1 (pretend it is your data).
 
 
 #create make-believe data
 dat1  -  data.frame(matrix( rnorm(100), ncol = 5))
 
 #Save dat1 as an R file. Handy for your work not great as a way 
 #to pass around data unless the client knows R and has R installed
 
 save( dat1, file = ~/Rjunk/ mydata.RData)
 
 #Save as a .csv file. Fast easy and can be opened in any 
 #text editor, spreadsheet or even a word processor. 
 
 write.csv(dat1, file = ~/Rjunk/ mydata.csv)
 
 
 
 To produce a Latex file and get a pdf.
 
 One starts with a  .Rnw (i.e. plain text with a .Rnw suffix)  file and then 
 compiles it.
 I used the command  Rscript -e library(knitr); knit('./Shiv1.Rnw') where 
 Shiv.Rnw was my LaTeX / knitr file.  It is easier and faster to use RStudio 
 for  this.
 
 You will probably need to install the xtable package and depending in your 
 LaTeX version you may need to install booktabs. 
 
 Start Latex file###
 \documentclass[12pt,letterpaper]{article}
 \usepackage[utf8]{inputenc}
 \usepackage{booktabs}
 \title{Magnum Opus Meum}
 \author{jrkrideau }
 \begin{document}
 
 \maketitle
 
 atable, echo=FALSE, results=asis=
 library(xtable) 
 dat1  -  data.frame(matrix( rnorm(100), ncol = 5))
 dat1.table  -  xtable(dat1)
 print(dat1.table,
 include.rownames=FALSE,
 booktabs = TRUE)
 @
 
 \end{document}
 
 End Latex file
 
 John Kane
 Kingston ON Canada
 
 
 -Original Message-
 From: shivibha...@ymail.com
 Sent: Fri, 21 Aug 2015 12:26:50 -0700 (PDT)
 To: r-help@r-project.org
 Subject: Re: [R] Output In R
 
 Thanks Jeff, this is helpful.
 The reason i am curious to know this is because I have worked for a long
 duration in SAS where in it gives us the flexibility to create a data set
 of
 our analysis and then we can easily detail out the same to the end user.
 
 In R seems like View or Sweave  or Shiny are the alternative.
 
 
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Output-In-R-tp4711227p4711368.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on your 
 desktop!
 
 __
 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] Output In R

2015-08-22 Thread John Kane
Hi Shivi,
A correction to my latex/knitr code.  I stupidly forgot the initial problem was 
the length of the data set.  To get it to print correctly we need to use the 
LaTeX package 'longtable'.  Clearly too many trees for me to see the forest.
Add \usepackage{longtable} to the Preamble.

#==Revised code for knitr/R
atable, echo=FALSE, results=asis=
library(xtable) 
dat1  -  data.frame(matrix( rnorm(2000), ncol = 5))
dat1.table  -  xtable(dat1)
print(dat1.table,tabular.environment='longtable',
floating = FALSE,
include.rownames=FALSE,
booktabs = TRUE)
@
#==end===

John Kane
Kingston ON Canada


 -Original Message-
 From: jrkrid...@inbox.com
 Sent: Sat, 22 Aug 2015 05:49:32 -0800
 To: shivibha...@ymail.com, r-help@r-project.org
 Subject: Re: [R] Output In R
 
 We are talking at cross-purposes here because SAS and R are radically
 different beasts. Just about everything you did in SAS does not work / is
 wrong /i s illegal/ is immoral / and possibly fattening.
 
 If you have not seen it, you may find Bob Muenchen's pdf and/or the
 expanded book R FOR SAS AND SPSS USERS (
https://science.nature.nps.gov/im/datamgmt/statistics/R/documents/R_for_SAS_SPSS_users.pdf
 ) useful.
 
 It is very easy to create the data set you want. You just need to think
 in R's somewhat twisted way.  Well if twisted my mind for the first 6
 weeks that I used it.
 
 Let's say you are doing some analysis. Don't send the data to the
 console. Instead save it in a R object (not sure if this is the correct
 term--I am sure the purists will correct me.)
 
 
 I am going to create a data.frame called dat1 (pretend it is your data).
 
 
 #create make-believe data
 dat1  -  data.frame(matrix( rnorm(100), ncol = 5))
 
 #Save dat1 as an R file. Handy for your work not great as a way
 #to pass around data unless the client knows R and has R installed
 
 save( dat1, file = ~/Rjunk/ mydata.RData)
 
 #Save as a .csv file. Fast easy and can be opened in any
 #text editor, spreadsheet or even a word processor.
 
 write.csv(dat1, file = ~/Rjunk/ mydata.csv)
 
 
 
 To produce a Latex file and get a pdf.
 
 One starts with a  .Rnw (i.e. plain text with a .Rnw suffix)  file and
 then compiles it.
 I used the command  Rscript -e library(knitr); knit('./Shiv1.Rnw')
 where Shiv.Rnw was my LaTeX / knitr file.  It is easier and faster to use
 RStudio for  this.
 
 You will probably need to install the xtable package and depending in
 your LaTeX version you may need to install booktabs.
 
 Start Latex file###
 \documentclass[12pt,letterpaper]{article}
 \usepackage[utf8]{inputenc}
 \usepackage{booktabs}
 \title{Magnum Opus Meum}
 \author{jrkrideau }
 \begin{document}
 
 \maketitle
 
 atable, echo=FALSE, results=asis=
 library(xtable)
 dat1  -  data.frame(matrix( rnorm(100), ncol = 5))
 dat1.table  -  xtable(dat1)
 print(dat1.table,
 include.rownames=FALSE,
 booktabs = TRUE)
 @
 
 \end{document}
 
 End Latex file
 
 John Kane
 Kingston ON Canada
 
 
 -Original Message-
 From: shivibha...@ymail.com
 Sent: Fri, 21 Aug 2015 12:26:50 -0700 (PDT)
 To: r-help@r-project.org
 Subject: Re: [R] Output In R
 
 Thanks Jeff, this is helpful.
 The reason i am curious to know this is because I have worked for a long
 duration in SAS where in it gives us the flexibility to create a data
 set
 of
 our analysis and then we can easily detail out the same to the end user.
 
 In R seems like View or Sweave  or Shiny are the alternative.
 
 
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Output-In-R-tp4711227p4711368.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on
 your desktop!
 
 __
 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.


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on your 
desktop!

__
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] Output In R

2015-08-22 Thread John Kane
We are talking at cross-purposes here because SAS and R are radically different 
beasts. Just about everything you did in SAS does not work / is wrong /i s 
illegal/ is immoral / and possibly fattening.

If you have not seen it, you may find Bob Muenchen's pdf and/or the expanded 
book R FOR SAS AND SPSS USERS ( 
https://science.nature.nps.gov/im/datamgmt/statistics/R/documents/R_for_SAS_SPSS_users.pdf
 ) useful.

It is very easy to create the data set you want. You just need to think in R's 
somewhat twisted way.  Well if twisted my mind for the first 6 weeks that I 
used it. 

Let's say you are doing some analysis. Don't send the data to the console. 
Instead save it in a R object (not sure if this is the correct term--I am sure 
the purists will correct me.) 


I am going to create a data.frame called dat1 (pretend it is your data).


#create make-believe data
dat1  -  data.frame(matrix( rnorm(100), ncol = 5))

#Save dat1 as an R file. Handy for your work not great as a way 
#to pass around data unless the client knows R and has R installed

save( dat1, file = ~/Rjunk/ mydata.RData)

#Save as a .csv file. Fast easy and can be opened in any 
#text editor, spreadsheet or even a word processor. 

write.csv(dat1, file = ~/Rjunk/ mydata.csv)



To produce a Latex file and get a pdf.

One starts with a  .Rnw (i.e. plain text with a .Rnw suffix)  file and then 
compiles it.
I used the command  Rscript -e library(knitr); knit('./Shiv1.Rnw') where 
Shiv.Rnw was my LaTeX / knitr file.  It is easier and faster to use RStudio for 
 this.

You will probably need to install the xtable package and depending in your 
LaTeX version you may need to install booktabs. 

Start Latex file###
\documentclass[12pt,letterpaper]{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\title{Magnum Opus Meum}
\author{jrkrideau }
\begin{document}

\maketitle

atable, echo=FALSE, results=asis=
library(xtable) 
dat1  -  data.frame(matrix( rnorm(100), ncol = 5))
dat1.table  -  xtable(dat1)
print(dat1.table,
include.rownames=FALSE,
booktabs = TRUE)
@

\end{document}

End Latex file

John Kane
Kingston ON Canada


 -Original Message-
 From: shivibha...@ymail.com
 Sent: Fri, 21 Aug 2015 12:26:50 -0700 (PDT)
 To: r-help@r-project.org
 Subject: Re: [R] Output In R
 
 Thanks Jeff, this is helpful.
 The reason i am curious to know this is because I have worked for a long
 duration in SAS where in it gives us the flexibility to create a data set
 of
 our analysis and then we can easily detail out the same to the end user.
 
 In R seems like View or Sweave  or Shiny are the alternative.
 
 
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Output-In-R-tp4711227p4711368.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on your 
desktop!

__
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] Output In R

2015-08-21 Thread Shivi82
Hi Jim,

Please see the sample code:
ak-read.csv(June.csv, header = TRUE)
ak%%select(sfxcode,mod,chargedweight)%%filter(mod=='AIR')

what i am trying to find is selecting the required var and then selecting
only AIR as a mode of transportation from mod.
I am getting the output but the total rows which fulfil this condition is
10500 where console shows only 3300. 
I want to share the output i.e. 10500 rows to my business. So want to see
the possible options to share the results with the business. R Markdown  R
Sweave might help - please suggest. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Output-In-R-tp4711227p4711335.html
Sent from the R help mailing list archive at Nabble.com.

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


  1   2   3   4   >