Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Import files:
- temp = list.files(pattern="*.csv") #Filenames from working directory
- for (i in 1:length(temp)) {
- assign(temp[i], read.delim(temp[i],sep=";", header = T, nrows = 6)) #Clean data to include only RGB
- }
- allvars <- ls(all.names = T) #List all variables
- getClasses <- function(variable) { #Find RGB classes and name
- red <- variable$R[3:5]
- green <- variable$G[3:5]
- blue <- variable$B[3:5]
- classes <- data.frame(red, green, blue)
- print(classes)
- }
- #This is where the problem happens:
- for (i in 1:length(allvars)) {
- assign(allvars[i], getClasses(allvars[i])) #Apply getClasses function to current variable and store new data
- }
- #Error: $ operator is invalid for atomic vectors
Add Comment
Please, Sign In to add comment