Output for pasting multiple vectors

classic Classic list List threaded Threaded
27 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Output for pasting multiple vectors

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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

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 <
[hidden email]> 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

David Winsemius
In reply to this post by Spencer Brackett
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 <[hidden email]> 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]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

Spencer Brackett
My apologies. Is there a way to edit this within R?

On Fri, Jun 21, 2019 at 9:47 PM David Winsemius <[hidden email]>
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 <
> [hidden email]> 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]]
> >
> > ______________________________________________
> > [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

David Winsemius


Sent from my iPhone

> On Jun 21, 2019, at 6:48 PM, Spencer Brackett <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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]]
>> >
>> > ______________________________________________
>> > [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

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 <[hidden email]> wrote:

>
>
>Sent from my iPhone
>
>> On Jun 21, 2019, at 6:48 PM, Spencer Brackett
><[hidden email]> 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
><[hidden email]> 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
><[hidden email]> 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]]
>>> >
>>> > ______________________________________________
>>> > [hidden email] 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]]
>
>______________________________________________
>[hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

Rui Barradas
In reply to this post by Spencer Brackett
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]]
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

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 <[hidden email]> 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]]
> >
> > ______________________________________________
> > [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

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) :
  <text>: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 <
[hidden email]> 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 <[hidden email]> 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]]
>> >
>> > ______________________________________________
>> > [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

David Winsemius
In reply to this post by Spencer Brackett

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 <[hidden email]> 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]]
>>>
>>> ______________________________________________
>>> [hidden email] 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]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

Rui Barradas
In reply to this post by Spencer Brackett
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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

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 <[hidden email]> 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

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) :
  <text>:28:0: unexpected end of input

Best,

Spencer



On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett <
[hidden email]> 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 <[hidden email]>
> 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

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) :
>    <text>:28:0: unexpected end of input
>
> Best,
>
> Spencer
>
>
>
> On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
> <[hidden email] <mailto:[hidden email]>>
> 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 <[hidden email]
>     <mailto:[hidden email]>> 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]]
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

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 <[hidden email]> 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) :
> >    <text>:28:0: unexpected end of input
> >
> > Best,
> >
> > Spencer
> >
> >
> >
> > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
> > <[hidden email] <mailto:[hidden email]>>
>
> > 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 <[hidden email]
> >     <mailto:[hidden email]>> 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

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 <[hidden email]
> <mailto:[hidden email]>> 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) :
>      >    <text>:28:0: unexpected end of input
>      >
>      > Best,
>      >
>      > Spencer
>      >
>      >
>      >
>      > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
>      > <[hidden email]
>     <mailto:[hidden email]>
>     <mailto:[hidden email]
>     <mailto:[hidden email]>>>
>      > 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
>     <[hidden email] <mailto:[hidden email]>
>      >     <mailto:[hidden email] <mailto:[hidden email]>>>
>     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]]
>      >
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

Spencer Brackett
The requested reprex....

Rendering reprex...
Error in parse(text = x, keep.source = TRUE) :
  <text>: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 <[hidden email]> 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 <[hidden email]
> > <mailto:[hidden email]>> 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) :
> >      >    <text>:28:0: unexpected end of input
> >      >
> >      > Best,
> >      >
> >      > Spencer
> >      >
> >      >
> >      >
> >      > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
> >      > <[hidden email]
> >     <mailto:[hidden email]>
> >     <mailto:[hidden email]
> >     <mailto:[hidden email]>>>
> >      > 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
> >     <[hidden email] <mailto:[hidden email]>
> >      >     <mailto:[hidden email] <mailto:[hidden email]>>>
> >     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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

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) :
>    <text>: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 <[hidden email]
> <mailto:[hidden email]>> 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
>     <[hidden email] <mailto:[hidden email]>
>      > <mailto:[hidden email] <mailto:[hidden email]>>> 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) :
>      >      >    <text>:28:0: unexpected end of input
>      >      >
>      >      > Best,
>      >      >
>      >      > Spencer
>      >      >
>      >      >
>      >      >
>      >      > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
>      >      > <[hidden email]
>     <mailto:[hidden email]>
>      >     <mailto:[hidden email]
>     <mailto:[hidden email]>>
>      >     <mailto:[hidden email]
>     <mailto:[hidden email]>
>      >     <mailto:[hidden email]
>     <mailto:[hidden email]>>>>
>      >      > 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
>      >     <[hidden email] <mailto:[hidden email]>
>     <mailto:[hidden email] <mailto:[hidden email]>>
>      >      >     <mailto:[hidden email]
>     <mailto:[hidden email]> <mailto:[hidden email]
>     <mailto:[hidden email]>>>>
>      >     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]]
>      >      >
>      >
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

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 <[hidden email]> 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) :
> >    <text>: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 <[hidden email]
> > <mailto:[hidden email]>> 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
> >     <[hidden email] <mailto:[hidden email]>
> >      > <mailto:[hidden email] <mailto:[hidden email]>>>
> 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) :
> >      >      >    <text>:28:0: unexpected end of input
> >      >      >
> >      >      > Best,
> >      >      >
> >      >      > Spencer
> >      >      >
> >      >      >
> >      >      >
> >      >      > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
> >      >      > <[hidden email]
> >     <mailto:[hidden email]>
> >      >     <mailto:[hidden email]
> >     <mailto:[hidden email]>>
> >      >     <mailto:[hidden email]
> >     <mailto:[hidden email]>
> >      >     <mailto:[hidden email]
> >     <mailto:[hidden email]>>>>
> >      >      > 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
> >      >     <[hidden email] <mailto:[hidden email]>
> >     <mailto:[hidden email] <mailto:[hidden email]>>
> >      >      >     <mailto:[hidden email]
> >     <mailto:[hidden email]> <mailto:[hidden email]
> >     <mailto:[hidden email]>>>>
> >      >     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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Output for pasting multiple vectors

Jeff Newmiller
In reply to this post by Rui Barradas
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 <[hidden email]> 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) :
>>    <text>: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 <[hidden email]
>> <mailto:[hidden email]>> 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
>>     <[hidden email] <mailto:[hidden email]>
>>      > <mailto:[hidden email] <mailto:[hidden email]>>>
>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) :
>>      >      >    <text>:28:0: unexpected end of input
>>      >      >
>>      >      > Best,
>>      >      >
>>      >      > Spencer
>>      >      >
>>      >      >
>>      >      >
>>      >      > On Tue, Jun 25, 2019 at 11:45 AM Spencer Brackett
>>      >      > <[hidden email]
>>     <mailto:[hidden email]>
>>      >     <mailto:[hidden email]
>>     <mailto:[hidden email]>>
>>      >     <mailto:[hidden email]
>>     <mailto:[hidden email]>
>>      >     <mailto:[hidden email]
>>     <mailto:[hidden email]>>>>
>>      >      > 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
>>      >     <[hidden email] <mailto:[hidden email]>
>>     <mailto:[hidden email] <mailto:[hidden email]>>
>>      >      >     <mailto:[hidden email]
>>     <mailto:[hidden email]> <mailto:[hidden email]
>>     <mailto:[hidden email]>>>>
>>      >     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]]
>>      >      >
>>      >
>>

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

______________________________________________
[hidden email] 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.
12