Re: [R-sig-phylo] issue with reading matrix in R package DispRity

2021-12-06 Thread Liam J. Revell

Hi Oliver & Marguerite.

It looks like the file is in "csv2" format -- with the comma as the 
decimal separator, and the semi-colon as column separator.


This file format can be read using read.csv2 instead of read.csv. (Or, 
alternatively, you can use read.csv but then update the arguments 
dec="," and sep=";".)


Hopefully this solves your problem.

All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

U.S. COVID-19 explorer web application:
https://covid19-explorer.org/

On 12/6/2021 9:52 PM, Marguerite Butler wrote:

EXTERNAL SENDER

Hi Oliver,
You have semicolons ; in your cells.  csv is "comma separated format". It
is using "," as the delimiter. Probably what is happening is the ";" is
interpreted as another delimiter in R, so you have a 2 column vector in
each cell. I would guess that htis will be read in as a list.

Why do you have two values in each cell? If they are important I would
suggest splitting them into two columns so that you only have one value per
cell.

Otherwise you can read in the list, and flatten it with code. But it would
probably be easier to just produce the .csv in the correct way.

An easy way to do this is to read in your .csv file with a word processor
and just do a search on ";" and replace with ",".   Then you should get 6
columns instead of three columns with two values each.

Marguerite

Marguerite



On Mon, Dec 6, 2021 at 2:08 PM Oliver Betz 
wrote:



Dear all:

I have an issue in correctly transferring the attached data frame to a
matrix to be processed in the R package DispRity.

I am running the following script that (1) reads in the attached
dataframe from Excel, (2) tansfers it to a matrix X and (3) uses the
column "subgroup" to define the two groups I want to work on.

Her is the script I am using:

#___

library (dispRity)

#(1) Reading dataframe
Data<-read.csv2("test.csv", row.names=1, header = T,
fileEncoding="UTF-8-BOM")

#(2) converts dataframe into a matrix
X<-data.matrix(Data)

#(3)define subsets
custom.subsets(X[, c(1,2)], group = as.factor(X[, 3]))

#___

However, once I have run the third line, I am getting an error message
such as:

Error: group argument must be either a "list", a "matrix", a
"data.frame" or a "phylo" object.



If I change the third line into: custom.subsets(dat[, c(2,3)], group =
as.factor(dat[, 4])), the error message is as follows:

Error in X[, 4] : subscript out of bounds
___


I will be very happy if anybody can give a hint how to resolve this
problem.


My best wishes,

Oliver Betz











___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=04%7C01%7Cliam.revell%40umb.edu%7C4caba0752954434f0b0608d9b92cba92%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637744424051280848%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=m8Yq%2FUOXRBTsfZa9BJ%2Bv81rieHq00FbwfRMNkiQvaHM%3Dreserved=0
Searchable archive at
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7C4caba0752954434f0b0608d9b92cba92%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637744424051280848%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=zEZn%2BQssRQcHPUZfU5lPWGO192XX0VLJGp2rJd4xAX0%3Dreserved=0




--

Marguerite A. Butler
Professor

Department of Biology
2538 McCarthy Mall, Edmondson Hall 216
Honolulu, HI 96822

Office: 808-956-4713
Dept: 808-956-8617
Lab:  808-956-5867
FAX:   808-956-4745
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbutlerlab.org%2Fdata=04%7C01%7Cliam.revell%40umb.edu%7C4caba0752954434f0b0608d9b92cba92%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637744424051280848%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=7%2FUMuSYsSCBP9WTDIeP71I1KW%2FY6gkNsLuE%2BA8hEzTk%3Dreserved=0
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmanoa.hawaii.edu%2Fbiology%2Fpeople%2Fmarguerite-butlerdata=04%7C01%7Cliam.revell%40umb.edu%7C4caba0752954434f0b0608d9b92cba92%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637744424051280848%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000sdata=qE73xEzLK7zy0T0lOXIo7EzZILQWbpMIqQjM2Ic6WsM%3Dreserved=0

Re: [R-sig-phylo] issue with reading matrix in R package DispRity

2021-12-06 Thread Marguerite Butler
Hi Oliver,
You have semicolons ; in your cells.  csv is "comma separated format". It
is using "," as the delimiter. Probably what is happening is the ";" is
interpreted as another delimiter in R, so you have a 2 column vector in
each cell. I would guess that htis will be read in as a list.

Why do you have two values in each cell? If they are important I would
suggest splitting them into two columns so that you only have one value per
cell.

Otherwise you can read in the list, and flatten it with code. But it would
probably be easier to just produce the .csv in the correct way.

An easy way to do this is to read in your .csv file with a word processor
and just do a search on ";" and replace with ",".   Then you should get 6
columns instead of three columns with two values each.

Marguerite

Marguerite



