Science_blog: tibble

Search This Blog

Showing posts with label tibble. Show all posts
Showing posts with label tibble. Show all posts

Thursday, 2 March 2023

Create dataframe in R

#####################How to create dataframe of different variables from .csv############

> install.packages ("tidyverse")

Check this link for installing tidyverse on updated Ubuntu

(https://rajivagriscienceblog.blogspot.com/2023/02/how-to-install-r-library-tidyverse-for.html)

> setwd("/home/rajiv/for_1695_datast_confidential/04_weather")

if it is windows then it should be ("C: //home/rajiv/for_1695_datast_confidential/04_weather")

> library('tidyverse')

> ec1 <- read.csv("ec1_weather_data.csv", header = TRUE, sep = ",")

1. data.frame

ec1weather <- data.frame(ec1$site,

                                      ec1$date,

                                      ec1$temeprarute)


2. Tibble

> ec1weather <- tibble(ec1$site,

                                      ec1$date,

                                      ec1$temeprarute)

3. cbind


> ec1weather <- cbind(ec1$site,

                                      ec1$date,

                                      ec1$temeprarute)

Note: The basic difference between three is that cbind and data.frame convert all variables in character (chr) but tibble convert as it is ie.e date to date, int to int and chr to chr. Remember type of data or class or str of data is necessary before to data analysis.  If date is chr then you can not plot a graph with ggplot. It will show error "error discrete value supplied to continuous scale"

To plot a graph with ggplot, check here:
https://rajivagriscienceblog.blogspot.com/2023/02/plooting-with-common-axis-in-ggarrange.html

Multidisciplinary Mega‑Journals: Has Their Time Passed?

     Over the past decade, multidisciplinary and so‑called “mega‑journals” became some of the most attractive destinations for researchers u...