0

i just waned to select the column 6 to 53 in this data "dd2.survey.data.csv"

but select function doesn't work with that Error

file.raw.items <- file.raw %>% select(7:53) %T>% print

Error in UseMethod("select_") : no applicable method for 'select_' applied to an object of class "character"

getwd()
setwd("C:/Users/bargsang/Desktop")
dir()
dir("dd2.survey.data.csv")

library(tidyverse)
library(magrittr) # %T>% 
install.packages("psych")
install.packages("psy")
library(psych) # pca, fa
library(psy) # screeplot
library(dplyr)
library(ggplot2)
library(magrittr)

file.raw <- "dd2.survey.data.csv"
file.raw

file.raw.items <- file.raw %>% select(6:53) %T>% print
##At this moment, 
##select function doesn't work. how can i solve it?
krads
  • 1,350
  • 8
  • 14
bargsang
  • 1
  • 1
  • 3

1 Answers1

0

You will need to use read.csv() or similar function to read your text file.

I'm not sure from your code whether you have other mistakes but where you currently have:

file.raw.items <- file.raw %>% select(6:53) %T>% print

You probably need to change it to something like:

file.raw.items <- read.csv(file = file.raw) %>% select(6:53) %T>% print()

In addition to missing read.csv() to read your file note you also ommitted the () at the end of print().

Be aware this will first read the entire file into memory, then select columns 6:53, then save the data.frame to file.raw.items.

Please see ?read.csv for options regarding specifying headers.

Also, note whether you want to use the additional option for stringsAsFactors = FALSE to ensure text stays as text (unless of course you want text read as Factors). Imported a csv-dataset to R but the values becomes factors

krads
  • 1,350
  • 8
  • 14
  • it was really basic thing.. Thank you very much. – bargsang Apr 08 '19 at 02:49
  • due to this, I was not able to kickstart it. Thx – bargsang Apr 08 '19 at 02:49
  • @bargsang Glad to help. Don't forget please to mark the answer as selected if it answers your question and upvote if it warrants it: [What should I do when someone answers my question?](https://stackoverflow.com/help/someone-answers) – krads Apr 08 '19 at 07:50