简体   繁体   中英

csv read from url has one line

When executing the code from a R console:

 csv <-getURL('https://raw.github.com/jeanpat/pyFISH/master/GUI/karyotyper/example%20classification/source%20data/features/jp-Jpp48-1-DAPI.csv')

> csv
[1]  "part10.png;0.516891479492;0.975990396158;6.73515981735;0.114155251142;0.114155251142;0.114155251142\npart18.png;0.53596496582;

> dat <- read.csv(csv)
Erreur dans file(file, "rt") : impossible d'ouvrir la connexion

csv is viewed as a char. How to make a dataframe?

Thank you.

JP

Your csv being a string after reading it with getURL , you need to do:

read.table(text = csv, sep = ';')

#           V1        V2        V3       V4        V5        V6        V7
# 1 part10.png 0.5168915 0.9759904 6.735160 0.1141553 0.1141553 0.1141553
# 2 part18.png 0.5359650 0.9546999 7.002188 0.1094092 0.1094092 0.1094092

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