0
votes

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?
1

1 Answers

0
votes

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