[R] how to convert strings back to values?
Dear All, It's Eszter from Hungary, a total beginner with R. My problem is the following: I have a dataset with binary values as a comma separated textfile. The samples are in the coloumns and the species are in the rows. I have to transpose it for the further PCoA analysis. There is no problem with reading the dataset. When I transpose the dataset, the original values become strings (instead of 0,1,0,0,1 I have 0,1,0,0,1). The distance matrix cannot be counted from the transposed dataset, I have 2 error messages: Warning in vegdist(tdf1, method = jaccard, binary = FALSE, diag = FALSE, : results may be meaningless because input data have negative entries Error in rowSums(x, prod(dn), p, na.rm) : 'x' must be numeric I do not understand the first, since I have only 1 and 0 in the dataset. I guess I have the second because of the strings instead of values in the dataset. Could you please help me solving these problems? I could not find anything about these in the manuals. Thank you, cheers: Eszter p.s. This is a new problem, last week I worked with a similar dataset and I did not get any error message like these. _ Menő csengőhangok (MP3 is!) és színes képek a mobilodra. Nálunk szinte mindent megtalálsz, KLIKK IDE! www.oplogo.hu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to convert strings back to values?
Examples of the code you used would have helped i.e. We don't know how you transposed your matrix. Did you use t()? In any event, as.integer() may be what you need. Francisco From: Illyes Eszter [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] how to convert strings back to values? Date: Wed, 9 Nov 2005 21:55:44 +0100 (CET) Dear All, It's Eszter from Hungary, a total beginner with R. My problem is the following: I have a dataset with binary values as a comma separated textfile. The samples are in the coloumns and the species are in the rows. I have to transpose it for the further PCoA analysis. There is no problem with reading the dataset. When I transpose the dataset, the original values become strings (instead of 0,1,0,0,1 I have 0,1,0,0,1). The distance matrix cannot be counted from the transposed dataset, I have 2 error messages: Warning in vegdist(tdf1, method = jaccard, binary = FALSE, diag = FALSE, : results may be meaningless because input data have negative entries Error in rowSums(x, prod(dn), p, na.rm) : 'x' must be numeric I do not understand the first, since I have only 1 and 0 in the dataset. I guess I have the second because of the strings instead of values in the dataset. Could you please help me solving these problems? I could not find anything about these in the manuals. Thank you, cheers: Eszter p.s. This is a new problem, last week I worked with a similar dataset and I did not get any error message like these. _ Menõ csengõhangok (MP3 is!) és színes képek a mobilodra. Nálunk szinte mindent megtalálsz, KLIKK IDE! www.oplogo.hu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to convert strings back to values?
Eszter, I suspect the problem is different than you think. It's possible that when you read in the data it assumed that the first column was data, not row names, and so when you transpose the first column becomes the first row. Since it is alpha, all the columns become factors rather then integers. Check to see on the non-transposed matrix wheter the number of rows and columns is correct. If it incorrectly treated the first column as data (as it would if you have the same number of column headings as columns), you could read it back in with x - read.table('file_name',header=TRUE, row.names=1) and then transpose it y - t(x) Often at that point the row and column names are stripped off, and you have to put them back. y - data.frame(y) row.names(y) - names(x) names(y) - row.names(x) I'm interested in PCoA in ecology, so let me know how it goes. HTH Dave Francisco J. Zagmutt wrote: Examples of the code you used would have helped i.e. We don't know how you transposed your matrix. Did you use t()? In any event, as.integer() may be what you need. Francisco From: Illyes Eszter [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] how to convert strings back to values? Date: Wed, 9 Nov 2005 21:55:44 +0100 (CET) Dear All, It's Eszter from Hungary, a total beginner with R. My problem is the following: I have a dataset with binary values as a comma separated textfile. The samples are in the coloumns and the species are in the rows. I have to transpose it for the further PCoA analysis. There is no problem with reading the dataset. When I transpose the dataset, the original values become strings (instead of 0,1,0,0,1 I have 0,1,0,0,1). The distance matrix cannot be counted from the transposed dataset, I have 2 error messages: Warning in vegdist(tdf1, method = jaccard, binary = FALSE, diag = FALSE, : results may be meaningless because input data have negative entries Error in rowSums(x, prod(dn), p, na.rm) : 'x' must be numeric I do not understand the first, since I have only 1 and 0 in the dataset. I guess I have the second because of the strings instead of values in the dataset. Could you please help me solving these problems? I could not find anything about these in the manuals. Thank you, cheers: Eszter p.s. This is a new problem, last week I worked with a similar dataset and I did not get any error message like these. _ Menõ csengõhangok (MP3 is!) és színes képek a mobilodra. Nálunk szinte mindent megtalálsz, KLIKK IDE! www.oplogo.hu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- David W. Roberts office 406-994-4548 Professor and Head FAX 406-994-3190 Department of Ecology email [EMAIL PROTECTED] Montana State University Bozeman, MT 59717-3460 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to convert strings back to values?
Problems like these could be caused by improperly spaced columns. Try table(tdf1). If you see only 0 and 1, then you should be fine. However I suspect that you might see things like 0, 0, 1, 1 which means that there is a an extra space between the delimiters. Report back what you get and we can work around a solution if need be. Regards, Adai On Wed, 2005-11-09 at 21:55 +0100, Illyes Eszter wrote: Dear All, It's Eszter from Hungary, a total beginner with R. My problem is the following: I have a dataset with binary values as a comma separated textfile. The samples are in the coloumns and the species are in the rows. I have to transpose it for the further PCoA analysis. There is no problem with reading the dataset. When I transpose the dataset, the original values become strings (instead of 0,1,0,0,1 I have 0,1,0,0,1). The distance matrix cannot be counted from the transposed dataset, I have 2 error messages: Warning in vegdist(tdf1, method = jaccard, binary = FALSE, diag = FALSE, : results may be meaningless because input data have negative entries Error in rowSums(x, prod(dn), p, na.rm) : 'x' must be numeric I do not understand the first, since I have only 1 and 0 in the dataset. I guess I have the second because of the strings instead of values in the dataset. Could you please help me solving these problems? I could not find anything about these in the manuals. Thank you, cheers: Eszter p.s. This is a new problem, last week I worked with a similar dataset and I did not get any error message like these. _ Menő csengőhangok (MP3 is!) és színes képek a mobilodra. Nálunk szinte mindent megtalálsz, KLIKK IDE! www.oplogo.hu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html