On Mon, Dec 6, 2021 at 2:08 PM Oliver Betz 
wrote:

>
> Dear all:
>
> I have an issue in correctly transferring the attached data frame to a
> matrix to be processed in the R package DispRity.
>
> I am running the following script that (1) reads in the attached
> dataframe from Excel, (2) tansfers it to a matrix X and (3) uses the
> column "subgroup" to define the two groups I want to work on.
>
> Her is the script I am using:
>
> #___
>
> library (dispRity)
>
> #(1) Reading dataframe
> Data<-read.csv2("test.csv", row.names=1, header = T,
> fileEncoding="UTF-8-BOM")
>
> #(2) converts dataframe into a matrix
> X<-data.matrix(Data)
>
> #(3)define subsets
> custom.subsets(X[, c(1,2)], group = as.factor(X[, 3]))
>
> #___
>
> However, once I have run the third line, I am getting an error message
> such as:
>
> Error: group argument must be either a "list", a "matrix", a
> "data.frame" or a "phylo" object.
>
> 
>
> If I change the third line into: custom.subsets(dat[, c(2,3)], group =
> as.factor(dat[, 4])), the error message is as follows:
>
> Error in X[, 4] : subscript out of bounds
> ___
>
>
> I will be very happy if anybody can give a hint how to resolve this
> problem.
>
>
> My best wishes,
>
> Oliver Betz
>
>
>
>
>
>
>
>
>
>
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at
> http://www.mail-archive.com/r-sig-phylo@r-project.org/
>


-- 

Marguerite A. Butler
Professor

Department of Biology
2538 McCarthy Mall, Edmondson Hall 216
Honolulu, HI 96822

Office: 808-956-4713
Dept: 808-956-8617
Lab:  808-956-5867
FAX:   808-956-4745
http://butlerlab.org
http://manoa.hawaii.edu/biology/people/marguerite-butler
http://www2.hawaii.edu/~mbutler

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] issue with reading matrix in R package DispRity

2021-12-06 Thread Oliver Betz


Dear all:

I have an issue in correctly transferring the attached data frame to a  
matrix to be processed in the R package DispRity.


I am running the following script that (1) reads in the attached  
dataframe from Excel, (2) tansfers it to a matrix X and (3) uses the  
column "subgroup" to define the two groups I want to work on.


Her is the script I am using:

#___

library (dispRity)

#(1) Reading dataframe
Data<-read.csv2("test.csv", row.names=1, header = T, fileEncoding="UTF-8-BOM")

#(2) converts dataframe into a matrix
X<-data.matrix(Data)

#(3)define subsets
custom.subsets(X[, c(1,2)], group = as.factor(X[, 3]))

#___

However, once I have run the third line, I am getting an error message  
such as:


Error: group argument must be either a "list", a "matrix", a  
"data.frame" or a "phylo" object.




If I change the third line into: custom.subsets(dat[, c(2,3)], group =  
as.factor(dat[, 4])), the error message is as follows:


Error in X[, 4] : subscript out of bounds
___


I will be very happy if anybody can give a hint how to resolve this problem.


My best wishes,

Oliver Betz











Species;PC1;PC2;subgroups
Sp1;-,99402;-,83812;1
Sp2;-,56798;-1,48448;1
Sp3;-1,44696;-,38381;1
Sp4;-1,43304;,08285;1
Sp5;-1,49947;-,54767;1
Sp6;-1,03741;-1,26732;1
Sp7;-1,53576;,51212;1
Sp8;-2,41595;,42931;1
Sp9;-,53884;-,55680;1
Sp10;-1,00361;-,26889;1
Sp11;-,94609;-,51118;1
Sp12;-,69936;-1,01976;1
Sp13;-,50821;-,91373;1
Sp14;-1,55634;1,90676;1
Sp15;,38214;-1,54963;1
Sp16;-,20776;-,72754;1
Sp17;,53908;-1,89034;1
Sp18;,76212;,50566;2
Sp19;,83697;,40428;2
Sp20;,39599;,89889;2
Sp21;,08640;,73930;2
Sp22;,10148;1,55637;2
Sp23;,45774;1,02045;2
Sp24;,50159;1,62344;2
Sp25;1,71349;-,15227;2
Sp26;,50170;,72145;2
Sp27;,80535;-,02320;2
Sp28;,31276;,17559;2
Sp29;,39681;1,52969;2
Sp30;,85238;-,28661;2
Sp31;1,05400;-,82751;2
Sp32;,78774;,08827;2
Sp33;1,06829;,30410;2
Sp34;,45918;,42574;2
Sp35;,61022;,14773;2
Sp36;,23850;2,11037;2
Sp37;,45708;,61214;2
Sp38;1,60977;-1,23980;2
Sp39;1,46004;-1,30585;2
___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/