read.csv

Is there a way to use read.csv to read from a string value rather than a file in R?

▼魔方 西西 提交于 2019-11-29 21:58:52
I'm writing an R package where the R code talks to a Java application. The Java application outputs a CSV formatted string and I want the R code to be able to directly read the string and convert it into a data.frame. Dirk Eddelbuettel Editing a 7-year old answer: By now, this is much simpler thanks to the text= argument which has been added to read.csv() and alike: R> data <- read.csv(text="flim,flam + 1.2,2.2 + 77.1,3.14") R> data flim flam 1 1.2 2.20 2 77.1 3.14 R> Yes, look at the help for textConnection() -- the very powerful notion in R is that essentially all readers (as e.g. read.table

read.csv row.names

纵然是瞬间 提交于 2019-11-29 05:59:55
I'm trying to read a column oriented csv file into R as a data frame. the first line of the file is like so: sDATE, sTIME,iGPS_ALT, ... and then each additional line is a measurement: 4/10/2011,2:15,78, ... when I try to read this into R, via d = read.csv('filename') I get a duplicate row.names error since R thinks that the first column of the data is the row names, and since all of the measurements were taken on the same day, the values in the first column do not change. If I put in row.names = NULL into the read.csv call, I get an extraneous column d$row.names which corresponds to the sDATE

Skip specific rows using read.csv in R [duplicate]

倖福魔咒の 提交于 2019-11-28 23:10:37
This question already has an answer here: How can I read the header but also skip lines - read.table()? 5 answers I wish to skip the 1st and 3rd rows of my csv file when importing the file into a data frame in R. In the original file my headers are on line 2. Using the skip argument in read.csv I can skip the 1st line and set the header argument to TRUE by I still have the 3rd line from the original file in my data frame. Can anyone suggest how to skip multiple specific rows in R, below is what I was able to cobble together? Can I pass a vector to the skip argument specifying the exact rows to

Difference between read.csv() and read.csv2() in R

Deadly 提交于 2019-11-28 22:18:46
In R , what is the difference between read.csv() and read.csv2() The official documentation says, In various European locales, as the comma character serves as the decimal point, the function read.csv2 should be used instead What does this mean. I don't see any difference at the superficial level. Can anybody give out a concrete example to clarify it further. They are (almost) the same functions - read.table . The only difference is default parameters. Look at source code: > read.csv function (file, header = TRUE, sep = ",", quote = "\"", dec = ".", fill = TRUE, comment.char = "", ...) read

Is there a way to use read.csv to read from a string value rather than a file in R?

喜你入骨 提交于 2019-11-28 17:18:27
问题 I'm writing an R package where the R code talks to a Java application. The Java application outputs a CSV formatted string and I want the R code to be able to directly read the string and convert it into a data.frame. 回答1: Editing a 7-year old answer: By now, this is much simpler thanks to the text= argument which has been added to read.csv() and alike: R> data <- read.csv(text="flim,flam + 1.2,2.2 + 77.1,3.14") R> data flim flam 1 1.2 2.20 2 77.1 3.14 R> Yes, look at the help for

Merging df.1, df.2, df.3 … df.x into one dataframe

会有一股神秘感。 提交于 2019-11-28 01:46:14
I am working on a project that imports all csv files from a given folder and merges them into one file. I was able to import the rows and columns I wanted from each of the files from the folder but now need help merging them all into one file. I do not know how many files I will eventually end up with (probably around 120) so I do not want to merge them 1 by 1. Here is what I have so far: # Import All files rowsToUse <- c(9:104,657:752) colsToUse <- c(15,27,28,29,30,33,35) filenames <- list.files("save", pattern="*.csv", full.names=TRUE) for (i in seq_along(filenames)) { assign(paste("df", i,

Read csv with dates and numbers

妖精的绣舞 提交于 2019-11-27 20:41:38
I have a problem when I import a csv file with R: example lines to import: 2010-07-27;91 2010-07-26;93 2010-07-23;88 I use the statement: data <- read.csv2(file="...", sep=";", dec=".", header=FALSE) when I try to aggregate this data with other ones originated by statistical analysis using cbind , the date is showed as an integer number because it was imported as factor. If I try to show it as a string using as.character , the numerical data are transformed into characters too so they are unusable for statistical procedures. Use colClasses argument: data <- read.csv2(file="...", sep=";", dec="

Weird error in R when importing (64-bit) integer with many digits

☆樱花仙子☆ 提交于 2019-11-27 15:36:25
I am importing a csv that has a single column which contains very long integers (for example: 2121020101132507598) a<-read.csv('temp.csv',as.is=T) When I import these integers as strings they come through correctly, but when imported as integers the last few digits are changed. I have no idea what is going on... 1 "4031320121153001444" 4031320121153001472 2 "4113020071082679601" 4113020071082679808 3 "4073020091116779570" 4073020091116779520 4 "2081720101128577687" 2081720101128577792 5 "4041720081087539887" 4041720081087539712 6 "4011120071074301496" 4011120071074301440 7 "4021520051054304372

Skip specific rows using read.csv in R [duplicate]

 ̄綄美尐妖づ 提交于 2019-11-27 14:43:39
问题 This question already has answers here : How can I read the header but also skip lines - read.table()? (5 answers) Closed 7 months ago . I wish to skip the 1st and 3rd rows of my csv file when importing the file into a data frame in R. In the original file my headers are on line 2. Using the skip argument in read.csv I can skip the 1st line and set the header argument to TRUE by I still have the 3rd line from the original file in my data frame. Can anyone suggest how to skip multiple specific

Difference between read.csv() and read.csv2() in R

允我心安 提交于 2019-11-27 13:24:48
问题 In R , what is the difference between read.csv() and read.csv2() The official documentation says, In various European locales, as the comma character serves as the decimal point, the function read.csv2 should be used instead What does this mean. I don't see any difference at the superficial level. Can anybody give out a concrete example to clarify it further. 回答1: They are (almost) the same functions - read.table . The only difference is default parameters. Look at source code: > read.csv