'Problems using write.csv in R with TR8 package - Data missing from CSV file
I am an ecologist very new to R and trying to write data to csv which has been downloaded using the TR8 package for R - the package provides data on plant species from various databases. I manage to retrieve the data and extract it to create a dataframe, however when I try to write the dataframe to csv, I get a csv file with nothing in it.
The code I have used to download and then extract the data from the package:
my_traits <- c("Galium aparine", "Lolium perenne",
"Sonchus asper")
my_traits<-tr8(my_traits,gui_config = TRUE, allow_persistent=TRUE)
print(my_traits)
abc<- data.frame(extract_traits(my_traits))
summary(abc)
The output I get from the above looks like this:
> summary(abc)
li_form_B li_span reprod_B strategy
Length:3 Length:3 Length:3 Length:3
Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character
self.st Breeding_sys flw_muell flw_kugler
Length:3 Length:3 Length:3 Length:3
Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character
poll_vect_B
Length:3
Class :character
Mode :character
li_form_B li_span
Galium aparine H (Hemicryptophyte) - T (Therophyte) a (annual)
Lolium perenne H (Hemicryptophyte) p (pluriennial-pollakanthic)
Sonchus asper H (Hemicryptophyte) - T (Therophyte) a (annual)
reprod_B strategy
Galium aparine s (by seed/by spore) cr (competitors/ruderals)
Lolium perenne s (by seed/by spore) c (competitors)
Sonchus asper s (by seed/by spore) cr (competitors/ruderals)
self.st Breeding_sys
Galium aparine SC (self-compatibel) AF (facultative autogamous)
Lolium perenne I+ (± self-incompatibel) - SI (self-incompatibel) X (allogamous)
Sonchus asper SC (self-compatibel) AF (facultative autogamous)
flw_muell
Galium aparine A (flowers with open nectar)Typical pollinators: beetles, flies, syrphids, wasps, medium tongued bees
Lolium perenne W (wind flowers)Typical pollinators: -
Sonchus asper B` (flower associations with totally hidden nectar)Typical pollinators: bees, bumble bees, wasps, bombylides, syrphids
flw_kugler
Galium aparine 1.2a (disk flowers with nectar open)
Lolium perenne 0 (not applicable)
Sonchus asper 7.2b (flower heads, Asteraceae, only ray flowers)
poll_vect_B
Galium aparine se (selfing) [the rule] - in (insects) [rare]
Lolium perenne wi (wind) [always]
Sonchus asper se (selfing) [the rule] - in (insects) [the rule]
I use the following to write to csv:
write.csv("abc", file = "c:\\Users\\Me\\My filepath\\abc.csv",
row.names = FALSE)
The resulting csv file opened in Excel looks like this:
x
abc
And that's all! One column with x in cell A1 and abc in cell A2. What am I missing?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
