read.csv

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

这一生的挚爱 提交于 2019-11-26 17:13:51
问题 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

Invalid multibyte string in read.csv

六眼飞鱼酱① 提交于 2019-11-26 15:25:57
I am trying to import a csv that is in Japanese. This code: url <- 'http://www.mof.go.jp/international_policy/reference/itn_transactions_in_securities/week.csv' x <- read.csv(url, header=FALSE, stringsAsFactors=FALSE) returns the following error: Error in type.convert(data[[i]], as.is = as.is[i], dec = dec, na.strings = character(0L)) : invalid multibyte string at '<91>ΊO<8b>y<82>ёΓ<e0><8f>،<94><94><84><94><83><8c>_<96>񓙂̏󋵁@(<8f>T<8e><9f><81>E<8e>w<92><e8><95>񍐋@<8a>փx<81>[<83>X<81>j' I tried changing the encoding ( Encoding(url) <- 'UTF-8' and also to latin1) and tried removing the read.csv

Imported a csv-dataset to R but the values becomes factors

痞子三分冷 提交于 2019-11-26 09:29:05
问题 I am very new to R and I am having trouble accessing a dataset I\'ve imported. I\'m using RStudio and used the Import Dataset function when importing my csv-file and pasted the line from the console-window to the source-window. The code looks as follows: setwd(\"c:/kalle/R\") stuckey <- read.csv(\"C:/kalle/R/stuckey.csv\") point <- stuckey$PTS time <- stuckey$MP However, the data isn\'t integer or numeric as I am used to but factors so when I try to plot the variables I only get histograms,

Why am I getting X. in my column names when reading a data frame?

删除回忆录丶 提交于 2019-11-26 09:09:00
问题 I asked a question about this a few months back, and I thought the answer had solved my problem, but I ran into the problem again and the solution didn\'t work for me. I\'m importing a CSV: orders <- read.csv(\"<file_location>\", sep=\",\", header=T, check.names = FALSE) Here\'s the structure of the dataframe: str(orders) \'data.frame\': 3331575 obs. of 2 variables: $ OrderID : num -2034590217 -2034590216 -2031892773 -2031892767 -2021008573 ... $ OrderDate: Factor w/ 402 levels \"2010-10-01\"

How to read only lines that fulfil a condition from a csv into R?

六月ゝ 毕业季﹏ 提交于 2019-11-26 07:34:05
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 5 years ago . I am trying to read a large csv file into R. I only want to read and work with some of the rows that fulfil a particular condition (e.g. Variable2 >= 3 ). This is a much smaller dataset. I want to read these lines directly into a dataframe, rather than load the whole dataset into a dataframe and then select according to the condition, since the whole dataset does not easily fit

How to detect the right encoding for read.csv?

孤街浪徒 提交于 2019-11-26 07:01:08
问题 I have this file (http://b7hq6v.alterupload.com/en/) that I want to read in R with read.csv . But I am not able to detect the correct encoding. It seems to be a kind of UTF-8. I am using R 2.12.1 on an WindowsXP Machine. Any Help? 回答1: First of all based on more general question on StackOverflow it is not possible to detect encoding of file in 100% certainty. I've struggle this many times and come to non-automatic solution: Use iconvlist to get all possible encodings: codepages <- setNames

read.csv, header on first line, skip second line [duplicate]

你说的曾经没有我的故事 提交于 2019-11-26 06:36:48
问题 This question already has an answer here: How can I read the header but also skip lines - read.table()? 5 answers I have a CSV file with two header rows, the first row I want to be the header, but the second row I want to discard. If I do the following command: data <- read.csv(\"HK Stocks bbg.csv\", header = T, stringsAsFactors = FALSE) The first row becomes the header and the second row of the file becomes the first row of my data frame: Xaaaaaaaaa X X.1 Xbbbbbbbbbb X.2 X.3 1 Date PX_LAST

Specifying colClasses in the read.csv

我是研究僧i 提交于 2019-11-26 06:17:08
问题 I am trying to specify the colClasses options in the read.csv function in R. In my data, the first column \"time\" is basically a character vector while the rest of the columns are numeric. data <- read.csv(\"test.csv\", comment.char=\"\" , colClasses=c(time=\"character\", \"numeric\"), strip.white=FALSE) In the above command, I would want R to read in the \"time\" column as \"character\" and the rest as numeric. Although, the \"data\" variable did have the correct result after the command

Invalid multibyte string in read.csv

Deadly 提交于 2019-11-26 02:57:19
问题 I am trying to import a csv that is in Japanese. This code: url <- \'http://www.mof.go.jp/international_policy/reference/itn_transactions_in_securities/week.csv\' x <- read.csv(url, header=FALSE, stringsAsFactors=FALSE) returns the following error: Error in type.convert(data[[i]], as.is = as.is[i], dec = dec, na.strings = character(0L)) : invalid multibyte string at \'<91>ΊO<8b>y<82>ёΓ<e0><8f>،<94><94><84><94><83><8c>_<96>񓙂̏󋵁@(<8f>T<8e><9f><81>E<8e>w<92><e8><95>񍐋@<8a>փx<81>[<83>X<81>j\' I

&#39;Incomplete final line&#39; warning when trying to read a .csv file into R

回眸只為那壹抹淺笑 提交于 2019-11-26 00:41:49
问题 I\'m trying to read a .csv file into R and upon using this formula: pheasant<-read.table(file.choose(),header=TRUE,sep=\",\") I get this warning message: \"incomplete final line found by readTableHeader on \'C:\\Documents and Settings...\" There are a couple of things I thought may have caused this warning, but unfortunately I don\'t know enough about R to diagnose the problem myself so I thought I\'d post here in the hope someone else can diagnose it for me! the .csv file was originally an