rannoudanames rannoudanames - 6 days ago 10
R Question

importing chopped data in r

Here is a segment of my data. When i do read.csv(data, sep = " ") i get a dataframe with columns and rows. However this data is all of one type, so i just need either one row, one column or a vector.

Any help is apreciated.

0 0 0 10 10 10 10 10 10 10 10 20 20 20 20 20 20 20 20 20 30 30 30 30 30 30 30 30 30 40 40 40 40 40 40 50 50 50 50 50 50 60 60 60 60 60 60 60 60 60 60 60 60 70 70 70 70 70 70 70 70 70 80 80 80 80 80 80 80 80 80 90 90 90 90 90 90 90 90 90 100 100 100 100 100 100 100 100 100 110 110 110 110 110 110 110 110 110 110 110 110 120 120 120 120 120 130 130 130 130 130 130 140 140 140 140 140 140 140 140 150 150 150

Answer

What about:

scan(data,what="numeric", sep=" ")

When you use ´read.csv´ (or any read.xxx) R understand that you're trying to import a table, so it creates a dataframe with columns and rows with the contents of the file. You can read as a string directly with scan or change the dataframe later:

Load the data:

df=read.csv(data, sep=" ")

Change it to a string:

as.numeric(df)