Error with read_csv

I am trying to import data using read_csv function in readr package in R but it is giving me following error:
Error in app$vspace(new_style$margin-top %||% 0) : attempt to apply non-function

my code is as follows:
library(tidyverse)
library(dslabs)
library(readr)
path <- system.file("extdata", package="dslabs")
filename <- file.path(path, "fertility-two-countries-example.csv")
wide_data <- readr::read_csv(filename)

read.csv function works here but I need the data in form of tibble which can be achieved by using read_csv

Hi, there is nothing wrong with it for me.

> wide_data 
# A tibble: 2 x 57
  country    `1960` `1961` `1962` `1963` `1964` `1965` `1966` `1967` `1968` `1969` `1970` `1971` `1972` `1973` `1974` `1975` `1976` `1977` `1978` `1979`
  <chr>       <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>
1 Germany      2.41   2.44   2.47   2.49   2.49   2.48   2.44   2.37   2.28   2.17   2.04   1.92   1.8    1.7    1.62   1.56   1.53   1.5    1.49   1.48
2 South Kor~   6.16   5.99   5.79   5.57   5.36   5.16   4.99   4.85   4.73   4.62   4.53   4.41   4.27   4.09   3.87   3.62   3.36   3.11   2.88   2.69
# ... with 36 more variables: 1980 <dbl>, 1981 <dbl>, 1982 <dbl>, 1983 <dbl>, 1984 <dbl>, 1985 <dbl>, 1986 <dbl>, 1987 <dbl>, 1988 <dbl>, 1989 <dbl>,
#   1990 <dbl>, 1991 <dbl>, 1992 <dbl>, 1993 <dbl>, 1994 <dbl>, 1995 <dbl>, 1996 <dbl>, 1997 <dbl>, 1998 <dbl>, 1999 <dbl>, 2000 <dbl>, 2001 <dbl>,
#   2002 <dbl>, 2003 <dbl>, 2004 <dbl>, 2005 <dbl>, 2006 <dbl>, 2007 <dbl>, 2008 <dbl>, 2009 <dbl>, 2010 <dbl>, 2011 <dbl>, 2012 <dbl>, 2013 <dbl>,
#   2014 <dbl>, 2015 <dbl>
other attached packages:
 [1] dslabs_0.7.4    forcats_0.5.1   stringr_1.4.0   dplyr_1.0.7     purrr_0.3.4     readr_2.0.1     tidyr_1.2.0     tibble_3.1.4    ggplot2_3.3.5  
[10] tidyverse_1.3.1

Regarding read.csv() working for you, you can just use as_tibble() after reading it in.

Your error though is possibly related to this:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.