[R] output my results into Excel
Dalthorp, Daniel
ddalthorp at usgs.gov
Wed Mar 2 22:10:02 CET 2016
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 <elopomorph at 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 <ddalthorp at usgs.gov>
> *Sent:* Wednesday, March 2, 2016 3:50 PM
> *To:* Michael
> *Cc:* r-help at 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 <elopomorph at 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 at 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
> ddalthorp at 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
ddalthorp at usgs.gov
[[alternative HTML version deleted]]
More information about the R-help
mailing list