Reputation: 4122
I cannot rewrite a piece of standard R code using magrittr
This works fine as standard R:
q1 <- tbl_df(read.csv('activity.csv',
header = TRUE,
sep = ',',
colClasses = c('numeric', 'POSIXct', 'numeric')))
But this does not using magrittr:
q1 <-
tbl_df(read.csv('activity.csv')) %>%
header = TRUE %>%
sep = ',' %>%
colClasses = c('numeric', 'POSIXct', 'numeric')
Error in "," %>% colClasses = c("numeric", "POSIXct", "numeric") :
target of assignment expands to non-language object
I kind of understand the gist of the error, but don't know what to do about it.
Upvotes: 1
Views: 110
Reputation: 54237
%>%
is used to chain multiple operations, not to specify parameters (see ?'%>%'
). So stick to the first one. :-) Or use
read.csv('activity.csv',
header = TRUE,
sep = ',',
colClasses = c('numeric', 'POSIXct', 'numeric')) %>%
tbl_df()
Upvotes: 4