R Programming - Unable to read files

0 votes

I've written an R program that reads multiple csv files. This code works if I give 'read.csv' command but it never works if I pass the name of the file as a parameter.

For example

dat <- function (x)  
 {     
awr <- data.table(read.csv(x))
  }

I passed

dat("hello.csv")

However, I'm not getting any error and the awr data set is not getting created.

For example:

awr <- data.table(read.csv("hello.csv")) ..it works...

Why is it not working when passed in the function?

Apr 16, 2019 in Data Analytics by Sophie may
• 10,620 points
542 views

1 answer to this question.

0 votes

This is happening because you're not returning any value from the function, try this:

dat <- function (x) data.table(read.csv(x)) 

answered Apr 16, 2019 by Tyrion anex
• 8,700 points

Related Questions In Data Analytics

+4 votes
0 answers

I was unable to cluster the data points using dbscan in R programming

After using dbscan package I was given with ...READ MORE

Feb 2, 2020 in Data Analytics by ramthotahappy
• 160 points
1,020 views
0 votes
1 answer

How can I use R to list all files with a specified extension ?

fls <- list.files(pattern = "\\.dbf$") $ at the ...READ MORE

answered May 11, 2018 in Data Analytics by zombie
• 3,790 points
893 views
0 votes
1 answer

Unable to install the 'devtools' package in R

Run the below command in your Ubuntu/Linux ...READ MORE

answered Jun 6, 2018 in Data Analytics by Bharani
• 4,660 points
1,690 views
0 votes
2 answers

What are the rules to define a variable name in R programming language?

The same rules almost follow for all ...READ MORE

answered Aug 26, 2019 in Data Analytics by anonymous
• 33,030 points
15,131 views
+1 vote
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21, 2019 in Data Analytics by anonymous
• 33,030 points
1,816 views
+10 votes
3 answers

Which is a better initiative to learn data science: Python or R?

Well it truly depends on your requirement, If ...READ MORE

answered Aug 9, 2018 in Data Analytics by Abhi
• 3,720 points
1,636 views
0 votes
1 answer

How can I perform word stemming in R

The tm package in R provides the stemDocument() function to stem the ...READ MORE

answered Aug 20, 2018 in Data Analytics by Abhi
• 3,720 points
4,542 views
0 votes
1 answer

How to know the type of an object?

To find the type of an object ...READ MORE

answered Sep 20, 2018 in Data Analytics by Abhi
• 3,720 points
714 views
0 votes
1 answer

R programming: How to pass variables from a r program to mysql function?

To include the R variables called start.date and end.date, you can use paste to ...READ MORE

answered Dec 28, 2018 in Data Analytics by Tyrion anex
• 8,700 points
1,335 views
+1 vote
3 answers

How to change the value of a variable using R programming in a data frame?

Try this: df$symbol <- as.character(df$symbol) df$symbol[df$sym ...READ MORE

answered Jan 11, 2019 in Data Analytics by Tyrion anex
• 8,700 points
35,831 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP