简体   繁体   中英

How can i write a function in Rstudio which automates data wrangling and takes as an input the file name and returns the cleaned data?

how can i make this piece of code into a function? how can i create a second function that would then take as an input the cleaned data and its variables to create a table as an output. Any help would be appreciated

phoenix <- read.csv("path of data", stringsAsFactors = T)
                                  
str(phoenix)
head(phoenix)#inspect first 6 rows of data

namechange <- function(data = dinoraw){ colnames(data)=c("Individual","eating_habits", "height_ft", "weight._lbs", "length_ft", "killer_rating", "intelligence", "age_m_of_yrs" ) return(data) } im trying to use this function but i need the function to put out a new data frame that is the same as the input data frame but with changed column names

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM