0

I am trying to rerun a bit of code I used for data analysis a while ago. I am not accustomed to R, so this might be a dumb error, sorry. The code stops at the very beginning, when I try to import data from csv and transform it to something usable.

I get "object d_beta [my data] not found". I'm using RStudio

I've made sure I've set the right wd and the file is indeed in it.

library(tidyverse)

d_beta <- read_csv("LIC_wyniki.csv")
d_beta %>%

      slice(seq(9, nrow(d_beta), by = 10)) %>% 
      select(2, 5, 7, 10) %>% 
      rename(t16_d2 = X2, t16_d5 = X5, t21_d2 = X7, t21_d5 = X10) %>% 
      mutate_all(as.numeric) %>% 
      mutate(suma16 = t16_d2 + t16_d5, suma21 = t21_d2 + t21_d5) %>% 
      mutate(prop_t16_d2 = t16_d2 / suma16, prop_t21_d2 = t21_d2 / suma21)->
      d_beta
Foxi
  • 3
  • 4
  • If i change it to the left: "Error in d_beta %>% slice(seq(9, nrow(d_beta), by = 10)) %>% select(2, : could not find function "%>%"" Same if I delete it – Foxi Jan 04 '19 at 11:58
  • 1
    (1) can you please edit the question to only include the latest information? it gets confusing. (2) without a [mcve] we're going to be guessing, probably ineffectively ... – Ben Bolker Jan 06 '19 at 16:04

1 Answers1

0

I've installed another library, added brackets at the file name and inserted a line for setting the wd again.

 library(tidyverse)
 library(readr)
 library(magrittr)
 setwd("C:/Users/eme13/OneDrive/Documents/Bioinf/Licencjat/Stat")

 d_beta<-read_csv("LIC_wyniki.csv")

  d_beta<-d_beta %>%
   slice(seq(9, nrow(d_beta), by = 10)) %>% 
   select(2, 5, 7, 10) %>% 
   rename(t16_d2 = X2, t16_d5 = X5, t21_d2 = X7, t21_d5 = X10) %>% 
   mutate_all(as.numeric) %>% 
   mutate(suma16 = t16_d2 + t16_d5, suma21 = t21_d2 + t21_d5) %>% 
   mutate(prop_t16_d2 = t16_d2 / suma16, prop_t21_d2 = t21_d2 / suma21)
d_beta

It works now.

Foxi
  • 3
  • 4