To be honest, I'm beginner R user that is trying to use a little bit a package called rfishbase (a biological package to get data from a website) that also use dplyr. I've tried to get used to the Rstudio and the package. Finally, I could make them work on my computer and I've managed to get "results" from my searches using rfishbase. The results are downloaded and presented as unnamed tables in tibble format on my console. However, I'm a little stock on how I can do to save/export these "tibble" data, that I see on my screen (cache) or on the console. I want to save the tibble in other formats as "cvs" or "xlsx". I tried it with "write.csv" from "dplyr" but I dont know what I should put on "x" argument (I'm not sure what is the name of these "tibbles") and got stock here.
I tried your suggestion but it is still not working. I'm sure I'm doing something wrong. The tibble I got is what I want to save in other formats, like csv or xlsx. Below there is an example of what I do, could you check or any body. Best wishes
> getwd()
[1] "C:/Users/Anyelo/Documents/recentfishes"
> library(rfishbase)
> library(dplyr)
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
> diet_items("Acipenser baerii")
# A tibble: 40,810 × 15
autoctr DietCode FoodI FoodII FoodIII Stage DietP…¹ ItemN…² Comment DietS…³ DietS…⁴ Alpha…⁵ PreyT…⁶
<int> <int> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <int> <int> <chr> <dbl>
1 122522 1 zoobenthos mollus… bivalv… n.a.… 1 gastro… 0.8% b… NA NA GAS NA
2 101628 1 nekton finfish bony f… juv.… 18.1 Trisop… 1% <i>… 481 NA POD NA
3 107359 1 zoobenthos benth.… lobste… juv.… 12.6 Galath… Galath… NA NA LOQ NA
4 119985 1 zoobenthos worms polych… juv.… 2.30 polych… NA NA NA WOR NA
5 116667 1 zoobenthos benth.… shrimp… juv.… 5 Pandal… Pandal… NA NA PDZ NA
6 112452 1 zoobenthos benth.… shrimp… juv.… 5.30 Macrop… 0.5% <… NA NA NA NA
7 95620 1 zoobenthos benth.… shrimp… juv.… 55.7 Nephro… <i>Nep… NA NA NA NA
8 125806 2 zoobenthos mollus… bivalv… juv.… 1.60 gastro… incl. … NA NA GAS NA
9 116668 2 nekton finfish bony f… juv.… 4.80 Merlan… <i>Mer… 29 NA WHG 4.37
10 112453 2 nekton finfish bony f… juv.… 5.10 Trisop… <i>Tri… 481 NA POD 3.83
# … with 40,800 more rows, 2 more variables: PreySeTroph <dbl>, PreyRemark <chr>, and abbreviated variable
# names ¹DietPercent, ²ItemName, ³DietSpeccode, ⁴DietSpeccodeSLB, ⁵AlphaCode, ⁶PreyTroph
# ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
> library(readr)
> write_csv(mysample,"C:/Users/Anyelo/Documents/recentfishes/data.csv")
Error in is.data.frame(x) : object 'mysample' not found
I followed your suggestions and worked better. I couldnt use writeXLS because it was very complicated to install on my R version, not as simple as "install.packages", so instead, I used openxlsx and started to be able to download files in my directory.